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,12 +130,25 @@ class EditScaffold extends StatelessWidget {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
|
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(
|
SaveCancelButtons(
|
||||||
isEnabled: isEnabled && onSavePressed != null,
|
isEnabled: isEnabled && onSavePressed != null,
|
||||||
isHeader: true,
|
isHeader: true,
|
||||||
isCancelEnabled: isCancelEnabled,
|
isCancelEnabled: isCancelEnabled,
|
||||||
saveLabel: saveLabel,
|
saveLabel: saveLabel,
|
||||||
isSaving: state.isSaving,
|
|
||||||
onSavePressed: (context) {
|
onSavePressed: (context) {
|
||||||
// Clear focus now to prevent un-focus after save from
|
// Clear focus now to prevent un-focus after save from
|
||||||
// marking the form as changed and to hide the keyboard
|
// marking the form as changed and to hide the keyboard
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import 'package:flutter/material.dart';
|
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/ui/app/buttons/app_text_button.dart';
|
||||||
import 'package:invoiceninja_flutter/utils/localization.dart';
|
import 'package:invoiceninja_flutter/utils/localization.dart';
|
||||||
|
|
||||||
|
|
@ -10,14 +9,12 @@ class SaveCancelButtons extends StatelessWidget {
|
||||||
this.saveLabel,
|
this.saveLabel,
|
||||||
this.cancelLabel,
|
this.cancelLabel,
|
||||||
this.isHeader = true,
|
this.isHeader = true,
|
||||||
this.isSaving = false,
|
|
||||||
this.isEnabled = true,
|
this.isEnabled = true,
|
||||||
this.isCancelEnabled = false,
|
this.isCancelEnabled = false,
|
||||||
});
|
});
|
||||||
|
|
||||||
final bool isEnabled;
|
final bool isEnabled;
|
||||||
final bool isCancelEnabled;
|
final bool isCancelEnabled;
|
||||||
final bool isSaving;
|
|
||||||
final String saveLabel;
|
final String saveLabel;
|
||||||
final String cancelLabel;
|
final String cancelLabel;
|
||||||
final bool isHeader;
|
final bool isHeader;
|
||||||
|
|
@ -32,7 +29,7 @@ class SaveCancelButtons extends StatelessWidget {
|
||||||
crossAxisAlignment:
|
crossAxisAlignment:
|
||||||
isHeader ? CrossAxisAlignment.stretch : CrossAxisAlignment.center,
|
isHeader ? CrossAxisAlignment.stretch : CrossAxisAlignment.center,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
if (onCancelPressed != null && !isSaving)
|
if (onCancelPressed != null)
|
||||||
Builder(builder: (BuildContext context) {
|
Builder(builder: (BuildContext context) {
|
||||||
return AppTextButton(
|
return AppTextButton(
|
||||||
label: cancelLabel ?? localization.cancel,
|
label: cancelLabel ?? localization.cancel,
|
||||||
|
|
@ -43,11 +40,9 @@ class SaveCancelButtons extends StatelessWidget {
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
Builder(builder: (BuildContext context) {
|
Builder(builder: (BuildContext context) {
|
||||||
return ActionTextButton(
|
return AppTextButton(
|
||||||
tooltip: saveLabel ?? localization.save,
|
label: saveLabel ?? localization.save,
|
||||||
isVisible: true,
|
isInHeader: isHeader,
|
||||||
isSaving: isSaving,
|
|
||||||
isHeader: isHeader,
|
|
||||||
onPressed: isEnabled ? () => onSavePressed(context) : null,
|
onPressed: isEnabled ? () => onSavePressed(context) : null,
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,6 @@ class CompanyGatewayScreen extends StatelessWidget {
|
||||||
isEnabled: settingsUIState.isChanged,
|
isEnabled: settingsUIState.isChanged,
|
||||||
isCancelEnabled: true,
|
isCancelEnabled: true,
|
||||||
isHeader: true,
|
isHeader: true,
|
||||||
isSaving: state.isSaving,
|
|
||||||
onSavePressed: viewModel.onSavePressed,
|
onSavePressed: viewModel.onSavePressed,
|
||||||
onCancelPressed: isMobile(context) || !settingsUIState.isChanged
|
onCancelPressed: isMobile(context) || !settingsUIState.isChanged
|
||||||
? null
|
? null
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue