Refactor
This commit is contained in:
parent
6f8236190d
commit
b8dd5b8810
|
|
@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
||||||
// This version must be updated in tandem with the pubspec version.
|
// This version must be updated in tandem with the pubspec version.
|
||||||
const String kAppVersion = '2.0.2';
|
const String kAppVersion = '2.0.2';
|
||||||
const String kSiteUrl = 'https://invoiceninja.com';
|
const String kSiteUrl = 'https://invoiceninja.com';
|
||||||
const String kAppUrl = 'https://admin.invoiceninja.com';
|
//const String kAppUrl = 'https://admin.invoiceninja.com';
|
||||||
//const String kAppUrl = 'https://staging.invoicing.co';
|
const String kAppUrl = 'https://staging.invoicing.co';
|
||||||
//const String kAppUrl = '';
|
//const String kAppUrl = '';
|
||||||
|
|
||||||
const String kAppPlansURL =
|
const String kAppPlansURL =
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ List<Middleware<AppState>> createStoreClientsMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editClient() {
|
Middleware<AppState> _editClient() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditClient;
|
final action = dynamicAction as EditClient;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -54,11 +54,7 @@ Middleware<AppState> _editClient() {
|
||||||
store.dispatch(UpdateCurrentRoute(ClientEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(ClientEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final client = await action.navigator.pushNamed(ClientEditScreen.route);
|
action.navigator.pushNamed(ClientEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && client != null) {
|
|
||||||
action.completer.complete(client);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ List<Middleware<AppState>> createStoreCompanyGatewaysMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editCompanyGateway() {
|
Middleware<AppState> _editCompanyGateway() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditCompanyGateway;
|
final action = dynamicAction as EditCompanyGateway;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -57,12 +57,7 @@ Middleware<AppState> _editCompanyGateway() {
|
||||||
store.dispatch(UpdateCurrentRoute(CompanyGatewayEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(CompanyGatewayEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final companyGateway =
|
action.navigator.pushNamed(CompanyGatewayEditScreen.route);
|
||||||
await action.navigator.pushNamed(CompanyGatewayEditScreen.route);
|
|
||||||
|
|
||||||
if (action.completer != null && companyGateway != null) {
|
|
||||||
action.completer.complete(companyGateway);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ List<Middleware<AppState>> createStoreDocumentsMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editDocument() {
|
Middleware<AppState> _editDocument() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditDocument;
|
final action = dynamicAction as EditDocument;
|
||||||
|
|
||||||
next(action);
|
next(action);
|
||||||
|
|
@ -48,11 +48,7 @@ Middleware<AppState> _editDocument() {
|
||||||
store.dispatch(UpdateCurrentRoute(DocumentEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(DocumentEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final document = await action.navigator.pushNamed(DocumentEditScreen.route);
|
action.navigator.pushNamed(DocumentEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && document != null) {
|
|
||||||
action.completer.complete(document);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ List<Middleware<AppState>> createStoreExpensesMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editExpense() {
|
Middleware<AppState> _editExpense() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditExpense;
|
final action = dynamicAction as EditExpense;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -55,11 +55,7 @@ Middleware<AppState> _editExpense() {
|
||||||
store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(ExpenseEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final expense = await action.navigator.pushNamed(ExpenseEditScreen.route);
|
action.navigator.pushNamed(ExpenseEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && expense != null) {
|
|
||||||
action.completer.complete(expense);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ List<Middleware<AppState>> createStoreGroupsMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editGroup() {
|
Middleware<AppState> _editGroup() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditGroup;
|
final action = dynamicAction as EditGroup;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -54,11 +54,7 @@ Middleware<AppState> _editGroup() {
|
||||||
store.dispatch(UpdateCurrentRoute(GroupEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(GroupEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final group = await action.navigator.pushNamed(GroupEditScreen.route);
|
action.navigator.pushNamed(GroupEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && group != null) {
|
|
||||||
action.completer.complete(group);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ Middleware<AppState> _viewInvoice() {
|
||||||
|
|
||||||
Middleware<AppState> _editInvoice() {
|
Middleware<AppState> _editInvoice() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditInvoice;
|
final action = dynamicAction as EditInvoice;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -108,11 +108,7 @@ Middleware<AppState> _editInvoice() {
|
||||||
store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final invoice = await action.navigator.pushNamed(InvoiceEditScreen.route);
|
action.navigator.pushNamed(InvoiceEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && invoice != null) {
|
|
||||||
action.completer.complete(invoice);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ List<Middleware<AppState>> createStorePaymentsMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editPayment() {
|
Middleware<AppState> _editPayment() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditPayment;
|
final action = dynamicAction as EditPayment;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -57,11 +57,7 @@ Middleware<AppState> _editPayment() {
|
||||||
store.dispatch(UpdateCurrentRoute(PaymentEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(PaymentEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final payment = await action.navigator.pushNamed(PaymentEditScreen.route);
|
action.navigator.pushNamed(PaymentEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && payment != null) {
|
|
||||||
action.completer.complete(null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ List<Middleware<AppState>> createStoreProductsMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editProduct() {
|
Middleware<AppState> _editProduct() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditProduct;
|
final action = dynamicAction as EditProduct;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -51,11 +51,7 @@ Middleware<AppState> _editProduct() {
|
||||||
store.dispatch(UpdateCurrentRoute(ProductEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(ProductEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final product = await action.navigator.pushNamed(ProductEditScreen.route);
|
action.navigator.pushNamed(ProductEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && product != null) {
|
|
||||||
action.completer.complete(product);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ List<Middleware<AppState>> createStoreProjectsMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editProject() {
|
Middleware<AppState> _editProject() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditProject;
|
final action = dynamicAction as EditProject;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -55,11 +55,7 @@ Middleware<AppState> _editProject() {
|
||||||
store.dispatch(UpdateCurrentRoute(ProjectEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(ProjectEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final project = await action.navigator.pushNamed(ProjectEditScreen.route);
|
action.navigator.pushNamed(ProjectEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && project != null) {
|
|
||||||
action.completer.complete(project);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ Middleware<AppState> _viewQuoteList() {
|
||||||
|
|
||||||
Middleware<AppState> _editQuote() {
|
Middleware<AppState> _editQuote() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditQuote;
|
final action = dynamicAction as EditQuote;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -108,11 +108,7 @@ Middleware<AppState> _editQuote() {
|
||||||
store.dispatch(UpdateCurrentRoute(QuoteEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(QuoteEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final quote = await action.navigator.pushNamed(QuoteEditScreen.route);
|
action.navigator.pushNamed(QuoteEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && quote != null) {
|
|
||||||
action.completer.complete(quote);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ List<Middleware<AppState>> createStoreTasksMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editTask() {
|
Middleware<AppState> _editTask() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditTask;
|
final action = dynamicAction as EditTask;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -54,11 +54,7 @@ Middleware<AppState> _editTask() {
|
||||||
store.dispatch(UpdateCurrentRoute(TaskEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(TaskEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final task = await action.navigator.pushNamed(TaskEditScreen.route);
|
action.navigator.pushNamed(TaskEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && task != null) {
|
|
||||||
action.completer.complete(task);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ List<Middleware<AppState>> createStoreTaxRatesMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editTaxRate() {
|
Middleware<AppState> _editTaxRate() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditTaxRate;
|
final action = dynamicAction as EditTaxRate;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -53,11 +53,7 @@ Middleware<AppState> _editTaxRate() {
|
||||||
store.dispatch(UpdateCurrentRoute(TaxRateEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(TaxRateEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final taxRate = await action.navigator.pushNamed(TaxRateEditScreen.route);
|
action.navigator.pushNamed(TaxRateEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && taxRate != null) {
|
|
||||||
action.completer.complete(taxRate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ List<Middleware<AppState>> createStoreUsersMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editUser() {
|
Middleware<AppState> _editUser() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditUser;
|
final action = dynamicAction as EditUser;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -53,11 +53,7 @@ Middleware<AppState> _editUser() {
|
||||||
store.dispatch(UpdateCurrentRoute(UserEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(UserEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final user = await action.navigator.pushNamed(UserEditScreen.route);
|
action.navigator.pushNamed(UserEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && user != null) {
|
|
||||||
action.completer.complete(user);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ List<Middleware<AppState>> createStoreVendorsMiddleware([
|
||||||
|
|
||||||
Middleware<AppState> _editVendor() {
|
Middleware<AppState> _editVendor() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction,
|
return (Store<AppState> store, dynamic dynamicAction,
|
||||||
NextDispatcher next) async {
|
NextDispatcher next) {
|
||||||
final action = dynamicAction as EditVendor;
|
final action = dynamicAction as EditVendor;
|
||||||
|
|
||||||
if (!action.force &&
|
if (!action.force &&
|
||||||
|
|
@ -55,11 +55,7 @@ Middleware<AppState> _editVendor() {
|
||||||
store.dispatch(UpdateCurrentRoute(VendorEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(VendorEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final vendor = await action.navigator.pushNamed(VendorEditScreen.route);
|
action.navigator.pushNamed(VendorEditScreen.route);
|
||||||
|
|
||||||
if (action.completer != null && vendor != null) {
|
|
||||||
action.completer.complete(vendor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ List<Middleware<AppState>> createStoreStubsMiddleware([
|
||||||
}
|
}
|
||||||
|
|
||||||
Middleware<AppState> _editStub() {
|
Middleware<AppState> _editStub() {
|
||||||
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) async {
|
return (Store<AppState> store, dynamic dynamicAction, NextDispatcher next) {
|
||||||
|
|
||||||
final action = dynamicAction as EditStub;
|
final action = dynamicAction as EditStub;
|
||||||
|
|
||||||
|
|
@ -53,12 +53,7 @@ Middleware<AppState> _editStub() {
|
||||||
store.dispatch(UpdateCurrentRoute(StubEditScreen.route));
|
store.dispatch(UpdateCurrentRoute(StubEditScreen.route));
|
||||||
|
|
||||||
if (isMobile(action.context)) {
|
if (isMobile(action.context)) {
|
||||||
final stub =
|
action.navigator.pushNamed(QuoteEditScreen.route);
|
||||||
await Navigator.of(action.context).pushNamed(StubEditScreen.route);
|
|
||||||
|
|
||||||
if (action.completer != null && stub != null) {
|
|
||||||
action.completer.complete(stub);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue