| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- import 'package:flutter/Material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
- import '../../../base/base_view.dart';
- import '../../../resource/assets.gen.dart';
- import '../../../resource/colors.gen.dart';
- import '../../../resource/string.gen.dart';
- import '../../../widget/gradient_btn.dart';
- import 'delete_profile_confirm_controller.dart';
- /// 确定时回调
- typedef OnConfirmCallback = void Function();
- /// 取消时回调
- typedef OnCancelCallback = void Function();
- /// 删除档案弹窗
- class DeleteProfileConfirmDialog {
- static const String _tag = "DeleteProfileConfirmDialog";
- /// 显示弹窗
- /// [targetName] Ta的名称
- /// [onConfirmCallback] 确认时回调
- static void show(String targetName, OnConfirmCallback onConfirmCallback) {
- SmartDialog.show(
- tag: _tag,
- // 点击遮罩,不关闭弹窗
- clickMaskDismiss: false,
- // 内容居中显示
- alignment: Alignment.center,
- // 动画类型
- animationType: SmartAnimationType.fade,
- builder:
- (BuildContext context) => IntrinsicHeight(
- child: Container(
- padding: EdgeInsets.symmetric(horizontal: 32.w),
- child: DeleteProfileConfirmView(
- targetName: targetName,
- onConfirmCallback: () {
- onConfirmCallback();
- SmartDialog.dismiss(tag: _tag);
- },
- onCancelCallback: () {
- // 关闭弹窗
- SmartDialog.dismiss(tag: _tag);
- },
- ),
- ),
- ),
- );
- }
- }
- /// 删除档案弹窗的内容
- class DeleteProfileConfirmView
- extends BaseView<DeleteProfileConfirmController> {
- final String targetName;
- final OnConfirmCallback onConfirmCallback;
- final OnCancelCallback onCancelCallback;
- const DeleteProfileConfirmView({
- super.key,
- required this.targetName,
- required this.onConfirmCallback,
- required this.onCancelCallback,
- });
- @override
- backgroundColor() => Colors.transparent;
- @override
- Widget buildBody(BuildContext context) {
- return Stack(
- children: [
- Container(
- padding: EdgeInsets.symmetric(vertical: 24.h, horizontal: 16.w),
- decoration: BoxDecoration(
- color: ColorName.white,
- borderRadius: BorderRadius.all(Radius.circular(16.r)),
- ),
- child: Column(
- // 包裹内容
- mainAxisSize: MainAxisSize.min,
- children: [
- // 标题
- _buildTitle(),
- SizedBox(height: 16.h),
- // 内容
- _buildContent(),
- SizedBox(height: 20.h),
- // 操作按钮
- _buildActionBtn(),
- ],
- ),
- ),
- Positioned(
- top: 0,
- right: 0,
- child: InkWell(
- onTap: () {
- controller.doOnCancel(onCancelCallback);
- },
- splashColor: ColorName.transparent,
- child: Container(
- padding: EdgeInsets.all(14.w),
- child: Assets.images.iconCustomDirectionEditClose.image(
- width: 24.w,
- height: 24.w,
- ),
- ),
- ),
- ),
- ],
- );
- }
- /// 标题
- Widget _buildTitle() {
- return Text(
- StringName.tipsDialogTitle,
- style: TextStyle(
- fontSize: 16.sp,
- color: ColorName.black80,
- fontWeight: FontWeight.bold,
- ),
- );
- }
- /// 输入框
- Widget _buildContent() {
- return Text(
- "确定要删除 $targetName 的档案吗?",
- style: TextStyle(
- fontSize: 14.sp,
- color: ColorName.black80,
- fontWeight: FontWeight.w400,
- ),
- );
- }
- /// 操作按钮
- Widget _buildActionBtn() {
- return Row(
- children: [
- // 取消
- Expanded(
- child: GradientTextBtn(
- StringName.dialogCancel,
- color: Color(0xFFF6F5FA),
- textColor: ColorName.black60,
- onPressed: () {
- controller.doOnCancel(onConfirmCallback);
- },
- ),
- ),
- SizedBox(width: 8.w),
- // 确定
- Expanded(
- child: GradientTextBtn(
- StringName.dialogConfirm,
- onPressed: () {
- controller.doOnConfirm(onConfirmCallback);
- },
- ),
- ),
- ],
- );
- }
- }
|