diff --git a/lib/ui/app/copy_to_clipboard.dart b/lib/ui/app/copy_to_clipboard.dart index 67c887ccb..dede59550 100644 --- a/lib/ui/app/copy_to_clipboard.dart +++ b/lib/ui/app/copy_to_clipboard.dart @@ -40,19 +40,9 @@ class CopyToClipboard extends StatelessWidget { }; if (showBorder) { - return GestureDetector( - onTap: onTap, - child: Container( - constraints: BoxConstraints(maxWidth: 180), - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4), - decoration: BoxDecoration( - border: Border.all( - color: Colors.grey, - ), - borderRadius: BorderRadius.all(Radius.circular(20)), - ), - child: widget, - ), + return ConstrainedBox( + child: OutlinedButton(onPressed: onTap, child: widget), + constraints: BoxConstraints(maxWidth: 180), ); } else { return InkWell( diff --git a/lib/ui/app/link_text.dart b/lib/ui/app/link_text.dart index 585fe0223..34e2bd083 100644 --- a/lib/ui/app/link_text.dart +++ b/lib/ui/app/link_text.dart @@ -1,10 +1,41 @@ // Flutter imports: import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; +import 'package:invoiceninja_flutter/data/models/entities.dart'; +import 'package:invoiceninja_flutter/redux/app/app_actions.dart'; // Package imports: import 'package:url_launcher/url_launcher.dart'; +class LinkTextRelatedEntity extends StatelessWidget { + const LinkTextRelatedEntity({ + Key key, + @required this.label, + @required this.entity, + @required this.relation, + }) : super(key: key); + + final String label; + final BaseEntity entity; + final BaseEntity relation; + + @override + Widget build(BuildContext context) { + return GestureDetector( + child: Text( + label, + textAlign: TextAlign.center, + style: TextStyle(decoration: TextDecoration.underline), + ), + onTap: () { + print('## clicked: ${DateTime.now()}'); + viewEntity(entity: relation); + viewEntity(entity: entity, addToStack: true); + }, + ); + } +} + class LinkTextSpan extends TextSpan { LinkTextSpan({TextStyle style, String url, String text}) : super( diff --git a/lib/ui/invoice/invoice_presenter.dart b/lib/ui/invoice/invoice_presenter.dart index 7e9721af4..cecaa7df5 100644 --- a/lib/ui/invoice/invoice_presenter.dart +++ b/lib/ui/invoice/invoice_presenter.dart @@ -10,6 +10,7 @@ import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/redux/invoice/invoice_selectors.dart'; import 'package:invoiceninja_flutter/ui/app/copy_to_clipboard.dart'; import 'package:invoiceninja_flutter/ui/app/entities/entity_status_chip.dart'; +import 'package:invoiceninja_flutter/ui/app/link_text.dart'; import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart'; import 'package:invoiceninja_flutter/utils/formatting.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; @@ -78,9 +79,8 @@ class InvoicePresenter extends EntityPresenter { ? localization.pending : invoice.number); case InvoiceFields.client: - return Text((state.clientState.map[invoice.clientId] ?? - ClientEntity(id: invoice.clientId)) - .listDisplayName); + return LinkTextRelatedEntity( + label: client.displayName, entity: client, relation: invoice); case InvoiceFields.project: return Text(state.projectState.get(invoice.projectId).listDisplayName); case InvoiceFields.vendor: