Skip to content

Commit

Permalink
Merge pull request #2 from andres2050/patch-2
Browse files Browse the repository at this point in the history
se agregan los atributos activeColor y color
  • Loading branch information
TioCoding committed Nov 19, 2018
2 parents 58738bb + 7bacb58 commit b560c40
Showing 1 changed file with 8 additions and 3 deletions.
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

0 comments on commit b560c40

Please sign in to comment.