Company selector
This commit is contained in:
parent
4899e61505
commit
b875d6e93b
|
|
@ -50,7 +50,7 @@ Middleware<AppState> _createLoginRequest(AuthRepositoryFlutter repository) {
|
|||
|
||||
store.dispatch(SelectCompany(1));
|
||||
store.dispatch(UserLoginSuccess());
|
||||
store.dispatch(LoadDashboardAction());
|
||||
//store.dispatch(LoadDashboardAction());
|
||||
|
||||
Navigator.of(action.context).pushNamed(AppRoutes.dashboard);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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: <Widget>[
|
||||
Expanded(
|
||||
child: Text('Test'),
|
||||
),
|
||||
MaterialButton(
|
||||
onPressed: () {
|
||||
|
||||
},
|
||||
child: Text('Change'),
|
||||
)
|
||||
],
|
||||
)
|
||||
Text(this.companyName),
|
||||
],
|
||||
)),
|
||||
color: Colors.white10,
|
||||
|
|
|
|||
|
|
@ -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<AppState, _ViewModel>(
|
||||
converter: _ViewModel.fromStore,
|
||||
builder: (context, vm) {
|
||||
return CustomDrawer(
|
||||
companyName: vm.companyName,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _ViewModel {
|
||||
final String companyName;
|
||||
|
||||
_ViewModel({
|
||||
@required this.companyName,
|
||||
});
|
||||
|
||||
static _ViewModel fromStore(Store<AppState> store) {
|
||||
return _ViewModel(
|
||||
companyName: store.state.selectedCompany().name,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue