This commit is contained in:
Hillel Coren 2018-12-13 21:21:58 +02:00
parent dc1472570c
commit 455ddf5f1b
2 changed files with 29 additions and 17 deletions

View File

@ -6,8 +6,10 @@ import 'package:invoiceninja_flutter/data/models/client_model.dart';
import 'package:invoiceninja_flutter/data/models/entities.dart';
import 'package:invoiceninja_flutter/redux/client/client_actions.dart';
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
import 'package:invoiceninja_flutter/ui/app/snackbar_row.dart';
import 'package:invoiceninja_flutter/ui/project/project_screen.dart';
import 'package:invoiceninja_flutter/ui/project/view/project_view_vm.dart';
import 'package:invoiceninja_flutter/utils/localization.dart';
import 'package:redux/redux.dart';
import 'package:invoiceninja_flutter/redux/project/project_actions.dart';
@ -81,16 +83,18 @@ class ProjectEditVM {
final Completer<Null> completer = new Completer<Null>();
store.dispatch(
SaveProjectRequest(completer: completer, project: project));
return completer.future.then((_) {
/*
Scaffold.of(context).showSnackBar(SnackBar(
content: IconMessage(
message: project.isNew
? 'Successfully Created Project'
: 'Successfully Updated Project',
),
duration: Duration(seconds: 3)));
*/
return completer.future.then((savedProject) {
if (project.isNew) {
Navigator.of(context).pushReplacementNamed(ProjectViewScreen.route);
} else {
Navigator.of(context).pop(savedProject);
}
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) {
return ErrorDialog(error);
});
});
},
);

View File

@ -5,6 +5,8 @@ import 'package:flutter_redux/flutter_redux.dart';
import 'package:invoiceninja_flutter/redux/ui/ui_actions.dart';
import 'package:invoiceninja_flutter/ui/stub/stub_screen.dart';
import 'package:redux/redux.dart';
import 'package:invoiceninja_flutter/ui/app/dialogs/error_dialog.dart';
import 'package:invoiceninja_flutter/ui/stub/view/stub_view_vm.dart';
import 'package:invoiceninja_flutter/redux/stub/stub_actions.dart';
import 'package:invoiceninja_flutter/data/models/stub_model.dart';
import 'package:invoiceninja_flutter/ui/stub/edit/stub_edit.dart';
@ -59,13 +61,19 @@ class StubEditVM {
final Completer<Null> completer = new Completer<Null>();
store.dispatch(SaveStubRequest(completer: completer, stub: stub));
return completer.future.then((_) {
Scaffold.of(context).showSnackBar(SnackBar(
content: IconMessage(
message: stub.isNew
? 'Successfully Created Stub'
: 'Successfully Updated Stub',
),
duration: Duration(seconds: 3)));
return completer.future.then((savedStub) {
if (stub.isNew) {
Navigator.of(context).pushReplacementNamed(StubViewScreen.route);
} else {
Navigator.of(context).pop(savedStub);
}
}).catchError((Object error) {
showDialog<ErrorDialog>(
context: context,
builder: (BuildContext context) {
return ErrorDialog(error);
});
});
});
},
);