From 339d402422cc906d4fe5c0b4404ccd7c7616f944 Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Tue, 2 Apr 2024 14:41:36 +0200 Subject: [PATCH] added unfocus when tapping outside textfield --- lib/view/pages/talk/chatView.dart | 57 +++++++++---------- .../pages/talk/components/chatTextfield.dart | 3 + 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/lib/view/pages/talk/chatView.dart b/lib/view/pages/talk/chatView.dart index e57aa36..1797b3a 100644 --- a/lib/view/pages/talk/chatView.dart +++ b/lib/view/pages/talk/chatView.dart @@ -108,38 +108,33 @@ class _ChatViewState extends State { ), ), ), - body: GestureDetector( - onTap: () { - FocusScope.of(context).requestFocus(FocusNode()); - }, - child: Container( - decoration: BoxDecoration( - image: DecorationImage( - image: const AssetImage('assets/background/chat.png'), - scale: 1.5, - opacity: 1, - repeat: ImageRepeat.repeat, - invertColors: AppTheme.isDarkMode(context) - ) - ), - child: data.primaryLoading() ? const LoadingSpinner() : Column( - children: [ - Expanded( - child: ListView( - reverse: true, - controller: _listController, - children: messages.reversed.toList(), - ), + body: Container( + decoration: BoxDecoration( + image: DecorationImage( + image: const AssetImage('assets/background/chat.png'), + scale: 1.5, + opacity: 1, + repeat: ImageRepeat.repeat, + invertColors: AppTheme.isDarkMode(context) + ) + ), + child: data.primaryLoading() ? const LoadingSpinner() : Column( + children: [ + Expanded( + child: ListView( + reverse: true, + controller: _listController, + children: messages.reversed.toList(), ), - Container( - color: Theme.of(context).colorScheme.background, - child: TalkNavigator.isSecondaryVisible(context) - ? ChatTextfield(widget.room.token) - : SafeArea(child: ChatTextfield(widget.room.token) - ), - ) - ], - ), + ), + Container( + color: Theme.of(context).colorScheme.background, + child: TalkNavigator.isSecondaryVisible(context) + ? ChatTextfield(widget.room.token) + : SafeArea(child: ChatTextfield(widget.room.token) + ), + ) + ], ), ), ); diff --git a/lib/view/pages/talk/components/chatTextfield.dart b/lib/view/pages/talk/components/chatTextfield.dart index 1ec6b68..885a9b1 100644 --- a/lib/view/pages/talk/components/chatTextfield.dart +++ b/lib/view/pages/talk/components/chatTextfield.dart @@ -156,6 +156,9 @@ class _ChatTextfieldState extends State { } setDraft(text); }, + onTapOutside: (PointerDownEvent event) { + FocusScope.of(context).requestFocus(FocusNode()); + }, ), ), const SizedBox(width: 15),