Refactor
This commit is contained in:
parent
6a5f2c1f77
commit
9e54f08bde
|
|
@ -20,7 +20,6 @@ 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';
|
||||
|
|
@ -94,22 +93,22 @@ class _InvoiceNinjaAppState extends State<InvoiceNinjaApp> {
|
|||
return LoginScreen();
|
||||
},
|
||||
DashboardScreen.route: (context) {
|
||||
widget.store.dispatch(ViewDashboard());
|
||||
widget.store.dispatch(LoadDashboard());
|
||||
return DashboardScreen();
|
||||
},
|
||||
ProductScreen.route: (context) {
|
||||
widget.store.dispatch(ViewProductList());
|
||||
widget.store.dispatch(LoadProducts());
|
||||
return ProductScreen();
|
||||
},
|
||||
ProductEditScreen.route: (context) => ProductEditScreen(),
|
||||
ClientScreen.route: (context) {
|
||||
widget.store.dispatch(ViewClientList());
|
||||
widget.store.dispatch(LoadClients());
|
||||
return ClientScreen();
|
||||
},
|
||||
ClientViewScreen.route: (context) => ClientViewScreen(),
|
||||
ClientEditScreen.route: (context) => ClientEditScreen(),
|
||||
InvoiceScreen.route: (context) {
|
||||
widget.store.dispatch(ViewInvoiceList());
|
||||
widget.store.dispatch(LoadInvoices());
|
||||
return InvoiceScreen();
|
||||
},
|
||||
InvoiceViewScreen.route: (context) => InvoiceViewScreen(),
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import 'package:invoiceninja/data/models/models.dart';
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||
|
||||
class ViewClientList implements PersistUI {}
|
||||
class ViewClientList implements PersistUI {
|
||||
final BuildContext context;
|
||||
ViewClientList(this.context);
|
||||
}
|
||||
|
||||
class ViewClient implements PersistUI {
|
||||
final int clientId;
|
||||
|
|
|
|||
|
|
@ -34,15 +34,6 @@ List<Middleware<AppState>> createStoreClientsMiddleware([
|
|||
];
|
||||
}
|
||||
|
||||
Middleware<AppState> _viewClientList() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
store.dispatch(LoadClients());
|
||||
store.dispatch(UpdateCurrentRoute(ClientScreen.route));
|
||||
|
||||
next(action);
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _editClient() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
next(action);
|
||||
|
|
@ -61,6 +52,15 @@ Middleware<AppState> _viewClient() {
|
|||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _viewClientList() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(ClientScreen.route));
|
||||
Navigator.of(action.context).pushReplacementNamed(ClientScreen.route);
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _archiveClient(ClientRepository repository) {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
var origClient = store.state.clientState.map[action.clientId];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import 'package:invoiceninja/data/models/models.dart';
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||
|
||||
class ViewInvoiceList implements PersistUI {}
|
||||
class ViewInvoiceList implements PersistUI {
|
||||
final BuildContext context;
|
||||
ViewInvoiceList(this.context);
|
||||
}
|
||||
|
||||
class ViewInvoice implements PersistUI {
|
||||
final int invoiceId;
|
||||
|
|
|
|||
|
|
@ -36,15 +36,6 @@ List<Middleware<AppState>> createStoreInvoicesMiddleware([
|
|||
];
|
||||
}
|
||||
|
||||
Middleware<AppState> _viewInvoiceList() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
store.dispatch(LoadInvoices());
|
||||
store.dispatch(UpdateCurrentRoute(InvoiceScreen.route));
|
||||
|
||||
next(action);
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _viewInvoice() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
next(action);
|
||||
|
|
@ -54,6 +45,15 @@ Middleware<AppState> _viewInvoice() {
|
|||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _viewInvoiceList() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(InvoiceScreen.route));
|
||||
Navigator.of(action.context).pushReplacementNamed(InvoiceScreen.route);
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _editInvoice() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
next(action);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ import 'package:invoiceninja/data/models/models.dart';
|
|||
import 'package:built_collection/built_collection.dart';
|
||||
import 'package:invoiceninja/redux/app/app_actions.dart';
|
||||
|
||||
class ViewProductList implements PersistUI {}
|
||||
class ViewProductList implements PersistUI {
|
||||
final BuildContext context;
|
||||
ViewProductList(this.context);
|
||||
}
|
||||
|
||||
class EditProduct implements PersistUI {
|
||||
final ProductEntity product;
|
||||
|
|
|
|||
|
|
@ -30,15 +30,6 @@ List<Middleware<AppState>> createStoreProductsMiddleware([
|
|||
];
|
||||
}
|
||||
|
||||
Middleware<AppState> _viewProductList() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
store.dispatch(LoadProducts());
|
||||
store.dispatch(UpdateCurrentRoute(ProductScreen.route));
|
||||
|
||||
next(action);
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _editProduct() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
next(action);
|
||||
|
|
@ -48,6 +39,15 @@ Middleware<AppState> _editProduct() {
|
|||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _viewProductList() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(ProductScreen.route));
|
||||
Navigator.of(action.context).pushReplacementNamed(ProductScreen.route);
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _archiveProduct(ProductRepository repository) {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
var origProduct = store.state.productState.map[action.productId];
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import 'package:invoiceninja/redux/dashboard/dashboard_actions.dart';
|
|||
import 'package:invoiceninja/redux/invoice/invoice_actions.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja/data/models/entities.dart';
|
||||
import 'package:invoiceninja/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja/ui/app/app_drawer_vm.dart';
|
||||
import 'package:invoiceninja/ui/client/client_screen.dart';
|
||||
import 'package:invoiceninja/ui/invoice/invoice_screen.dart';
|
||||
|
|
@ -104,7 +105,7 @@ class AppDrawer extends StatelessWidget {
|
|||
DrawerTile(
|
||||
icon: FontAwesomeIcons.users,
|
||||
title: AppLocalization.of(context).clients,
|
||||
onTap: () => navigator.pushReplacementNamed(ClientScreen.route),
|
||||
onTap: () => store.dispatch(ViewClientList(context)),
|
||||
onCreateTap: () {
|
||||
navigator.pop();
|
||||
store.dispatch(
|
||||
|
|
@ -114,7 +115,7 @@ class AppDrawer extends StatelessWidget {
|
|||
DrawerTile(
|
||||
icon: FontAwesomeIcons.cube,
|
||||
title: AppLocalization.of(context).products,
|
||||
onTap: () => navigator.pushReplacementNamed(ProductScreen.route),
|
||||
onTap: () => store.dispatch(ViewProductList(context)),
|
||||
onCreateTap: () {
|
||||
navigator.pop();
|
||||
store.dispatch(
|
||||
|
|
@ -124,7 +125,7 @@ class AppDrawer extends StatelessWidget {
|
|||
DrawerTile(
|
||||
icon: FontAwesomeIcons.filePdfO,
|
||||
title: AppLocalization.of(context).invoices,
|
||||
onTap: () => navigator.pushReplacementNamed(InvoiceScreen.route),
|
||||
onTap: () => store.dispatch(ViewProductList(context)),
|
||||
onCreateTap: () {
|
||||
navigator.pop();
|
||||
store.dispatch(
|
||||
|
|
|
|||
Loading…
Reference in New Issue