From c2b4e76fe3eaffdfaa46d68e94f3851883b03a9a Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Thu, 18 Jul 2019 16:44:16 +0300 Subject: [PATCH] Documents --- lib/ui/app/document_tile.dart | 34 +++++++++++++------ lib/ui/app/form_card.dart | 4 ++- lib/ui/app/icon_text.dart | 2 +- .../expense/view/expense_view_documents.dart | 27 +++++++++++++-- lib/utils/i18n.dart | 6 ++++ 5 files changed, 58 insertions(+), 15 deletions(-) diff --git a/lib/ui/app/document_tile.dart b/lib/ui/app/document_tile.dart index 472ee7105..5bf15e0bc 100644 --- a/lib/ui/app/document_tile.dart +++ b/lib/ui/app/document_tile.dart @@ -5,6 +5,7 @@ import 'package:invoiceninja_flutter/data/models/models.dart'; import 'package:invoiceninja_flutter/redux/app/app_state.dart'; import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart'; import 'package:invoiceninja_flutter/ui/app/form_card.dart'; +import 'package:invoiceninja_flutter/utils/formatting.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; class DocumentTile extends StatelessWidget { @@ -69,22 +70,35 @@ class DocumentTile extends StatelessWidget { children: [ InkWell( onTap: () => showDocumentModal(context), - child: Padding( - padding: const EdgeInsets.all(10), + child: Card( child: Column( - mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding( - padding: const EdgeInsets.only( - left: 16, top: 16, right: 16, bottom: 28), - child: Text(document.name ?? '', - style: Theme.of(context).textTheme.subhead), - ), DocumentPreview(document), + Padding( + padding: EdgeInsets.all(8), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + document.name ?? '', + style: Theme.of(context).textTheme.subhead, + overflow: TextOverflow.ellipsis, + ), + Text( + formatDate( + convertTimestampToDateString(document.updatedAt), + context), + style: Theme.of(context).textTheme.caption, + overflow: TextOverflow.ellipsis, + ), + ], + ), + ) ], ), ), - ) + ), ], ); } diff --git a/lib/ui/app/form_card.dart b/lib/ui/app/form_card.dart index 5f8240635..8b98c2440 100644 --- a/lib/ui/app/form_card.dart +++ b/lib/ui/app/form_card.dart @@ -4,9 +4,11 @@ class FormCard extends StatelessWidget { const FormCard({ Key key, @required this.children, + this.crossAxisAlignment, }) : super(key: key); final List children; + final CrossAxisAlignment crossAxisAlignment; @override Widget build(BuildContext context) { @@ -21,7 +23,7 @@ class FormCard extends StatelessWidget { width: double.infinity, child: Column( mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, + crossAxisAlignment: crossAxisAlignment ?? CrossAxisAlignment.center, children: children, ), ), diff --git a/lib/ui/app/icon_text.dart b/lib/ui/app/icon_text.dart index a6ba4c27c..82117bc80 100644 --- a/lib/ui/app/icon_text.dart +++ b/lib/ui/app/icon_text.dart @@ -10,7 +10,7 @@ class IconText extends StatelessWidget { return Row( children: [ Icon(icon), - SizedBox(width: 6.0), + SizedBox(width: 8), Text(text), ], ); diff --git a/lib/ui/expense/view/expense_view_documents.dart b/lib/ui/expense/view/expense_view_documents.dart index 4f2f3c7a7..d466a31ae 100644 --- a/lib/ui/expense/view/expense_view_documents.dart +++ b/lib/ui/expense/view/expense_view_documents.dart @@ -3,6 +3,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/document/document_selectors.dart'; +import 'package:invoiceninja_flutter/ui/app/buttons/elevated_button.dart'; import 'package:invoiceninja_flutter/ui/app/document_tile.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; @@ -36,9 +37,29 @@ class _ExpenseViewDocumentsState extends State { return ListView( children: [ - Container( - color: Theme.of(context).backgroundColor, - height: 12.0, + Padding( + padding: const EdgeInsets.all(14), + child: Row( + children: [ + Expanded( + child: ElevatedButton( + icon: Icons.camera_alt, + label: localization.takePicture, + //onPressed: _confirmDelete, + ), + ), + SizedBox( + width: 14, + ), + Expanded( + child: ElevatedButton( + icon: Icons.attach_file, + label: localization.uploadFile, + //onPressed: _confirmDelete, + ), + ), + ], + ), ), GridView.count( physics: NeverScrollableScrollPhysics(), diff --git a/lib/utils/i18n.dart b/lib/utils/i18n.dart index daf110315..b7f3812f5 100644 --- a/lib/utils/i18n.dart +++ b/lib/utils/i18n.dart @@ -14,6 +14,8 @@ abstract class LocaleCodeAware { mixin LocalizationsProvider on LocaleCodeAware { static final Map> _localizedValues = { 'en': { + 'take_picture': 'Take Picture', + 'upload_file': 'Upload File', 'document': 'Document', 'documents': 'Documents', 'new_document': 'New Document', @@ -12264,6 +12266,10 @@ mixin LocalizationsProvider on LocaleCodeAware { String get noHistory => _localizedValues[localeCode]['no_history']; + String get takePicture => _localizedValues[localeCode]['take_picture']; + + String get uploadFile => _localizedValues[localeCode]['upload_file']; + String lookup(String key) { final lookupKey = toSnakeCase(key); return _localizedValues[localeCode][lookupKey] ??