Skip to content

Commit e47029c

Browse files
committed
feat(Footer): add Footer widget
1 parent a725218 commit e47029c

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

lib/flutter_weui.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ export 'dialog.dart';
1313
export 'touchable.dart';
1414
export 'media_box.dart';
1515
export 'panel.dart';
16+
export 'footer.dart';

lib/footer.dart

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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

Comments
 (0)