Skip to content

Commit 9d0df65

Browse files
committed
compose [nfc]: Pull out method for computing topic for hint text
This method is trivial for now, but provides a home for logic to be added next. In particular this separates the computation of how the topic should appear in the hint text from what the topic should be in the API, in `destination`.
1 parent 47bbfe2 commit 9d0df65

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

lib/widgets/compose_box.dart

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -579,23 +579,31 @@ class _StreamContentInputState extends State<_StreamContentInput> {
579579
super.dispose();
580580
}
581581

582+
/// The topic name to use in the hint text.
583+
TopicName _hintTopic() {
584+
return TopicName(widget.controller.topic.textNormalized);
585+
}
586+
582587
@override
583588
Widget build(BuildContext context) {
584589
final store = PerAccountStoreWidget.of(context);
585590
final zulipLocalizations = ZulipLocalizations.of(context);
591+
586592
final streamName = store.streams[widget.narrow.streamId]?.name
587593
?? zulipLocalizations.unknownChannelName;
588-
final topic = TopicName(widget.controller.topic.textNormalized);
594+
final hintDestination =
595+
// No i18n of this use of "#" and ">" string; those are part of how
596+
// Zulip expresses channels and topics, not any normal English punctuation,
597+
// so don't make sense to translate. See:
598+
// https://github.com/zulip/zulip-flutter/pull/1148#discussion_r1941990585
599+
'#$streamName > ${_hintTopic().displayName}';
600+
589601
return _ContentInput(
590602
narrow: widget.narrow,
591-
destination: TopicNarrow(widget.narrow.streamId, topic),
603+
destination: TopicNarrow(widget.narrow.streamId,
604+
TopicName(widget.controller.topic.textNormalized)),
592605
controller: widget.controller,
593-
hintText: zulipLocalizations.composeBoxChannelContentHint(
594-
// No i18n of this use of "#" and ">" string; those are part of how
595-
// Zulip expresses channels and topics, not any normal English punctuation,
596-
// so don't make sense to translate. See:
597-
// https://github.com/zulip/zulip-flutter/pull/1148#discussion_r1941990585
598-
'#$streamName > ${topic.displayName}'));
606+
hintText: zulipLocalizations.composeBoxChannelContentHint(hintDestination));
599607
}
600608
}
601609

0 commit comments

Comments
 (0)