Added LinkTextRelatedEntity widget
This commit is contained in:
parent
478ce989d8
commit
af5d830a10
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue