You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansu_ui/lib/dialog/as_dialog.dart

103 lines
2.8 KiB

4 years ago
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ansu_ui/styles/as_colors.dart';
4 years ago
import 'package:ansu_ui/extension/list_extension.dart';
4 years ago
class ASDialog extends StatelessWidget {
4 years ago
final bool close;
///按钮组
final List<Widget>? items;
4 years ago
///按钮与按钮之间的间距
final double? spacer;
4 years ago
final EdgeInsets? padding;
4 years ago
final Widget child;
final EdgeInsets? childPadding;
4 years ago
ASDialog({
Key? key,
4 years ago
this.close = false,
this.items,
this.spacer,
this.padding,
required this.child,
4 years ago
this.childPadding,
}) : super(key: key);
double get _widgetSpacer => spacer ?? 20.w;
4 years ago
EdgeInsets get _widgetPadding =>
padding ??
4 years ago
EdgeInsets.only(
top: 13.w,
bottom: 20.w,
);
EdgeInsets get _childPadding =>
childPadding ??
4 years ago
EdgeInsets.only(
top: 40.w,
bottom: 50.w,
);
@override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 28.w),
child: Material(
color: kForegroundColor,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15.w),
),
child: Stack(
children: [
4 years ago
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: child,
4 years ago
),
),
),
...(items ?? [])
.sepWidget(separate: SizedBox(height: _widgetSpacer)),
4 years ago
],
),
),
close
4 years ago
? 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(),
],
),
),
),
);
}
}