From 4899e61505429e9825883f3ca77aa2f6d0b0f0c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 May 2018 07:54:58 -0700 Subject: [PATCH] Company selector --- lib/data/file_storage.dart | 2 - lib/data/repositories/auth_repository.dart | 8 -- .../repositories/dashboard_repository.dart | 4 +- lib/data/web_client.dart | 2 +- lib/redux/company/company_reducer.dart | 4 - lib/redux/dashboard/dashboard_middleware.dart | 3 - lib/ui/app/custom_drawer.dart | 78 +++++++++++++++++++ lib/ui/app/sidebar.dart | 60 -------------- lib/ui/auth/login.dart | 3 - lib/ui/client/clients.dart | 4 +- lib/ui/dashboard/dashboard.dart | 4 +- 11 files changed, 84 insertions(+), 88 deletions(-) create mode 100644 lib/ui/app/custom_drawer.dart delete mode 100644 lib/ui/app/sidebar.dart diff --git a/lib/data/file_storage.dart b/lib/data/file_storage.dart index 777342714..1d121dbfa 100644 --- a/lib/data/file_storage.dart +++ b/lib/data/file_storage.dart @@ -20,8 +20,6 @@ class FileStorage { final file = await _getLocalFile(); final contents = await file.readAsString(); - print('LOADING PRODUCTS FROM FILE...'); - /* return serializers .deserializeWith(AppState.serializer, json.decode(contents)) diff --git a/lib/data/repositories/auth_repository.dart b/lib/data/repositories/auth_repository.dart index 29821afd1..5fe848e3e 100644 --- a/lib/data/repositories/auth_repository.dart +++ b/lib/data/repositories/auth_repository.dart @@ -29,14 +29,6 @@ class AuthRepositoryFlutter { 'password': password, }); - print('== LOGN RESPONSE =='); - print(data); - - // TODO remove handle on server - for (int i=1; i CompanyEntity.fromJson(company)).toList(); /* diff --git a/lib/data/repositories/dashboard_repository.dart b/lib/data/repositories/dashboard_repository.dart index ce064b716..b94df6d46 100644 --- a/lib/data/repositories/dashboard_repository.dart +++ b/lib/data/repositories/dashboard_repository.dart @@ -19,9 +19,7 @@ class DashboardRepositoryFlutter { }); Future loadItem(CompanyEntity company, AuthState auth) async { - print('== Load item =='); - print('url: ' + auth.url + '/dashboard'); - print('token: ' + company.token); + final data = await webClient.fetchItem( auth.url + '/dashboard', company.token); diff --git a/lib/data/web_client.dart b/lib/data/web_client.dart index 5647fc724..a83a2bf41 100644 --- a/lib/data/web_client.dart +++ b/lib/data/web_client.dart @@ -52,7 +52,7 @@ class WebClient { Future postList(String url, String token, var data) async { final http.Response response = await sendPostRequest(url, token, data); - print(response.body); + //print(response.body); return BaseListResponse .fromJson(json.decode(response.body)) diff --git a/lib/redux/company/company_reducer.dart b/lib/redux/company/company_reducer.dart index 9652eec6a..d1b66d60a 100644 --- a/lib/redux/company/company_reducer.dart +++ b/lib/redux/company/company_reducer.dart @@ -21,9 +21,5 @@ Reducer companyEntityReducer = combineReducers([ ]); CompanyEntity loadCompanySuccessReducer(CompanyEntity company, LoadCompanySuccess action) { - print('loadCompanySuccessReducer'); - print(company); - print(action.company); - return action.company; } \ No newline at end of file diff --git a/lib/redux/dashboard/dashboard_middleware.dart b/lib/redux/dashboard/dashboard_middleware.dart index 6f7570a58..07b41bc62 100644 --- a/lib/redux/dashboard/dashboard_middleware.dart +++ b/lib/redux/dashboard/dashboard_middleware.dart @@ -24,9 +24,6 @@ List> createStoreDashboardMiddleware([ Middleware _createLoadDashboard(DashboardRepositoryFlutter repository) { return (Store store, action, NextDispatcher next) { - print('== LOAD DASHBOARD =='); - print(store.state.selectedCompany()); - print(store.state.auth); repository.loadItem(store.state.selectedCompany(), store.state.auth).then( (data) => store.dispatch(DashboardLoadedAction(data)) diff --git a/lib/ui/app/custom_drawer.dart b/lib/ui/app/custom_drawer.dart new file mode 100644 index 000000000..d25049e7c --- /dev/null +++ b/lib/ui/app/custom_drawer.dart @@ -0,0 +1,78 @@ +import 'package:flutter/material.dart'; +import 'package:invoiceninja/routes.dart'; + +class CustomDrawer extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Drawer( + child: ListView( + children: [ + Container( + child: DrawerHeader( + child: Column( + children: [ + Expanded( + child: Center( + child: Text('Logo'), + ), + ), + Row( + children: [ + Expanded( + child: Text('Test'), + ), + MaterialButton( + onPressed: () { + + }, + child: Text('Change'), + ) + ], + ) + ], + )), + color: Colors.white10, + ), + ListTile( + leading: Icon(Icons.dashboard), + title: Text('Dashboard'), + onTap: () { + Navigator.of(context).popAndPushNamed(AppRoutes.dashboard); + }, + ), + /* + ListTile( + leading: Icon(Icons.people), + title: Text('Clients'), + onTap: () { + Navigator.of(context).pop(); + Navigator.of(context).pushNamed(AppRoutes.clientScreen); + }, + ), + */ + ListTile( + leading: Icon(Icons.language), + title: Text('Products'), + onTap: () { + Navigator.of(context).popAndPushNamed(AppRoutes.products); + }, + ), + /* + ListTile( + leading: Icon(Icons.email), + title: Text('Invoices'), + onTap: () {}, + ), + */ + ListTile( + leading: Icon(Icons.power_settings_new), + title: Text('Log Out'), + onTap: () { + Navigator.of(context).popAndPushNamed(AppRoutes.login); + }, + ), + ], + ), + ); + } +} diff --git a/lib/ui/app/sidebar.dart b/lib/ui/app/sidebar.dart deleted file mode 100644 index 274671ad4..000000000 --- a/lib/ui/app/sidebar.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:invoiceninja/routes.dart'; - -class Sidebar extends StatelessWidget { - @override - Widget build(BuildContext context) { - return new Drawer( - child: new ListView( - children: [ - new Container( - child: new DrawerHeader( - child: new Center( - child: new Text('Logo'), - ), - ), - color: Colors.white10, - ), - new ListTile( - leading: new Icon(Icons.dashboard), - title: new Text('Dashboard'), - onTap: () { - Navigator.of(context).popAndPushNamed(AppRoutes.dashboard); - }, - ), - /* - new ListTile( - leading: new Icon(Icons.people), - title: new Text('Clients'), - onTap: () { - Navigator.of(context).pop(); - Navigator.of(context).pushNamed(AppRoutes.clientScreen); - }, - ), - */ - new ListTile( - leading: new Icon(Icons.language), - title: new Text('Products'), - onTap: () { - Navigator.of(context).popAndPushNamed(AppRoutes.products); - }, - ), - /* - new ListTile( - leading: new Icon(Icons.email), - title: new Text('Invoices'), - onTap: () {}, - ), - */ - new ListTile( - leading: new Icon(Icons.power_settings_new), - title: new Text('Log Out'), - onTap: () { - Navigator.of(context).popAndPushNamed(AppRoutes.login); - }, - ), - ], - ), - ); - } -} diff --git a/lib/ui/auth/login.dart b/lib/ui/auth/login.dart index 307383233..14d9be21e 100644 --- a/lib/ui/auth/login.dart +++ b/lib/ui/auth/login.dart @@ -51,8 +51,6 @@ class _LoginScreenState extends State { converter: (Store store) { return (BuildContext context, String email, String password, String url) { store.dispatch(UserLoginRequest(context, email, password, url)); - //store.dispatch(UserLoginSuccess(User(token, 1))); - //Navigator.of(context).pushNamed('/dashboard'); }; }, builder: (BuildContext context, loginAction) { return Scaffold( @@ -92,7 +90,6 @@ class _LoginScreenState extends State { Padding( padding: EdgeInsets.only(top: 20.0), child: Material( - //borderRadius: BorderRadius.circular(30.0), shadowColor: Colors.lightBlueAccent.shade100, elevation: 5.0, child: MaterialButton( diff --git a/lib/ui/client/clients.dart b/lib/ui/client/clients.dart index fc82ecdd9..990d55273 100644 --- a/lib/ui/client/clients.dart +++ b/lib/ui/client/clients.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; import 'package:invoiceninja/keys.dart'; -import 'package:invoiceninja/ui/app/sidebar.dart'; +import 'package:invoiceninja/ui/app/custom_drawer.dart'; class ClientList extends StatelessWidget { ClientList() : super(key: NinjaKeys.clientList); @@ -11,7 +11,7 @@ class ClientList extends StatelessWidget { appBar: new AppBar( title: new Text('Clients'), ), - drawer: new Sidebar(), + drawer: new CustomDrawer(), body: new Center( child: new Column( mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/ui/dashboard/dashboard.dart b/lib/ui/dashboard/dashboard.dart index c210d852b..980a04b90 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/sidebar.dart'; +import 'package:invoiceninja/ui/app/custom_drawer.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: Sidebar(), + drawer: CustomDrawer(), body: DashboardVM(), ); }