|
| 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