diff --git a/lib/ui/app/buttons/action_flat_button.dart b/lib/ui/app/buttons/action_flat_button.dart deleted file mode 100644 index 39ba1e93f..000000000 --- a/lib/ui/app/buttons/action_flat_button.dart +++ /dev/null @@ -1,55 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_redux/flutter_redux.dart'; -import 'package:invoiceninja_flutter/redux/app/app_state.dart'; -import 'package:invoiceninja_flutter/ui/app/buttons/app_text_button.dart'; - -class ActionTextButton extends StatelessWidget { - const ActionTextButton({ - this.onPressed, - this.tooltip, - this.isSaving = false, - this.isVisible = true, - this.isHeader = false, - }); - - final bool isSaving; - final bool isVisible; - final Function onPressed; - final String tooltip; - final bool isHeader; - - @override - Widget build(BuildContext context) { - final store = StoreProvider.of(context); - final state = store.state; - - if (!isVisible) { - return Container(); - } - - if (isSaving) { - return SizedBox( - width: 80, - child: IconButton( - onPressed: null, - icon: SizedBox( - width: 28, - height: 28, - child: CircularProgressIndicator( - valueColor: AlwaysStoppedAnimation( - state.hasAccentColor || state.prefState.enableDarkMode - ? Colors.white - : state.accentColor), - ), - ), - ), - ); - } - - return AppTextButton( - label: tooltip, - isInHeader: isHeader, - onPressed: onPressed, - ); - } -} diff --git a/lib/ui/app/edit_scaffold.dart b/lib/ui/app/edit_scaffold.dart index fe4a251ed..db990025f 100644 --- a/lib/ui/app/edit_scaffold.dart +++ b/lib/ui/app/edit_scaffold.dart @@ -130,30 +130,43 @@ class EditScaffold extends StatelessWidget { ], ), actions: [ - SaveCancelButtons( - isEnabled: isEnabled && onSavePressed != null, - isHeader: true, - isCancelEnabled: isCancelEnabled, - saveLabel: saveLabel, - isSaving: state.isSaving, - onSavePressed: (context) { - // Clear focus now to prevent un-focus after save from - // marking the form as changed and to hide the keyboard - FocusScope.of(context).unfocus( - disposition: UnfocusDisposition.previouslyFocusedChild); + if (state.isSaving) + Padding( + padding: const EdgeInsets.only(right: 20), + child: Center( + child: SizedBox( + width: 28, + height: 28, + child: CircularProgressIndicator( + color: + state.prefState.enableDarkMode ? Colors.white : null, + ), + )), + ) + else + SaveCancelButtons( + isEnabled: isEnabled && onSavePressed != null, + isHeader: true, + isCancelEnabled: isCancelEnabled, + saveLabel: saveLabel, + onSavePressed: (context) { + // Clear focus now to prevent un-focus after save from + // marking the form as changed and to hide the keyboard + FocusScope.of(context).unfocus( + disposition: UnfocusDisposition.previouslyFocusedChild); - onSavePressed(context); - }, - onCancelPressed: isMobile(context) - ? null - : (context) { - if (onCancelPressed != null) { - onCancelPressed(context); - } else { - store.dispatch(ResetSettings()); - } - }, - ), + onSavePressed(context); + }, + onCancelPressed: isMobile(context) + ? null + : (context) { + if (onCancelPressed != null) { + onCancelPressed(context); + } else { + store.dispatch(ResetSettings()); + } + }, + ), if (actions != null && !state.isSaving) PopupMenuButton( icon: Icon( diff --git a/lib/ui/app/forms/save_cancel_buttons.dart b/lib/ui/app/forms/save_cancel_buttons.dart index 669b9695d..66890b16c 100644 --- a/lib/ui/app/forms/save_cancel_buttons.dart +++ b/lib/ui/app/forms/save_cancel_buttons.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:invoiceninja_flutter/ui/app/buttons/action_flat_button.dart'; import 'package:invoiceninja_flutter/ui/app/buttons/app_text_button.dart'; import 'package:invoiceninja_flutter/utils/localization.dart'; @@ -10,14 +9,12 @@ class SaveCancelButtons extends StatelessWidget { this.saveLabel, this.cancelLabel, this.isHeader = true, - this.isSaving = false, this.isEnabled = true, this.isCancelEnabled = false, }); final bool isEnabled; final bool isCancelEnabled; - final bool isSaving; final String saveLabel; final String cancelLabel; final bool isHeader; @@ -32,7 +29,7 @@ class SaveCancelButtons extends StatelessWidget { crossAxisAlignment: isHeader ? CrossAxisAlignment.stretch : CrossAxisAlignment.center, children: [ - if (onCancelPressed != null && !isSaving) + if (onCancelPressed != null) Builder(builder: (BuildContext context) { return AppTextButton( label: cancelLabel ?? localization.cancel, @@ -43,11 +40,9 @@ class SaveCancelButtons extends StatelessWidget { ); }), Builder(builder: (BuildContext context) { - return ActionTextButton( - tooltip: saveLabel ?? localization.save, - isVisible: true, - isSaving: isSaving, - isHeader: isHeader, + return AppTextButton( + label: saveLabel ?? localization.save, + isInHeader: isHeader, onPressed: isEnabled ? () => onSavePressed(context) : null, ); }), diff --git a/lib/ui/company_gateway/company_gateway_screen.dart b/lib/ui/company_gateway/company_gateway_screen.dart index 612597128..38f689c45 100644 --- a/lib/ui/company_gateway/company_gateway_screen.dart +++ b/lib/ui/company_gateway/company_gateway_screen.dart @@ -88,7 +88,6 @@ class CompanyGatewayScreen extends StatelessWidget { isEnabled: settingsUIState.isChanged, isCancelEnabled: true, isHeader: true, - isSaving: state.isSaving, onSavePressed: viewModel.onSavePressed, onCancelPressed: isMobile(context) || !settingsUIState.isChanged ? null