From f6140c65353686d8bfa6b20687b1b0cd0e4016b5 Mon Sep 17 00:00:00 2001 From: Nico Vidoni <30844036+smallTrogdor@users.noreply.github.com> Date: Fri, 13 Dec 2024 15:28:15 +0100 Subject: [PATCH] feat: add bottom safe area of content for Modal Sheets' (#243) --- CHANGELOG.md | 1 + lib/src/modal/sbb_modal.dart | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d8155b..03ff5a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ It is expected that you keep this format strictly, since we depend on it in our ### Changed - Dropped support for `Flutter SDK 3.19.6`: minimum supported version is 3.22.3 +- `showSBBModalSheet` & `showCustomSBBModalSheet`: add bottom safe area of content if `useSafeArea` is true ### Deprecated - `SBBIconFormButton` diff --git a/lib/src/modal/sbb_modal.dart b/lib/src/modal/sbb_modal.dart index ddac6b0..b47c03d 100644 --- a/lib/src/modal/sbb_modal.dart +++ b/lib/src/modal/sbb_modal.dart @@ -108,10 +108,9 @@ Future showSBBModalSheet({ enableDrag: enableDrag, constraints: constraints, builder: (BuildContext context) { - return SBBModalSheet( - title: title, - child: child, - ); + return useSafeArea + ? _wrapWithBottomSafeArea(SBBModalSheet(title: title, child: child)) + : SBBModalSheet(title: title, child: child); }, barrierColor: SBBInternal.barrierColor, ); @@ -149,10 +148,9 @@ Future showCustomSBBModalSheet({ enableDrag: enableDrag, constraints: constraints, builder: (BuildContext context) { - return SBBModalSheet.custom( - header: header, - child: child, - ); + return useSafeArea + ? _wrapWithBottomSafeArea(SBBModalSheet.custom(header: header, child: child)) + : SBBModalSheet.custom(header: header, child: child); }, barrierColor: SBBInternal.barrierColor, ); @@ -306,3 +304,12 @@ class _CloseButton extends StatelessWidget { ), ); } + +Widget _wrapWithBottomSafeArea(Widget child) { + return SafeArea( + top: false, + left: false, + right: false, + child: child, + ); +}