Company selector
This commit is contained in:
parent
ed1ec0f4f7
commit
4899e61505
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -21,9 +21,5 @@ Reducer<CompanyEntity> companyEntityReducer = combineReducers([
|
|||
]);
|
||||
|
||||
CompanyEntity loadCompanySuccessReducer(CompanyEntity company, LoadCompanySuccess action) {
|
||||
print('loadCompanySuccessReducer');
|
||||
print(company);
|
||||
print(action.company);
|
||||
|
||||
return action.company;
|
||||
}
|
||||
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue