From a38a8252d87ed0462498a35c9fe76d8ca72a1f47 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 8 Dec 2020 14:24:58 +0800 Subject: [PATCH 1/3] update list tile --- lib/list_tile/as_list_tile.dart | 7 +++++- lib/list_tile/as_option_tile.dart | 39 ++++++++++++++++++------------- 2 files changed, 29 insertions(+), 17 deletions(-) diff --git a/lib/list_tile/as_list_tile.dart b/lib/list_tile/as_list_tile.dart index 2a7eebb..50b029e 100644 --- a/lib/list_tile/as_list_tile.dart +++ b/lib/list_tile/as_list_tile.dart @@ -14,12 +14,16 @@ class ASListTile extends StatefulWidget { ///宽度,默认332px final double width; + + ///对齐方式 + final CrossAxisAlignment crossAxisAlignment; ASListTile({ Key key, this.title, this.text, this.trail, this.width, + this.crossAxisAlignment, }) : super(key: key); @override @@ -33,7 +37,8 @@ class _ASListTileState extends State { margin: EdgeInsets.symmetric(vertical: 8.w), alignment: Alignment.centerLeft, child: Row( - crossAxisAlignment: CrossAxisAlignment.start, + crossAxisAlignment: + widget.crossAxisAlignment ?? CrossAxisAlignment.start, children: [ Container( width: 85.w, diff --git a/lib/list_tile/as_option_tile.dart b/lib/list_tile/as_option_tile.dart index 82a639f..2b98731 100644 --- a/lib/list_tile/as_option_tile.dart +++ b/lib/list_tile/as_option_tile.dart @@ -11,11 +11,15 @@ class ASOptionTile extends StatelessWidget { ///单个Widget final Widget item; + ///内边距 + final EdgeInsetsGeometry padding; + ///item 推荐使用`ASOptionTileItem`,`ASVerticalTileItem`,`ASListTile` - ASOptionTile({Key key, this.items, this.item}) : super(key: key); + ASOptionTile({Key key, this.items, this.item, this.padding}) + : super(key: key); ///单个子组件的Tile - ASOptionTile.single({Key key, @required this.item}) + ASOptionTile.single({Key key, @required this.item, this.padding}) : items = [], super(key: key); @@ -23,21 +27,24 @@ class ASOptionTile extends StatelessWidget { @override Widget build(BuildContext context) { - return Material( - color: kForegroundColor, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5.w), + return Padding( + padding: this.padding ?? EdgeInsets.fromLTRB(10.w, 10.w, 10.w, 0), + child: Material( + color: kForegroundColor, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.w), + ), + child: item ?? + Column( + children: List.generate(length * 2 - 1, (index) { + final displayIndex = index ~/ 2; + if (index.isEven) + return items[displayIndex]; + else + return ASDivider(indent: 14.w, endIndent: 14.w); + }), + ), ), - child: item ?? - Column( - children: List.generate(length * 2 - 1, (index) { - final displayIndex = index ~/ 2; - if (index.isEven) - return items[displayIndex]; - else - return ASDivider(indent: 14.w, endIndent: 14.w); - }), - ), ); } } From 92da3f4da82ebe29ad8157f2e59712a66e8a18e3 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 8 Dec 2020 14:31:48 +0800 Subject: [PATCH 2/3] update list tile --- lib/list_tile/as_option_tile.dart | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/lib/list_tile/as_option_tile.dart b/lib/list_tile/as_option_tile.dart index 2b98731..0f0a248 100644 --- a/lib/list_tile/as_option_tile.dart +++ b/lib/list_tile/as_option_tile.dart @@ -27,24 +27,23 @@ class ASOptionTile extends StatelessWidget { @override Widget build(BuildContext context) { - return Padding( - padding: this.padding ?? EdgeInsets.fromLTRB(10.w, 10.w, 10.w, 0), - child: Material( + return Material( color: kForegroundColor, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(5.w), ), - child: item ?? - Column( - children: List.generate(length * 2 - 1, (index) { - final displayIndex = index ~/ 2; - if (index.isEven) - return items[displayIndex]; - else - return ASDivider(indent: 14.w, endIndent: 14.w); - }), - ), - ), - ); + child: Padding( + padding: this.padding ?? EdgeInsets.fromLTRB(10.w, 10.w, 10.w, 0), + child: item ?? + Column( + children: List.generate(length * 2 - 1, (index) { + final displayIndex = index ~/ 2; + if (index.isEven) + return items[displayIndex]; + else + return ASDivider(indent: 14.w, endIndent: 14.w); + }), + ), + )); } } From 2f4c29535ffe485cccdec451ad277381005c81df Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Tue, 8 Dec 2020 15:05:04 +0800 Subject: [PATCH 3/3] update list tile --- example/lib/example_listtile.dart | 15 +++++---------- lib/list_tile/as_list_tile.dart | 2 +- lib/list_tile/as_option_tile.dart | 6 ++++-- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/example/lib/example_listtile.dart b/example/lib/example_listtile.dart index ad377f5..8ec6128 100644 --- a/example/lib/example_listtile.dart +++ b/example/lib/example_listtile.dart @@ -20,25 +20,20 @@ class _ExampleListTileState extends State { SizedBox( height: 8.w, ), - Container( - color: Color(0xFFFFFFFF), - padding: EdgeInsets.symmetric(horizontal: 8.w), - child: Column( - children: [ - ASListTile( + ASOptionTile( + items: [ + ASListTile( title: '转单号(UPS)', text: 'DFADN2329TNAGA', trail: Icon(Icons.ac_unit_rounded), ), - ASDivider(), - ASListTile( + ASListTile( title: '订单编号', text: 'DDAWMFOAGNAIOWNGOANIWOGNAOWIDJAWIOHFA92474Y2798489TY892YH8G67TGT2UBF29GB8298H42897YH472H', // trail: Icon(Icons.ac_unit_outlined), ), - ], - ), + ], ), 20.hb, ASOptionTile( diff --git a/lib/list_tile/as_list_tile.dart b/lib/list_tile/as_list_tile.dart index 50b029e..a432dc2 100644 --- a/lib/list_tile/as_list_tile.dart +++ b/lib/list_tile/as_list_tile.dart @@ -34,7 +34,7 @@ class _ASListTileState extends State { @override Widget build(BuildContext context) { return Container( - margin: EdgeInsets.symmetric(vertical: 8.w), + margin: EdgeInsets.symmetric(vertical: 8.w,horizontal: 10.w), alignment: Alignment.centerLeft, child: Row( crossAxisAlignment: diff --git a/lib/list_tile/as_option_tile.dart b/lib/list_tile/as_option_tile.dart index 0f0a248..99584ff 100644 --- a/lib/list_tile/as_option_tile.dart +++ b/lib/list_tile/as_option_tile.dart @@ -33,7 +33,7 @@ class ASOptionTile extends StatelessWidget { borderRadius: BorderRadius.circular(5.w), ), child: Padding( - padding: this.padding ?? EdgeInsets.fromLTRB(10.w, 10.w, 10.w, 0), + padding: this.padding ?? EdgeInsets.zero, child: item ?? Column( children: List.generate(length * 2 - 1, (index) { @@ -41,7 +41,9 @@ class ASOptionTile extends StatelessWidget { if (index.isEven) return items[displayIndex]; else - return ASDivider(indent: 14.w, endIndent: 14.w); + return this.padding == null + ? ASDivider(indent: 10.w, endIndent: 10.w) + : ASDivider(); }), ), ));