@@ -4,7 +4,6 @@ import 'dart:math';
4
4
import 'package:desktop_drop/desktop_drop.dart' ;
5
5
import 'package:flutter/material.dart' ;
6
6
import 'package:flutter/services.dart' ;
7
- import 'package:photo_manager/photo_manager.dart' ;
8
7
import 'package:stream_chat_flutter/platform_widget_builder/src/platform_widget_builder.dart' ;
9
8
import 'package:stream_chat_flutter/src/message_input/attachment_button.dart' ;
10
9
import 'package:stream_chat_flutter/src/message_input/command_button.dart' ;
@@ -125,8 +124,10 @@ class StreamMessageInput extends StatefulWidget {
125
124
this .hideSendAsDm = false ,
126
125
this .enableVoiceRecording = false ,
127
126
this .sendVoiceRecordingAutomatically = false ,
128
- this .idleSendButton,
129
- this .activeSendButton,
127
+ Widget ? idleSendIcon,
128
+ @Deprecated ("Use 'idleSendIcon' instead" ) Widget ? idleSendButton,
129
+ Widget ? activeSendIcon,
130
+ @Deprecated ("Use 'activeSendIcon' instead" ) Widget ? activeSendButton,
130
131
this .showCommandsButton = true ,
131
132
this .userMentionsTileBuilder,
132
133
this .maxAttachmentSize = kDefaultMaxAttachmentSize,
@@ -164,7 +165,17 @@ class StreamMessageInput extends StatefulWidget {
164
165
)
165
166
bool useNativeAttachmentPickerOnMobile = false ,
166
167
this .pollConfig,
167
- }) : useSystemAttachmentPicker = useSystemAttachmentPicker || //
168
+ }) : assert (
169
+ idleSendIcon == null || idleSendButton == null ,
170
+ 'idleSendIcon and idleSendButton cannot be used together' ,
171
+ ),
172
+ idleSendIcon = idleSendIcon ?? idleSendButton,
173
+ assert (
174
+ activeSendIcon == null || activeSendButton == null ,
175
+ 'activeSendIcon and activeSendButton cannot be used together' ,
176
+ ),
177
+ activeSendIcon = activeSendIcon ?? activeSendButton,
178
+ useSystemAttachmentPicker = useSystemAttachmentPicker || //
168
179
useNativeAttachmentPickerOnMobile;
169
180
170
181
/// The predicate used to send a message on desktop/web
@@ -292,10 +303,18 @@ class StreamMessageInput extends StatefulWidget {
292
303
final bool autofocus;
293
304
294
305
/// Send button widget in an idle state
295
- final Widget ? idleSendButton;
306
+ final Widget ? idleSendIcon;
307
+
308
+ /// Send button widget in an idle state
309
+ @Deprecated ("Use 'idleSendIcon' instead" )
310
+ Widget ? get idleSendButton => idleSendIcon;
296
311
297
312
/// Send button widget in an active state
298
- final Widget ? activeSendButton;
313
+ final Widget ? activeSendIcon;
314
+
315
+ /// Send button widget in an active state
316
+ @Deprecated ("Use 'activeSendIcon' instead" )
317
+ Widget ? get activeSendButton => activeSendIcon;
299
318
300
319
/// Customize the tile for the mentions overlay.
301
320
final UserMentionTileBuilder ? userMentionsTileBuilder;
@@ -470,7 +489,7 @@ class StreamMessageInput extends StatefulWidget {
470
489
471
490
/// State of [StreamMessageInput]
472
491
class StreamMessageInputState extends State <StreamMessageInput >
473
- with RestorationMixin <StreamMessageInput >, WidgetsBindingObserver {
492
+ with RestorationMixin <StreamMessageInput > {
474
493
bool get _commandEnabled => _effectiveController.message.command != null ;
475
494
476
495
bool _actionsShrunk = false ;
@@ -514,7 +533,6 @@ class StreamMessageInputState extends State<StreamMessageInput>
514
533
@override
515
534
void initState () {
516
535
super .initState ();
517
- WidgetsBinding .instance.addObserver (this );
518
536
if (widget.messageInputController == null ) {
519
537
_createLocalController ();
520
538
} else {
@@ -544,29 +562,6 @@ class StreamMessageInputState extends State<StreamMessageInput>
544
562
super .didChangeDependencies ();
545
563
}
546
564
547
- bool _askingForPermission = false ;
548
-
549
- @override
550
- void didChangeAppLifecycleState (AppLifecycleState state) async {
551
- if (state == AppLifecycleState .resumed &&
552
- _permissionState != null &&
553
- ! _askingForPermission) {
554
- _askingForPermission = true ;
555
-
556
- try {
557
- final newPermissionState = await PhotoManager .requestPermissionExtend ();
558
- if (newPermissionState != _permissionState && mounted) {
559
- setState (() {
560
- _permissionState = newPermissionState;
561
- });
562
- }
563
- } catch (_) {}
564
-
565
- _askingForPermission = false ;
566
- }
567
- super .didChangeAppLifecycleState (state);
568
- }
569
-
570
565
@override
571
566
void didUpdateWidget (covariant StreamMessageInput oldWidget) {
572
567
super .didUpdateWidget (oldWidget);
@@ -601,8 +596,6 @@ class StreamMessageInputState extends State<StreamMessageInput>
601
596
// ignore: no-empty-block
602
597
void _focusNodeListener () {}
603
598
604
- PermissionState ? _permissionState;
605
-
606
599
@override
607
600
Widget build (BuildContext context) {
608
601
final channel = StreamChannel .of (context).channel;
@@ -840,16 +833,16 @@ class StreamMessageInputState extends State<StreamMessageInput>
840
833
}
841
834
842
835
Widget _buildSendButton (BuildContext context) {
843
- if (widget.sendButtonBuilder != null ) {
844
- return widget. sendButtonBuilder ! (context, _effectiveController);
836
+ if (widget.sendButtonBuilder case final builder ? ) {
837
+ return builder (context, _effectiveController);
845
838
}
846
839
847
840
return StreamMessageSendButton (
848
841
onSendMessage: sendMessage,
849
842
timeOut: _effectiveController.cooldownTimeOut,
850
843
isIdle: ! widget.validator (_effectiveController.message),
851
- idleSendButton : widget.idleSendButton ,
852
- activeSendButton : widget.activeSendButton ,
844
+ idleSendIcon : widget.idleSendIcon ,
845
+ activeSendIcon : widget.activeSendIcon ,
853
846
);
854
847
}
855
848
@@ -1580,7 +1573,6 @@ class StreamMessageInputState extends State<StreamMessageInput>
1580
1573
_focusNode? .dispose ();
1581
1574
_onChangedDebounced.cancel ();
1582
1575
_audioRecorderController.dispose ();
1583
- WidgetsBinding .instance.removeObserver (this );
1584
1576
super .dispose ();
1585
1577
}
1586
1578
}
0 commit comments