@@ -271,17 +271,18 @@ class _ContentInput extends StatelessWidget {
271
271
required this .controller,
272
272
required this .focusNode,
273
273
required this .hintText,
274
+ this .enabled = true ,
274
275
});
275
276
276
277
final Narrow narrow;
277
278
final ComposeContentController controller;
278
279
final FocusNode focusNode;
279
280
final String hintText;
281
+ final bool enabled;
280
282
281
283
@override
282
284
Widget build (BuildContext context) {
283
285
ColorScheme colorScheme = Theme .of (context).colorScheme;
284
-
285
286
return InputDecorator (
286
287
decoration: const InputDecoration (),
287
288
child: ConstrainedBox (
@@ -303,6 +304,7 @@ class _ContentInput extends StatelessWidget {
303
304
decoration: InputDecoration .collapsed (hintText: hintText),
304
305
maxLines: null ,
305
306
textCapitalization: TextCapitalization .sentences,
307
+ enabled: enabled,
306
308
);
307
309
}),
308
310
));
@@ -377,32 +379,37 @@ class _FixedDestinationContentInput extends StatelessWidget {
377
379
required this .narrow,
378
380
required this .controller,
379
381
required this .focusNode,
382
+ required this .enabled,
380
383
});
381
384
382
385
final SendableNarrow narrow;
383
386
final ComposeContentController controller;
384
387
final FocusNode focusNode;
388
+ final bool enabled;
385
389
386
390
String _hintText (BuildContext context) {
387
391
final zulipLocalizations = ZulipLocalizations .of (context);
388
- switch (narrow) {
389
- case TopicNarrow (: final streamId, : final topic):
392
+ switch (( narrow, enabled) ) {
393
+ case ( TopicNarrow (: final streamId, : final topic), _ ):
390
394
final store = PerAccountStoreWidget .of (context);
391
395
final streamName = store.streams[streamId]? .name
392
396
?? zulipLocalizations.composeBoxUnknownChannelName;
393
397
return zulipLocalizations.composeBoxChannelContentHint (streamName, topic);
394
398
395
- case DmNarrow (otherRecipientIds: []): // The self-1:1 thread.
399
+ case ( DmNarrow (otherRecipientIds: []), _ ): // The self-1:1 thread.
396
400
return zulipLocalizations.composeBoxSelfDmContentHint;
397
401
398
- case DmNarrow (otherRecipientIds: [final otherUserId]):
402
+ case ( DmNarrow (otherRecipientIds: [final otherUserId]), true ):
399
403
final store = PerAccountStoreWidget .of (context);
400
404
final fullName = store.users[otherUserId]? .fullName;
401
405
if (fullName == null ) return zulipLocalizations.composeBoxGenericContentHint;
402
406
return zulipLocalizations.composeBoxDmContentHint (fullName);
403
407
404
- case DmNarrow (): // A group DM thread.
408
+ case ( DmNarrow (), true ): // A group DM thread.
405
409
return zulipLocalizations.composeBoxGroupDmContentHint;
410
+
411
+ case (DmNarrow (), false ):
412
+ return zulipLocalizations.composeBoxDeactivatedDmContentHint;
406
413
}
407
414
}
408
415
@@ -412,7 +419,8 @@ class _FixedDestinationContentInput extends StatelessWidget {
412
419
narrow: narrow,
413
420
controller: controller,
414
421
focusNode: focusNode,
415
- hintText: _hintText (context));
422
+ hintText: _hintText (context),
423
+ enabled: enabled);
416
424
}
417
425
}
418
426
@@ -492,10 +500,15 @@ Future<void> _uploadFiles({
492
500
}
493
501
494
502
abstract class _AttachUploadsButton extends StatelessWidget {
495
- const _AttachUploadsButton ({required this .contentController, required this .contentFocusNode});
503
+ const _AttachUploadsButton ({
504
+ required this .contentController,
505
+ required this .contentFocusNode,
506
+ required this .enabled,
507
+ });
496
508
497
509
final ComposeContentController contentController;
498
510
final FocusNode contentFocusNode;
511
+ final bool enabled;
499
512
500
513
IconData get icon;
501
514
String tooltip (ZulipLocalizations zulipLocalizations);
@@ -534,7 +547,7 @@ abstract class _AttachUploadsButton extends StatelessWidget {
534
547
return IconButton (
535
548
icon: Icon (icon),
536
549
tooltip: tooltip (zulipLocalizations),
537
- onPressed: () => _handlePress (context));
550
+ onPressed: enabled ? () => _handlePress (context) : null );
538
551
}
539
552
}
540
553
@@ -578,7 +591,11 @@ Future<Iterable<_File>> _getFilePickerFiles(BuildContext context, FileType type)
578
591
}
579
592
580
593
class _AttachFileButton extends _AttachUploadsButton {
581
- const _AttachFileButton ({required super .contentController, required super .contentFocusNode});
594
+ const _AttachFileButton ({
595
+ required super .contentController,
596
+ required super .contentFocusNode,
597
+ required super .enabled,
598
+ });
582
599
583
600
@override
584
601
IconData get icon => Icons .attach_file;
@@ -594,7 +611,11 @@ class _AttachFileButton extends _AttachUploadsButton {
594
611
}
595
612
596
613
class _AttachMediaButton extends _AttachUploadsButton {
597
- const _AttachMediaButton ({required super .contentController, required super .contentFocusNode});
614
+ const _AttachMediaButton ({
615
+ required super .contentController,
616
+ required super .contentFocusNode,
617
+ required super .enabled,
618
+ });
598
619
599
620
@override
600
621
IconData get icon => Icons .image;
@@ -611,7 +632,11 @@ class _AttachMediaButton extends _AttachUploadsButton {
611
632
}
612
633
613
634
class _AttachFromCameraButton extends _AttachUploadsButton {
614
- const _AttachFromCameraButton ({required super .contentController, required super .contentFocusNode});
635
+ const _AttachFromCameraButton ({
636
+ required super .contentController,
637
+ required super .contentFocusNode,
638
+ required super .enabled,
639
+ });
615
640
616
641
@override
617
642
IconData get icon => Icons .camera_alt;
@@ -667,11 +692,13 @@ class _SendButton extends StatefulWidget {
667
692
required this .topicController,
668
693
required this .contentController,
669
694
required this .getDestination,
695
+ this .enabled = true ,
670
696
});
671
697
672
698
final ComposeTopicController ? topicController;
673
699
final ComposeContentController contentController;
674
700
final MessageDestination Function () getDestination;
701
+ final bool enabled;
675
702
676
703
@override
677
704
State <_SendButton > createState () => _SendButtonState ();
@@ -774,7 +801,7 @@ class _SendButtonState extends State<_SendButton> {
774
801
),
775
802
color: foregroundColor,
776
803
icon: const Icon (Icons .send),
777
- onPressed: _send));
804
+ onPressed: widget.enabled ? _send : null ));
778
805
}
779
806
}
780
807
@@ -785,13 +812,15 @@ class _ComposeBoxLayout extends StatelessWidget {
785
812
required this .sendButton,
786
813
required this .contentController,
787
814
required this .contentFocusNode,
815
+ this .enabled = true ,
788
816
});
789
817
790
818
final Widget ? topicInput;
791
819
final Widget contentInput;
792
820
final Widget sendButton;
793
821
final ComposeContentController contentController;
794
822
final FocusNode contentFocusNode;
823
+ final bool enabled;
795
824
796
825
@override
797
826
Widget build (BuildContext context) {
@@ -835,9 +864,21 @@ class _ComposeBoxLayout extends StatelessWidget {
835
864
data: themeData.copyWith (
836
865
iconTheme: themeData.iconTheme.copyWith (color: colorScheme.onSurfaceVariant)),
837
866
child: Row (children: [
838
- _AttachFileButton (contentController: contentController, contentFocusNode: contentFocusNode),
839
- _AttachMediaButton (contentController: contentController, contentFocusNode: contentFocusNode),
840
- _AttachFromCameraButton (contentController: contentController, contentFocusNode: contentFocusNode),
867
+ _AttachFileButton (
868
+ contentController: contentController,
869
+ contentFocusNode: contentFocusNode,
870
+ enabled: enabled,
871
+ ),
872
+ _AttachMediaButton (
873
+ contentController: contentController,
874
+ contentFocusNode: contentFocusNode,
875
+ enabled: enabled,
876
+ ),
877
+ _AttachFromCameraButton (
878
+ contentController: contentController,
879
+ contentFocusNode: contentFocusNode,
880
+ enabled: enabled,
881
+ ),
841
882
])),
842
883
])))); }
843
884
}
@@ -925,6 +966,20 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
925
966
926
967
@override FocusNode get contentFocusNode => _contentFocusNode;
927
968
final _contentFocusNode = FocusNode ();
969
+ late bool enabled;
970
+
971
+ @override
972
+ void didChangeDependencies () {
973
+ super .didChangeDependencies ();
974
+ final store = PerAccountStoreWidget .of (context);
975
+ enabled = switch (widget.narrow) {
976
+ DmNarrow (: final otherRecipientIds) => otherRecipientIds.every ((id) =>
977
+ store.users[id]? .isActive ?? true ),
978
+ TopicNarrow () => true ,
979
+ };
980
+
981
+ if (! enabled) _contentController.clear ();
982
+ }
928
983
929
984
@override
930
985
void dispose () {
@@ -939,15 +994,18 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
939
994
contentController: _contentController,
940
995
contentFocusNode: _contentFocusNode,
941
996
topicInput: null ,
997
+ enabled: enabled,
942
998
contentInput: _FixedDestinationContentInput (
943
999
narrow: widget.narrow,
944
1000
controller: _contentController,
945
1001
focusNode: _contentFocusNode,
1002
+ enabled: enabled,
946
1003
),
947
1004
sendButton: _SendButton (
948
1005
topicController: null ,
949
1006
contentController: _contentController,
950
1007
getDestination: () => widget.narrow.destination,
1008
+ enabled: enabled,
951
1009
));
952
1010
}
953
1011
}
0 commit comments