This commit is contained in:
unknown 2018-05-23 13:13:50 -07:00
parent 269d9955a6
commit 020b8df8bd
2 changed files with 11 additions and 9 deletions

View File

@ -4,14 +4,14 @@ import 'package:invoiceninja/data/models/entities.dart';
class CustomDrawer extends StatelessWidget { class CustomDrawer extends StatelessWidget {
final List<CompanyEntity> companies; final List<CompanyEntity> companies;
final String selectedCompanyName; final CompanyEntity selectedCompany;
final String selectedCompanyIndex; final String selectedCompanyIndex;
final Function(String) onCompanyChanged; final Function(String) onCompanyChanged;
CustomDrawer({ CustomDrawer({
Key key, Key key,
@required this.companies, @required this.companies,
@required this.selectedCompanyName, @required this.selectedCompany,
@required this.selectedCompanyIndex, @required this.selectedCompanyIndex,
@required this.onCompanyChanged, @required this.onCompanyChanged,
}) : super(key: key); }) : super(key: key);
@ -20,7 +20,7 @@ class CustomDrawer extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
final _singleCompany = Align( final _singleCompany = Align(
alignment: FractionalOffset.bottomLeft, alignment: FractionalOffset.bottomLeft,
child: Text(selectedCompanyName), child: Text(selectedCompany.name),
); );
final _multipleCompanies = Align( final _multipleCompanies = Align(
@ -35,7 +35,6 @@ class CustomDrawer extends StatelessWidget {
) )
).toList(), ).toList(),
onChanged: (value) { onChanged: (value) {
print('on change: ' + value);
this.onCompanyChanged(value); this.onCompanyChanged(value);
}, },
), ),
@ -50,9 +49,12 @@ class CustomDrawer extends StatelessWidget {
children: <Widget>[ children: <Widget>[
Expanded( Expanded(
child: Center( child: Center(
child: Text('Logo'), child: new Image.network(this.selectedCompany.logoUrl )
), ),
), ),
SizedBox(
height: 14.0,
),
this.companies.length > 1 ? _multipleCompanies : _singleCompany, this.companies.length > 1 ? _multipleCompanies : _singleCompany,
], ],
)), )),

View File

@ -18,7 +18,7 @@ class CustomDrawerVM extends StatelessWidget {
builder: (context, vm) { builder: (context, vm) {
return CustomDrawer( return CustomDrawer(
companies: vm.companies, companies: vm.companies,
selectedCompanyName: vm.selectedCompanyName, selectedCompany: vm.selectedCompany,
selectedCompanyIndex: vm.selectedCompanyIndex, selectedCompanyIndex: vm.selectedCompanyIndex,
onCompanyChanged: vm.onCompanyChanged, onCompanyChanged: vm.onCompanyChanged,
); );
@ -29,13 +29,13 @@ class CustomDrawerVM extends StatelessWidget {
class _ViewModel { class _ViewModel {
final List<CompanyEntity> companies; final List<CompanyEntity> companies;
final String selectedCompanyName; final CompanyEntity selectedCompany;
final String selectedCompanyIndex; final String selectedCompanyIndex;
final Function(String) onCompanyChanged; final Function(String) onCompanyChanged;
_ViewModel({ _ViewModel({
@required this.companies, @required this.companies,
@required this.selectedCompanyName, @required this.selectedCompany,
@required this.selectedCompanyIndex, @required this.selectedCompanyIndex,
@required this.onCompanyChanged, @required this.onCompanyChanged,
}); });
@ -43,7 +43,7 @@ class _ViewModel {
static _ViewModel fromStore(Store<AppState> store) { static _ViewModel fromStore(Store<AppState> store) {
return _ViewModel( return _ViewModel(
companies: companiesSelector(store.state), companies: companiesSelector(store.state),
selectedCompanyName: store.state.selectedCompany().name, selectedCompany: store.state.selectedCompany(),
selectedCompanyIndex: store.state.selectedCompanyIndex.toString(), selectedCompanyIndex: store.state.selectedCompanyIndex.toString(),
onCompanyChanged: (String companyId) { onCompanyChanged: (String companyId) {
store.dispatch(SelectCompany(int.parse(companyId))); store.dispatch(SelectCompany(int.parse(companyId)));