This commit is contained in:
Hillel Coren 2018-12-18 17:08:57 +02:00
parent 3c866714d6
commit 7e0eb3626f
15 changed files with 62 additions and 23 deletions

View File

@ -74,4 +74,6 @@ ProjectUIState get projectUIState;
QuoteUIState get quoteUIState; QuoteUIState get quoteUIState;
static Serializer<UIState> get serializer => _$uIStateSerializer; static Serializer<UIState> get serializer => _$uIStateSerializer;
bool containsRoute(String route) => currentRoute.contains(route);
} }

View File

@ -60,8 +60,11 @@ class ClientEditVM {
origClient: state.clientState.map[client.id], origClient: state.clientState.map[client.id],
staticState: state.staticState, staticState: state.staticState,
isSaving: state.isSaving, isSaving: state.isSaving,
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(ClientScreen.route)), if (state.uiState.currentRoute.contains(ClientScreen.route)) {
store.dispatch(UpdateCurrentRoute(ClientViewScreen.route));
}
},
onChanged: (ClientEntity client) => onChanged: (ClientEntity client) =>
store.dispatch(UpdateClient(client)), store.dispatch(UpdateClient(client)),
onSavePressed: (BuildContext context) { onSavePressed: (BuildContext context) {

View File

@ -109,8 +109,11 @@ class ClientViewVM {
}, },
onRefreshed: (context, loadActivities) => onRefreshed: (context, loadActivities) =>
_handleRefresh(context, loadActivities), _handleRefresh(context, loadActivities),
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(ClientScreen.route)), if (state.uiState.currentRoute.contains(ClientScreen.route)) {
store.dispatch(UpdateCurrentRoute(ClientScreen.route));
}
},
onActionSelected: (BuildContext context, EntityAction action) { onActionSelected: (BuildContext context, EntityAction action) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
switch (action) { switch (action) {

View File

@ -85,8 +85,11 @@ class InvoiceEditVM extends EntityEditVM {
invoice: invoice, invoice: invoice,
invoiceItem: state.invoiceUIState.editingItem, invoiceItem: state.invoiceUIState.editingItem,
origInvoice: store.state.invoiceState.map[invoice.id], origInvoice: store.state.invoiceState.map[invoice.id],
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(InvoiceScreen.route)), if (state.uiState.currentRoute.contains(InvoiceScreen.route)) {
store.dispatch(UpdateCurrentRoute(InvoiceViewScreen.route));
}
},
onSavePressed: (BuildContext context) { onSavePressed: (BuildContext context) {
final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>(); final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>();
store.dispatch( store.dispatch(

View File

@ -149,8 +149,11 @@ class InvoiceViewVM extends EntityViewVM {
}); });
}, },
onRefreshed: (context) => _handleRefresh(context), onRefreshed: (context) => _handleRefresh(context),
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(InvoiceScreen.route)), if (state.uiState.currentRoute.contains(InvoiceScreen.route)) {
store.dispatch(UpdateCurrentRoute(InvoiceScreen.route));
}
},
onClientPressed: (BuildContext context) => onClientPressed: (BuildContext context) =>
store.dispatch(ViewClient(clientId: client.id, context: context)), store.dispatch(ViewClient(clientId: client.id, context: context)),
onPaymentPressed: (BuildContext context, PaymentEntity payment) => store onPaymentPressed: (BuildContext context, PaymentEntity payment) => store

View File

@ -83,7 +83,9 @@ class PaymentEditVM {
store.dispatch(UserSettingsChanged(emailPayment: value)); store.dispatch(UserSettingsChanged(emailPayment: value));
}, },
onBackPressed: () { onBackPressed: () {
store.dispatch(UpdateCurrentRoute(PaymentScreen.route)); if (state.uiState.currentRoute.contains(PaymentScreen.route)) {
store.dispatch(UpdateCurrentRoute(PaymentViewScreen.route));
}
}, },
onSavePressed: (BuildContext context) { onSavePressed: (BuildContext context) {
final Completer<Null> completer = errorCompleter(context) final Completer<Null> completer = errorCompleter(context)

View File

@ -58,7 +58,9 @@ class ProductEditVM {
store.dispatch(UpdateProduct(product)); store.dispatch(UpdateProduct(product));
}, },
onBackPressed: () { onBackPressed: () {
if (state.uiState.currentRoute.contains(ProductScreen.route)) {
store.dispatch(UpdateCurrentRoute(ProductScreen.route)); store.dispatch(UpdateCurrentRoute(ProductScreen.route));
}
}, },
onSavePressed: (BuildContext context) { onSavePressed: (BuildContext context) {
store.dispatch(SaveProductRequest( store.dispatch(SaveProductRequest(

View File

@ -68,7 +68,9 @@ class ProjectEditVM {
store.dispatch(UpdateProject(project)); store.dispatch(UpdateProject(project));
}, },
onBackPressed: () { onBackPressed: () {
store.dispatch(UpdateCurrentRoute(ProjectScreen.route)); if (state.uiState.currentRoute.contains(ProjectScreen.route)) {
store.dispatch(UpdateCurrentRoute(ProjectViewScreen.route));
}
}, },
onAddClientPressed: (context, completer) { onAddClientPressed: (context, completer) {
store.dispatch(EditClient( store.dispatch(EditClient(

View File

@ -71,8 +71,11 @@ class ProjectViewVM {
onRefreshed: (context) => _handleRefresh(context), onRefreshed: (context) => _handleRefresh(context),
onClientPressed: (BuildContext context) => store onClientPressed: (BuildContext context) => store
.dispatch(ViewClient(clientId: project.clientId, context: context)), .dispatch(ViewClient(clientId: project.clientId, context: context)),
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(ProjectScreen.route)), if (state.uiState.currentRoute.contains(ProjectScreen.route)) {
store.dispatch(UpdateCurrentRoute(ProjectScreen.route));
}
},
onActionSelected: (BuildContext context, EntityAction action) { onActionSelected: (BuildContext context, EntityAction action) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
switch (action) { switch (action) {

View File

@ -64,8 +64,11 @@ class QuoteEditVM extends EntityEditVM {
invoice: quote, invoice: quote,
invoiceItem: state.quoteUIState.editingItem, invoiceItem: state.quoteUIState.editingItem,
origInvoice: store.state.quoteState.map[quote.id], origInvoice: store.state.quoteState.map[quote.id],
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(QuoteScreen.route)), if (state.uiState.currentRoute.contains(QuoteScreen.route)) {
store.dispatch(UpdateCurrentRoute(QuoteViewScreen.route));
}
},
onSavePressed: (BuildContext context) { onSavePressed: (BuildContext context) {
final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>(); final Completer<InvoiceEntity> completer = Completer<InvoiceEntity>();
store.dispatch(SaveQuoteRequest(completer: completer, quote: quote)); store.dispatch(SaveQuoteRequest(completer: completer, quote: quote));

View File

@ -102,8 +102,11 @@ class QuoteViewVM extends EntityViewVM {
}); });
}, },
onRefreshed: (context) => _handleRefresh(context), onRefreshed: (context) => _handleRefresh(context),
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(QuoteScreen.route)), if (state.uiState.currentRoute.contains(QuoteScreen.route)) {
store.dispatch(UpdateCurrentRoute(QuoteScreen.route));
}
},
onClientPressed: (BuildContext context) { onClientPressed: (BuildContext context) {
store.dispatch(ViewClient(clientId: client.id, context: context)); store.dispatch(ViewClient(clientId: client.id, context: context));
}, },

View File

@ -66,7 +66,9 @@ class TaskEditVM {
store.dispatch(UpdateTask(task)); store.dispatch(UpdateTask(task));
}, },
onBackPressed: () { onBackPressed: () {
if (state.uiState.currentRoute.contains(TaskScreen.route)) {
store.dispatch(UpdateCurrentRoute(TaskScreen.route)); store.dispatch(UpdateCurrentRoute(TaskScreen.route));
}
}, },
onAddClientPressed: (context, completer) { onAddClientPressed: (context, completer) {
store.dispatch(EditClient( store.dispatch(EditClient(

View File

@ -66,8 +66,11 @@ class TaskViewVM {
store.dispatch(EditTask(task: task, context: context)); store.dispatch(EditTask(task: task, context: context));
}, },
onRefreshed: (context) => _handleRefresh(context), onRefreshed: (context) => _handleRefresh(context),
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(TaskScreen.route)), if (state.uiState.currentRoute.contains(TaskScreen.route)) {
store.dispatch(UpdateCurrentRoute(TaskScreen.route));
}
},
onActionSelected: (BuildContext context, EntityAction action) { onActionSelected: (BuildContext context, EntityAction action) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
switch (action) { switch (action) {

View File

@ -60,7 +60,9 @@ class StubEditVM {
store.dispatch(UpdateStub(stub)); store.dispatch(UpdateStub(stub));
}, },
onBackPressed: () { onBackPressed: () {
store.dispatch(UpdateCurrentRoute(StubScreen.route)); if (state.uiState.currentRoute.contains(StubScreen.route)) {
store.dispatch(UpdateCurrentRoute(StubViewScreen.route));
}
}, },
onSavePressed: (BuildContext context) { onSavePressed: (BuildContext context) {
final Completer<StubEntity> completer = new Completer<StubEntity>(); final Completer<StubEntity> completer = new Completer<StubEntity>();

View File

@ -66,8 +66,11 @@ class StubViewVM {
store.dispatch(EditStub(stub: stub, context: context)); store.dispatch(EditStub(stub: stub, context: context));
}, },
onRefreshed: (context) => _handleRefresh(context), onRefreshed: (context) => _handleRefresh(context),
onBackPressed: () => onBackPressed: () {
store.dispatch(UpdateCurrentRoute(StubScreen.route)), if (state.uiState.currentRoute.contains(StubScreen.route)) {
store.dispatch(UpdateCurrentRoute(StubScreen.route));
}
},
onActionSelected: (BuildContext context, EntityAction action) { onActionSelected: (BuildContext context, EntityAction action) {
final localization = AppLocalization.of(context); final localization = AppLocalization.of(context);
switch (action) { switch (action) {