@@ -768,9 +768,6 @@ class _PrivateChatRoomState extends ConsumerState<_PrivateChatRoom> {
768768 final currentUserId = api? .currentUserId;
769769 final timeline = _buildTimeline ();
770770 final typingLabel = _typingLabel ();
771- final canSend = ! _isSending &&
772- (_messageController.text.trim ().isNotEmpty ||
773- _selectedAttachment != null );
774771
775772 return SafeArea (
776773 child: Column (
@@ -857,56 +854,84 @@ class _PrivateChatRoomState extends ConsumerState<_PrivateChatRoom> {
857854 ),
858855 Padding (
859856 padding: const EdgeInsets .fromLTRB (12 , 8 , 12 , 12 ),
860- child: Row (
861- crossAxisAlignment: CrossAxisAlignment .end,
862- children: < Widget > [
863- Column (
864- mainAxisSize: MainAxisSize .min,
857+ child: ValueListenableBuilder <TextEditingValue >(
858+ valueListenable: _messageController,
859+ builder: (
860+ BuildContext context,
861+ TextEditingValue value,
862+ Widget ? child,
863+ ) {
864+ final canSend = ! _isSending &&
865+ (value.text.trim ().isNotEmpty ||
866+ _selectedAttachment != null );
867+
868+ return Row (
869+ crossAxisAlignment: CrossAxisAlignment .end,
865870 children: < Widget > [
866- IconButton (
867- tooltip: 'Send photo' ,
868- onPressed: _isSending
869- ? null
870- : () => _pickAttachment (PrivateChatMessageType .image),
871- icon: const Icon (Icons .photo_outlined),
871+ Column (
872+ mainAxisSize: MainAxisSize .min,
873+ children: < Widget > [
874+ IconButton (
875+ tooltip: 'Send photo' ,
876+ onPressed: _isSending
877+ ? null
878+ : () => _pickAttachment (
879+ PrivateChatMessageType .image,
880+ ),
881+ icon: const Icon (Icons .photo_outlined),
882+ ),
883+ const SizedBox (height: 2 ),
884+ IconButton (
885+ tooltip: 'Send video' ,
886+ onPressed: _isSending
887+ ? null
888+ : () => _pickAttachment (
889+ PrivateChatMessageType .video,
890+ ),
891+ icon: const Icon (Icons .videocam_outlined),
892+ ),
893+ ],
872894 ),
873- const SizedBox (height: 2 ),
874- IconButton (
875- tooltip: 'Send video' ,
876- onPressed: _isSending
877- ? null
878- : () => _pickAttachment (PrivateChatMessageType .video),
879- icon: const Icon (Icons .videocam_outlined),
895+ const SizedBox (width: 8 ),
896+ Expanded (
897+ child: TextField (
898+ controller: _messageController,
899+ maxLines: 4 ,
900+ minLines: 1 ,
901+ maxLength: 2000 ,
902+ enabled: ! _isSending,
903+ decoration: const InputDecoration (
904+ hintText: 'Write a message...' ,
905+ counterText: '' ,
906+ ),
907+ textInputAction: TextInputAction .send,
908+ onSubmitted: (_) {
909+ if (canSend) {
910+ _sendMessage ();
911+ }
912+ },
913+ ),
880914 ),
881- ],
882- ),
883- const SizedBox (width: 8 ),
884- Expanded (
885- child: TextField (
886- controller: _messageController,
887- maxLines: 4 ,
888- minLines: 1 ,
889- maxLength: 2000 ,
890- decoration: const InputDecoration (
891- hintText: 'Write a message...' ,
892- counterText: '' ,
915+ const SizedBox (width: 8 ),
916+ AnimatedScale (
917+ duration: const Duration (milliseconds: 160 ),
918+ scale: canSend ? 1 : 0.94 ,
919+ child: IconButton .filled (
920+ onPressed: canSend ? _sendMessage : null ,
921+ icon: _isSending
922+ ? const SizedBox (
923+ width: 18 ,
924+ height: 18 ,
925+ child: CircularProgressIndicator (
926+ strokeWidth: 2 ,
927+ ),
928+ )
929+ : const Icon (Icons .send_rounded),
930+ ),
893931 ),
894- textInputAction: TextInputAction .send,
895- onSubmitted: (_) => _sendMessage (),
896- ),
897- ),
898- const SizedBox (width: 8 ),
899- IconButton .filled (
900- onPressed: canSend ? _sendMessage : null ,
901- icon: _isSending
902- ? const SizedBox (
903- width: 18 ,
904- height: 18 ,
905- child: CircularProgressIndicator (strokeWidth: 2 ),
906- )
907- : const Icon (Icons .send_rounded),
908- ),
909- ],
932+ ],
933+ );
934+ },
910935 ),
911936 ),
912937 ],
0 commit comments