|
|
@@ -0,0 +1,171 @@
|
|
|
+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);
|
|
|
+ },
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ],
|
|
|
+ );
|
|
|
+ }
|
|
|
+}
|