add OptionTile

null_safety
小赖 4 years ago
parent 7cd8581032
commit 3daa146ea9

@ -1,6 +1,5 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:ansu_ui/divider/as_divider.dart';
import 'package:ansu_ui/widget/as_listtile.dart';
import 'package:flutter/material.dart';
class ExampleListTile extends StatefulWidget {
@ -17,7 +16,9 @@ class _ExampleListTileState extends State<ExampleListTile> {
title: 'ASListTile',
body: ListView(
children: [
SizedBox(height: 8.w,),
SizedBox(
height: 8.w,
),
Container(
color: Color(0xFFFFFFFF),
padding: EdgeInsets.symmetric(horizontal: 8.w),
@ -38,6 +39,17 @@ class _ExampleListTileState extends State<ExampleListTile> {
],
),
),
20.hb,
ASOptionTile(
items: List.generate(
3,
(index) => ASOptionTileItem(
leading: Icon(Icons.verified),
title: Text('Test'),
onPressed: () {},
),
),
),
],
),
);

@ -14,7 +14,8 @@ export 'drawer/as_drawer.dart';
export 'pickers/as_date_picker.dart';
export 'pickers/as_picker_box.dart';
export 'dialog/as_dialog.dart';
export 'widget/as_listtile.dart';
export 'list_tile/as_list_tile.dart';
export 'list_tile/as_option_tile.dart';
export 'tag/as_tag.dart';
export 'divider/as_divider.dart';
export 'text_field/as_search_text_field.dart';

@ -3,7 +3,9 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
extension SizedBoxExt on num {
/// SizedBox
Widget get wb => SizedBox(width: ScreenUtil().setWidth(this));
/// SizedBox
Widget get hb => SizedBox(height: ScreenUtil().setWidth(this));
}

@ -0,0 +1,80 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ansu_ui/extension/sizedbox_extension.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
///Tile
class ASOptionTile extends StatelessWidget {
///使 ASOptionTileItem
final List<Widget> items;
const ASOptionTile({Key key, @required this.items}) : super(key: key);
int get length => items.length;
@override
Widget build(BuildContext context) {
return Material(
color: kForegroundColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.w),
),
child: Column(
children: List.generate(length * 2 - 1, (index) {
final displayIndex = index ~/ 2;
if (index.isEven)
return items[displayIndex];
else
return ASDivider();
}),
),
);
}
}
class ASOptionTileItem extends StatelessWidget {
final Widget leading;
final Widget title;
final onPressed;
const ASOptionTileItem({
Key key,
this.leading,
this.title,
this.onPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return InkWell(
onTap: onPressed,
borderRadius: BorderRadius.circular(5.w),
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 46.w),
child: Row(
children: [
14.wb,
leading ?? SizedBox(),
leading != null ? 8.wb : 0.wb,
Expanded(
child: DefaultTextStyle(
style: TextStyle(
color: Colors.black.withOpacity(0.65),
fontSize: 14.sp,
),
child: title,
),
),
14.wb,
Icon(
CupertinoIcons.chevron_forward,
size: 16.w,
),
14.wb,
],
),
),
);
}
}

@ -56,7 +56,7 @@ class ASSearchTextField extends StatefulWidget implements PreferredSizeWidget {
_ASSearchTextFieldState createState() => _ASSearchTextFieldState();
@override
Size get preferredSize => Size.fromHeight(42.w);
Size get preferredSize => Size.fromHeight(42);
}
class _ASSearchTextFieldState extends State<ASSearchTextField> {

Loading…
Cancel
Save