|
@@ -39,10 +39,10 @@ class ButtonWidget extends StatelessWidget {
|
|
final bool isDisabled;
|
|
final bool isDisabled;
|
|
final ButtonSize buttonSize;
|
|
final ButtonSize buttonSize;
|
|
|
|
|
|
- ///Setting this flag to true will show a success conformation as a 'check'
|
|
|
|
|
|
+ ///Setting this flag to true will show a success confirmation as a 'check'
|
|
///icon once the onTap(). This is expected to be used only if time taken to
|
|
///icon once the onTap(). This is expected to be used only if time taken to
|
|
///execute onTap() takes less than debouce time.
|
|
///execute onTap() takes less than debouce time.
|
|
- final bool shouldShowSuccessConformation;
|
|
|
|
|
|
+ final bool shouldShowSuccessConfirmation;
|
|
|
|
|
|
///Setting this flag to false will restrict the loading and success states of
|
|
///Setting this flag to false will restrict the loading and success states of
|
|
///the button from surfacing on the UI. The ExecutionState of the button will
|
|
///the button from surfacing on the UI. The ExecutionState of the button will
|
|
@@ -84,7 +84,7 @@ class ButtonWidget extends StatelessWidget {
|
|
this.iconColor,
|
|
this.iconColor,
|
|
this.shouldSurfaceExecutionStates = true,
|
|
this.shouldSurfaceExecutionStates = true,
|
|
this.progressStatus,
|
|
this.progressStatus,
|
|
- this.shouldShowSuccessConformation = false,
|
|
|
|
|
|
+ this.shouldShowSuccessConfirmation = false,
|
|
super.key,
|
|
super.key,
|
|
});
|
|
});
|
|
|
|
|
|
@@ -151,7 +151,7 @@ class ButtonWidget extends StatelessWidget {
|
|
buttonAction: buttonAction,
|
|
buttonAction: buttonAction,
|
|
shouldSurfaceExecutionStates: shouldSurfaceExecutionStates,
|
|
shouldSurfaceExecutionStates: shouldSurfaceExecutionStates,
|
|
progressStatus: progressStatus,
|
|
progressStatus: progressStatus,
|
|
- shouldShowSuccessConformation: shouldShowSuccessConformation,
|
|
|
|
|
|
+ shouldShowSuccessConfirmation: shouldShowSuccessConfirmation,
|
|
);
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -168,7 +168,7 @@ class ButtonChildWidget extends StatefulWidget {
|
|
final bool isInAlert;
|
|
final bool isInAlert;
|
|
final bool shouldSurfaceExecutionStates;
|
|
final bool shouldSurfaceExecutionStates;
|
|
final ValueNotifier<String>? progressStatus;
|
|
final ValueNotifier<String>? progressStatus;
|
|
- final bool shouldShowSuccessConformation;
|
|
|
|
|
|
+ final bool shouldShowSuccessConfirmation;
|
|
|
|
|
|
const ButtonChildWidget({
|
|
const ButtonChildWidget({
|
|
required this.buttonStyle,
|
|
required this.buttonStyle,
|
|
@@ -177,7 +177,7 @@ class ButtonChildWidget extends StatefulWidget {
|
|
required this.buttonSize,
|
|
required this.buttonSize,
|
|
required this.isInAlert,
|
|
required this.isInAlert,
|
|
required this.shouldSurfaceExecutionStates,
|
|
required this.shouldSurfaceExecutionStates,
|
|
- required this.shouldShowSuccessConformation,
|
|
|
|
|
|
+ required this.shouldShowSuccessConfirmation,
|
|
this.progressStatus,
|
|
this.progressStatus,
|
|
this.onTap,
|
|
this.onTap,
|
|
this.labelText,
|
|
this.labelText,
|
|
@@ -206,7 +206,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
|
|
ExecutionState executionState = ExecutionState.idle;
|
|
ExecutionState executionState = ExecutionState.idle;
|
|
|
|
|
|
@override
|
|
@override
|
|
- void initState() {
|
|
|
|
|
|
+ Widget build(BuildContext context) {
|
|
progressStatus = widget.progressStatus;
|
|
progressStatus = widget.progressStatus;
|
|
checkIconColor = widget.buttonStyle.checkIconColor ??
|
|
checkIconColor = widget.buttonStyle.checkIconColor ??
|
|
widget.buttonStyle.defaultIconColor;
|
|
widget.buttonStyle.defaultIconColor;
|
|
@@ -226,12 +226,6 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
|
|
iconColor = widget.buttonStyle.defaultIconColor;
|
|
iconColor = widget.buttonStyle.defaultIconColor;
|
|
labelStyle = widget.buttonStyle.defaultLabelStyle;
|
|
labelStyle = widget.buttonStyle.defaultLabelStyle;
|
|
}
|
|
}
|
|
-
|
|
|
|
- super.initState();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @override
|
|
|
|
- Widget build(BuildContext context) {
|
|
|
|
if (executionState == ExecutionState.successful) {
|
|
if (executionState == ExecutionState.successful) {
|
|
Future.delayed(Duration(seconds: widget.isInAlert ? 1 : 2), () {
|
|
Future.delayed(Duration(seconds: widget.isInAlert ? 1 : 2), () {
|
|
setState(() {
|
|
setState(() {
|
|
@@ -405,7 +399,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
|
|
executionState = ExecutionState.error;
|
|
executionState = ExecutionState.error;
|
|
_debouncer.cancelDebounce();
|
|
_debouncer.cancelDebounce();
|
|
});
|
|
});
|
|
- widget.shouldShowSuccessConformation && _debouncer.isActive()
|
|
|
|
|
|
+ widget.shouldShowSuccessConfirmation && _debouncer.isActive()
|
|
? executionState = ExecutionState.successful
|
|
? executionState = ExecutionState.successful
|
|
: null;
|
|
: null;
|
|
_debouncer.cancelDebounce();
|
|
_debouncer.cancelDebounce();
|
|
@@ -427,8 +421,13 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
|
|
setState(() {
|
|
setState(() {
|
|
executionState = ExecutionState.successful;
|
|
executionState = ExecutionState.successful;
|
|
Future.delayed(
|
|
Future.delayed(
|
|
- Duration(seconds: widget.shouldSurfaceExecutionStates ? 2 : 0),
|
|
|
|
- () {
|
|
|
|
|
|
+ Duration(
|
|
|
|
+ seconds: widget.isInAlert
|
|
|
|
+ ? 1
|
|
|
|
+ : widget.shouldSurfaceExecutionStates
|
|
|
|
+ ? 2
|
|
|
|
+ : 0,
|
|
|
|
+ ), () {
|
|
widget.isInAlert
|
|
widget.isInAlert
|
|
? Navigator.of(context, rootNavigator: true)
|
|
? Navigator.of(context, rootNavigator: true)
|
|
.pop(widget.buttonAction)
|
|
.pop(widget.buttonAction)
|
|
@@ -458,7 +457,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
|
|
} else {
|
|
} else {
|
|
if (widget.isInAlert) {
|
|
if (widget.isInAlert) {
|
|
Future.delayed(
|
|
Future.delayed(
|
|
- Duration(seconds: widget.shouldShowSuccessConformation ? 1 : 0),
|
|
|
|
|
|
+ Duration(seconds: widget.shouldShowSuccessConfirmation ? 1 : 0),
|
|
() => Navigator.of(context).pop(widget.buttonAction),
|
|
() => Navigator.of(context).pop(widget.buttonAction),
|
|
);
|
|
);
|
|
}
|
|
}
|