Skip to content

Commit 9505fcb

Browse files
committed
More vibrant colors
1 parent 28ea613 commit 9505fcb

File tree

1 file changed

+88
-101
lines changed

1 file changed

+88
-101
lines changed

lib/src/theme.dart

Lines changed: 88 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ ThemePair phoenixTheme({
2828
splashFactory: NoSplash.splashFactory,
2929
dividerColor: _dividerColor(lightScheme),
3030
cardColor: _cardColor(lightScheme),
31-
// inputDecorationTheme: _inputDecorationTheme(lightScheme),
3231
menuTheme: _menuTheme(lightScheme),
3332
popupMenuTheme: _popupMenuTheme(lightScheme),
3433
dialogTheme: _dialogTheme(lightScheme),
@@ -38,6 +37,9 @@ ThemePair phoenixTheme({
3837
dividerTheme: _dividerTheme(lightScheme),
3938
progressIndicatorTheme: _progressIndicatorTheme(lightScheme),
4039
switchTheme: _switchTheme(lightScheme),
40+
checkboxTheme: _checkBoxTheme(lightScheme),
41+
floatingActionButtonTheme: _floatingActionButtonTheme(lightScheme),
42+
elevatedButtonTheme: _elevatedButtonTheme(lightScheme),
4143
navigationRailTheme: _naviRailTheme(lightScheme),
4244
navigationBarTheme: _naviBarTheme(lightScheme),
4345
appBarTheme: _appBarTheme(lightScheme),
@@ -51,7 +53,6 @@ ThemePair phoenixTheme({
5153
splashFactory: NoSplash.splashFactory,
5254
dividerColor: _dividerColor(darkScheme),
5355
cardColor: _cardColor(darkScheme),
54-
// inputDecorationTheme: _inputDecorationTheme(darkScheme),
5556
menuTheme: _menuTheme(darkScheme),
5657
popupMenuTheme: _popupMenuTheme(darkScheme),
5758
dialogTheme: _dialogTheme(darkScheme),
@@ -61,6 +62,9 @@ ThemePair phoenixTheme({
6162
dividerTheme: _dividerTheme(darkScheme),
6263
progressIndicatorTheme: _progressIndicatorTheme(darkScheme),
6364
switchTheme: _switchTheme(darkScheme),
65+
checkboxTheme: _checkBoxTheme(darkScheme),
66+
floatingActionButtonTheme: _floatingActionButtonTheme(darkScheme),
67+
elevatedButtonTheme: _elevatedButtonTheme(darkScheme),
6468
navigationRailTheme: _naviRailTheme(darkScheme),
6569
navigationBarTheme: _naviBarTheme(darkScheme),
6670
appBarTheme: _appBarTheme(darkScheme),
@@ -194,21 +198,55 @@ DropdownMenuThemeData _dropdownMenuTheme(ColorScheme colorScheme) {
194198

195199
SliderThemeData _sliderTheme(ColorScheme colorScheme) {
196200
return SliderThemeData(
197-
thumbColor: Colors.white,
198201
overlayShape: const RoundSliderOverlayShape(
199202
overlayRadius: 13,
200203
),
201204
overlayColor:
202205
colorScheme.primary.withOpacity(colorScheme.isLight ? 0.4 : 0.7),
203-
thumbShape: const RoundSliderThumbShape(elevation: 3.0),
204-
inactiveTrackColor: colorScheme.onSurface.withOpacity(0.3),
206+
inactiveTrackColor: colorScheme.primary.withOpacity(0.5),
207+
trackShape: CustomTrackShape(),
205208
);
206209
}
207210

211+
class CustomTrackShape extends RoundedRectSliderTrackShape {
212+
@override
213+
void paint(
214+
PaintingContext context,
215+
Offset offset, {
216+
required RenderBox parentBox,
217+
required SliderThemeData sliderTheme,
218+
required Animation<double> enableAnimation,
219+
required TextDirection textDirection,
220+
required Offset thumbCenter,
221+
Offset? secondaryOffset,
222+
bool isDiscrete = false,
223+
bool isEnabled = false,
224+
double additionalActiveTrackHeight = 0,
225+
}) {
226+
super.paint(
227+
context,
228+
offset,
229+
parentBox: parentBox,
230+
sliderTheme: sliderTheme,
231+
enableAnimation: enableAnimation,
232+
textDirection: textDirection,
233+
thumbCenter: thumbCenter,
234+
isDiscrete: isDiscrete,
235+
isEnabled: isEnabled,
236+
additionalActiveTrackHeight: 0,
237+
);
238+
}
239+
}
240+
208241
SwitchThemeData _switchTheme(ColorScheme colorScheme) {
209242
return SwitchThemeData(
210243
trackOutlineColor: WidgetStateColor.resolveWith(
211-
(states) => Colors.transparent,
244+
(states) => switch (states.toList()) {
245+
[WidgetState.disabled] ||
246+
[WidgetState.disabled, WidgetState.selected] =>
247+
colorScheme.onSurface.withOpacity(0.3),
248+
_ => colorScheme.primary,
249+
},
212250
),
213251
thumbColor: WidgetStateProperty.resolveWith(
214252
(states) => _getSwitchThumbColor(states, colorScheme),
@@ -226,27 +264,24 @@ Color _getSwitchThumbColor(Set<WidgetState> states, ColorScheme colorScheme) {
226264
}
227265
return colorScheme.onSurface.withOpacity(0.5);
228266
} else {
229-
return colorScheme.onPrimary;
267+
return colorScheme.isLight ? colorScheme.primary : colorScheme.primaryFixed;
230268
}
231269
}
232270

233271
Color _getSwitchTrackColor(Set<WidgetState> states, ColorScheme colorScheme) {
234-
final uncheckedColor = colorScheme.onSurface.withOpacity(.25);
235-
final disabledUncheckedColor = colorScheme.onSurface.withOpacity(.15);
236-
final disabledCheckedColor = colorScheme.onSurface.withOpacity(.18);
272+
return switch (states.toList()) {
273+
[WidgetState.disabled] ||
274+
[WidgetState.disabled, WidgetState.selected] =>
275+
colorScheme.onSurface.withOpacity(0.3),
276+
[] => colorScheme.surface,
277+
_ => colorScheme.primaryContainer,
278+
};
279+
}
237280

238-
if (states.contains(WidgetState.disabled)) {
239-
if (states.contains(WidgetState.selected)) {
240-
return disabledCheckedColor;
241-
}
242-
return disabledUncheckedColor;
243-
} else {
244-
if (states.contains(WidgetState.selected)) {
245-
return colorScheme.primary;
246-
} else {
247-
return uncheckedColor;
248-
}
249-
}
281+
CheckboxThemeData _checkBoxTheme(ColorScheme colorScheme) {
282+
return CheckboxThemeData(
283+
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(3)),
284+
);
250285
}
251286

252287
ProgressIndicatorThemeData _progressIndicatorTheme(ColorScheme colorScheme) {
@@ -256,6 +291,37 @@ ProgressIndicatorThemeData _progressIndicatorTheme(ColorScheme colorScheme) {
256291
);
257292
}
258293

294+
FloatingActionButtonThemeData _floatingActionButtonTheme(
295+
ColorScheme colorScheme,
296+
) {
297+
const elevation = 1.0;
298+
return FloatingActionButtonThemeData(
299+
elevation: elevation,
300+
focusElevation: elevation,
301+
hoverElevation: elevation,
302+
disabledElevation: elevation,
303+
highlightElevation: elevation,
304+
shape: RoundedRectangleBorder(
305+
borderRadius: BorderRadius.circular(30),
306+
),
307+
);
308+
}
309+
310+
ElevatedButtonThemeData _elevatedButtonTheme(ColorScheme colorScheme) {
311+
return ElevatedButtonThemeData(
312+
style: ElevatedButton.styleFrom(
313+
backgroundColor: colorScheme.isLight
314+
? colorScheme.primaryFixed
315+
: colorScheme.primaryContainer,
316+
elevation: 0,
317+
shadowColor: Colors.transparent,
318+
shape: RoundedRectangleBorder(
319+
borderRadius: BorderRadius.circular(30),
320+
),
321+
),
322+
);
323+
}
324+
259325
NavigationRailThemeData _naviRailTheme(ColorScheme colorScheme) {
260326
return NavigationRailThemeData(
261327
indicatorColor: _indicatorColor(colorScheme),
@@ -306,84 +372,5 @@ SnackBarThemeData _snackBarThemeData(ColorScheme colorScheme) {
306372
);
307373
}
308374

309-
// InputDecorationTheme _inputDecorationTheme(ColorScheme colorScheme) {
310-
// final radius = BorderRadius.circular(kButtonRadius);
311-
// const width = 1.0;
312-
// const strokeAlign = 0.0;
313-
// final border = colorScheme.outline;
314-
// final fill = border.scale(
315-
// lightness: colorScheme.isLight ? 0.8 : -0.5,
316-
// );
317-
318-
// final disabledBorder =
319-
// border.scale(lightness: colorScheme.isLight ? 0.2 : -0.2);
320-
321-
// const textStyle = TextStyle(
322-
// fontSize: 14,
323-
// fontWeight: FontWeight.normal,
324-
// );
325-
// return InputDecorationTheme(
326-
// filled: true,
327-
// fillColor: fill,
328-
// border: OutlineInputBorder(
329-
// borderSide: BorderSide(
330-
// width: width,
331-
// color: border,
332-
// ),
333-
// borderRadius: radius,
334-
// ),
335-
// focusedBorder: OutlineInputBorder(
336-
// borderSide: BorderSide(width: width, color: colorScheme.primary),
337-
// borderRadius: radius,
338-
// ),
339-
// enabledBorder: OutlineInputBorder(
340-
// borderSide:
341-
// BorderSide(width: width, color: border, strokeAlign: strokeAlign),
342-
// borderRadius: radius,
343-
// ),
344-
// activeIndicatorBorder:
345-
// const BorderSide(width: width, strokeAlign: strokeAlign),
346-
// outlineBorder: const BorderSide(width: width, strokeAlign: strokeAlign),
347-
// focusedErrorBorder: OutlineInputBorder(
348-
// borderSide: BorderSide(
349-
// width: width,
350-
// color: colorScheme.error,
351-
// strokeAlign: strokeAlign,
352-
// ),
353-
// borderRadius: radius,
354-
// ),
355-
// errorBorder: OutlineInputBorder(
356-
// borderSide: BorderSide(
357-
// width: width,
358-
// color: colorScheme.error,
359-
// strokeAlign: strokeAlign,
360-
// ),
361-
// borderRadius: radius,
362-
// ),
363-
// disabledBorder: OutlineInputBorder(
364-
// borderSide: BorderSide(
365-
// width: width,
366-
// color: disabledBorder,
367-
// strokeAlign: strokeAlign,
368-
// ),
369-
// borderRadius: radius,
370-
// ),
371-
// iconColor: colorScheme.onSurface,
372-
// helperStyle: textStyle,
373-
// hintStyle: textStyle,
374-
// labelStyle: textStyle,
375-
// suffixStyle: textStyle.copyWith(
376-
// color: colorScheme.onSurface.scale(lightness: -0.2),
377-
// ),
378-
// prefixStyle: textStyle.copyWith(
379-
// color: colorScheme.onSurface.scale(lightness: -0.2),
380-
// ),
381-
// isDense: !isMobile,
382-
// contentPadding: isMobile
383-
// ? null
384-
// : const EdgeInsets.only(left: 12, right: 12, bottom: 9, top: 10),
385-
// );
386-
// }
387-
388375
bool get isMobile =>
389376
!kIsWeb && Platform.isAndroid || Platform.isIOS || Platform.isFuchsia;

0 commit comments

Comments
 (0)