Refactor
This commit is contained in:
parent
44e51e6c8e
commit
6e07e16046
|
|
@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja/redux/app/app_middleware.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:invoiceninja/routes.dart';
|
||||
import 'package:invoiceninja/ui/auth/login_vm.dart';
|
||||
import 'package:invoiceninja/ui/dashboard/dashboard_screen.dart';
|
||||
import 'package:invoiceninja/ui/product/product_screen.dart';
|
||||
|
|
@ -67,16 +66,15 @@ class _InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
|||
*/
|
||||
title: 'Invoice Ninja',
|
||||
routes: {
|
||||
AppRoutes.login: (context) {
|
||||
LoginVM.route: (context) {
|
||||
widget.store.dispatch(LoadStateRequest(context));
|
||||
return LoginVM();
|
||||
},
|
||||
AppRoutes.dashboard: (context) {
|
||||
DashboardScreen.route: (context) {
|
||||
widget.store.dispatch(LoadDashboardAction());
|
||||
return DashboardScreen();
|
||||
},
|
||||
AppRoutes.products: (context) {
|
||||
print('== LODING ROUTE ==');
|
||||
ProductScreen.route: (context) {
|
||||
widget.store.dispatch(LoadProductsAction());
|
||||
return ProductScreen();
|
||||
},
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import 'package:invoiceninja/redux/app/app_state.dart';
|
|||
import 'package:invoiceninja/redux/auth/auth_actions.dart';
|
||||
import 'package:invoiceninja/redux/dashboard/dashboard_actions.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja/routes.dart';
|
||||
import 'package:invoiceninja/ui/dashboard/dashboard_screen.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
|
|
@ -43,7 +43,7 @@ Middleware<AppState> _createLoadState(PersistenceRepository repository) {
|
|||
if (exists) {
|
||||
repository.loadData().then((state) {
|
||||
store.dispatch(LoadStateSuccess(state));
|
||||
Navigator.of(action.context).pushReplacementNamed(AppRoutes.dashboard);
|
||||
Navigator.of(action.context).pushReplacementNamed(DashboardScreen.route);
|
||||
}).catchError((error) {
|
||||
print(error);
|
||||
store.dispatch(LoadUserLogin());
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
class AppRoutes {
|
||||
static final login = '/';
|
||||
static final dashboard = '/dashboard';
|
||||
static final clients = '/clients';
|
||||
static final products = '/products';
|
||||
}
|
||||
|
|
@ -3,9 +3,10 @@ import 'package:flutter_redux/flutter_redux.dart';
|
|||
import 'package:invoiceninja/constants.dart';
|
||||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja/routes.dart';
|
||||
import 'package:invoiceninja/data/models/entities.dart';
|
||||
import 'package:invoiceninja/ui/app/app_drawer_vm.dart';
|
||||
import 'package:invoiceninja/ui/dashboard/dashboard_screen.dart';
|
||||
import 'package:invoiceninja/ui/product/product_screen.dart';
|
||||
import 'package:invoiceninja/utils/localization.dart';
|
||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||
|
||||
|
|
@ -71,7 +72,7 @@ class AppDrawer extends StatelessWidget {
|
|||
leading: Icon(FontAwesomeIcons.tachometerAlt),
|
||||
title: Text(AppLocalization.of(context).dashboard),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushReplacementNamed(AppRoutes.dashboard);
|
||||
Navigator.of(context).pushReplacementNamed(DashboardScreen.route);
|
||||
},
|
||||
),
|
||||
/*
|
||||
|
|
@ -89,7 +90,7 @@ class AppDrawer extends StatelessWidget {
|
|||
title: Text(AppLocalization.of(context).products),
|
||||
onTap: () {
|
||||
StoreProvider.of<AppState>(context).dispatch(SearchProducts(null));
|
||||
Navigator.of(context).pushReplacementNamed(AppRoutes.products);
|
||||
Navigator.of(context).pushReplacementNamed(ProductScreen.route);
|
||||
},
|
||||
),
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja/routes.dart';
|
||||
import 'package:invoiceninja/ui/auth/login_vm.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:invoiceninja/ui/app/app_drawer.dart';
|
||||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
|
|
@ -52,7 +52,7 @@ class AppDrawerVM {
|
|||
while(Navigator.of(context).canPop()) {
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
Navigator.of(context).pushReplacementNamed(AppRoutes.login);
|
||||
Navigator.of(context).pushReplacementNamed(LoginVM.route);
|
||||
store.dispatch(UserLogout());
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import 'dart:async';
|
||||
import 'package:invoiceninja/routes.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja/ui/dashboard/dashboard_screen.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja/redux/auth/auth_actions.dart';
|
||||
|
|
@ -13,6 +13,8 @@ import 'package:invoiceninja/redux/auth/auth_state.dart';
|
|||
class LoginVM extends StatelessWidget {
|
||||
LoginVM({Key key}) : super(key: key);
|
||||
|
||||
static final String route = '/';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
@ -56,7 +58,7 @@ class _ViewModel {
|
|||
final Completer<Null> completer = new Completer<Null>();
|
||||
store.dispatch(UserLoginRequest(completer, email.trim(), password.trim(), url.trim(), secret.trim()));
|
||||
completer.future.then((_) {
|
||||
Navigator.of(context).pushReplacementNamed(AppRoutes.dashboard);
|
||||
Navigator.of(context).pushReplacementNamed(DashboardScreen.route);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/keys.dart';
|
||||
import 'package:invoiceninja/ui/app/app_drawer_vm.dart';
|
||||
import 'package:invoiceninja/utils/localization.dart';
|
||||
|
||||
class ClientList extends StatelessWidget {
|
||||
|
||||
static final String route = '/clients';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Scaffold(
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/keys.dart';
|
||||
import 'package:invoiceninja/ui/app/app_drawer_vm.dart';
|
||||
import 'package:invoiceninja/ui/dashboard/dashboard_vm.dart';
|
||||
import 'package:invoiceninja/utils/localization.dart';
|
||||
|
||||
class DashboardScreen extends StatelessWidget {
|
||||
|
||||
static final String route = '/dashboard';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:invoiceninja/keys.dart';
|
||||
import 'package:invoiceninja/utils/localization.dart';
|
||||
|
||||
class ProductItem extends StatelessWidget {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import 'package:flutter/foundation.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/ui/app/loading_indicator.dart';
|
||||
import 'package:invoiceninja/ui/product/product_item.dart';
|
||||
import 'package:invoiceninja/keys.dart';
|
||||
import 'package:invoiceninja/ui/product/product_list_vm.dart';
|
||||
|
||||
class ProductList extends StatelessWidget {
|
||||
|
|
|
|||
|
|
@ -1,21 +1,20 @@
|
|||
import 'package:invoiceninja/redux/ui/list_ui_state.dart';
|
||||
import 'package:invoiceninja/ui/app/app_search.dart';
|
||||
import 'package:invoiceninja/ui/app/app_search_button.dart';
|
||||
import 'package:invoiceninja/utils/localization.dart';
|
||||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:invoiceninja/keys.dart';
|
||||
import 'package:invoiceninja/ui/product/product_list_vm.dart';
|
||||
import 'package:invoiceninja/ui/product/product_details_vm.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja/ui/app/app_drawer_vm.dart';
|
||||
import 'package:invoiceninja/ui/app/app_bottom_bar.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
||||
class ProductScreen extends StatelessWidget {
|
||||
|
||||
static final String route = '/products';
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var store = StoreProvider.of<AppState>(context);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
name: invoiceninja
|
||||
description: Mobile app for Invoice Ninja
|
||||
version: 0.0.1
|
||||
author: Hillel Coren
|
||||
homepage: https://www.invoiceninja.com
|
||||
documentation: http://docs.invoiceninja.com
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
|
|
|
|||
|
|
@ -3,17 +3,10 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_redux/flutter_redux.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
import 'package:invoiceninja/routes.dart';
|
||||
import 'package:invoiceninja/ui/auth/login_vm.dart';
|
||||
import 'package:invoiceninja/ui/dashboard/dashboard_screen.dart';
|
||||
import 'package:invoiceninja/ui/product/product_screen.dart';
|
||||
import 'package:invoiceninja/redux/app/app_reducer.dart';
|
||||
import 'package:invoiceninja/redux/app/app_state.dart';
|
||||
import 'package:invoiceninja/redux/auth/auth_middleware.dart';
|
||||
import 'package:invoiceninja/redux/auth/auth_actions.dart';
|
||||
import 'package:invoiceninja/redux/dashboard/dashboard_actions.dart';
|
||||
import 'package:invoiceninja/redux/dashboard/dashboard_middleware.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja/redux/product/product_middleware.dart';
|
||||
import 'package:invoiceninja/utils/localization.dart';
|
||||
//import 'package:redux_logging/redux_logging.dart';
|
||||
|
|
@ -67,26 +60,6 @@ class _InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
|||
*/
|
||||
title: 'Invoice Ninja',
|
||||
routes: {
|
||||
AppRoutes.login: (context) {
|
||||
StoreProvider.of<AppState>(context).dispatch(LoadUserLogin());
|
||||
return LoginVM();
|
||||
},
|
||||
AppRoutes.dashboard: (context) {
|
||||
StoreProvider.of<AppState>(context).dispatch(LoadDashboardAction());
|
||||
return DashboardScreen();
|
||||
},
|
||||
AppRoutes.products: (context) {
|
||||
if (StoreProvider
|
||||
.of<AppState>(context)
|
||||
.state
|
||||
.productState()
|
||||
.isStale()) {
|
||||
StoreProvider
|
||||
.of<AppState>(context)
|
||||
.dispatch(LoadProductsAction());
|
||||
}
|
||||
return ProductScreen();
|
||||
},
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue