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 8b8e1da
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 36 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,11 +885,11 @@ 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),
labelStyle: effectiveTextTheme.small.copyWith(fontSize: 12),
fieldWidth: 58,
fieldPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
periodHeight: 50,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/theme/themes/default_theme_variant.dart
Original file line number Diff line number Diff line change
Expand Up @@ -858,11 +858,11 @@ 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),
labelStyle: effectiveTextTheme.small.copyWith(fontSize: 12),
fieldWidth: 58,
fieldPadding: const EdgeInsets.symmetric(horizontal: 12, vertical: 8),
periodHeight: 50,
Expand Down

0 comments on commit 8b8e1da

Please sign in to comment.