diff --git a/lib/redux/auth/auth_middleware.dart b/lib/redux/auth/auth_middleware.dart index 2c06ec98d..972cd1ed4 100644 --- a/lib/redux/auth/auth_middleware.dart +++ b/lib/redux/auth/auth_middleware.dart @@ -50,7 +50,7 @@ Middleware _createLoginRequest(AuthRepositoryFlutter repository) { store.dispatch(SelectCompany(1)); store.dispatch(UserLoginSuccess()); - store.dispatch(LoadDashboardAction()); + //store.dispatch(LoadDashboardAction()); Navigator.of(action.context).pushNamed(AppRoutes.dashboard); } diff --git a/lib/ui/app/custom_drawer.dart b/lib/ui/app/custom_drawer.dart index d25049e7c..3d2ad8a2a 100644 --- a/lib/ui/app/custom_drawer.dart +++ b/lib/ui/app/custom_drawer.dart @@ -2,6 +2,13 @@ import 'package:flutter/material.dart'; import 'package:invoiceninja/routes.dart'; class CustomDrawer extends StatelessWidget { + final String companyName; + + CustomDrawer({ + Key key, + @required this.companyName, + }) : super(key: key); + @override Widget build(BuildContext context) { return Drawer( @@ -16,19 +23,7 @@ class CustomDrawer extends StatelessWidget { child: Text('Logo'), ), ), - Row( - children: [ - Expanded( - child: Text('Test'), - ), - MaterialButton( - onPressed: () { - - }, - child: Text('Change'), - ) - ], - ) + Text(this.companyName), ], )), color: Colors.white10, diff --git a/lib/ui/app/custom_drawer_vm.dart b/lib/ui/app/custom_drawer_vm.dart new file mode 100644 index 000000000..bc9ed9f10 --- /dev/null +++ b/lib/ui/app/custom_drawer_vm.dart @@ -0,0 +1,39 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_redux/flutter_redux.dart'; +import 'package:redux/redux.dart'; +import 'package:invoiceninja/redux/dashboard/dashboard_actions.dart'; +import 'package:invoiceninja/data/models/models.dart'; +import 'package:invoiceninja/ui/app/custom_drawer.dart'; +import 'package:invoiceninja/redux/app/app_state.dart'; +import 'package:invoiceninja/redux/dashboard/dashboard_state.dart'; + +class CustomDrawerVM extends StatelessWidget { + CustomDrawerVM({Key key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return StoreConnector( + converter: _ViewModel.fromStore, + builder: (context, vm) { + return CustomDrawer( + companyName: vm.companyName, + ); + }, + ); + } +} + +class _ViewModel { + final String companyName; + + _ViewModel({ + @required this.companyName, + }); + + static _ViewModel fromStore(Store store) { + return _ViewModel( + companyName: store.state.selectedCompany().name, + ); + } +} diff --git a/lib/ui/dashboard/dashboard.dart b/lib/ui/dashboard/dashboard.dart index 980a04b90..5b624008f 100644 --- a/lib/ui/dashboard/dashboard.dart +++ b/lib/ui/dashboard/dashboard.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:invoiceninja/keys.dart'; -import 'package:invoiceninja/ui/app/custom_drawer.dart'; +import 'package:invoiceninja/ui/app/custom_drawer_vm.dart'; import 'package:invoiceninja/ui/dashboard/dashboard_vm.dart'; class Dashboard extends StatelessWidget { @@ -12,7 +12,7 @@ class Dashboard extends StatelessWidget { appBar: AppBar( title: Text('Dashboard'), ), - drawer: CustomDrawer(), + drawer: CustomDrawerVM(), body: DashboardVM(), ); }