From 81f5217c26e88d324b6ee90a2257d238cdee1c2e Mon Sep 17 00:00:00 2001 From: Moshe Dicker Date: Fri, 1 Nov 2024 12:00:02 -0400 Subject: [PATCH] remove defaults from button theme --- lib/src/components/button.dart | 11 +++++++---- lib/src/theme/components/button.dart | 8 ++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/src/components/button.dart b/lib/src/components/button.dart index 8e041c83..99fe6d74 100644 --- a/lib/src/components/button.dart +++ b/lib/src/components/button.dart @@ -552,7 +552,8 @@ class _ShadButtonState extends State { if (widget.size != null) { return defaultHeightForSize(theme, widget.size!); } - return defaultHeightForSize(theme, buttonTheme(theme).size); + return defaultHeightForSize( + theme, buttonTheme(theme).size ?? ShadButtonSize.regular); } double? defaultWidthForSize(ShadThemeData theme, ShadButtonSize size) { @@ -567,7 +568,8 @@ class _ShadButtonState extends State { if (widget.size != null) { return defaultWidthForSize(theme, widget.size!); } - return defaultWidthForSize(theme, buttonTheme(theme).size); + return defaultWidthForSize( + theme, buttonTheme(theme).size ?? ShadButtonSize.regular); } EdgeInsetsGeometry defaultPaddingForSize( @@ -582,7 +584,8 @@ class _ShadButtonState extends State { if (widget.size != null) { return defaultPaddingForSize(theme, widget.size!); } - return defaultPaddingForSize(theme, buttonTheme(theme).size); + return defaultPaddingForSize( + theme, buttonTheme(theme).size ?? ShadButtonSize.regular); } Color? background(ShadThemeData theme) { @@ -722,7 +725,7 @@ class _ShadButtonState extends State { // Applies the foreground color filter to the icon if provided var icon = widget.icon; - if (icon != null && applyIconColorFilter) { + if (icon != null && (applyIconColorFilter ?? true)) { icon = ColorFiltered( colorFilter: ColorFilter.mode( hasPressedForegroundColor && pressed diff --git a/lib/src/theme/components/button.dart b/lib/src/theme/components/button.dart index 2b0d9633..7c5cf52c 100644 --- a/lib/src/theme/components/button.dart +++ b/lib/src/theme/components/button.dart @@ -14,9 +14,9 @@ import 'package:shadcn_ui/src/utils/gesture_detector.dart'; class ShadButtonTheme { const ShadButtonTheme({ this.merge = true, - this.applyIconColorFilter = true, + this.applyIconColorFilter, this.cursor, - this.size = ShadButtonSize.regular, + this.size, this.sizesTheme, this.backgroundColor, this.hoverBackgroundColor, @@ -40,9 +40,9 @@ class ShadButtonTheme { }); final bool merge; - final bool applyIconColorFilter; + final bool? applyIconColorFilter; final MouseCursor? cursor; - final ShadButtonSize size; + final ShadButtonSize? size; final ShadButtonSizesTheme? sizesTheme; final Color? backgroundColor; final Color? hoverBackgroundColor;