Skip to content

Commit 87da5d4

Browse files
authored
feat(text-editor): add inputLetterSpacing and inputShadows to TextEditorStyle (#788)
Instead of hard-coding letterSpacing: 0 and shadows: [] in the text input copyWith, move these values into TextEditorStyle as configurable properties with the same defaults: - inputLetterSpacing (default: 0) — fixes font alignment issues - inputShadows (default: []) — prevents unwanted shadow rendering This preserves the existing behavior by default while allowing users to override these values (e.g. set to null) when they need the font's native letter spacing or shadows. Both hintStyle and style in TextEditorInput now read from these style properties.
1 parent 3f3128e commit 87da5d4

2 files changed

Lines changed: 22 additions & 3 deletions

File tree

lib/core/models/styles/text_editor_style.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ class TextEditorStyle {
7575
Radius.circular(4),
7676
),
7777
this.inputTextFieldPadding = EdgeInsets.zero,
78+
this.inputLetterSpacing = 0,
79+
this.inputShadows = const [],
7880
});
7981

8082
/// Background color of the app bar in the text editor.
@@ -129,6 +131,18 @@ class TextEditorStyle {
129131
/// on various platforms. Set to null to use the default line height.
130132
final double? textHeight;
131133

134+
/// Letter spacing applied to the text input field style.
135+
///
136+
/// Defaults to `0` to fix alignment issues with some fonts.
137+
/// Set to `null` to use the font's default letter spacing.
138+
final double? inputLetterSpacing;
139+
140+
/// Shadows applied to the text input field style.
141+
///
142+
/// Defaults to an empty list to prevent unwanted shadow rendering
143+
/// with some fonts. Set to `null` to use the font's default shadows.
144+
final List<Shadow>? inputShadows;
145+
132146
/// Controls how extra leading from the [TextStyle.height] multiplier is
133147
/// distributed above and below the text glyph.
134148
///
@@ -166,6 +180,8 @@ class TextEditorStyle {
166180
EdgeInsets? textFieldMargin,
167181
EdgeInsets? textFieldPadding,
168182
TextStyle? fontSizeBottomSheetTitle,
183+
double? inputLetterSpacing,
184+
List<Shadow>? inputShadows,
169185
}) {
170186
return TextEditorStyle(
171187
textHeight: textHeight ?? this.textHeight,
@@ -192,6 +208,8 @@ class TextEditorStyle {
192208
textFieldPadding: textFieldPadding ?? this.textFieldPadding,
193209
fontSizeBottomSheetTitle:
194210
fontSizeBottomSheetTitle ?? this.fontSizeBottomSheetTitle,
211+
inputLetterSpacing: inputLetterSpacing ?? this.inputLetterSpacing,
212+
inputShadows: inputShadows ?? this.inputShadows,
195213
);
196214
}
197215
}

lib/features/text_editor/widgets/text_editor_input.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,16 @@ class _TextEditorInputState extends State<TextEditorInput> {
200200
hintStyle: widget.selectedTextStyle.copyWith(
201201
color: widget.configs.style.inputHintColor,
202202
fontSize: widget.textFontSize,
203-
shadows: [],
203+
letterSpacing: widget.configs.style.inputLetterSpacing,
204+
shadows: widget.configs.style.inputShadows,
204205
),
205206
backgroundColor: widget.backgroundColor,
206207
style: widget.selectedTextStyle.copyWith(
207208
color: widget.textColor,
208209
fontSize: widget.textFontSize,
209-
letterSpacing: 0,
210+
letterSpacing: widget.configs.style.inputLetterSpacing,
211+
shadows: widget.configs.style.inputShadows,
210212
decoration: TextDecoration.none,
211-
shadows: [],
212213
),
213214

214215
/// If we edit an layer we focus to the textfield after the

0 commit comments

Comments
 (0)