From 471c2f942d674d4a884d3cb1fb1c9bc98e81bdd1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Jun 2018 02:16:00 -0700 Subject: [PATCH] Clients --- analysis_options.yaml | 4 ++ lib/ui/client/client_details.dart | 109 ++++++++++++++++++++++++------ lib/utils/localization.dart | 4 ++ 3 files changed, 95 insertions(+), 22 deletions(-) create mode 100644 analysis_options.yaml diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 000000000..dbda7cafb --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,4 @@ +analyzer: + strong-mode: true + language: + enableSuperMixins: true \ No newline at end of file diff --git a/lib/ui/client/client_details.dart b/lib/ui/client/client_details.dart index 97d02ca2f..259b7c3f1 100644 --- a/lib/ui/client/client_details.dart +++ b/lib/ui/client/client_details.dart @@ -5,43 +5,108 @@ import 'package:invoiceninja/ui/app/progress_button.dart'; import 'package:invoiceninja/ui/client/client_details_vm.dart'; import 'package:invoiceninja/utils/localization.dart'; -class ClientDetails extends StatelessWidget { +class ClientDetails extends StatefulWidget { final ClientDetailsVM viewModel; - static final GlobalKey _formKey = GlobalKey(); - static final GlobalKey> _nameKey = - GlobalKey>(); - ClientDetails({ Key key, @required this.viewModel, }) : super(key: key); + @override + _ClientDetailsState createState() => new _ClientDetailsState(); +} + +class _ClientDetailsState extends State + with SingleTickerProviderStateMixin { + static final GlobalKey _formKey = GlobalKey(); + static final GlobalKey> _nameKey = + GlobalKey>(); + TabController _controller; + + @override + void initState() { + super.initState(); + _controller = new TabController(vsync: this, length: 2); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { var localization = AppLocalization.of(context); + Widget _overview() { + return Padding( + padding: EdgeInsets.all(16.0), + child: ListView( + children: [ + ListTile( + leading: Icon(Icons.pin_drop), + title: Text(widget.viewModel.client.address1), + subtitle: Text(localization.billingAddress), + ) + ], + ), + ); + } + + Widget _details() { + return Padding( + padding: EdgeInsets.all(16.0), + child: ListView( + children: [ + ListTile( + leading: Icon(Icons.pin_drop), + title: Text(widget.viewModel.client.address1), + subtitle: Text(localization.billingAddress), + ) + ], + ), + ); + } + return Scaffold( appBar: AppBar( - title: Text(viewModel.client.id == null + title: Text(widget.viewModel.client.id == null ? localization.newClient - : viewModel.client.displayName), // Text(localizations.clientDetails), - actions: viewModel.client.id == null ? [] : [ - ActionMenuButton( - entity: viewModel.client, - onSelected: viewModel.onActionSelected, - )], + : widget.viewModel.client + .displayName), // Text(localizations.clientDetails), + bottom: TabBar( + controller: _controller, + //isScrollable: true, + tabs: [ + Tab( + text: localization.overview, + ), + Tab( + text: localization.details, + ), + ], + ), + actions: widget.viewModel.client.id == null + ? [] + : [ + ActionMenuButton( + entity: widget.viewModel.client, + onSelected: widget.viewModel.onActionSelected, + ) + ], ), - body: Padding( - padding: EdgeInsets.all(16.0), - child: ListView(children: [ - ListTile( - leading: Icon(Icons.location_city), - title: Text(viewModel.client.address1), - subtitle: Text(localization.billingAddress), - ) - ],), - ) + body: TabBarView( + controller: _controller, + children: [ + _overview(), + _details(), + ], + ), + /* + body: + */ /* body: Padding( padding: EdgeInsets.all(16.0), diff --git a/lib/utils/localization.dart b/lib/utils/localization.dart index d70c762f5..acd4dc487 100644 --- a/lib/utils/localization.dart +++ b/lib/utils/localization.dart @@ -47,6 +47,8 @@ class AppLocalization { 'save': 'Save', 'an_error_occurred': 'An error occurred', 'paid_to_date': 'Paid to Date', + 'overview': 'Overview', + 'details': 'Details', 'product': 'Product', 'products': 'Products', @@ -104,6 +106,8 @@ class AppLocalization { String get descending => _localizedValues[locale.languageCode]['descending']; String get save => _localizedValues[locale.languageCode]['save']; String get paidToDate => _localizedValues[locale.languageCode]['paid_to_date']; + String get overview => _localizedValues[locale.languageCode]['overview']; + String get details => _localizedValues[locale.languageCode]['details']; String get product => _localizedValues[locale.languageCode]['product']; String get products => _localizedValues[locale.languageCode]['products'];