From 42574583edf76709ba4bbd65ade95b87bd8d314d Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Tue, 2 Apr 2024 14:32:37 +0200 Subject: [PATCH 1/4] added unfocus when tapping on background image --- lib/view/pages/talk/chatView.dart | 57 +++++++++++++++++-------------- 1 file changed, 31 insertions(+), 26 deletions(-) diff --git a/lib/view/pages/talk/chatView.dart b/lib/view/pages/talk/chatView.dart index 4931187..e57aa36 100644 --- a/lib/view/pages/talk/chatView.dart +++ b/lib/view/pages/talk/chatView.dart @@ -108,33 +108,38 @@ class _ChatViewState extends State { ), ), ), - 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(), + 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(), + ), ), - ), - 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) + ), + ) + ], + ), ), ), ); From 339d402422cc906d4fe5c0b4404ccd7c7616f944 Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Tue, 2 Apr 2024 14:41:36 +0200 Subject: [PATCH 2/4] 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), From 21411e1517598c55c2ef966c24e3fc45179ee8e3 Mon Sep 17 00:00:00 2001 From: Pupsi28 Date: Tue, 2 Apr 2024 15:03:37 +0200 Subject: [PATCH 3/4] added unfocus at textfields for custon events and feedback --- lib/view/pages/more/feedback/feedbackDialog.dart | 3 +++ .../pages/timetable/customTimetableEventEditDialog.dart | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/view/pages/more/feedback/feedbackDialog.dart b/lib/view/pages/more/feedback/feedbackDialog.dart index 3f63e26..fb3a478 100644 --- a/lib/view/pages/more/feedback/feedbackDialog.dart +++ b/lib/view/pages/more/feedback/feedbackDialog.dart @@ -68,6 +68,9 @@ class _FeedbackDialogState extends State { ), minLines: 4, maxLines: 7, + onTapOutside: (PointerDownEvent event) { + FocusScope.of(context).requestFocus(FocusNode()); + }, ), ), const SizedBox(height: 10), diff --git a/lib/view/pages/timetable/customTimetableEventEditDialog.dart b/lib/view/pages/timetable/customTimetableEventEditDialog.dart index 02844f3..7808e66 100644 --- a/lib/view/pages/timetable/customTimetableEventEditDialog.dart +++ b/lib/view/pages/timetable/customTimetableEventEditDialog.dart @@ -67,6 +67,9 @@ class _AddCustomTimetableEventDialogState extends State Date: Tue, 2 Apr 2024 16:45:43 +0200 Subject: [PATCH 4/4] resolved pr comments --- .../pages/more/feedback/feedbackDialog.dart | 5 ++-- lib/view/pages/talk/chatView.dart | 14 +++++------ .../pages/talk/components/chatTextfield.dart | 5 ++-- .../customTimetableEventEditDialog.dart | 9 +++----- lib/widget/focusBehaviour.dart | 7 ++++++ lib/widget/quickMenu.dart | 23 ------------------- 6 files changed, 21 insertions(+), 42 deletions(-) create mode 100644 lib/widget/focusBehaviour.dart delete mode 100644 lib/widget/quickMenu.dart diff --git a/lib/view/pages/more/feedback/feedbackDialog.dart b/lib/view/pages/more/feedback/feedbackDialog.dart index fb3a478..2e0a3e7 100644 --- a/lib/view/pages/more/feedback/feedbackDialog.dart +++ b/lib/view/pages/more/feedback/feedbackDialog.dart @@ -14,6 +14,7 @@ import '../../../../api/mhsl/server/feedback/addFeedbackParams.dart'; import '../../../../model/accountData.dart'; import '../../../../storage/base/settingsProvider.dart'; import '../../../../widget/filePick.dart'; +import '../../../../widget/focusBehaviour.dart'; import '../../../../widget/infoDialog.dart'; class FeedbackDialog extends StatefulWidget { @@ -68,9 +69,7 @@ class _FeedbackDialogState extends State { ), minLines: 4, maxLines: 7, - onTapOutside: (PointerDownEvent event) { - FocusScope.of(context).requestFocus(FocusNode()); - }, + onTapOutside: (PointerDownEvent event) => FocusBehaviour.textFieldTapOutside(context), ), ), const SizedBox(height: 10), diff --git a/lib/view/pages/talk/chatView.dart b/lib/view/pages/talk/chatView.dart index 1797b3a..92fe293 100644 --- a/lib/view/pages/talk/chatView.dart +++ b/lib/view/pages/talk/chatView.dart @@ -110,13 +110,13 @@ class _ChatViewState extends State { ), 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) - ) + 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: [ diff --git a/lib/view/pages/talk/components/chatTextfield.dart b/lib/view/pages/talk/components/chatTextfield.dart index 885a9b1..5513d8a 100644 --- a/lib/view/pages/talk/components/chatTextfield.dart +++ b/lib/view/pages/talk/components/chatTextfield.dart @@ -14,6 +14,7 @@ import '../../../../api/marianumcloud/webdav/webdavApi.dart'; import '../../../../model/chatList/chatProps.dart'; import '../../../../storage/base/settingsProvider.dart'; import '../../../../widget/filePick.dart'; +import '../../../../widget/focusBehaviour.dart'; import '../../files/fileUploadDialog.dart'; class ChatTextfield extends StatefulWidget { @@ -156,9 +157,7 @@ class _ChatTextfieldState extends State { } setDraft(text); }, - onTapOutside: (PointerDownEvent event) { - FocusScope.of(context).requestFocus(FocusNode()); - }, + onTapOutside: (PointerDownEvent event) => FocusBehaviour.textFieldTapOutside(context), ), ), const SizedBox(width: 15), diff --git a/lib/view/pages/timetable/customTimetableEventEditDialog.dart b/lib/view/pages/timetable/customTimetableEventEditDialog.dart index 7808e66..f08aafd 100644 --- a/lib/view/pages/timetable/customTimetableEventEditDialog.dart +++ b/lib/view/pages/timetable/customTimetableEventEditDialog.dart @@ -15,6 +15,7 @@ import '../../../api/mhsl/customTimetableEvent/update/updateCustomTimetableEvent import '../../../api/mhsl/customTimetableEvent/update/updateCustomTimetableEventParams.dart'; import '../../../model/accountData.dart'; import '../../../model/timetable/timetableProps.dart'; +import '../../../widget/focusBehaviour.dart'; import '../../../widget/infoDialog.dart'; import 'customTimetableColors.dart'; @@ -67,9 +68,7 @@ class _AddCustomTimetableEventDialogState extends State FocusBehaviour.textFieldTapOutside(context), ), ), ListTile( @@ -81,9 +80,7 @@ class _AddCustomTimetableEventDialogState extends State FocusBehaviour.textFieldTapOutside(context), ), ), const Divider(), diff --git a/lib/widget/focusBehaviour.dart b/lib/widget/focusBehaviour.dart new file mode 100644 index 0000000..fe5a52b --- /dev/null +++ b/lib/widget/focusBehaviour.dart @@ -0,0 +1,7 @@ +import 'package:flutter/cupertino.dart'; + +class FocusBehaviour { + static void textFieldTapOutside(BuildContext context) { + FocusScope.of(context).requestFocus(FocusNode()); + } +} \ No newline at end of file diff --git a/lib/widget/quickMenu.dart b/lib/widget/quickMenu.dart deleted file mode 100644 index 0c39968..0000000 --- a/lib/widget/quickMenu.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:flutter/material.dart'; - -class QuickMenu { - static void quickMenu(BuildContext context, BuildContext widgetContext, List> items) { - final RenderBox overlay = Overlay.of(context).context.findRenderObject() as RenderBox; - - final RenderBox widgetRenderBox = widgetContext.findRenderObject() as RenderBox; - final Offset position = widgetRenderBox.localToGlobal(Offset.zero); - - showMenu( - context: context, - position: RelativeRect.fromRect( - Rect.fromPoints( - position, - position.translate(0, 0), - ), - Offset.zero & overlay.size, - ), - items: items, - ); - } - -} \ No newline at end of file