From 2a144f1deab75a05770dcd68000baaa67ec6e3ca Mon Sep 17 00:00:00 2001 From: Feichtmeier Date: Thu, 14 Nov 2024 20:26:09 +0100 Subject: [PATCH] feat: chipzzz --- lib/src/theme.dart | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/lib/src/theme.dart b/lib/src/theme.dart index 66d4d13..e69210d 100644 --- a/lib/src/theme.dart +++ b/lib/src/theme.dart @@ -119,6 +119,10 @@ ThemeData _phoenixTheme({ drawerTheme: _drawerTheme(colorScheme), inputDecorationTheme: _inputDecorationTheme(colorScheme), listTileTheme: _createListTileTheme(colorScheme), + chipTheme: _createChipTheme( + selectedColor: colorScheme.primary, + colorScheme: colorScheme, + ), ); } @@ -571,3 +575,40 @@ ListTileThemeData _createListTileTheme(ColorScheme colorScheme) { ), ); } + +ChipThemeData _createChipTheme({ + required Color selectedColor, + required ColorScheme colorScheme, +}) { + final isHC = colorScheme.primary == Colors.black || + colorScheme.primary == Colors.white; + final selectedBackgroundColor = + isHC ? colorScheme.inverseSurface : selectedColor; + final selectedForeGroundColor = + isHC ? colorScheme.onInverseSurface : colorScheme.onSurface; + + return ChipThemeData( + selectedColor: selectedBackgroundColor.withOpacity(isHC ? 1 : 0.4), + labelStyle: TextStyle( + color: colorScheme.onSurface, + ), + checkmarkColor: selectedForeGroundColor, + secondaryLabelStyle: TextStyle( + color: selectedForeGroundColor, + fontWeight: isHC ? FontWeight.bold : FontWeight.normal, + ), + side: WidgetStateBorderSide.resolveWith( + (s) => BorderSide( + color: s.contains(WidgetState.selected) + ? selectedBackgroundColor.withOpacity(isHC ? 1 : 0.1) + : (isHC ? colorScheme.outlineVariant : colorScheme.outline) + .withOpacity( + s.contains(WidgetState.disabled) ? (isHC ? 0.3 : 0.7) : 1, + ), + ), + ), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(100), + ), + ); +}