Skip to content

Commit

Permalink
feat: allow safe area configuration for bottom sheets (#2)
Browse files Browse the repository at this point in the history
Allows the `ignoreSafeArea` param for the showBottomSheet funciton.
This setting defaults to "true", such that any `SafeArea` widget
is ignored in a bottom sheet (barring the bottom padding value).
When set to "false", a safe area widget is respected and the
bottomsheet padded accordingly. This is most likely used
with "fullscreen" bottom sheets.
  • Loading branch information
buehler authored Feb 21, 2024
1 parent a0e14d8 commit ebd2cce
Show file tree
Hide file tree
Showing 11 changed files with 150 additions and 39 deletions.
33 changes: 0 additions & 33 deletions .github/test__.__yml

This file was deleted.

4 changes: 4 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- main

concurrency:
group: release
cancel-in-progress: true

jobs:
package_and_publish:
name: Package and Publish
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test Packages

on:
pull_request:
branches:
- '**'
workflow_dispatch:

concurrency:
group: tests-${{ github.ref }}
cancel-in-progress: true

jobs:
lint:
name: Lint and Analyze
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- run: dart pub global activate melos
- run: melos bootstrap
- run: melos run build_runner
- run: melos run lint

test:
name: Test Package "${{ matrix.package }}"
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include:
- package: fluorflow
executor: flutter
- package: fluorflow_generator
executor: dart
steps:
- uses: actions/checkout@v4
- uses: subosito/flutter-action@v2
with:
channel: stable
- run: dart pub global activate melos
- run: melos bootstrap
- run: melos run build_runner
- run: ${{ matrix.executor }} pub get
working-directory: packages/${{ matrix.package }}
- run: ${{ matrix.executor }} test
working-directory: packages/${{ matrix.package }}

test_result:
if: ${{ always() }}
runs-on: ubuntu-latest
name: Test Results
needs:
- test
steps:
- name: Check test matrix status
if: ${{ needs.test.result != 'success' }}
run: exit 1
4 changes: 4 additions & 0 deletions packages/fluorflow/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ linter:
prefer_relative_imports: true
prefer_single_quotes: true
prefer_expression_function_bodies: true

analyzer:
exclude:
- example/
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down Expand Up @@ -344,7 +344,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -471,7 +471,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -520,7 +520,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1430"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ class BottomSheetConfig {
/// If set to false, the bottom sheet will be displayed at the bottom third(-ish) of the screen.
final bool defaultFullscreen;

/// Whether the bottom sheet should ignore the safe area and take up the entire screen.
/// This is most likely used in combination with [defaultFullscreen].
final bool defaultIgnoreSafeArea;

/// Whether the bottom sheet can be dragged by the user.
final bool defaultDraggable;

/// Decorate a bottom sheet or simple bottomsheet with a [BottomSheetConfig].
const BottomSheetConfig({
this.defaultBarrierColor = 0x80000000,
this.defaultFullscreen = false,
this.defaultIgnoreSafeArea = true,
this.defaultDraggable = true,
});
}
11 changes: 11 additions & 0 deletions packages/fluorflow/lib/src/bottom_sheets/bottom_sheet_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,28 @@ class BottomSheetService {
/// Shows a bottom sheet and returns a future with the result.
/// Use the convenience methods generated by the generator to show a bottom sheet
/// and return the result in an easy way.
///
/// - [sheet] marks the sheet that is opened.
/// - [barrierColor] configures the color that is used behind the bottom sheet
/// if a portion of the screen is still visible.
/// - [fullscreen] configures whether the bottom sheet should take up the entire screen. If true, the [barrierColor]
/// is still applied, but may not be visible.
/// - [draggable] defines if the bottom sheet can be closed by dragging it down towards the bottom.
/// - [ignoreSafeArea] allows the bottom sheet to ignore [SafeArea] widgets and always uses the whole
/// screen if possible. This is most likely used in combination with [fullscreen].
Future<TResult?> showBottomSheet<TResult, TSheet extends FluorFlowOverlay>(
TSheet sheet, {
Color barrierColor = const Color(0x80000000),
bool fullscreen = false,
bool draggable = true,
bool ignoreSafeArea = true,
}) =>
Get.bottomSheet(
sheet,
barrierColor: barrierColor,
isScrollControlled: fullscreen,
enableDrag: draggable,
ignoreSafeArea: ignoreSafeArea,
);

/// Closes the currently open bottom sheet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ class BottomSheetBuilder implements Builder {
configAnnotation?.read('defaultFullscreen').boolValue ??
false)
.code))
..optionalParameters.add(Parameter((b) => b
..name = 'ignoreSafeArea'
..type = refer('bool')
..named = true
..defaultTo = literalBool(
configAnnotation?.read('defaultIgnoreSafeArea').boolValue ??
true)
.code))
..optionalParameters.add(Parameter((b) => b
..name = 'draggable'
..type = refer('bool')
Expand Down Expand Up @@ -121,6 +129,7 @@ class BottomSheetBuilder implements Builder {
'barrierColor': refer('barrierColor'),
'fullscreen': refer('fullscreen'),
'draggable': refer('draggable'),
'ignoreSafeArea': refer('ignoreSafeArea'),
}, [
methodTupleRef,
refer(sheetClass.displayName, assetId.uri.toString()),
Expand Down
Loading

0 comments on commit ebd2cce

Please sign in to comment.