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

se agregan los atributos activeColor y color #2

Merged
merged 1 commit into from Nov 19, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/navigation_dot_bar.dart
Expand Up @@ -5,8 +5,10 @@ import 'package:flutter/material.dart';
class BottomNavigationDotBar extends StatefulWidget{

final List<BottomNavigationDotBarItem> items;
final Color activeColor;
final Color color;

const BottomNavigationDotBar({@required this.items, Key key}): super(key: key);
const BottomNavigationDotBar({@required this.items, this.activeColor, this.color, Key key}): super(key: key);

@override
State<StatefulWidget> createState() => _BottomNavigationDotBarState();
Expand All @@ -18,6 +20,7 @@ class _BottomNavigationDotBarState extends State<BottomNavigationDotBar>{
GlobalKey _keyBottomBar = GlobalKey();
double _numPositionBase, _numDifferenceBase, _positionLeftIndicatorDot;
int _indexPageSelected = 0;
Color _color, _activeColor;

@override
void initState() {
Expand All @@ -26,6 +29,8 @@ class _BottomNavigationDotBarState extends State<BottomNavigationDotBar>{
}

_afterLayout(_) {
_color = widget.color ?? Colors.black45;
_activeColor = widget.activeColor ?? Theme.of(context).primaryColor;
final sizeBottomBar = (_keyBottomBar.currentContext.findRenderObject() as RenderBox).size;
_numPositionBase = ((sizeBottomBar.width / widget.items.length));
_numDifferenceBase = (_numPositionBase - (_numPositionBase / 2) + 2);
Expand All @@ -51,7 +56,7 @@ class _BottomNavigationDotBarState extends State<BottomNavigationDotBar>{
),
),
AnimatedPositioned(
child: CircleAvatar(radius: 2.5, backgroundColor: Colors.black87),
child: CircleAvatar(radius: 2.5, backgroundColor: _activeColor),
duration: Duration(milliseconds: 400),
curve: Curves.fastOutSlowIn,
left: _positionLeftIndicatorDot,
Expand All @@ -66,7 +71,7 @@ class _BottomNavigationDotBarState extends State<BottomNavigationDotBar>{
List<_NavigationIconButton> _createNavigationIconButtonList(Map<int, BottomNavigationDotBarItem> mapItem){
List<_NavigationIconButton> children = List<_NavigationIconButton>();
mapItem.forEach((index, item) =>
children.add(_NavigationIconButton(item.icon, (index == _indexPageSelected) ? Colors.black87 : Colors.black45,item.onTap,() { _changeOptionBottomBar(index); }))
children.add(_NavigationIconButton(item.icon, (index == _indexPageSelected) ? _activeColor : _color,item.onTap,() { _changeOptionBottomBar(index); }))
);
return children;
}
Expand Down