Show emails as copyable links in the datatable
This commit is contained in:
parent
3614243bdd
commit
e836a415c1
|
|
@ -6,24 +6,24 @@ import 'package:invoiceninja_flutter/utils/localization.dart';
|
|||
class CopyToClipboard extends StatelessWidget {
|
||||
const CopyToClipboard({
|
||||
Key key,
|
||||
@required this.child,
|
||||
@required this.value,
|
||||
this.child,
|
||||
this.showBorder = false,
|
||||
}) : super(key: key);
|
||||
|
||||
final Widget child;
|
||||
final String value;
|
||||
final bool showBorder;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (value == null) {
|
||||
if ((value ?? '').isEmpty) {
|
||||
return child;
|
||||
}
|
||||
|
||||
final widget = child == null ? Text(value) : child;
|
||||
final localization = AppLocalization.of(context);
|
||||
|
||||
return InkWell(
|
||||
child: child,
|
||||
onTap: () {
|
||||
final onTap = () {
|
||||
Clipboard.setData(ClipboardData(text: value));
|
||||
showToast(
|
||||
localization.copiedToClipboard.replaceFirst(
|
||||
|
|
@ -31,7 +31,27 @@ class CopyToClipboard extends StatelessWidget {
|
|||
value.replaceAll('\n', ' '),
|
||||
),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
if (showBorder) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
color: Colors.grey,
|
||||
),
|
||||
borderRadius: BorderRadius.all(Radius.circular(20)),
|
||||
),
|
||||
child: widget,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
return InkWell(
|
||||
child: widget,
|
||||
onTap: onTap,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1383,6 +1383,7 @@ class _ContactUsDialogState extends State<ContactUsDialog> {
|
|||
'message': _message,
|
||||
'send_logs': _includeLogs ? 'true' : '',
|
||||
'platform': getPlatformLetter(),
|
||||
'version': state.appVersion,
|
||||
}))
|
||||
.then((dynamic response) async {
|
||||
setState(() => _isSaving = false);
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
// Project imports:
|
||||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/copy_to_clipboard.dart';
|
||||
import 'package:invoiceninja_flutter/ui/app/presenters/entity_presenter.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
|
||||
|
|
@ -64,7 +65,10 @@ class ClientPresenter extends EntityPresenter {
|
|||
case ClientFields.contactName:
|
||||
return Text(client.primaryContact.fullName);
|
||||
case ClientFields.contactEmail:
|
||||
return Text(client.primaryContact.email);
|
||||
return CopyToClipboard(
|
||||
value: client.primaryContact.email,
|
||||
showBorder: true,
|
||||
);
|
||||
case ClientFields.contactPhone:
|
||||
return Text(client.primaryContact.phone);
|
||||
case ClientFields.address1:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/credit/credit_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/presenters/entity_presenter.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
|
|
@ -142,7 +143,10 @@ class CreditPresenter extends EntityPresenter {
|
|||
if (field == CreditFields.contactName) {
|
||||
return Text(contact?.fullName ?? '');
|
||||
}
|
||||
return Text(contact?.email ?? '');
|
||||
return CopyToClipboard(
|
||||
value: contact?.email ?? '',
|
||||
showBorder: true,
|
||||
);
|
||||
case CreditFields.partial:
|
||||
return Text(formatNumber(credit.partial, context));
|
||||
case CreditFields.partialDueDate:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/models.dart';
|
||||
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/presenters/entity_presenter.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
|
|
@ -161,7 +162,10 @@ class InvoicePresenter extends EntityPresenter {
|
|||
if (field == InvoiceFields.contactName) {
|
||||
return Text(contact?.fullName ?? '');
|
||||
}
|
||||
return Text(contact?.email ?? '');
|
||||
return CopyToClipboard(
|
||||
value: contact?.email ?? '',
|
||||
showBorder: true,
|
||||
);
|
||||
case InvoiceFields.partial:
|
||||
return Text(formatNumber(invoice.partial, context));
|
||||
case InvoiceFields.partialDueDate:
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import 'package:invoiceninja_flutter/data/models/models.dart';
|
|||
import 'package:invoiceninja_flutter/data/models/quote_model.dart';
|
||||
import 'package:invoiceninja_flutter/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja_flutter/redux/quote/quote_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/presenters/entity_presenter.dart';
|
||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||
|
|
@ -135,7 +136,10 @@ class QuotePresenter extends EntityPresenter {
|
|||
if (field == QuoteFields.contactName) {
|
||||
return Text(contact?.fullName ?? '');
|
||||
}
|
||||
return Text(contact?.email ?? '');
|
||||
return CopyToClipboard(
|
||||
value: contact?.email ?? '',
|
||||
showBorder: true,
|
||||
);
|
||||
case QuoteFields.partial:
|
||||
return Text(formatNumber(quote.partial, context));
|
||||
case QuoteFields.partialDueDate:
|
||||
|
|
|
|||
Loading…
Reference in New Issue