adapt as option tile

master
张萌 3 years ago
parent 1fb96257af
commit 2ca1997739

@ -1,7 +1,8 @@
import 'package:ansu_ui/divider/as_divider.dart';
import 'package:ansu_ui/extension/list_extension.dart';
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:ansu_ui/divider/as_divider.dart';
///Tile ///Tile
class ASOptionTile extends StatelessWidget { class ASOptionTile extends StatelessWidget {
@ -27,6 +28,7 @@ class ASOptionTile extends StatelessWidget {
{Key? key, required this.item, this.padding, this.leading}) {Key? key, required this.item, this.padding, this.leading})
: items = [], : items = [],
super(key: key); super(key: key);
int get length => items!.length; int get length => items!.length;
@override @override
@ -38,15 +40,16 @@ class ASOptionTile extends StatelessWidget {
alignment: Alignment.centerLeft, alignment: Alignment.centerLeft,
child: this.leading is String child: this.leading is String
? Padding( ? Padding(
padding:EdgeInsets.symmetric(vertical: 14.w,horizontal: 10.w), padding: EdgeInsets.symmetric(
child: Text( vertical: 14.w, horizontal: 10.w),
child: Text(
this.leading, this.leading,
style: TextStyle( style: TextStyle(
color: kTextColor, color: kTextColor,
fontSize: 16.sp, fontSize: 16.sp,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
) )
: this.leading, : this.leading,
), ),
); );
@ -62,15 +65,13 @@ class ASOptionTile extends StatelessWidget {
child: item ?? child: item ??
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(length * 2 - 1, (index) { children: items!.sepWidget(
final displayIndex = index ~/ 2; separate: this.padding == null
if (index.isEven) ? ASDivider(
return items![displayIndex]; indent: 10.w,
else endIndent: 10.w,
return this.padding == null )
? ASDivider(indent: 10.w, endIndent: 10.w) : ASDivider()),
: ASDivider();
}),
), ),
)); ));
} }

Loading…
Cancel
Save