111
This commit is contained in:
@@ -2,17 +2,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
import '../../core/theme/app_spacing.dart';
|
||||
|
||||
/// 现代弹窗模板 - 基于 modernization-v2.md 规范
|
||||
/// 現代彈窗模板 - 基於 modernization-v2.md 規範
|
||||
///
|
||||
/// 使用方法:
|
||||
/// ```dart
|
||||
/// ModernDialog.show(
|
||||
/// context: context,
|
||||
/// title: '确认操作',
|
||||
/// description: '确定要执行此操作吗?',
|
||||
/// title: '確認操作',
|
||||
/// description: '確定要執行此操作嗎?',
|
||||
/// actions: [
|
||||
/// ModernDialogAction(label: '取消', isDestructive: false),
|
||||
/// ModernDialogAction(label: '确认', isPrimary: true),
|
||||
/// ModernDialogAction(label: '確認', isPrimary: true),
|
||||
/// ],
|
||||
/// );
|
||||
/// ```
|
||||
@@ -34,7 +34,7 @@ class ModernDialog extends StatelessWidget {
|
||||
this.onClose,
|
||||
});
|
||||
|
||||
/// 显示现代弹窗
|
||||
/// 顯示現代彈窗
|
||||
static Future<T?> show<T>({
|
||||
required BuildContext context,
|
||||
String? title,
|
||||
@@ -57,12 +57,12 @@ class ModernDialog extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
/// 显示确认弹窗
|
||||
/// 顯示確認彈窗
|
||||
static Future<bool> confirm({
|
||||
required BuildContext context,
|
||||
required String title,
|
||||
String? description,
|
||||
String confirmText = '确认',
|
||||
String confirmText = '確認',
|
||||
String cancelText = '取消',
|
||||
bool isDestructive = false,
|
||||
}) async {
|
||||
@@ -83,7 +83,7 @@ class ModernDialog extends StatelessWidget {
|
||||
return result ?? false;
|
||||
}
|
||||
|
||||
/// 显示信息弹窗
|
||||
/// 顯示信息彈窗
|
||||
static Future<void> info({
|
||||
required BuildContext context,
|
||||
required String title,
|
||||
@@ -116,7 +116,7 @@ class ModernDialog extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标题
|
||||
// 標題
|
||||
if (titleWidget != null)
|
||||
titleWidget!
|
||||
else if (title != null)
|
||||
@@ -136,12 +136,12 @@ class ModernDialog extends StatelessWidget {
|
||||
),
|
||||
const SizedBox(height: AppSpacing.md),
|
||||
],
|
||||
// 自定义内容
|
||||
// 自定義內容
|
||||
if (content != null) ...[
|
||||
content!,
|
||||
const SizedBox(height: AppSpacing.lg),
|
||||
],
|
||||
// 按钮
|
||||
// 按鈕
|
||||
if (actions != null && actions!.isNotEmpty)
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
@@ -189,7 +189,7 @@ class ModernDialog extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 弹窗按钮配置
|
||||
/// 彈窗按鈕配置
|
||||
class ModernDialogAction {
|
||||
final String label;
|
||||
final dynamic returnValue;
|
||||
|
||||
Reference in New Issue
Block a user