From 020b8df8bd1bdaa2d61ac4cb59ab09ea4e6cfa02 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 May 2018 13:13:50 -0700 Subject: [PATCH] Refactor --- lib/ui/app/custom_drawer.dart | 12 +++++++----- lib/ui/app/custom_drawer_vm.dart | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/ui/app/custom_drawer.dart b/lib/ui/app/custom_drawer.dart index c579c7a3f..1b48e698b 100644 --- a/lib/ui/app/custom_drawer.dart +++ b/lib/ui/app/custom_drawer.dart @@ -4,14 +4,14 @@ import 'package:invoiceninja/data/models/entities.dart'; class CustomDrawer extends StatelessWidget { final List companies; - final String selectedCompanyName; + final CompanyEntity selectedCompany; final String selectedCompanyIndex; final Function(String) onCompanyChanged; CustomDrawer({ Key key, @required this.companies, - @required this.selectedCompanyName, + @required this.selectedCompany, @required this.selectedCompanyIndex, @required this.onCompanyChanged, }) : super(key: key); @@ -20,7 +20,7 @@ class CustomDrawer extends StatelessWidget { Widget build(BuildContext context) { final _singleCompany = Align( alignment: FractionalOffset.bottomLeft, - child: Text(selectedCompanyName), + child: Text(selectedCompany.name), ); final _multipleCompanies = Align( @@ -35,7 +35,6 @@ class CustomDrawer extends StatelessWidget { ) ).toList(), onChanged: (value) { - print('on change: ' + value); this.onCompanyChanged(value); }, ), @@ -50,9 +49,12 @@ class CustomDrawer extends StatelessWidget { children: [ Expanded( child: Center( - child: Text('Logo'), + child: new Image.network(this.selectedCompany.logoUrl ) ), ), + SizedBox( + height: 14.0, + ), this.companies.length > 1 ? _multipleCompanies : _singleCompany, ], )), diff --git a/lib/ui/app/custom_drawer_vm.dart b/lib/ui/app/custom_drawer_vm.dart index 3b201d269..e43275d76 100644 --- a/lib/ui/app/custom_drawer_vm.dart +++ b/lib/ui/app/custom_drawer_vm.dart @@ -18,7 +18,7 @@ class CustomDrawerVM extends StatelessWidget { builder: (context, vm) { return CustomDrawer( companies: vm.companies, - selectedCompanyName: vm.selectedCompanyName, + selectedCompany: vm.selectedCompany, selectedCompanyIndex: vm.selectedCompanyIndex, onCompanyChanged: vm.onCompanyChanged, ); @@ -29,13 +29,13 @@ class CustomDrawerVM extends StatelessWidget { class _ViewModel { final List companies; - final String selectedCompanyName; + final CompanyEntity selectedCompany; final String selectedCompanyIndex; final Function(String) onCompanyChanged; _ViewModel({ @required this.companies, - @required this.selectedCompanyName, + @required this.selectedCompany, @required this.selectedCompanyIndex, @required this.onCompanyChanged, }); @@ -43,7 +43,7 @@ class _ViewModel { static _ViewModel fromStore(Store store) { return _ViewModel( companies: companiesSelector(store.state), - selectedCompanyName: store.state.selectedCompany().name, + selectedCompany: store.state.selectedCompany(), selectedCompanyIndex: store.state.selectedCompanyIndex.toString(), onCompanyChanged: (String companyId) { store.dispatch(SelectCompany(int.parse(companyId)));