chore: Better bottom sheets on desktop

This commit is contained in:
krille-chan 2024-12-08 17:39:57 +01:00
commit dea29161c8
No known key found for this signature in database
2 changed files with 33 additions and 24 deletions

View file

@ -8,25 +8,34 @@ Future<T?> showAdaptiveBottomSheet<T>({
required Widget Function(BuildContext) builder, required Widget Function(BuildContext) builder,
bool isDismissible = true, bool isDismissible = true,
bool isScrollControlled = true, bool isScrollControlled = true,
double maxHeight = 512, double maxHeight = 600,
bool useRootNavigator = true, bool useRootNavigator = true,
}) => }) {
showModalBottomSheet( final dialogMode = FluffyThemes.isColumnMode(context);
return showModalBottomSheet(
context: context, context: context,
builder: builder, builder: (context) => Padding(
// this sadly is ugly on desktops but otherwise breaks `.of(context)` calls 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),
),
),
useRootNavigator: useRootNavigator, useRootNavigator: useRootNavigator,
isDismissible: isDismissible, isDismissible: isDismissible,
isScrollControlled: isScrollControlled, isScrollControlled: isScrollControlled,
constraints: BoxConstraints( constraints: BoxConstraints(
maxHeight: maxHeight, maxHeight: maxHeight + (dialogMode ? 32 : 0),
maxWidth: FluffyThemes.columnWidth * 1.25, maxWidth: FluffyThemes.columnWidth * 1.25 + 64,
), ),
backgroundColor: Colors.transparent,
showDragHandle: !dialogMode,
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(AppConfig.borderRadius),
topRight: Radius.circular(AppConfig.borderRadius),
),
),
); );
}

View file

@ -92,10 +92,10 @@ class PublicRoomBottomSheet extends StatelessWidget {
chunk?.name ?? roomAlias ?? chunk?.roomId ?? 'Unknown', chunk?.name ?? roomAlias ?? chunk?.roomId ?? 'Unknown',
overflow: TextOverflow.fade, overflow: TextOverflow.fade,
), ),
leading: IconButton( leading: Center(
icon: const Icon(Icons.arrow_downward_outlined), child: CloseButton(
onPressed: Navigator.of(context, rootNavigator: false).pop, onPressed: Navigator.of(context, rootNavigator: false).pop,
tooltip: L10n.of(context).close, ),
), ),
actions: [ actions: [
Padding( Padding(