add bottomDialog

null_safety
小赖 4 years ago
parent 0bc8b1ff2e
commit c98577607d

@ -27,8 +27,3 @@ minSdkVersion 21
* 文件命名规则 `as_***`,例如 `as_button`
* 类名命名规则 `AS***`,例如`ASButton`
## ROADMAP
- [ ] Dialog
- [ ] ListTile

@ -41,6 +41,17 @@ class _ExampleDialogState extends State<ExampleDialog> {
onpressed: () {},
));
}),
ListTile(
title: 'BOTTOM DIALOG'.text,
onTap: () {
showASBottomDialog(
context,
items: [
ASBottomDialogItem(title: 'TEST'.text, onPressed: () {}),
],
);
},
),
],
),
);

@ -34,6 +34,9 @@ export 'pickers/as_date_range_picker_part.dart';
export 'dialog/as_dialog.dart';
export 'dialog/as_dialog_button.dart';
export 'dialog/as_delete_dialog.dart';
export 'dialog/as_bottom_dialog.dart';
export 'dialog/as_bottom_dialog_item.dart';
export 'dialog/as_show_bottom_dialog.dart';
export 'list_tile/as_list_tile.dart';
export 'list_tile/as_option_tile.dart';

@ -0,0 +1,48 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:ansu_ui/buttons/as_material_button.dart';
import 'package:flutter/material.dart';
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:ansu_ui/extension/string_extension.dart';
import 'package:ansu_ui/extension/text_extension.dart';
import 'package:ansu_ui/extension/num_extension.dart';
///ASDialog
///
///`items`
///
///with auto cancel
class ASBottomDialog extends StatefulWidget {
final List<Widget> items;
ASBottomDialog({Key key, @required this.items}) : super(key: key);
@override
_ASBottomDialogState createState() => _ASBottomDialogState();
}
class _ASBottomDialogState extends State<ASBottomDialog> {
_buildCancel() {
return ASMaterialButton(
color: kForegroundColor,
onPressed: () {
Navigator.pop(context);
},
child: '取消'.text.bold.black.size(18),
);
}
@override
Widget build(BuildContext context) {
return Material(
color: kBackgroundColor,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: [
...widget.items.sepWidget(separate: ASDivider()),
10.hb,
_buildCancel(),
],
),
);
}
}

@ -0,0 +1,29 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:ansu_ui/buttons/as_material_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ansu_ui/extension/text_style_extension.dart';
///ASBottomDialog item
class ASBottomDialogItem extends StatelessWidget {
final Widget title;
final VoidCallback onPressed;
const ASBottomDialogItem({Key key, @required this.title, this.onPressed})
: super(key: key);
@override
Widget build(BuildContext context) {
return ASMaterialButton(
height: 48.w,
color: kForegroundColor,
onPressed: () {
Navigator.pop(context);
onPressed();
},
child: DefaultTextStyle(
style: TextStyle().black.bold.size(18),
child: title,
),
);
}
}

@ -0,0 +1,15 @@
import 'package:ansu_ui/dialog/as_bottom_dialog.dart';
import 'package:flutter/material.dart';
///`items` better with ASBottomDialogItem
showASBottomDialog(
BuildContext context, {
List<Widget> items,
}) async {
return await showModalBottomSheet(
context: context,
builder: (context) {
return ASBottomDialog(items: items);
},
);
}
Loading…
Cancel
Save