完成Dialog

null_safety
小赖 4 years ago
parent 3564cb0472
commit ee90d3356b

@ -3,8 +3,6 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
class ExampleDialog extends StatefulWidget {
ExampleDialog({Key key}) : super(key: key);
@override
_ExampleDialogState createState() => _ExampleDialogState();
}
@ -19,7 +17,20 @@ class _ExampleDialogState extends State<ExampleDialog> {
ASButton.info(
title: '打开对话框',
onPressed: () {
Get.dialog(ASDialog());
Get.dialog(ASDialog(
close: true,
child: Text('确认吗'),
items: [
ASDialogButton.outline(
title: '确认',
onPressed: () {},
),
ASDialogButton(
title: '确认',
onPressed: () {},
),
],
));
}),
],
),

@ -60,7 +60,7 @@ class _ExampleListTileState extends State<ExampleListTile> {
20.hb,
ASOptionTile.single(
item: ASVerticalTileItem(
title: 'AS Vertical Tile',
title: Text('AS Vertical Tile'),
child: TextField(),
),
),

@ -13,7 +13,9 @@ export 'bar/as_tabbar.dart';
export 'drawer/as_drawer.dart';
export 'pickers/as_date_picker.dart';
export 'pickers/as_picker_box.dart';
export 'dialog/as_dialog.dart';
export 'dialog/as_dialog_button.dart';
export 'list_tile/as_list_tile.dart';
export 'list_tile/as_option_tile.dart';

@ -113,8 +113,6 @@ class _ASLongButtonState extends State<ASLongButton> {
borderRadius: BorderRadius.circular(widget.radius ?? 22.5.w)),
color: widget.bgColor ?? kForegroundColor,
elevation: 0,
// // focusElevation: 0,
// // hoverElevation: 0,
highlightElevation: 0,
);
}

@ -2,15 +2,52 @@ import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ansu_ui/extension/sizedbox_extension.dart';
class ASDialog extends StatefulWidget {
ASDialog({Key key}) : super(key: key);
final bool close;
///
final List<Widget> items;
///
final double spacer;
final EdgeInsets padding;
final Widget child;
final EdgeInsets childPadding;
ASDialog({
Key key,
this.close = false,
this.items,
this.spacer,
this.padding,
@required this.child,
this.childPadding,
}) : super(key: key);
@override
_ASDialogState createState() => _ASDialogState();
}
class _ASDialogState extends State<ASDialog> {
double get _widgetSpacer => widget.spacer ?? 20.w;
EdgeInsets get _widgetPadding =>
widget.padding ??
EdgeInsets.only(
top: 13.w,
bottom: 20.w,
);
EdgeInsets get _childPadding =>
widget.childPadding ??
EdgeInsets.only(
top: 40.w,
bottom: 50.w,
);
@override
Widget build(BuildContext context) {
return Center(
@ -23,27 +60,48 @@ class _ASDialogState extends State<ASDialog> {
),
child: Stack(
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
height: 100,
),
],
),
Positioned(
right: 0,
top: 0,
child: IconButton(
iconSize: 20.w,
icon: Icon(
CupertinoIcons.clear_circled,
color: Color(0xFF060606).withOpacity(0.85),
),
onPressed: () => Navigator.pop(context),
splashRadius: 16.w,
Padding(
padding: _widgetPadding,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Center(
child: DefaultTextStyle(
style: TextStyle(
color: kTextColor,
fontSize: 20.sp,
fontWeight: FontWeight.bold,
),
child: Padding(
padding: _childPadding,
child: widget.child,
),
),
),
...List.generate(widget.items.length * 2 - 1, (index) {
if (index.isEven)
return widget.items[index ~/ 2];
else
return _widgetSpacer.hb;
}),
],
),
),
widget.close
? Positioned(
right: 0,
top: 0,
child: IconButton(
iconSize: 20.w,
icon: Icon(
CupertinoIcons.clear_circled,
color: Color(0xFF060606).withOpacity(0.85),
),
onPressed: () => Navigator.pop(context),
splashRadius: 16.w,
),
)
: SizedBox(),
],
),
),

@ -0,0 +1,32 @@
import 'package:ansu_ui/buttons/as_longbutton.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASDialogButton extends StatelessWidget {
final String title;
final VoidCallback onPressed;
final bool outline;
const ASDialogButton(
{Key key, this.title, this.onPressed, this.outline = false})
: super(key: key);
const ASDialogButton.outline({Key key, this.title, this.onPressed})
: outline = true,
super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 36.w),
child: outline
? ASLongButton.hollow(
title: title,
onPressed: onPressed,
)
: ASLongButton.solid(
title: title,
onPressed: onPressed,
),
);
}
}

@ -2,10 +2,13 @@ import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
extension SizedBoxExt on num {
extension NumExt on num {
/// SizedBox
Widget get wb => SizedBox(width: ScreenUtil().setWidth(this));
Widget get wb => SizedBox(width: this.w);
/// SizedBox
Widget get hb => SizedBox(height: ScreenUtil().setWidth(this));
Widget get hb => SizedBox(height: this.w);
///
BorderRadius get radius => BorderRadius.circular(this.w);
}

@ -4,7 +4,7 @@ import 'package:flutter/material.dart';
class ASVerticalTileItem extends StatelessWidget {
///
final String title;
final Widget title;
///child
final Widget child;
@ -32,12 +32,12 @@ class ASVerticalTileItem extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
title,
DefaultTextStyle(
style: TextStyle(
color: kTextSubColor,
fontSize: 14.sp,
),
child: title,
),
13.hb,
ASDivider(),

Loading…
Cancel
Save