From dea29161c8155bcc55a12295a6b6c531ab8902f8 Mon Sep 17 00:00:00 2001 From: krille-chan Date: Sun, 8 Dec 2024 17:39:57 +0100 Subject: [PATCH] chore: Better bottom sheets on desktop --- lib/utils/adaptive_bottom_sheet.dart | 49 ++++++++++++++--------- lib/widgets/public_room_bottom_sheet.dart | 8 ++-- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/lib/utils/adaptive_bottom_sheet.dart b/lib/utils/adaptive_bottom_sheet.dart index d21ca6c44..e5010102d 100644 --- a/lib/utils/adaptive_bottom_sheet.dart +++ b/lib/utils/adaptive_bottom_sheet.dart @@ -8,25 +8,34 @@ Future showAdaptiveBottomSheet({ required Widget Function(BuildContext) builder, bool isDismissible = true, bool isScrollControlled = true, - double maxHeight = 512, + double maxHeight = 600, bool useRootNavigator = true, -}) => - showModalBottomSheet( - context: context, - builder: builder, - // this sadly is ugly on desktops but otherwise breaks `.of(context)` calls - useRootNavigator: useRootNavigator, - isDismissible: isDismissible, - isScrollControlled: isScrollControlled, - constraints: BoxConstraints( - maxHeight: maxHeight, - maxWidth: FluffyThemes.columnWidth * 1.25, +}) { + final dialogMode = FluffyThemes.isColumnMode(context); + return showModalBottomSheet( + context: context, + builder: (context) => Padding( + padding: + dialogMode ? const EdgeInsets.only(bottom: 32.0) : EdgeInsets.zero, + child: ClipRRect( + borderRadius: dialogMode + ? BorderRadius.circular(AppConfig.borderRadius) + : const BorderRadius.only( + topLeft: Radius.circular(AppConfig.borderRadius), + topRight: Radius.circular(AppConfig.borderRadius), + ), + child: builder(context), ), - clipBehavior: Clip.hardEdge, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(AppConfig.borderRadius), - topRight: Radius.circular(AppConfig.borderRadius), - ), - ), - ); + ), + useRootNavigator: useRootNavigator, + isDismissible: isDismissible, + isScrollControlled: isScrollControlled, + constraints: BoxConstraints( + maxHeight: maxHeight + (dialogMode ? 32 : 0), + maxWidth: FluffyThemes.columnWidth * 1.25 + 64, + ), + backgroundColor: Colors.transparent, + showDragHandle: !dialogMode, + clipBehavior: Clip.hardEdge, + ); +} diff --git a/lib/widgets/public_room_bottom_sheet.dart b/lib/widgets/public_room_bottom_sheet.dart index 812f0055b..48dc0e94f 100644 --- a/lib/widgets/public_room_bottom_sheet.dart +++ b/lib/widgets/public_room_bottom_sheet.dart @@ -92,10 +92,10 @@ class PublicRoomBottomSheet extends StatelessWidget { chunk?.name ?? roomAlias ?? chunk?.roomId ?? 'Unknown', overflow: TextOverflow.fade, ), - leading: IconButton( - icon: const Icon(Icons.arrow_downward_outlined), - onPressed: Navigator.of(context, rootNavigator: false).pop, - tooltip: L10n.of(context).close, + leading: Center( + child: CloseButton( + onPressed: Navigator.of(context, rootNavigator: false).pop, + ), ), actions: [ Padding(