refactor: 重构弹窗组件支持自定义图标组件
This commit is contained in:
@@ -23,11 +23,13 @@ class AppModalDialog extends StatelessWidget {
|
||||
required this.message,
|
||||
required this.actions,
|
||||
this.icon,
|
||||
this.iconWidget,
|
||||
});
|
||||
|
||||
final String title;
|
||||
final String message;
|
||||
final IconData? icon;
|
||||
final Widget? iconWidget;
|
||||
final List<AppModalDialogAction> actions;
|
||||
|
||||
@override
|
||||
@@ -59,9 +61,9 @@ class AppModalDialog extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
if (icon != null)
|
||||
if (iconWidget != null || icon != null)
|
||||
Container(
|
||||
width: 36,
|
||||
height: 36,
|
||||
@@ -70,9 +72,12 @@ class AppModalDialog extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Icon(icon, color: colors.primary, size: 20),
|
||||
child:
|
||||
iconWidget ??
|
||||
Icon(icon, color: colors.primary, size: 20),
|
||||
),
|
||||
if (icon != null) const SizedBox(width: AppSpacing.sm),
|
||||
if (iconWidget != null || icon != null)
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
Expanded(
|
||||
child: Text(
|
||||
title,
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GuaIcon extends StatelessWidget {
|
||||
const GuaIcon({super.key, this.color, this.size = 20});
|
||||
|
||||
final Color? color;
|
||||
final double size;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final effectiveColor =
|
||||
color ?? Theme.of(context).colorScheme.onPrimaryContainer;
|
||||
return Text(
|
||||
'爻',
|
||||
style: TextStyle(
|
||||
fontSize: size * 0.85,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: effectiveColor,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user