@@ -272,17 +272,18 @@ class _ContentInput extends StatelessWidget {
272
272
required this .controller,
273
273
required this .focusNode,
274
274
required this .hintText,
275
+ this .enabled = true ,
275
276
});
276
277
277
278
final Narrow narrow;
278
279
final ComposeContentController controller;
279
280
final FocusNode focusNode;
280
281
final String hintText;
282
+ final bool enabled;
281
283
282
284
@override
283
285
Widget build (BuildContext context) {
284
286
ColorScheme colorScheme = Theme .of (context).colorScheme;
285
-
286
287
return InputDecorator (
287
288
decoration: const InputDecoration (),
288
289
child: ConstrainedBox (
@@ -304,6 +305,7 @@ class _ContentInput extends StatelessWidget {
304
305
decoration: InputDecoration .collapsed (hintText: hintText),
305
306
maxLines: null ,
306
307
textCapitalization: TextCapitalization .sentences,
308
+ enabled: enabled,
307
309
);
308
310
}),
309
311
));
@@ -378,32 +380,37 @@ class _FixedDestinationContentInput extends StatelessWidget {
378
380
required this .narrow,
379
381
required this .controller,
380
382
required this .focusNode,
383
+ required this .enabled,
381
384
});
382
385
383
386
final SendableNarrow narrow;
384
387
final ComposeContentController controller;
385
388
final FocusNode focusNode;
389
+ final bool enabled;
386
390
387
391
String _hintText (BuildContext context) {
388
392
final zulipLocalizations = ZulipLocalizations .of (context);
389
- switch (narrow) {
390
- case TopicNarrow (: final streamId, : final topic):
393
+ switch (( narrow, enabled) ) {
394
+ case ( TopicNarrow (: final streamId, : final topic), _ ):
391
395
final store = PerAccountStoreWidget .of (context);
392
396
final streamName = store.streams[streamId]? .name
393
397
?? zulipLocalizations.composeBoxUnknownChannelName;
394
398
return zulipLocalizations.composeBoxChannelContentHint (streamName, topic);
395
399
396
- case DmNarrow (otherRecipientIds: []): // The self-1:1 thread.
400
+ case ( DmNarrow (otherRecipientIds: []), _ ): // The self-1:1 thread.
397
401
return zulipLocalizations.composeBoxSelfDmContentHint;
398
402
399
- case DmNarrow (otherRecipientIds: [final otherUserId]):
403
+ case ( DmNarrow (otherRecipientIds: [final otherUserId]), true ):
400
404
final store = PerAccountStoreWidget .of (context);
401
405
final fullName = store.users[otherUserId]? .fullName;
402
406
if (fullName == null ) return zulipLocalizations.composeBoxGenericContentHint;
403
407
return zulipLocalizations.composeBoxDmContentHint (fullName);
404
408
405
- case DmNarrow (): // A group DM thread.
409
+ case ( DmNarrow (), true ): // A group DM thread.
406
410
return zulipLocalizations.composeBoxGroupDmContentHint;
411
+
412
+ case (DmNarrow (), false ):
413
+ return zulipLocalizations.composeBoxDeactivatedDmContentHint;
407
414
}
408
415
}
409
416
@@ -413,7 +420,8 @@ class _FixedDestinationContentInput extends StatelessWidget {
413
420
narrow: narrow,
414
421
controller: controller,
415
422
focusNode: focusNode,
416
- hintText: _hintText (context));
423
+ hintText: _hintText (context),
424
+ enabled: enabled);
417
425
}
418
426
}
419
427
@@ -493,10 +501,15 @@ Future<void> _uploadFiles({
493
501
}
494
502
495
503
abstract class _AttachUploadsButton extends StatelessWidget {
496
- const _AttachUploadsButton ({required this .contentController, required this .contentFocusNode});
504
+ const _AttachUploadsButton ({
505
+ required this .contentController,
506
+ required this .contentFocusNode,
507
+ required this .enabled,
508
+ });
497
509
498
510
final ComposeContentController contentController;
499
511
final FocusNode contentFocusNode;
512
+ final bool enabled;
500
513
501
514
IconData get icon;
502
515
String tooltip (ZulipLocalizations zulipLocalizations);
@@ -535,7 +548,7 @@ abstract class _AttachUploadsButton extends StatelessWidget {
535
548
return IconButton (
536
549
icon: Icon (icon),
537
550
tooltip: tooltip (zulipLocalizations),
538
- onPressed: () => _handlePress (context));
551
+ onPressed: enabled ? () => _handlePress (context) : null );
539
552
}
540
553
}
541
554
@@ -579,7 +592,11 @@ Future<Iterable<_File>> _getFilePickerFiles(BuildContext context, FileType type)
579
592
}
580
593
581
594
class _AttachFileButton extends _AttachUploadsButton {
582
- const _AttachFileButton ({required super .contentController, required super .contentFocusNode});
595
+ const _AttachFileButton ({
596
+ required super .contentController,
597
+ required super .contentFocusNode,
598
+ required super .enabled,
599
+ });
583
600
584
601
@override
585
602
IconData get icon => Icons .attach_file;
@@ -595,7 +612,11 @@ class _AttachFileButton extends _AttachUploadsButton {
595
612
}
596
613
597
614
class _AttachMediaButton extends _AttachUploadsButton {
598
- const _AttachMediaButton ({required super .contentController, required super .contentFocusNode});
615
+ const _AttachMediaButton ({
616
+ required super .contentController,
617
+ required super .contentFocusNode,
618
+ required super .enabled,
619
+ });
599
620
600
621
@override
601
622
IconData get icon => Icons .image;
@@ -612,7 +633,11 @@ class _AttachMediaButton extends _AttachUploadsButton {
612
633
}
613
634
614
635
class _AttachFromCameraButton extends _AttachUploadsButton {
615
- const _AttachFromCameraButton ({required super .contentController, required super .contentFocusNode});
636
+ const _AttachFromCameraButton ({
637
+ required super .contentController,
638
+ required super .contentFocusNode,
639
+ required super .enabled,
640
+ });
616
641
617
642
@override
618
643
IconData get icon => Icons .camera_alt;
@@ -668,11 +693,13 @@ class _SendButton extends StatefulWidget {
668
693
required this .topicController,
669
694
required this .contentController,
670
695
required this .getDestination,
696
+ this .enabled = true ,
671
697
});
672
698
673
699
final ComposeTopicController ? topicController;
674
700
final ComposeContentController contentController;
675
701
final MessageDestination Function () getDestination;
702
+ final bool enabled;
676
703
677
704
@override
678
705
State <_SendButton > createState () => _SendButtonState ();
@@ -792,7 +819,7 @@ class _SendButtonState extends State<_SendButton> {
792
819
),
793
820
color: foregroundColor,
794
821
icon: const Icon (Icons .send),
795
- onPressed: _send));
822
+ onPressed: widget.enabled ? _send : null ));
796
823
}
797
824
}
798
825
@@ -803,13 +830,15 @@ class _ComposeBoxLayout extends StatelessWidget {
803
830
required this .sendButton,
804
831
required this .contentController,
805
832
required this .contentFocusNode,
833
+ this .enabled = true ,
806
834
});
807
835
808
836
final Widget ? topicInput;
809
837
final Widget contentInput;
810
838
final Widget sendButton;
811
839
final ComposeContentController contentController;
812
840
final FocusNode contentFocusNode;
841
+ final bool enabled;
813
842
814
843
@override
815
844
Widget build (BuildContext context) {
@@ -853,9 +882,21 @@ class _ComposeBoxLayout extends StatelessWidget {
853
882
data: themeData.copyWith (
854
883
iconTheme: themeData.iconTheme.copyWith (color: colorScheme.onSurfaceVariant)),
855
884
child: Row (children: [
856
- _AttachFileButton (contentController: contentController, contentFocusNode: contentFocusNode),
857
- _AttachMediaButton (contentController: contentController, contentFocusNode: contentFocusNode),
858
- _AttachFromCameraButton (contentController: contentController, contentFocusNode: contentFocusNode),
885
+ _AttachFileButton (
886
+ contentController: contentController,
887
+ contentFocusNode: contentFocusNode,
888
+ enabled: enabled,
889
+ ),
890
+ _AttachMediaButton (
891
+ contentController: contentController,
892
+ contentFocusNode: contentFocusNode,
893
+ enabled: enabled,
894
+ ),
895
+ _AttachFromCameraButton (
896
+ contentController: contentController,
897
+ contentFocusNode: contentFocusNode,
898
+ enabled: enabled,
899
+ ),
859
900
])),
860
901
])))); }
861
902
}
@@ -943,6 +984,20 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
943
984
944
985
@override FocusNode get contentFocusNode => _contentFocusNode;
945
986
final _contentFocusNode = FocusNode ();
987
+ late bool enabled;
988
+
989
+ @override
990
+ void didChangeDependencies () {
991
+ super .didChangeDependencies ();
992
+ final store = PerAccountStoreWidget .of (context);
993
+ enabled = switch (widget.narrow) {
994
+ DmNarrow (: final otherRecipientIds) => otherRecipientIds.every ((id) =>
995
+ store.users[id]? .isActive ?? true ),
996
+ TopicNarrow () => true ,
997
+ };
998
+
999
+ if (! enabled) _contentController.clear ();
1000
+ }
946
1001
947
1002
@override
948
1003
void dispose () {
@@ -957,15 +1012,18 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox
957
1012
contentController: _contentController,
958
1013
contentFocusNode: _contentFocusNode,
959
1014
topicInput: null ,
1015
+ enabled: enabled,
960
1016
contentInput: _FixedDestinationContentInput (
961
1017
narrow: widget.narrow,
962
1018
controller: _contentController,
963
1019
focusNode: _contentFocusNode,
1020
+ enabled: enabled,
964
1021
),
965
1022
sendButton: _SendButton (
966
1023
topicController: null ,
967
1024
contentController: _contentController,
968
1025
getDestination: () => widget.narrow.destination,
1026
+ enabled: enabled,
969
1027
));
970
1028
}
971
1029
}
0 commit comments