Skip to content

Commit a725218

Browse files
committed
feat(Panel): add Panel widget
1 parent 78930d6 commit a725218

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

lib/flutter_weui.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ export 'load_more.dart';
1212
export 'dialog.dart';
1313
export 'touchable.dart';
1414
export 'media_box.dart';
15+
export 'panel.dart';

lib/panel.dart

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import 'package:flutter/material.dart';
2+
import 'touchable.dart';
3+
4+
class Panel extends StatelessWidget {
5+
Panel({Key key, this.title, @required this.body, this.footer = false, this.onFooterPressed}) : super(key: key);
6+
final String title;
7+
final Widget body;
8+
final bool footer;
9+
final VoidCallback onFooterPressed;
10+
@override
11+
Widget build(BuildContext context) {
12+
TextStyle titleStyle = TextStyle(fontSize: 13, color: Color(0xff808080));
13+
return Container(
14+
decoration: BoxDecoration(color: Colors.white, border: Border(top: BorderSide(color: const Color(0xffe5e5e5)))),
15+
margin: const EdgeInsets.only(top: 10),
16+
child: Column(
17+
crossAxisAlignment: CrossAxisAlignment.start,
18+
children: <Widget>[
19+
Offstage(
20+
child: Container(
21+
padding: const EdgeInsets.only(top: 14, right: 15, bottom: 10, left: 15),
22+
child: Text(title, style: titleStyle),
23+
),
24+
offstage: title == null,
25+
),
26+
Offstage(
27+
child: Divider(height: 1, color: const Color(0xffe5e5e5), indent: 15),
28+
offstage: title == null,
29+
),
30+
Container(child: body),
31+
Offstage(
32+
child: Divider(height: 1, color: const Color(0xffe5e5e5), indent: 15),
33+
offstage: !footer,
34+
),
35+
Offstage(
36+
child: TouchableHighlight(
37+
onPressed: () {
38+
if (onFooterPressed != null) onFooterPressed();
39+
},
40+
child: Padding(
41+
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 15),
42+
child: Row(
43+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
44+
children: <Widget>[
45+
Text("查看更多", style: TextStyle(fontSize: 14, color: Color(0xff586c94))),
46+
Icon(Icons.chevron_right, color: Color(0xFF888888), size: 20)
47+
],
48+
),
49+
),
50+
),
51+
offstage: !footer,
52+
),
53+
Divider(height: 1, color: const Color(0xffe5e5e5), indent: 0),
54+
],
55+
),
56+
);
57+
}
58+
}

0 commit comments

Comments
 (0)