Adjust loading indicator
This commit is contained in:
parent
4ee3b041e9
commit
5dd1981b8d
|
|
@ -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<AppState>(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<Color>(
|
||||
state.hasAccentColor || state.prefState.enableDarkMode
|
||||
? Colors.white
|
||||
: state.accentColor),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return AppTextButton(
|
||||
label: tooltip,
|
||||
isInHeader: isHeader,
|
||||
onPressed: onPressed,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -130,30 +130,43 @@ class EditScaffold extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
actions: <Widget>[
|
||||
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<EntityAction>(
|
||||
icon: Icon(
|
||||
|
|
|
|||
|
|
@ -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: <Widget>[
|
||||
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,
|
||||
);
|
||||
}),
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue