Skip to content

Commit 524a58e

Browse files
committed
compose [nfc]: Make variant of _ContentInput without the typing notifier
We'll use this for the edit-message compose box.
1 parent 8e9f428 commit 524a58e

File tree

1 file changed

+57
-6
lines changed

1 file changed

+57
-6
lines changed

lib/widgets/compose_box.dart

Lines changed: 57 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,34 @@ class ComposeContentController extends ComposeController<ContentValidationError>
394394
}
395395
}
396396

397-
class _ContentInput extends StatefulWidget {
398-
const _ContentInput({
397+
abstract class _ContentInput extends StatefulWidget {
398+
factory _ContentInput.withTypingNotifier({
399+
required Narrow narrow,
400+
required SendableNarrow destination,
401+
required ComposeBoxController controller,
402+
required String hintText,
403+
}) => _ContentInputWithTypingNotifier._(
404+
narrow: narrow,
405+
destination: destination,
406+
controller: controller,
407+
hintText: hintText,
408+
);
409+
410+
// We'll use this soon.
411+
// ignore: unused_element
412+
factory _ContentInput.noTypingNotifier({
413+
required Narrow narrow,
414+
required SendableNarrow destination,
415+
required ComposeBoxController controller,
416+
required String hintText,
417+
}) => _ContentInputNoTypingNotifier._(
418+
narrow: narrow,
419+
destination: destination,
420+
controller: controller,
421+
hintText: hintText,
422+
);
423+
424+
const _ContentInput._({
399425
required this.narrow,
400426
required this.destination,
401427
required this.controller,
@@ -406,12 +432,33 @@ class _ContentInput extends StatefulWidget {
406432
final SendableNarrow destination;
407433
final ComposeBoxController controller;
408434
final String hintText;
435+
}
436+
437+
class _ContentInputWithTypingNotifier extends _ContentInput {
438+
const _ContentInputWithTypingNotifier._({
439+
required super.narrow,
440+
required super.destination,
441+
required super.controller,
442+
required super.hintText,
443+
}) : super._();
444+
445+
@override
446+
State<_ContentInput> createState() => _ContentInputStateWithTypingNotifier();
447+
}
448+
449+
class _ContentInputNoTypingNotifier extends _ContentInput {
450+
const _ContentInputNoTypingNotifier._({
451+
required super.narrow,
452+
required super.destination,
453+
required super.controller,
454+
required super.hintText,
455+
}) : super._();
409456

410457
@override
411-
State<_ContentInput> createState() => _ContentInputState();
458+
State<_ContentInput> createState() => _ContentInputStateNoTypingNotifier();
412459
}
413460

414-
class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserver, _TypingNotifierMixin {
461+
class _ContentInputStateBase extends State<_ContentInput> {
415462
static double maxHeight(BuildContext context) {
416463
final clampingTextScaler = MediaQuery.textScalerOf(context)
417464
.clamp(maxScaleFactor: 1.5);
@@ -486,6 +533,10 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
486533
}
487534
}
488535

536+
537+
class _ContentInputStateWithTypingNotifier extends _ContentInputStateBase with WidgetsBindingObserver, _TypingNotifierMixin {}
538+
class _ContentInputStateNoTypingNotifier extends _ContentInputStateBase {}
539+
489540
mixin _TypingNotifierMixin on State<_ContentInput>, WidgetsBindingObserver {
490541
@override
491542
void initState() {
@@ -647,7 +698,7 @@ class _StreamContentInputState extends State<_StreamContentInput> {
647698
// ignore: dead_null_aware_expression // null topic names soon to be enabled
648699
: '#$streamName > ${hintTopic.displayName ?? store.realmEmptyTopicDisplayName}';
649700

650-
return _ContentInput(
701+
return _ContentInput.withTypingNotifier(
651702
narrow: widget.narrow,
652703
destination: TopicNarrow(widget.narrow.streamId,
653704
TopicName(widget.controller.topic.textNormalized)),
@@ -734,7 +785,7 @@ class _FixedDestinationContentInput extends StatelessWidget {
734785

735786
@override
736787
Widget build(BuildContext context) {
737-
return _ContentInput(
788+
return _ContentInput.withTypingNotifier(
738789
narrow: narrow,
739790
destination: narrow,
740791
controller: controller,

0 commit comments

Comments
 (0)