FLUTTER ECOSYSTEM

FlutterWay/bottom_sheet_scaffold

스캐폴드 본문을 드래그하여 하단 시트를 슬라이드하세요! 매우 간단하고 사용자 정의 가능한 하단 시트입니다.

bottom_sheet_scaffold 프로젝트 이미지
Stars
3
Forks
4
최근 푸시(UTC)
2023. 7. 16.
프로젝트 상태
활성
FlutterWay GitHub avatar
GITHUB Organization

FlutterWay ↗

언어DartSwiftKotlinObjective-C

이 저장소가 배포한 패키지

사용 중인 의존성

의존성 목록 4 개
  • flutter{"sdk":"flutter"}
  • get^4.6.5
  • flutter_test개발 의존성{"sdk":"flutter"}
  • flutter_lints개발 의존성^2.0.0

원본 README

아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.

README 펼치기 / 접기

bottom_sheet_scaffold

Slide your bottom sheet by sliding the body of the scaffold!. Very simple and customizable bottom sheet implementation.

https://raw.githubusercontent.com/FlutterWay/files/main/bottom_sheet_views/bottomSheetPoster.png

Features

  • Easy usage
  • Determine the height of the bottom sheet by sliding the body of the scaffold
  • Draggable bottom sheet body
  • Animated Opacity
  • Fully customizable
  • Listen the status of bottom sheet by using BottomSheetBuilder
  • No need to set any header to slide bottom sheet

Scaffold Swipping

https://raw.githubusercontent.com/FlutterWay/files/main/bottom_sheet_views/bottom_sheet_swipping_with_scaffold_body.gif

Header Swipping

https://raw.githubusercontent.com/FlutterWay/files/main/bottom_sheet_views/bottom_sheet_swipping_with_header.gif

Gradient Opacity

https://raw.githubusercontent.com/FlutterWay/files/main/bottom_sheet_views/bottom_sheet_gradient_opacity.gif

Fixed height

https://raw.githubusercontent.com/FlutterWay/files/main/bottom_sheet_views/bottom_sheet_auto_swipping_closed.gif

Custom

https://raw.githubusercontent.com/FlutterWay/files/main/bottom_sheet_views/bottom_sheet_custom.gif

Usage

Change your Scaffold into BottomSheetScaffold.

BottomSheetScaffold(
      draggableBody: true,
      dismissOnClick: true,
      barrierColor: Colors.black54,
      bottomSheet: DraggableBottomSheet(
        animationDuration: Duration(milliseconds: 200),
        body: BottomSheetBody(),
        header: BottomSheetHeader(),//header is not required
      ),
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ScaffoldBody(),
    )
You can customize OnWillPop of BottomSheet
BottomSheetScaffold(
      draggableBody: true,
      dismissOnClick: true,
      onWillPop: (() async {
        if (BottomSheetPanel.isOpen) {
          BottomSheetPanel.close();
          return false;
        } else {
          return true;
        }
      }),
      barrierColor: Colors.black54,
      bottomSheet: DraggableBottomSheet(
        animationDuration: Duration(milliseconds: 200),
        body: BottomSheetBody(),
        header: BottomSheetHeader(),//header is not required
      ),
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: ScaffoldBody(),
    )

Barrier not being displayed in scaffold to be used inside

If you use Scaffold inside BottomSheetScaffold, you should wrap the body of the Scaffold with BarrierViewer. This way you can display the barrier color you defined when the bottom sheet is opened

return BottomSheetScaffold(
      bottomSheet: DraggableBottomSheet(
        animationDuration: const Duration(milliseconds: 200),
        body: Container(
            width: double.infinity,
            height: 500,
            alignment: Alignment.center,
            child: const Text(
              "Bottom Sheet",
              style: TextStyle(fontSize: 36, color: Colors.black),
            )),
        header: Container(
          height: 60,
          color: Colors.blue,
          child: const Center(
              child: Text(
            "Drag me",
            style: TextStyle(color: Colors.white),
          )),
        ),
      ),
      appBar: AppBar(
        title: const Text(
          "My AppBar",
        ),
      ),
      body: Scaffold(
        body: BarrierViewer(
          child: Center(
            child: Column(

DraggableBottomSheet

DraggableBottomSheet(
    {super.key,
    this.maxHeight = 500,
    this.minHeight = 0,
    this.header,
    this.animationDuration = const Duration(milliseconds: 200),
    this.autoSwipped = true,
    this.draggableBody = true,
    this.gradientOpacity = true,
    this.headerVisibilityOnTap = true,
    this.backgroundColor = Colors.white60,
    this.onHide,
    this.radius = 30,
    this.onShow,
    required this.body})

BottomSheetPanel

Open bottom sheet

BottomSheetPanel.open();

Close bottom sheet

BottomSheetPanel.close();

Update height of bottom sheet

BottomSheetPanel.close();

Check if bottom sheet is opened

BottomSheetPanel.isOpen;

Check if bottom sheet is expanded

BottomSheetPanel.isExpanded;

Check if bottom sheet is collapsed

BottomSheetPanel.isCollapsed;

DraggableArea

If you set the parameter "draggableBody" in DraggableBottomSheet to false, you will need the DraggableArea widget to scroll the bottom sheet.

DraggableBottomSheet(
        draggableBody: false,
        body: Column(
          children: [
            DraggableArea(
              child: Container(
                height: 80,
                width: double.infinity,
                color: Colors.blue,
                alignment: Alignment.center,
                child: const Text(
                  "Drag Me",
                  style: TextStyle(color: Colors.white),
                ),
              ),
            ),
            Container(
              height: 500,
              color: Colors.red,
              child: const Center(
                  child: Text(
                "Bottom Sheet",
                style: TextStyle(fontSize: 36, color: Colors.white),
              )),
            )
          ],
        ),
      )

BottomSheetBuilder

Use BottomSheetBuilder if you need to listen bottom sheet status to change something in your page.

BottomSheetBuilder(
        builder: (status, context) {
          return FloatingActionButton(
            onPressed: () {
              if (BottomSheetPanel.isExpanded) {
                BottomSheetPanel.close();
              } else {
                BottomSheetPanel.open();
              }
            },
            child: Icon(!status.isExpanded
                ? Icons.open_in_browser
                : Icons.close_fullscreen),
          );
        },
      )

Example

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return BottomSheetScaffold(
      bottomSheet: DraggableBottomSheet(
        body: const Center(
            child: Text(
          "Bottom Sheet",
          style: TextStyle(fontSize: 36, color: Colors.black),
        )),
        header: Container(
          height: 60,
          color: Colors.blue,
          child: const Center(
              child: Text(
            "Drag me",
            style: TextStyle(color: Colors.white),
          )),
        ),
      ),
      appBar: AppBar(
        title: const Text(
          "My AppBar",
        ),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            const SizedBox(
              height: 100,
            ),
            BottomSheetBuilder(
              builder: (status, context) {
                return MaterialButton(
                  color: Colors.blue,
                  onPressed: () {
                    if (BottomSheetPanel.isExpanded) {
                      BottomSheetPanel.close();
                    } else {
                      BottomSheetPanel.open();
                    }
                  },
                  child: Icon(!status.isExpanded
                      ? Icons.open_in_browser
                      : Icons.close_fullscreen),
                );
              },
            ),
            const Text(
              'Body of scaffold',
            ),
          ],
        ),
      ),
    );
  }
}