Only show save/cancel if there are changes
This commit is contained in:
parent
72b24f34b2
commit
e82b948aac
|
|
@ -619,11 +619,9 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
case TaskStatusEditScreen.route:
|
case TaskStatusEditScreen.route:
|
||||||
return hasTaskStatusChanges(
|
return hasTaskStatusChanges(
|
||||||
taskStatusUIState.editing, taskStatusState.map);
|
taskStatusUIState.editing, taskStatusState.map);
|
||||||
|
|
||||||
case ExpenseCategoryEditScreen.route:
|
case ExpenseCategoryEditScreen.route:
|
||||||
return hasExpenseCategoryChanges(
|
return hasExpenseCategoryChanges(
|
||||||
expenseCategoryUIState.editing, expenseCategoryState.map);
|
expenseCategoryUIState.editing, expenseCategoryState.map);
|
||||||
|
|
||||||
case RecurringInvoiceEditScreen.route:
|
case RecurringInvoiceEditScreen.route:
|
||||||
return hasRecurringInvoiceChanges(
|
return hasRecurringInvoiceChanges(
|
||||||
recurringInvoiceUIState.editing, recurringInvoiceState.map);
|
recurringInvoiceUIState.editing, recurringInvoiceState.map);
|
||||||
|
|
@ -638,7 +636,7 @@ abstract class AppState implements Built<AppState, AppStateBuilder> {
|
||||||
return hasDesignChanges(designUIState.editing, designState.map);
|
return hasDesignChanges(designUIState.editing, designState.map);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uiState.currentRoute.startsWith('/settings')) {
|
if (uiState.isInSettings) {
|
||||||
return settingsUIState.isChanged;
|
return settingsUIState.isChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ abstract class UIState implements Built<UIState, UIStateBuilder> {
|
||||||
|
|
||||||
bool get isViewing => !isEditing && !isEmailing;
|
bool get isViewing => !isEditing && !isEmailing;
|
||||||
|
|
||||||
bool get isInSettings => currentRoute.contains('settings');
|
bool get isInSettings => currentRoute.startsWith('/settings');
|
||||||
|
|
||||||
bool get isPreviewing => previewStack.isNotEmpty;
|
bool get isPreviewing => previewStack.isNotEmpty;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,13 @@ class EditScaffold extends StatelessWidget {
|
||||||
final store = StoreProvider.of<AppState>(context);
|
final store = StoreProvider.of<AppState>(context);
|
||||||
final state = store.state;
|
final state = store.state;
|
||||||
|
|
||||||
|
bool showButtons = true;
|
||||||
|
if (state.uiState.isInSettings &&
|
||||||
|
!state.uiState.isEditing &&
|
||||||
|
!state.settingsUIState.isChanged) {
|
||||||
|
showButtons = false;
|
||||||
|
}
|
||||||
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -50,18 +57,19 @@ class EditScaffold extends StatelessWidget {
|
||||||
automaticallyImplyLeading: isMobile(context),
|
automaticallyImplyLeading: isMobile(context),
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
SaveCancelButtons(
|
if (showButtons)
|
||||||
saveLabel: saveLabel,
|
SaveCancelButtons(
|
||||||
isSaving: state.isSaving,
|
saveLabel: saveLabel,
|
||||||
onSavePressed: (context) {
|
isSaving: state.isSaving,
|
||||||
// Clear focus now to prevent un-focus after save from
|
onSavePressed: (context) {
|
||||||
// marking the form as changed and to hide the keyboard
|
// Clear focus now to prevent un-focus after save from
|
||||||
FocusScope.of(context).unfocus(
|
// marking the form as changed and to hide the keyboard
|
||||||
disposition: UnfocusDisposition.previouslyFocusedChild);
|
FocusScope.of(context).unfocus(
|
||||||
|
disposition: UnfocusDisposition.previouslyFocusedChild);
|
||||||
|
|
||||||
onSavePressed(context);
|
onSavePressed(context);
|
||||||
|
|
||||||
/* The debouncer has been disabled b/c if you click
|
/* The debouncer has been disabled b/c if you click
|
||||||
save too quickly the changes are lost
|
save too quickly the changes are lost
|
||||||
if (Debouncer.isDebouncing) {
|
if (Debouncer.isDebouncing) {
|
||||||
Timer(Duration(milliseconds: kDebounceDelay), () {
|
Timer(Duration(milliseconds: kDebounceDelay), () {
|
||||||
|
|
@ -71,17 +79,17 @@ class EditScaffold extends StatelessWidget {
|
||||||
onSavePressed(context);
|
onSavePressed(context);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
},
|
},
|
||||||
onCancelPressed: isMobile(context)
|
onCancelPressed: isMobile(context)
|
||||||
? null
|
? null
|
||||||
: (context) {
|
: (context) {
|
||||||
if (onCancelPressed != null) {
|
if (onCancelPressed != null) {
|
||||||
onCancelPressed(context);
|
onCancelPressed(context);
|
||||||
} else {
|
} else {
|
||||||
store.dispatch(ResetSettings());
|
store.dispatch(ResetSettings());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
bottom: appBarBottom,
|
bottom: appBarBottom,
|
||||||
),
|
),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue