Added LinkTextRelatedEntity widget
This commit is contained in:
parent
478ce989d8
commit
af5d830a10
|
|
@ -40,19 +40,9 @@ class CopyToClipboard extends StatelessWidget {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (showBorder) {
|
if (showBorder) {
|
||||||
return GestureDetector(
|
return ConstrainedBox(
|
||||||
onTap: onTap,
|
child: OutlinedButton(onPressed: onTap, child: widget),
|
||||||
child: Container(
|
constraints: BoxConstraints(maxWidth: 180),
|
||||||
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,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,41 @@
|
||||||
// Flutter imports:
|
// Flutter imports:
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.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:
|
// Package imports:
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
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 {
|
class LinkTextSpan extends TextSpan {
|
||||||
LinkTextSpan({TextStyle style, String url, String text})
|
LinkTextSpan({TextStyle style, String url, String text})
|
||||||
: super(
|
: super(
|
||||||
|
|
|
||||||
|
|
@ -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/redux/invoice/invoice_selectors.dart';
|
||||||
import 'package:invoiceninja_flutter/ui/app/copy_to_clipboard.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/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/ui/app/presenters/entity_presenter.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
import 'package:invoiceninja_flutter/utils/formatting.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
@ -78,9 +79,8 @@ class InvoicePresenter extends EntityPresenter {
|
||||||
? localization.pending
|
? localization.pending
|
||||||
: invoice.number);
|
: invoice.number);
|
||||||
case InvoiceFields.client:
|
case InvoiceFields.client:
|
||||||
return Text((state.clientState.map[invoice.clientId] ??
|
return LinkTextRelatedEntity(
|
||||||
ClientEntity(id: invoice.clientId))
|
label: client.displayName, entity: client, relation: invoice);
|
||||||
.listDisplayName);
|
|
||||||
case InvoiceFields.project:
|
case InvoiceFields.project:
|
||||||
return Text(state.projectState.get(invoice.projectId).listDisplayName);
|
return Text(state.projectState.get(invoice.projectId).listDisplayName);
|
||||||
case InvoiceFields.vendor:
|
case InvoiceFields.vendor:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue