chore: Nicer scaffold dialog for column mode
Signed-off-by: Krille <c.kussowski@famedly.com>
This commit is contained in:
parent
955ceec288
commit
64ba93d8ea
2 changed files with 34 additions and 16 deletions
|
|
@ -21,6 +21,7 @@ extension EventInfoDialogExtension on Event {
|
||||||
class EventInfoDialog extends StatelessWidget {
|
class EventInfoDialog extends StatelessWidget {
|
||||||
final Event event;
|
final Event event;
|
||||||
final L10n l10n;
|
final L10n l10n;
|
||||||
|
|
||||||
const EventInfoDialog({
|
const EventInfoDialog({
|
||||||
required this.event,
|
required this.event,
|
||||||
required this.l10n,
|
required this.l10n,
|
||||||
|
|
@ -41,10 +42,8 @@ class EventInfoDialog extends StatelessWidget {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(L10n.of(context).messageInfo),
|
title: Text(L10n.of(context).messageInfo),
|
||||||
leading: IconButton(
|
leading: CloseButton(
|
||||||
icon: const Icon(Icons.arrow_downward_outlined),
|
|
||||||
onPressed: Navigator.of(context, rootNavigator: false).pop,
|
onPressed: Navigator.of(context, rootNavigator: false).pop,
|
||||||
tooltip: L10n.of(context).close,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: ListView(
|
body: ListView(
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,40 @@ Future<T?> showAdaptiveBottomSheet<T>({
|
||||||
bool isScrollControlled = true,
|
bool isScrollControlled = true,
|
||||||
bool useRootNavigator = true,
|
bool useRootNavigator = true,
|
||||||
}) {
|
}) {
|
||||||
final maxHeight = min(MediaQuery.of(context).size.height - 32, 600);
|
if (FluffyThemes.isColumnMode(context)) {
|
||||||
final dialogMode = FluffyThemes.isColumnMode(context);
|
return showDialog<T>(
|
||||||
return showModalBottomSheet(
|
context: context,
|
||||||
|
useRootNavigator: useRootNavigator,
|
||||||
|
barrierDismissible: isDismissible,
|
||||||
|
useSafeArea: true,
|
||||||
|
builder: (context) => Container(
|
||||||
|
margin: const EdgeInsets.all(16),
|
||||||
|
constraints: const BoxConstraints(
|
||||||
|
maxWidth: 480,
|
||||||
|
maxHeight: 720,
|
||||||
|
),
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: Material(
|
||||||
|
elevation: Theme.of(context).dialogTheme.elevation ?? 4,
|
||||||
|
shadowColor: Theme.of(context).dialogTheme.shadowColor,
|
||||||
|
borderRadius: BorderRadius.circular(AppConfig.borderRadius),
|
||||||
|
color: Theme.of(context).scaffoldBackgroundColor,
|
||||||
|
clipBehavior: Clip.hardEdge,
|
||||||
|
child: builder(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return showModalBottomSheet<T>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => Padding(
|
builder: (context) => Padding(
|
||||||
padding: dialogMode
|
padding: EdgeInsets.zero,
|
||||||
? const EdgeInsets.symmetric(vertical: 32.0)
|
|
||||||
: EdgeInsets.zero,
|
|
||||||
child: ClipRRect(
|
child: ClipRRect(
|
||||||
borderRadius: dialogMode
|
borderRadius: const BorderRadius.only(
|
||||||
? BorderRadius.circular(AppConfig.borderRadius)
|
topLeft: Radius.circular(AppConfig.borderRadius / 2),
|
||||||
: const BorderRadius.only(
|
topRight: Radius.circular(AppConfig.borderRadius / 2),
|
||||||
topLeft: Radius.circular(AppConfig.borderRadius),
|
),
|
||||||
topRight: Radius.circular(AppConfig.borderRadius),
|
|
||||||
),
|
|
||||||
child: builder(context),
|
child: builder(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
@ -34,7 +53,7 @@ Future<T?> showAdaptiveBottomSheet<T>({
|
||||||
isDismissible: isDismissible,
|
isDismissible: isDismissible,
|
||||||
isScrollControlled: isScrollControlled,
|
isScrollControlled: isScrollControlled,
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxHeight: maxHeight + (dialogMode ? 64 : 0),
|
maxHeight: min(MediaQuery.of(context).size.height - 32, 600),
|
||||||
maxWidth: FluffyThemes.columnWidth * 1.25,
|
maxWidth: FluffyThemes.columnWidth * 1.25,
|
||||||
),
|
),
|
||||||
backgroundColor: Colors.transparent,
|
backgroundColor: Colors.transparent,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue