Working on snackbar
This commit is contained in:
parent
aad8b4d49f
commit
a80239ee48
|
|
@ -1,7 +1,9 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:invoiceninja/redux/product/product_actions.dart';
|
||||
import 'package:invoiceninja/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja/ui/app/snackbar_row.dart';
|
||||
import 'package:invoiceninja/ui/client/client_screen.dart';
|
||||
import 'package:invoiceninja/ui/client/edit/client_edit_vm.dart';
|
||||
import 'package:invoiceninja/ui/client/view/client_view_vm.dart';
|
||||
|
|
@ -35,20 +37,30 @@ List<Middleware<AppState>> createStoreClientsMiddleware([
|
|||
}
|
||||
|
||||
Middleware<AppState> _editClient() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) async {
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(ClientEditScreen.route));
|
||||
Navigator.of(action.context).pushNamed(ClientEditScreen.route);
|
||||
final message = await Navigator.of(action.context).pushNamed(ClientEditScreen.route);
|
||||
|
||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: message,
|
||||
)));
|
||||
};
|
||||
}
|
||||
|
||||
Middleware<AppState> _viewClient() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) async {
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(ClientViewScreen.route));
|
||||
Navigator.of(action.context).pushNamed(ClientViewScreen.route);
|
||||
final message = await Navigator.of(action.context).pushNamed(ClientViewScreen.route);
|
||||
|
||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: message,
|
||||
)));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:invoiceninja/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja/ui/app/snackbar_row.dart';
|
||||
import 'package:invoiceninja/ui/invoice/edit/invoice_edit_vm.dart';
|
||||
import 'package:invoiceninja/ui/invoice/invoice_screen.dart';
|
||||
import 'package:invoiceninja/ui/invoice/view/invoice_view_vm.dart';
|
||||
|
|
@ -39,11 +40,16 @@ List<Middleware<AppState>> createStoreInvoicesMiddleware([
|
|||
}
|
||||
|
||||
Middleware<AppState> _viewInvoice() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) async {
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(InvoiceViewScreen.route));
|
||||
Navigator.of(action.context).pushNamed(InvoiceViewScreen.route);
|
||||
final message = await Navigator.of(action.context).pushNamed(InvoiceViewScreen.route);
|
||||
|
||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: message,
|
||||
)));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -57,11 +63,16 @@ Middleware<AppState> _viewInvoiceList() {
|
|||
}
|
||||
|
||||
Middleware<AppState> _editInvoice() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) async {
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(InvoiceEditScreen.route));
|
||||
Navigator.of(action.context).pushNamed(InvoiceEditScreen.route);
|
||||
final message = await Navigator.of(action.context).pushNamed(InvoiceEditScreen.route);
|
||||
|
||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: message,
|
||||
)));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:invoiceninja/data/models/models.dart';
|
||||
import 'package:invoiceninja/redux/ui/ui_actions.dart';
|
||||
import 'package:invoiceninja/ui/app/snackbar_row.dart';
|
||||
import 'package:invoiceninja/ui/product/edit/product_edit_vm.dart';
|
||||
import 'package:invoiceninja/ui/product/product_screen.dart';
|
||||
import 'package:redux/redux.dart';
|
||||
|
|
@ -31,11 +32,16 @@ List<Middleware<AppState>> createStoreProductsMiddleware([
|
|||
}
|
||||
|
||||
Middleware<AppState> _editProduct() {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) {
|
||||
return (Store<AppState> store, dynamic action, NextDispatcher next) async {
|
||||
next(action);
|
||||
|
||||
store.dispatch(UpdateCurrentRoute(ProductEditScreen.route));
|
||||
Navigator.of(action.context).pushNamed(ProductEditScreen.route);
|
||||
final message = await Navigator.of(action.context).pushNamed(ProductEditScreen.route);
|
||||
|
||||
Scaffold.of(action.context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
message: message,
|
||||
)));
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,12 +100,13 @@ class ClientEditVM {
|
|||
store.dispatch(
|
||||
SaveClientRequest(completer: completer, client: client));
|
||||
return completer.future.then((_) {
|
||||
final localization = AppLocalization.of(context);
|
||||
if (client.isNew) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(localization.successfullyCreatedClient);
|
||||
Navigator.of(context).push<ClientViewScreen>(
|
||||
MaterialPageRoute(builder: (_) => ClientViewScreen()));
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(localization.successfullyUpdatedClient);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
showDialog<ErrorDialog>(
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ class ClientViewVM {
|
|||
}
|
||||
return completer.future.then((_) {
|
||||
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(message);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
|
|
|
|||
|
|
@ -73,17 +73,18 @@ class InvoiceEditVM {
|
|||
onBackPressed: () =>
|
||||
store.dispatch(UpdateCurrentRoute(InvoiceScreen.route)),
|
||||
onSavePressed: (BuildContext context) {
|
||||
final localization = AppLocalization.of(context);
|
||||
final Completer<Null> completer = new Completer<Null>();
|
||||
store.dispatch(
|
||||
SaveInvoiceRequest(completer: completer, invoice: invoice));
|
||||
return completer.future.then((_) {
|
||||
if (invoice.isNew) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(localization.successfullyCreatedInvoice);
|
||||
Navigator
|
||||
.of(context)
|
||||
.push<InvoiceViewScreen>(MaterialPageRoute(builder: (_) => InvoiceViewScreen()));
|
||||
} else {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(localization.successfullyUpdatedInvoice);
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
showDialog<ErrorDialog>(
|
||||
|
|
@ -118,7 +119,7 @@ class InvoiceEditVM {
|
|||
}
|
||||
return completer.future.then((_) {
|
||||
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(message);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ class InvoiceViewVM {
|
|||
if (message != null) {
|
||||
return completer.future.then((_) {
|
||||
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(message);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ class ProductEditVM {
|
|||
}
|
||||
return completer.future.then((_) {
|
||||
if ([EntityAction.archive, EntityAction.delete].contains(action)) {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop(message);
|
||||
} else {
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
content: SnackBarRow(
|
||||
|
|
|
|||
Loading…
Reference in New Issue