Skip to content

Commit

Permalink
feat: chipzzz
Browse files Browse the repository at this point in the history
  • Loading branch information
Feichtmeier committed Nov 14, 2024
1 parent adbc04c commit 2a144f1
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions lib/src/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ ThemeData _phoenixTheme({
drawerTheme: _drawerTheme(colorScheme),
inputDecorationTheme: _inputDecorationTheme(colorScheme),
listTileTheme: _createListTileTheme(colorScheme),
chipTheme: _createChipTheme(
selectedColor: colorScheme.primary,
colorScheme: colorScheme,
),
);
}

Expand Down Expand Up @@ -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),
),
);
}

0 comments on commit 2a144f1

Please sign in to comment.