diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..3287bb6 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,13 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Flutter", + "request": "launch", + "type": "dart" + } + ] +} \ No newline at end of file diff --git a/example/lib/exampleHiddenDrawer/example_hidden_drawer.dart b/example/lib/exampleHiddenDrawer/example_hidden_drawer.dart index c753fe5..e6d7766 100644 --- a/example/lib/exampleHiddenDrawer/example_hidden_drawer.dart +++ b/example/lib/exampleHiddenDrawer/example_hidden_drawer.dart @@ -13,6 +13,8 @@ class ExampleHiddenDrawer extends StatelessWidget { colorLineSelected: Colors.teal, baseStyle: TextStyle( color: Colors.white.withOpacity(0.8), fontSize: 25.0 ), selectedStyle: TextStyle(color: Colors.teal), + icon: Icon(Icons.home), + ), Screen1() ), @@ -22,6 +24,7 @@ class ExampleHiddenDrawer extends StatelessWidget { colorLineSelected: Colors.orange, baseStyle: TextStyle( color: Colors.white.withOpacity(0.8), fontSize: 25.0 ), selectedStyle: TextStyle(color: Colors.orange), + menuIcon: Icons.school, ), Screen2() ) @@ -33,6 +36,13 @@ class ExampleHiddenDrawer extends StatelessWidget { initPositionSelected: 0, screens: itens, backgroundColorMenu: Colors.cyan, + title: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text("Titulo Legal", style: TextStyle(color: Colors.white , fontSize: 50), textAlign: TextAlign.center,), + ], + ) // typeOpen: TypeOpen.FROM_RIGHT, // enableScaleAnimin: true, // enableCornerAnimin: true, @@ -47,7 +57,7 @@ class ExampleHiddenDrawer extends StatelessWidget { // backgroundColorContent: Colors.blue, // backgroundColorAppBar: Colors.blue, // elevationAppBar: 4.0, - // tittleAppBar: Center(child: Icon(Icons.ac_unit),), + // tittleAppBar: Center(child: Icon(Icons.ac_unit),), // enableShadowItensMenu: true, // backgroundMenu: DecorationImage(image: ExactAssetImage('assets/bg_news.jpg'),fit: BoxFit.cover), ); diff --git a/lib/hidden_drawer/hidden_drawer_menu.dart b/lib/hidden_drawer/hidden_drawer_menu.dart index 663ddd0..6800d26 100644 --- a/lib/hidden_drawer/hidden_drawer_menu.dart +++ b/lib/hidden_drawer/hidden_drawer_menu.dart @@ -83,6 +83,8 @@ class HiddenDrawerMenu extends StatelessWidget { final TypeOpen typeOpen; + final Widget title; + HiddenDrawerMenu({ this.screens, this.initPositionSelected = 0, @@ -106,6 +108,7 @@ class HiddenDrawerMenu extends StatelessWidget { this.enableScaleAnimin = true, this.enableCornerAnimin = true, this.typeOpen = TypeOpen.FROM_LEFT, + this.title, }); @override @@ -121,15 +124,20 @@ class HiddenDrawerMenu extends StatelessWidget { menu: buildMenu(), typeOpen: typeOpen, initPositionSelected: initPositionSelected, + title: title, screenSelectedBuilder: (position, bloc) { List actions = List(); - if (typeOpen == TypeOpen.FROM_RIGHT) { - actions.add(IconButton( + if (typeOpen == TypeOpen.FROM_RIGHT) + { + actions.add( + IconButton( icon: iconMenuAppBar, onPressed: () { bloc.toggle(); - })); + }, + ), + ); } if (actionsAppBar != null) { @@ -138,14 +146,19 @@ class HiddenDrawerMenu extends StatelessWidget { return Scaffold( backgroundColor: backgroundColorContent, - appBar: AppBar( - backgroundColor: backgroundColorAppBar, - elevation: elevationAppBar, - title: getTittleAppBar(position), - centerTitle: isTitleCentered, - leading: _buildLeading(bloc), - actions: actions, - ), + appBar: screens[position].itemMenu.hideAppBar + ? null + : AppBar( + backgroundColor: + screens[position].itemMenu.appBarColor != null + ? screens[position].itemMenu.appBarColor + : backgroundColorAppBar, + elevation: elevationAppBar, + title: getTittleAppBar(position), + centerTitle: isTitleCentered, + leading: _buildLeading(bloc), + actions: actions, + ), body: screens[position].screen, ); }, @@ -179,6 +192,7 @@ class HiddenDrawerMenu extends StatelessWidget { initPositionSelected: initPositionSelected, enableShadowItensMenu: enableShadowItensMenu, typeOpen: typeOpen, + title: title, ); } diff --git a/lib/menu/hidden_menu.dart b/lib/menu/hidden_menu.dart index a800f43..69841aa 100644 --- a/lib/menu/hidden_menu.dart +++ b/lib/menu/hidden_menu.dart @@ -25,6 +25,8 @@ class HiddenMenu extends StatefulWidget { final TypeOpen typeOpen; + final Widget title; + HiddenMenu( {Key key, this.background, @@ -33,7 +35,8 @@ class HiddenMenu extends StatefulWidget { this.initPositionSelected, this.backgroundColorMenu, this.enableShadowItensMenu = false, - this.typeOpen = TypeOpen.FROM_LEFT}) + this.typeOpen = TypeOpen.FROM_LEFT, + this.title}) : super(key: key); @override @@ -63,59 +66,74 @@ class _HiddenMenuState extends State { image: widget.background, color: widget.backgroundColorMenu, ), - child: Center( - child: Container( - padding: EdgeInsets.only(top: 40.0, bottom: 40.0), - decoration: BoxDecoration( - boxShadow: widget.enableShadowItensMenu - ? [ - new BoxShadow( - color: const Color(0x44000000), - offset: const Offset(0.0, 5.0), - blurRadius: 50.0, - spreadRadius: 30.0, - ), - ] - : []), - child: NotificationListener( - onNotification: (scroll) { - scroll.disallowGlow(); - }, - child: ListView.builder( - shrinkWrap: true, - padding: EdgeInsets.all(0.0), - itemCount: widget.itens.length, - itemBuilder: (context, index) { - if (widget.typeOpen == TypeOpen.FROM_LEFT) { - return ItemHiddenMenu( - name: widget.itens[index].name, - selected: index == _indexSelected, - colorLineSelected: - widget.itens[index].colorLineSelected, - baseStyle: widget.itens[index].baseStyle, - selectedStyle: widget.itens[index].selectedStyle, - onTap: () { - SimpleHiddenDrawerProvider.of(context) - .setSelectedMenuPosition(index); - }, - ); - } else { - return ItemHiddenMenuRight( - name: widget.itens[index].name, - selected: index == _indexSelected, - colorLineSelected: - widget.itens[index].colorLineSelected, - baseStyle: widget.itens[index].baseStyle, - selectedStyle: widget.itens[index].selectedStyle, - onTap: () { - SimpleHiddenDrawerProvider.of(context) - .setSelectedMenuPosition(index); - }, - ); - } - }), + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Expanded( + child: Container( + alignment: Alignment.center, + child: widget.title, + ), + ), + Center( + child: Container( + padding: EdgeInsets.only(top: 40.0, bottom: 40.0), + decoration: BoxDecoration( + boxShadow: widget.enableShadowItensMenu + ? [ + new BoxShadow( + color: const Color(0x44000000), + offset: const Offset(0.0, 5.0), + blurRadius: 50.0, + spreadRadius: 30.0, + ), + ] + : []), + child: NotificationListener( + onNotification: (scroll) { + scroll.disallowGlow(); + }, + child: ListView.builder( + shrinkWrap: true, + padding: EdgeInsets.all(0.0), + itemCount: widget.itens.length, + itemBuilder: (context, index) { + if (widget.typeOpen == TypeOpen.FROM_LEFT) { + return ItemHiddenMenu( + menuIcon: widget.itens[index].menuIcon, + name: widget.itens[index].name, + selected: index == _indexSelected, + colorLineSelected: + widget.itens[index].colorLineSelected, + baseStyle: widget.itens[index].baseStyle, + selectedStyle: widget.itens[index].selectedStyle, + onTap: () { + SimpleHiddenDrawerProvider.of(context) + .setSelectedMenuPosition(index); + }, + icon: widget.itens[index].icon, + ); + } else { + return ItemHiddenMenuRight( + name: widget.itens[index].name, + selected: index == _indexSelected, + colorLineSelected: + widget.itens[index].colorLineSelected, + baseStyle: widget.itens[index].baseStyle, + selectedStyle: widget.itens[index].selectedStyle, + onTap: () { + SimpleHiddenDrawerProvider.of(context) + .setSelectedMenuPosition(index); + }, + ); + } + }), + ), + ), ), - ), + Spacer() + ], ), ), ); diff --git a/lib/menu/item_hidden_menu.dart b/lib/menu/item_hidden_menu.dart index b4e5c01..40643a9 100644 --- a/lib/menu/item_hidden_menu.dart +++ b/lib/menu/item_hidden_menu.dart @@ -17,15 +17,53 @@ class ItemHiddenMenu extends StatelessWidget { final bool selected; - ItemHiddenMenu({ - Key key, - this.name, - this.selected = false, - this.onTap, - this.colorLineSelected = Colors.blue, - this.baseStyle, - this.selectedStyle, - }) : super(key: key); + //You need hide the app bar, in some cases like Slives + final bool hideAppBar; + + //Menu Icon + final IconData menuIcon; + + //A diferent color for a specific appbar + final Color appBarColor; + + final Icon icon; + + _getMenuIcon() { + print("Icon: ${icon}"); + if (menuIcon != null || icon != null) { + return Row( + children: [ + SizedBox(width: 5), + icon ?? + Icon( + menuIcon, + color: + this.selected ? this.selectedStyle.color : this.baseStyle.color, + ), + ], + ); + } + + return Row(); + } + + ItemHiddenMenu( + + {Key key, + this.name, + this.selected = false, + this.onTap, + this.colorLineSelected = Colors.blue, + this.baseStyle, + this.selectedStyle, + this.hideAppBar = false, + this.menuIcon, + this.appBarColor, + this.icon, + }) + : super(key: key){ + print("casa ${icon}"); + } @override Widget build(BuildContext context) { @@ -46,6 +84,7 @@ class ItemHiddenMenu extends StatelessWidget { width: 5.0, ), ), + _getMenuIcon(), Expanded( child: Container( margin: EdgeInsets.only(left: 20.0), diff --git a/lib/simple_hidden_drawer/simple_hidden_drawer.dart b/lib/simple_hidden_drawer/simple_hidden_drawer.dart index b2fdc7c..5394894 100644 --- a/lib/simple_hidden_drawer/simple_hidden_drawer.dart +++ b/lib/simple_hidden_drawer/simple_hidden_drawer.dart @@ -29,6 +29,7 @@ class SimpleHiddenDrawer extends StatefulWidget { /// anable animation borderRadius final bool enableCornerAnimin; + final Widget title; /// Function of the recive screen to show final Widget Function(int position, SimpleHiddenDrawerBloc bloc) screenSelectedBuilder; @@ -49,7 +50,8 @@ class SimpleHiddenDrawer extends StatefulWidget { this.menu, this.enableScaleAnimin = true, this.enableCornerAnimin = true, - this.typeOpen = TypeOpen.FROM_LEFT, + this.typeOpen = TypeOpen.FROM_LEFT, + this.title, }) : assert(screenSelectedBuilder != null), assert(menu != null), super(key: key); diff --git a/pubspec.lock b/pubspec.lock index a1e8431..7642229 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,5 +1,5 @@ # Generated by pub -# See https://www.dartlang.org/tools/pub/glossary#lockfile +# See https://dart.dev/tools/pub/glossary#lockfile packages: async: dependency: transitive @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.1.0" + version: "2.2.0" boolean_selector: dependency: transitive description: @@ -66,14 +66,14 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.5.0" + version: "1.7.0" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" sky_engine: dependency: transitive description: flutter @@ -120,7 +120,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.4" + version: "0.2.5" typed_data: dependency: transitive description: @@ -136,4 +136,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.2.0 <3.0.0" + dart: ">=2.2.2 <3.0.0"