diff --git a/packages/core/lib/presentation/widget/buttons/elevated.dart b/packages/core/lib/presentation/widget/buttons/elevated.dart index 592254b..d28a4b5 100644 --- a/packages/core/lib/presentation/widget/buttons/elevated.dart +++ b/packages/core/lib/presentation/widget/buttons/elevated.dart @@ -18,6 +18,7 @@ class RElevated extends StatelessWidget { this.isFullWidth = false, this.isLoading = false, this.child, + this.enabled = true, }) : assert(text != null || child != null, 'Either text or child must be provided'); final String? text; @@ -33,10 +34,11 @@ class RElevated extends StatelessWidget { final double radius; final TextStyle? textStyle; final bool isLoading; + final bool enabled; @override Widget build(BuildContext context) { - final bool isEnabled = onPressed != null && !isLoading; + final bool isEnabled = enabled && !isLoading; return ElevatedButton( onPressed: isEnabled ? onPressed : null, diff --git a/packages/core/lib/presentation/widget/buttons/outline_elevated.dart b/packages/core/lib/presentation/widget/buttons/outline_elevated.dart index 4d1e629..5e116e4 100644 --- a/packages/core/lib/presentation/widget/buttons/outline_elevated.dart +++ b/packages/core/lib/presentation/widget/buttons/outline_elevated.dart @@ -16,7 +16,8 @@ class ROutlinedElevated extends StatefulWidget { this.child, this.width, this.height, - }):assert(text!=null || child != null, 'Either text or child must be provided'); + this.enabled = true, + }) : assert(text != null || child != null, 'Either text or child must be provided'); final String? text; final VoidCallback? onPressed; @@ -30,6 +31,7 @@ class ROutlinedElevated extends StatefulWidget { double? radius; TextStyle? textStyle; Widget? child; + bool enabled; @override State createState() => _ROutlinedElevatedState(); @@ -73,14 +75,14 @@ class _ROutlinedElevatedState extends State { child: OutlinedButton( key: _widgetKey, statesController: _statesController, - onPressed: widget.onPressed, + onPressed: widget.enabled ? widget.onPressed : null, style: ButtonStyle( side: WidgetStateProperty.resolveWith((states) { if (states.contains(WidgetState.pressed)) { return BorderSide(color: widget.borderColor ?? AppColor.blueNormal, width: 2); } else if (states.contains(WidgetState.disabled)) { return BorderSide( - color: widget.borderColor ?? AppColor.blueNormal.withAlpha(38), + color: widget.borderColor?.disabledColor ?? AppColor.blueNormal.withAlpha(38), width: 2, ); } @@ -103,7 +105,9 @@ class _ROutlinedElevatedState extends State { if (states.contains(WidgetState.pressed)) { return Colors.white; } else if (states.contains(WidgetState.disabled)) { - return AppColor.blueNormal.withAlpha(38); + return widget.foregroundColor?.disabledColor ?? + widget.borderColor?.disabledColor ?? + AppColor.blueNormal.disabledColor; } return widget.foregroundColor ?? widget.borderColor ?? AppColor.blueNormal; }), @@ -115,9 +119,9 @@ class _ROutlinedElevatedState extends State { textStyle: WidgetStateProperty.resolveWith((states) { if (states.contains(WidgetState.pressed)) { return widget.textStyle?.copyWith(color: Colors.white) ?? - AppFonts.yekan20.copyWith(color: Colors.white); + AppFonts.yekan18.copyWith(color: Colors.white); } - return widget.textStyle ?? AppFonts.yekan20.copyWith(color: AppColor.blueNormal); + return widget.textStyle ?? AppFonts.yekan18.copyWith(color: AppColor.blueNormal); }), ), child: widget.child ?? Text(widget.text ?? ''),