Company selector

This commit is contained in:
unknown 2018-05-23 07:54:58 -07:00
parent ed1ec0f4f7
commit 4899e61505
11 changed files with 84 additions and 88 deletions

View File

@ -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))

View File

@ -29,14 +29,6 @@ class AuthRepositoryFlutter {
'password': password,
});
print('== LOGN RESPONSE ==');
print(data);
// TODO remove handle on server
for (int i=1; i<data.length; i++) {
data[i].id = i;
}
return data.map((company) => CompanyEntity.fromJson(company)).toList();
/*

View File

@ -19,9 +19,7 @@ class DashboardRepositoryFlutter {
});
Future<dynamic> 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);

View File

@ -52,7 +52,7 @@ class WebClient {
Future<dynamic> 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))

View File

@ -21,9 +21,5 @@ Reducer<CompanyEntity> companyEntityReducer = combineReducers([
]);
CompanyEntity loadCompanySuccessReducer(CompanyEntity company, LoadCompanySuccess action) {
print('loadCompanySuccessReducer');
print(company);
print(action.company);
return action.company;
}

View File

@ -24,9 +24,6 @@ List<Middleware<AppState>> createStoreDashboardMiddleware([
Middleware<AppState> _createLoadDashboard(DashboardRepositoryFlutter repository) {
return (Store<AppState> 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))

View File

@ -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: <Widget>[
Container(
child: DrawerHeader(
child: Column(
children: <Widget>[
Expanded(
child: Center(
child: Text('Logo'),
),
),
Row(
children: <Widget>[
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);
},
),
],
),
);
}
}

View File

@ -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: <Widget>[
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);
},
),
],
),
);
}
}

View File

@ -51,8 +51,6 @@ class _LoginScreenState extends State<LoginScreen> {
converter: (Store<AppState> 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<LoginScreen> {
Padding(
padding: EdgeInsets.only(top: 20.0),
child: Material(
//borderRadius: BorderRadius.circular(30.0),
shadowColor: Colors.lightBlueAccent.shade100,
elevation: 5.0,
child: MaterialButton(

View File

@ -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,

View File

@ -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(),
);
}