• Stars
    star
    209
  • Rank 188,325 (Top 4 %)
  • Language
    Dart
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Drawer behavior is a library that provide an extra behavior on drawer, such as, move view or scaling view's height while drawer on slide.

pub package fdsfd

Drawer Behavior - Flutter

Drawer behavior is a library that provide an extra behavior on drawer, such as, move view or scaling view's height while drawer on slide.

Alt Text


Code Base & Credit : https://github.com/matthew-carroll/flutter_ui_challenge_zoom_menu


Table of contents

Todo

https://github.com/shiburagi/Drawer-Behavior-Flutter/projects/1

NEW UPDATES

Version 2.3

  • Peek Menu
  • ClassName.identifier: SideDrawer.count(), SideDrawer.child() and SideDrawer.custom()
  • Uncontrol SideDrawer

Version 2.0

  • Sound null-safety

Version 1.0

  • Elevation Config
  • 3D effect
  • Multi-Drawer
  • Right Drawer

Version 0.0

  • Floating action button with location and animator
  • Bottom navigation bar
  • Extended body
  • AndroidX support

Usage

  1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  drawerbehavior: latest_version
  1. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

  1. Import it

Now in your Dart code, you can use:

import 'package:drawerbehavior/drawerbehavior.dart';

---

Android Native

Drawer-Behavior ---

Example

class DrawerScale extends StatefulWidget {
  @override
  _DrawerScaleState createState() => _DrawerScaleState();
}

class _DrawerScaleState extends State<DrawerScale> {
  late int selectedMenuItemId;

  @override
  void initState() {
    selectedMenuItemId = menu.items[0].id;
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return DrawerScaffold(
      appBar: AppBar(
          title: Text("Drawer - Scale"),
          actions: [IconButton(icon: Icon(Icons.add), onPressed: () {})]),
      drawers: [
        SideDrawer(
          percentage: 0.6,
          menu: menu,
          direction: Direction.left,
          animation: true,
          color: Theme.of(context).primaryColor,
          selectedItemId: selectedMenuItemId,
          onMenuItemSelected: (itemId) {
            setState(() {
              selectedMenuItemId = itemId;
            });
          },
        )
      ],
      builder: (context, id) => IndexedStack(
        index: id,
        children: menu.items
            .map((e) => Center(
                  child: Text("Page~${e.title}"),
                ))
            .toList(),
      ),
    );
  }
}

Migration (Null-safety Release)

---

mainDrawer (DrawerScaffold) -> defaultDirection (DrawerScaffold)

new DrawerScaffold(
  mainDrawer: Direction.right,
  ...
);

to

new DrawerScaffold(
  defaultDirection: Direction.right,
  ...
);

---

Migration

---

contentView (Screen) -> builder (ScreenBuilder)

contentView: Screen(
  contentBuilder: (context) => Center(child: _widget),
  color: Colors.white,
),

to

builder: (context, id) => Center(child: _widget),

---

menuView (MenuView) -> drawers (List<SideDrawer>)

menuView: new MenuView(
    menu: menu,
    headerView: headerView(context),
    animation: false,
    mainAxisAlignment: MainAxisAlignment.start,
    color: Theme.of(context).primaryColor,
    selectedItemId: selectedMenuItemId,
    onMenuItemSelected: (String itemId) {
      selectedMenuItemId = itemId;
      if (itemId == 'restaurant') {
        setState(() => _widget = Text("1"));
      } else {
        setState(() => _widget = Text("default"));
      }
    },
  ),

to

drawers: [
  SideDrawer(
    menu: menu,
    direction: Direction.left, // Drawer position, left or right
    animation: true,
    color: Theme.of(context).primaryColor,
    selectedItemId: selectedMenuItemId,
    onMenuItemSelected: (itemId) {
      setState(() {
        selectedMenuItemId = itemId;
      });
    },
  )
],

percentage (DrawerScaffold) -> drawers (List<SideDrawer>))

DrawerScaffold(
  percentage: 0.6,
  ...
);

to

DrawerScaffold(
  drawers: [
    SideDrawer(
      percentage: 0.6,
      ...
    )
  ]  
  ...
);

Preview

Scale Effect

new DrawerScaffold(
  drawers: [
    SideDrawer(
      percentage: 0.6,
      ...
    )
  ]
  ...
);

Right Drawer

new DrawerScaffold(
  drawers: [
    SideDrawer(
      direction:Direction.right
      ...
    )
  ]
  ...
);

3D Effect

new DrawerScaffold(
  drawers: [
    SideDrawer(
      degree: 45,
      ...
    )
  ]
  ...
);

Drawer with Header

new DrawerScaffold(
  headerView: headerView(context),
  ...
);

Drawer with Footer

new DrawerScaffold(
  footerView: footerView(context),
  ...
);

Drawer with Header and Custom Builder

new DrawerScaffold(
  headerView: headerView(context),
  drawers: [
      SideDrawer(
        itemBuilder:
            (BuildContext context, MenuItem menuItem, bool isSelected) {
          return Container(
            color: isSelected
                ? Theme.of(context).accentColor.withOpacity(0.7)
                : Colors.transparent,
            padding: EdgeInsets.fromLTRB(24, 16, 24, 16),
            child: Text(
              menuItem.title,
              style: Theme.of(context).textTheme.subtitle1?.copyWith(
                  color: isSelected ? Colors.black87 : Colors.white70),
            ),
          );
        }
      )
  ],
  ...
);

Peek Drawer

new DrawerScaffold(
  headerView: headerView(context),
  drawers: [
      SideDrawer(
        peekMenu: true,
        percentage: 1,
        menu: menuWithIcon,
        direction: Direction.left,
      )
  ],
  ...
);

Customize

DrawerScaffold

DrawerScaffoldController controller;
List<SideDrawer> drawers;
ScreenBuilder builder;
bool enableGestures; // default: true
PreferredSizeWidget appBar;
double cornerRadius; // default: 16
double bacgroundColor; // default: Theme.of(context).scaffoldBackgroundColor
Widget floatingActionButton;
Widget bottomNavigationBar;
FloatingActionButtonLocation floatingActionButtonLocation;
FloatingActionButtonAnimator floatingActionButtonAnimator;
List<BoxShadow> contentShadow;
Widget bottomSheet;
bool extendBodyBehindAppBar;
List<Widget> persistentFooterButtons;
bool primary;
bool resizeToAvoidBottomInset;
bool resizeToAvoidBottomPadding;

/// Listen to offset value on slide event for which [SideDrawer]
Function(SideDrawer, double) onSlide;
/// Listen to which [SideDrawer] is opened (offset=1)
Function(SideDrawer) onOpened;
/// Listen to which [SideDrawer] is closed (offset=0)
Function(SideDrawer) onClosed;

SideDrawer

double percentage; // default: 0.8
double elevation; // default: 4
double cornerRadius;
double degree; // 15-45 degree
double peekSize; // 56px
Menu menu;
String selectedItemId;
Direction direction;
Duration duration;
Curve curve;
bool animation; //default: false
bool slide; //default: false
bool peekMenu; //default: false
bool hideOnItemPressed; //default: true
Function(String) onMenuItemSelected;
Widget headerView;
Widget footerView;
DecorationImage background;
Color color;
Color selectorColor;
TextStyle textStyle;
Alignment alignment;
EdgeInsets padding;
Function(BuildContext, MenuItem, bool) itemBuilder;

MenuItem

String id;
String title;
IconData icon;

Contributor

More Repositories

1

Drawer-Behavior

Drawer behavior is a library that provide an extra behavior on drawer, such as, move view or scaling view's height while drawer on slide.
Kotlin
585
star
2

BlockEditText

Block EditText is a library provide an input view present in multiple block style that common use in TAC or credit card field.
Kotlin
120
star
3

Stylish-Widget-for-Android

StylishWidget is a library for an Android Application project to make the UI more beautiful and allow to use third party font. This library also contain few view that created by me.
Java
39
star
4

Messaging-App

Java
29
star
5

payment_flow_challenge

Dart
23
star
6

payment_flow_bank

Dart
17
star
7

Atomic

An android restful api/networking library using okhttp library as backbone.
Kotlin
14
star
8

Reward-App-Flutter-UI

Dart
14
star
9

JsonToDart

VS Code Extension
TypeScript
9
star
10

ExpandableRecycler

A library provide expand & collapse state for recyclerview.
Java
8
star
11

Locale-Editor

an application to convert multi-language Android/ Swift strings file to excel file, and otherwise
Java
7
star
12

Calendar-View-Flutter-UI

Dart
7
star
13

Todo-App-Flutter-Complete

Dart
6
star
14

whatsapp-searchbar

Android Search Bar like Whatsapp app
Java
5
star
15

BlockEditText-Kotlin

Kotlin
4
star
16

Coordinator-Layout---Flutter

a Library contains widget/layout to handle collapsing header behavio
Dart
3
star
17

Pinterest-Clone

Kotlin
3
star
18

MinimalMUI

A Material UI template for react js
JavaScript
3
star
19

ordering_app

Dart
2
star
20

Todo-App-Flutter

Dart
2
star
21

Firestore-Experiment

Java
1
star
22

todo_flutter_app

Dart
1
star
23

flutter_geofence

Dart
1
star
24

shiburagi

1
star
25

flutter_messenger_app_challenge

Dart
1
star
26

Whatsapp-Indicator-TabLayout

Android TabLayout with Indicator like Whatsapp
Java
1
star
27

SignUpPhone

Java
1
star
28

MinimalMUI_Flutter

Dart
1
star
29

zariman_dev

Dart
1
star
30

marketplace-template-flutter

Dart
1
star
31

Challenge_404

Dart
1
star
32

JsonToAndroidView

Java
1
star