From 5b50a81d94e7f866e26116da53b29403f1781b64 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 May 2018 12:07:00 -0700 Subject: [PATCH] Company selector --- lib/ui/app/custom_drawer.dart | 11 +++++++---- lib/ui/app/custom_drawer_vm.dart | 4 ++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/ui/app/custom_drawer.dart b/lib/ui/app/custom_drawer.dart index e8846aa7b..ff8d3e560 100644 --- a/lib/ui/app/custom_drawer.dart +++ b/lib/ui/app/custom_drawer.dart @@ -6,12 +6,14 @@ class CustomDrawer extends StatelessWidget { final String companyName; final bool hasMultipleCompanies; final List companies; + final String selectedCompanyId; CustomDrawer({ Key key, @required this.companyName, @required this.hasMultipleCompanies, @required this.companies, + @required this.selectedCompanyId, }) : super(key: key); @override @@ -24,14 +26,15 @@ class CustomDrawer extends StatelessWidget { final _multipleCompanies = Align( alignment: FractionalOffset.bottomLeft, child: new DropdownButton( + value: this.selectedCompanyId, items: this.companies.map((CompanyEntity company) => DropdownMenuItem( - value: company.id.toString(), - child: Text(company.id.toString()), + value: (this.companies.indexOf(company) + 1).toString(), + child: Text(company.name), ) ).toList(), - onChanged: (_) { - + onChanged: (value) { + print('on change: ' + value); }, ), /* diff --git a/lib/ui/app/custom_drawer_vm.dart b/lib/ui/app/custom_drawer_vm.dart index 6ae5f2f01..3bdbab7fa 100644 --- a/lib/ui/app/custom_drawer_vm.dart +++ b/lib/ui/app/custom_drawer_vm.dart @@ -19,6 +19,7 @@ class CustomDrawerVM extends StatelessWidget { companyName: vm.companyName, hasMultipleCompanies: vm.hasMultipleCompanies, companies: vm.companies, + selectedCompanyId: vm.selectedCompanyId, ); }, ); @@ -29,11 +30,13 @@ class _ViewModel { final String companyName; final bool hasMultipleCompanies; final List companies; + final String selectedCompanyId; _ViewModel({ @required this.companyName, @required this.hasMultipleCompanies, @required this.companies, + @required this.selectedCompanyId, }); static _ViewModel fromStore(Store store) { @@ -41,6 +44,7 @@ class _ViewModel { companyName: store.state.selectedCompany().name, hasMultipleCompanies: store.state.companyState2.company.token != null, companies: companiesSelector(store.state), + selectedCompanyId: store.state.selectedCompanyId.toString(), ); } }