Browse Source

Used better variable names and comments

ashilkn 2 years ago
parent
commit
4ea6a9a22b
2 changed files with 12 additions and 11 deletions
  1. 1 1
      lib/ui/account/delete_account_page.dart
  2. 11 10
      lib/ui/components/button_widget.dart

+ 1 - 1
lib/ui/account/delete_account_page.dart

@@ -100,7 +100,7 @@ class DeleteAccountPage extends StatelessWidget {
                 labelText: "No, delete account",
                 labelText: "No, delete account",
                 icon: Icons.no_accounts_outlined,
                 icon: Icons.no_accounts_outlined,
                 onTap: () async => {await _initiateDelete(context)},
                 onTap: () async => {await _initiateDelete(context)},
-                shouldDisableExecutionStates: true,
+                shouldSurfaceExecutionStates: false,
               )
               )
             ],
             ],
           ),
           ),

+ 11 - 10
lib/ui/components/button_widget.dart

@@ -38,10 +38,11 @@ class ButtonWidget extends StatelessWidget {
   final bool isDisabled;
   final bool isDisabled;
   final ButtonSize buttonSize;
   final ButtonSize buttonSize;
 
 
-  ///Setting this flag to true will disable the loading and success states
-  ///of the button. This can be set to true if loading and success states aren't
-  ///required in a particular context
-  final bool shouldDisableExecutionStates;
+  ///Setting this flag to true will restrict the loading and success states of
+  ///the button from surfacing on the UI. The ExecutionState of the button will
+  ///change irrespective of the value of this flag. Only that it won't be
+  ///surfaced on the UI
+  final bool shouldSurfaceExecutionStates;
 
 
   /// iconColor should only be specified when we do not want to honor the default
   /// iconColor should only be specified when we do not want to honor the default
   /// iconColor based on buttonType. Most of the items, default iconColor is what
   /// iconColor based on buttonType. Most of the items, default iconColor is what
@@ -70,7 +71,7 @@ class ButtonWidget extends StatelessWidget {
     this.buttonAction,
     this.buttonAction,
     this.isInAlert = false,
     this.isInAlert = false,
     this.iconColor,
     this.iconColor,
-    this.shouldDisableExecutionStates = false,
+    this.shouldSurfaceExecutionStates = true,
     super.key,
     super.key,
   });
   });
 
 
@@ -135,7 +136,7 @@ class ButtonWidget extends StatelessWidget {
       labelText: labelText,
       labelText: labelText,
       icon: icon,
       icon: icon,
       buttonAction: buttonAction,
       buttonAction: buttonAction,
-      shouldDisableExecutionStates: shouldDisableExecutionStates,
+      shouldSurfaceExecutionStates: shouldSurfaceExecutionStates,
     );
     );
   }
   }
 }
 }
@@ -150,14 +151,14 @@ class ButtonChildWidget extends StatefulWidget {
   final ButtonSize buttonSize;
   final ButtonSize buttonSize;
   final ButtonAction? buttonAction;
   final ButtonAction? buttonAction;
   final bool isInAlert;
   final bool isInAlert;
-  final bool shouldDisableExecutionStates;
+  final bool shouldSurfaceExecutionStates;
   const ButtonChildWidget({
   const ButtonChildWidget({
     required this.buttonStyle,
     required this.buttonStyle,
     required this.buttonType,
     required this.buttonType,
     required this.isDisabled,
     required this.isDisabled,
     required this.buttonSize,
     required this.buttonSize,
     required this.isInAlert,
     required this.isInAlert,
-    required this.shouldDisableExecutionStates,
+    required this.shouldSurfaceExecutionStates,
     this.onTap,
     this.onTap,
     this.labelText,
     this.labelText,
     this.icon,
     this.icon,
@@ -231,7 +232,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
               switchInCurve: Curves.easeInOutExpo,
               switchInCurve: Curves.easeInOutExpo,
               switchOutCurve: Curves.easeInOutExpo,
               switchOutCurve: Curves.easeInOutExpo,
               child: executionState == ExecutionState.idle ||
               child: executionState == ExecutionState.idle ||
-                      widget.shouldDisableExecutionStates
+                      !widget.shouldSurfaceExecutionStates
                   ? widget.buttonType.hasTrailingIcon
                   ? widget.buttonType.hasTrailingIcon
                       ? Row(
                       ? Row(
                           mainAxisAlignment: MainAxisAlignment.spaceBetween,
                           mainAxisAlignment: MainAxisAlignment.spaceBetween,
@@ -341,7 +342,7 @@ class _ButtonChildWidgetState extends State<ButtonChildWidget> {
   bool get _shouldRegisterGestures =>
   bool get _shouldRegisterGestures =>
       !widget.isDisabled &&
       !widget.isDisabled &&
       (executionState == ExecutionState.idle ||
       (executionState == ExecutionState.idle ||
-          widget.shouldDisableExecutionStates);
+          !widget.shouldSurfaceExecutionStates);
 
 
   void _onTap() async {
   void _onTap() async {
     if (widget.onTap != null) {
     if (widget.onTap != null) {