|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'touchable.dart'; |
| 3 | + |
| 4 | +class Link { |
| 5 | + Link({this.text, this.onPressed}); |
| 6 | + final String text; |
| 7 | + final VoidCallback onPressed; |
| 8 | +} |
| 9 | + |
| 10 | +class Footer extends StatelessWidget { |
| 11 | + Footer({Key key, this.text = "", this.links = const []}) : super(key: key); |
| 12 | + final String text; |
| 13 | + final List<Link> links; |
| 14 | + |
| 15 | + List<Widget> _getLinks() { |
| 16 | + List<Widget> linksWidget = List(); |
| 17 | + for (int i = 0; i < links.length; i++) { |
| 18 | + if (i == links.length - 1) { |
| 19 | + linksWidget.add(TouchableOpacity( |
| 20 | + onPressed: () { |
| 21 | + VoidCallback _onPressed = links.elementAt(i).onPressed; |
| 22 | + if (_onPressed != null) _onPressed(); |
| 23 | + }, |
| 24 | + child: Padding( |
| 25 | + padding: const EdgeInsets.symmetric(horizontal: 8), |
| 26 | + child: Text( |
| 27 | + links.elementAt(i).text, |
| 28 | + style: TextStyle(fontSize: 14, color: Color(0xff586c94)), |
| 29 | + ), |
| 30 | + ), |
| 31 | + )); |
| 32 | + } else { |
| 33 | + linksWidget.add(TouchableOpacity( |
| 34 | + onPressed: () { |
| 35 | + VoidCallback _onPressed = links.elementAt(i).onPressed; |
| 36 | + if (_onPressed != null) _onPressed(); |
| 37 | + }, |
| 38 | + child: Container( |
| 39 | + padding: const EdgeInsets.symmetric(horizontal: 8), |
| 40 | + decoration: BoxDecoration(border: Border(right: BorderSide(color: Color(0xffe5e5e5)))), |
| 41 | + child: Text( |
| 42 | + links.elementAt(i).text, |
| 43 | + style: TextStyle(fontSize: 14, color: Color(0xff586c94)), |
| 44 | + ), |
| 45 | + ), |
| 46 | + )); |
| 47 | + } |
| 48 | + } |
| 49 | + return linksWidget; |
| 50 | + } |
| 51 | + |
| 52 | + @override |
| 53 | + Widget build(BuildContext context) { |
| 54 | + return Column( |
| 55 | + children: <Widget>[ |
| 56 | + Row(mainAxisAlignment: MainAxisAlignment.center, children: _getLinks()), |
| 57 | + Text(text, style: TextStyle(fontSize: 12, color: const Color(0xff808080))), |
| 58 | + ], |
| 59 | + ); |
| 60 | + } |
| 61 | +} |
0 commit comments