Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App bar colors #19

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
12 changes: 11 additions & 1 deletion example/lib/exampleHiddenDrawer/example_hidden_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()
),
Expand All @@ -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()
)
Expand All @@ -33,6 +36,13 @@ class ExampleHiddenDrawer extends StatelessWidget {
initPositionSelected: 0,
screens: itens,
backgroundColorMenu: Colors.cyan,
title: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text("Titulo Legal", style: TextStyle(color: Colors.white , fontSize: 50), textAlign: TextAlign.center,),
],
)
// typeOpen: TypeOpen.FROM_RIGHT,
// enableScaleAnimin: true,
// enableCornerAnimin: true,
Expand All @@ -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),
);
Expand Down
36 changes: 25 additions & 11 deletions lib/hidden_drawer/hidden_drawer_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class HiddenDrawerMenu extends StatelessWidget {

final TypeOpen typeOpen;

final Widget title;

HiddenDrawerMenu({
this.screens,
this.initPositionSelected = 0,
Expand All @@ -106,6 +108,7 @@ class HiddenDrawerMenu extends StatelessWidget {
this.enableScaleAnimin = true,
this.enableCornerAnimin = true,
this.typeOpen = TypeOpen.FROM_LEFT,
this.title,
});

@override
Expand All @@ -121,15 +124,20 @@ class HiddenDrawerMenu extends StatelessWidget {
menu: buildMenu(),
typeOpen: typeOpen,
initPositionSelected: initPositionSelected,
title: title,
screenSelectedBuilder: (position, bloc) {
List<Widget> 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) {
Expand All @@ -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,
);
},
Expand Down Expand Up @@ -179,6 +192,7 @@ class HiddenDrawerMenu extends StatelessWidget {
initPositionSelected: initPositionSelected,
enableShadowItensMenu: enableShadowItensMenu,
typeOpen: typeOpen,
title: title,
);
}

Expand Down
124 changes: 71 additions & 53 deletions lib/menu/hidden_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class HiddenMenu extends StatefulWidget {

final TypeOpen typeOpen;

final Widget title;

HiddenMenu(
{Key key,
this.background,
Expand All @@ -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
Expand Down Expand Up @@ -63,59 +66,74 @@ class _HiddenMenuState extends State<HiddenMenu> {
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<OverscrollIndicatorNotification>(
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: <Widget>[
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<OverscrollIndicatorNotification>(
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()
],
),
),
);
Expand Down
57 changes: 48 additions & 9 deletions lib/menu/item_hidden_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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: <Widget>[
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) {
Expand All @@ -46,6 +84,7 @@ class ItemHiddenMenu extends StatelessWidget {
width: 5.0,
),
),
_getMenuIcon(),
Expanded(
child: Container(
margin: EdgeInsets.only(left: 20.0),
Expand Down
4 changes: 3 additions & 1 deletion lib/simple_hidden_drawer/simple_hidden_drawer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down
Loading