Skip to content

Commit b4abec9

Browse files
committed
compose [nfc]: Pass hint widget to _ContentInput
This will give us more control over styling part of the text later Signed-off-by: Zixuan James Li <[email protected]>
1 parent a4bb99e commit b4abec9

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

lib/widgets/compose_box.dart

+14-12
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,13 @@ class _ContentInput extends StatefulWidget {
374374
required this.narrow,
375375
required this.destination,
376376
required this.controller,
377-
required this.hintText,
377+
required this.hint,
378378
});
379379

380380
final Narrow narrow;
381381
final SendableNarrow destination;
382382
final ComposeBoxController controller;
383-
final String hintText;
383+
final Widget hint;
384384

385385
@override
386386
State<_ContentInput> createState() => _ContentInputState();
@@ -487,6 +487,10 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
487487
@override
488488
Widget build(BuildContext context) {
489489
final designVariables = DesignVariables.of(context);
490+
final contentTextStyle = TextStyle(
491+
fontSize: _fontSize,
492+
height: _lineHeightRatio,
493+
color: designVariables.textInput);
490494

491495
return ComposeAutocomplete(
492496
narrow: widget.narrow,
@@ -505,10 +509,7 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
505509
// Let the content show through the `contentPadding` so that
506510
// our [InsetShadowBox] can fade it smoothly there.
507511
clipBehavior: Clip.none,
508-
style: TextStyle(
509-
fontSize: _fontSize,
510-
height: _lineHeightRatio,
511-
color: designVariables.textInput),
512+
style: contentTextStyle,
512513
// From the spec at
513514
// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3960-5147&node-type=text&m=dev
514515
// > Compose box has the height to fit 2 lines. This is [done] to
@@ -527,9 +528,10 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
527528
// that 54px distance while also making the scrolling work like
528529
// this and offering two lines of touchable area.
529530
contentPadding: const EdgeInsets.symmetric(vertical: _verticalPadding),
530-
hintText: widget.hintText,
531-
hintStyle: TextStyle(
532-
color: designVariables.textInput.withFadedAlpha(0.5))))))));
531+
hint: DefaultTextStyle.merge(
532+
style: contentTextStyle.copyWith(
533+
color: designVariables.textInput.withFadedAlpha(0.5)),
534+
child: widget.hint)))))));
533535
}
534536
}
535537

@@ -586,8 +588,8 @@ class _StreamContentInputState extends State<_StreamContentInput> {
586588
narrow: widget.narrow,
587589
destination: TopicNarrow(widget.narrow.streamId, topic),
588590
controller: widget.controller,
589-
hintText: zulipLocalizations.composeBoxChannelContentHint(
590-
streamName, topic.displayName));
591+
hint: Text(zulipLocalizations.composeBoxChannelContentHint(
592+
streamName, topic.displayName)));
591593
}
592594
}
593595

@@ -668,7 +670,7 @@ class _FixedDestinationContentInput extends StatelessWidget {
668670
narrow: narrow,
669671
destination: narrow,
670672
controller: controller,
671-
hintText: _hintText(context));
673+
hint: Text(_hintText(context)));
672674
}
673675
}
674676

0 commit comments

Comments
 (0)