From 3d9000d2ae78a57ff2187988fc1a193cc4a55e7a Mon Sep 17 00:00:00 2001 From: Kelrap Date: Fri, 2 Aug 2024 12:12:34 -0400 Subject: [PATCH] Code cleanup --- lib/pages/chat/chat.dart | 6 ++-- lib/pangea/utils/overlay.dart | 33 +++++++++++--------- lib/pangea/widgets/chat/message_toolbar.dart | 2 +- lib/pangea/widgets/chat/overlay_header.dart | 5 +-- 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/lib/pages/chat/chat.dart b/lib/pages/chat/chat.dart index 632863df3..65dc88ad2 100644 --- a/lib/pages/chat/chat.dart +++ b/lib/pages/chat/chat.dart @@ -1132,7 +1132,9 @@ class ChatController extends State replyEvent = replyTo ?? selectedEvents.first; selectedEvents.clear(); }); + // #Pangea MatrixState.pAnyState.closeAllOverlays(); + // Pangea inputFocus.requestFocus(); } @@ -1248,10 +1250,8 @@ class ChatController extends State followerAnchor: Alignment.center, backgroundColor: const Color.fromRGBO(0, 0, 0, 1).withAlpha(100), closePrevOverlay: false, - targetScreen: true, onDismiss: hideEmojiPicker, - centered: false, - bottom: true, + position: OverlayEnum.bottom, ); // Pangea# } diff --git a/lib/pangea/utils/overlay.dart b/lib/pangea/utils/overlay.dart index b8bfbc935..3ac41f4ba 100644 --- a/lib/pangea/utils/overlay.dart +++ b/lib/pangea/utils/overlay.dart @@ -11,6 +11,13 @@ import '../../config/themes.dart'; import '../../widgets/matrix.dart'; import 'error_handler.dart'; +enum OverlayEnum { + transform, + centered, + topRight, + bottom, +} + class OverlayUtil { static showOverlay({ required BuildContext context, @@ -26,10 +33,8 @@ class OverlayUtil { Alignment? targetAnchor, Alignment? followerAnchor, bool closePrevOverlay = true, - bool targetScreen = false, Function? onDismiss, - bool centered = true, - bool bottom = false, + OverlayEnum position = OverlayEnum.transform, }) { try { if (closePrevOverlay) { @@ -48,24 +53,24 @@ class OverlayUtil { onDismiss: onDismiss, ), Positioned( - top: (targetScreen && !centered && !bottom) + top: (position == OverlayEnum.topRight) ? FluffyThemes.isColumnMode(context) ? 20 : 65 : null, - right: (targetScreen && !centered) - ? bottom + right: (position == OverlayEnum.topRight) + ? FluffyThemes.isColumnMode(context) + ? 20 + : 15 + : (position == OverlayEnum.bottom) ? 0 - : FluffyThemes.isColumnMode(context) - ? 20 - : 15 - : null, - left: bottom ? 0 : null, - bottom: bottom ? 0 : null, + : null, + left: (position == OverlayEnum.bottom) ? 0 : null, + bottom: (position == OverlayEnum.bottom) ? 0 : null, width: width, height: height, - child: targetScreen - ? centered + child: (position != OverlayEnum.transform) + ? (position == OverlayEnum.centered) ? Center(child: child) : child : CompositedTransformFollower( diff --git a/lib/pangea/widgets/chat/message_toolbar.dart b/lib/pangea/widgets/chat/message_toolbar.dart index c79d1ad5b..7323f361c 100644 --- a/lib/pangea/widgets/chat/message_toolbar.dart +++ b/lib/pangea/widgets/chat/message_toolbar.dart @@ -136,7 +136,7 @@ class ToolbarDisplayController { backgroundColor: const Color.fromRGBO(0, 0, 0, 1).withAlpha(200), closePrevOverlay: MatrixState.pangeaController.subscriptionController.isSubscribed, - targetScreen: true, + position: OverlayEnum.centered, onDismiss: controller.clearSelectedEvents, ); diff --git a/lib/pangea/widgets/chat/overlay_header.dart b/lib/pangea/widgets/chat/overlay_header.dart index 5b072b3ff..f6da14281 100644 --- a/lib/pangea/widgets/chat/overlay_header.dart +++ b/lib/pangea/widgets/chat/overlay_header.dart @@ -87,11 +87,8 @@ class OverlayHeader extends StatelessWidget { transformTargetId: "", targetAnchor: Alignment.center, followerAnchor: Alignment.center, - backgroundColor: Colors.transparent, closePrevOverlay: false, - targetScreen: true, - onDismiss: closeToolbar, - centered: false, + position: OverlayEnum.topRight, ); } }