Giter VIP home page Giter VIP logo

easy_sidemenu's Introduction

Easy Sidemenu

logo
GitHub Pub Version GitHub repo size

Easy sidemenu is An easy to use side menu (bar) for flutter that you can use for navigation in your application.

Sidemenu is a menu that is usually located on the left or right of the page and can used for navigation or other things. Sidemenu is similar to bottom navigation bar but in the side of screen and usually used for larger screens.

Screenshots

Open Compact
Open Compact
Auto
Auto

Demo

You can see web demo here: https://jamalianpour.github.io/easy_sidemenu

Usage

1. add dependencies into you project pubspec.yaml file
dependencies:
  easy_sidemenu: ^0.3.1

Run flutter packages get in the root directory of your app.

2. import easy sidemenu lib
import 'package:easy_sidemenu/easy_sidemenu.dart';

Now you can use SideMenu as a widget in your code.

3. use SideMenu

You must first define a list of items to display on SideMenu:

List<SideMenuItem> items = [
  SideMenuItem(
    // Priority of item to show on SideMenu, lower value is displayed at the top
    priority: 0,
    title: 'Dashboard',
    onTap: () => page.jumpToPage(0),
    icon: Icon(Icons.home),
    badgeContent: Text(
      '3',
      style: TextStyle(color: Colors.white),
    ),
  ),
  SideMenuItem(
    priority: 1,
    title: 'Settings',
    onTap: () => page.jumpToPage(1),
    icon: Icon(Icons.settings),
  ),
  SideMenuItem(
    priority: 2,
    title: 'Exit',
    onTap: () {},
    icon: Icon(Icons.exit_to_app),
  ),
];
priority rule:
  • Priority should start from 0
  • Priority value should be unique

After that you need to warp your main page to a row and then add SideMenu as first child of that, like below:

PageController page = PageController();
Row(
  mainAxisAlignment: MainAxisAlignment.start,
  children: [
    SideMenu(
      // Page controller to manage a PageView
      controller: page,
      // Will shows on top of all items, it can be a logo or a Title text
      title: Image.asset('assets/images/easy_sidemenu.png'),
      // Will show on bottom of SideMenu when displayMode was SideMenuDisplayMode.open
      footer: Text('demo'),
      // Notify when display mode changed
      onDisplayModeChanged: (mode) {
        print(mode);
      },
      // List of SideMenuItem to show them on SideMenu
      items: items,
    ),
    Expanded(
      child: PageView(
        controller: page,
        children: [
          Container(
            child: Center(
              child: Text('Dashboard'),
            ),
          ),
          Container(
            child: Center(
              child: Text('Settings'),
            ),
          ),
        ],
      ),
    ),
  ],
),

Style

you can change style of side menu with SideMenuStyle :

style: SideMenuStyle(
  displayMode: SideMenuDisplayMode.auto,
  decoration: BoxDecoration(),
  openSideMenuWidth: 200,
  compactSideMenuWidth: 40,
  hoverColor: Colors.blue[100],
  selectedColor: Colors.lightBlue,
  selectedIconColor: Colors.white,
  unselectedIconColor: Colors.black54,
  backgroundColor: Colors.grey,
  selectedTitleTextStyle: TextStyle(color: Colors.white),
  unselectedTitleTextStyle: TextStyle(color: Colors.black54),
  iconSize: 20,
),

Example style

Code
style: SideMenuStyle(
  displayMode: SideMenuDisplayMode.auto,
  hoverColor: Colors.blue[100],
  selectedColor: Colors.blue[600],
  selectedTitleTextStyle: TextStyle(color: Colors.white),
  selectedIconColor: Colors.white,
  unselectedIconColor: Colors.white70,
  unselectedTitleTextStyle: TextStyle(color: Colors.white70),
  decoration: BoxDecoration(
      borderRadius: BorderRadius.all(Radius.circular(8)),
      boxShadow: [
        BoxShadow(
          color: Color.fromARGB(255, 79, 117, 134),
          spreadRadius: 1,
          blurRadius: 10,
          offset: Offset(0, 0), // changes position of shadow
        ),
      ]),
  backgroundColor: Color.fromARGB(255, 79, 117, 134),
  // openSideMenuWidth: 200
),

Open

Style Props

props types description
displayMode SideMenuDisplayMode? SideMenuDisplayMode.auto, SideMenuDisplayMode.open, SideMenuDisplayMode.compact
decoration BoxDecoration? Decoration of SideMenu background (container)
openSideMenuWidth double? Width of SideMenu when displayMode was SideMenuDisplayMode.open
compactSideMenuWidth double? Width of SideMenu when displayMode was SideMenuDisplayMode.compact
hoverColor Color? Color of SideMenuItem when mouse hover on that
selectedColor Color? Background color of SideMenuItem when item is selected
selectedIconColor Color? Color of icon when item is selected
unselectedIconColor Color? Color of icon when item is unselected
backgroundColor Color? Background color of SideMenu
selectedTitleTextStyle TextStyle? Style of title text when item is selected
unselectedTitleTextStyle TextStyle? Style of title text when item is unselected
iconSize double? Size of icon on SideMenuItem
toggleColor Color? Color of toggle button

Feel free to fork this repository and send pull request ๐Ÿ๐Ÿ‘

easy_sidemenu's People

Contributors

jamalianpour avatar myconsciousness avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.