Created
February 17, 2019 19:07
-
-
Save JulianBissekkou/b9aeb684416ae7aecb20f82fe0eccdd7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ReachableIcon extends StatefulWidget { | |
final Widget child; | |
final int index; | |
final VoidCallback onSelect; | |
ReachableIcon({ | |
@required this.child, | |
@required this.index, | |
@required this.onSelect, | |
}); | |
@override | |
_ReachableIconState createState() => _ReachableIconState(); | |
} | |
class _ReachableIconState extends State<ReachableIcon> { | |
bool _isFocused = false; | |
@override | |
Widget build(BuildContext context) { | |
return Reachable( | |
index: widget.index, | |
onSelect: widget.onSelect, | |
onFocusChanged: (isFocused) { | |
setState(() => _isFocused = isFocused); | |
}, | |
child: AnimatedContainer( | |
duration: Duration(milliseconds: 200), | |
decoration: BoxDecoration( | |
color: _isFocused ? Colors.black45 : Colors.transparent, | |
shape: BoxShape.circle, | |
), | |
padding: EdgeInsets.all(16), | |
alignment: Alignment.center, | |
child: widget.child, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment