Skip to content

Commit

Permalink
fix: update theme
Browse files Browse the repository at this point in the history
  • Loading branch information
nank1ro committed Nov 25, 2024
1 parent 23c55f2 commit 9e22fbc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 34 deletions.
35 changes: 7 additions & 28 deletions lib/src/components/time_picker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,9 @@ class _ShadTimePickerFieldState extends State<ShadTimePickerField> {
height: 24 / 16,
);

final effectivePlaceholderStyle =
defaultPlaceholderStyle.merge(controller.placeholderStyle);
final effectivePlaceholderStyle = defaultPlaceholderStyle
.merge(theme.timePickerTheme.placeholderStyle)
.merge(controller.placeholderStyle);

final defaultLabelStyle = theme.textTheme.small.copyWith(fontSize: 12);
final effectiveLabelStyle = defaultLabelStyle.merge(widget.labelStyle);
Expand Down Expand Up @@ -798,11 +799,6 @@ class ShadTimePickerTextEditingController extends TextEditingController {
assert(
!value.composing.isValid || !withComposing || value.isComposingRangeValid,
);
// If the composing range is out of range for the current text, ignore it to
// preserve the tree integrity, otherwise in release mode a RangeError will
// be thrown and this EditableText will be built with a broken subtree.
final composingRegionOutOfRange =
!value.isComposingRangeValid || !withComposing;

final theme = ShadTheme.of(context);

Expand All @@ -817,29 +813,12 @@ class ShadTimePickerTextEditingController extends TextEditingController {
final intValue = int.tryParse(value.text);
if (intValue == null) return const TextSpan();

if (composingRegionOutOfRange) {
return TextSpan(
style: style,
children: [
if (value.text.length == 1 && intValue < 10)
TextSpan(text: '0', style: effectivePlaceholderStyle),
TextSpan(text: text),
],
);
}

final composingStyle =
style?.merge(const TextStyle(decoration: TextDecoration.underline)) ??
const TextStyle(decoration: TextDecoration.underline);
return TextSpan(
style: style,
children: <TextSpan>[
TextSpan(text: value.composing.textBefore(value.text)),
TextSpan(
style: composingStyle,
text: value.composing.textInside(value.text),
),
TextSpan(text: value.composing.textAfter(value.text)),
children: [
if (value.text.length == 1 && intValue < 10)
TextSpan(text: '0', style: effectivePlaceholderStyle),
TextSpan(text: text),
],
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,9 @@ class ShadDefaultThemeNoSecondaryBorderVariant extends ShadThemeVariant {
fontSize: 16,
height: 24 / 16,
),
placeholderStyle: defaultTextTheme.large.copyWith(
fontWeight: FontWeight.w500,
color: colorScheme.foreground,
placeholderStyle: effectiveTextTheme.muted.copyWith(
fontSize: 16,
height: 24 / 16,
),
labelStyle: defaultTextTheme.small.copyWith(fontSize: 12),
fieldWidth: 58,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/theme/themes/default_theme_variant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ class ShadDefaultThemeVariant extends ShadThemeVariant {
fontSize: 16,
height: 24 / 16,
),
placeholderStyle: defaultTextTheme.large.copyWith(
fontWeight: FontWeight.w500,
color: colorScheme.foreground,
placeholderStyle: effectiveTextTheme.muted.copyWith(
fontSize: 16,
height: 24 / 16,
),
labelStyle: defaultTextTheme.small.copyWith(fontSize: 12),
fieldWidth: 58,
Expand Down

0 comments on commit 9e22fbc

Please sign in to comment.