refactor(apps): 主题系统迁移至 ColorScheme + 扩展架构并支持 Dark Mode
This commit is contained in:
@@ -21,6 +21,7 @@ class AppButton extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
final isDisabled = onPressed == null || isLoading;
|
||||
|
||||
if (isOutlined) {
|
||||
@@ -30,17 +31,15 @@ class AppButton extends StatelessWidget {
|
||||
onPressed: isLoading ? null : onPressed,
|
||||
style: OutlinedButton.styleFrom(
|
||||
backgroundColor: isDisabled
|
||||
? AppColors.authSecondaryButtonBackground.withValues(
|
||||
alpha: 0.55,
|
||||
)
|
||||
: AppColors.authSecondaryButtonBackground,
|
||||
? colorScheme.secondaryContainer.withValues(alpha: 0.55)
|
||||
: colorScheme.secondaryContainer,
|
||||
foregroundColor: isDisabled
|
||||
? AppColors.authLinkMuted
|
||||
: AppColors.authSecondaryButtonText,
|
||||
? colorScheme.outline
|
||||
: colorScheme.onSecondaryContainer,
|
||||
side: BorderSide(
|
||||
color: isDisabled
|
||||
? AppColors.authSecondaryButtonBorder.withValues(alpha: 0.7)
|
||||
: AppColors.authSecondaryButtonBorder,
|
||||
? colorScheme.outlineVariant.withValues(alpha: 0.7)
|
||||
: colorScheme.outlineVariant,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(AppRadius.full),
|
||||
@@ -48,10 +47,10 @@ class AppButton extends StatelessWidget {
|
||||
padding: const EdgeInsets.symmetric(horizontal: AppSpacing.xl),
|
||||
),
|
||||
child: isLoading
|
||||
? const AppLoadingIndicator(
|
||||
? AppLoadingIndicator(
|
||||
variant: AppLoadingVariant.button,
|
||||
color: AppColors.authSecondaryButtonText,
|
||||
trackColor: AppColors.authSecondaryButtonBorder,
|
||||
color: colorScheme.onSecondaryContainer,
|
||||
trackColor: colorScheme.outlineVariant,
|
||||
)
|
||||
: Text(
|
||||
text,
|
||||
@@ -72,7 +71,7 @@ class AppButton extends StatelessWidget {
|
||||
? const []
|
||||
: [
|
||||
BoxShadow(
|
||||
color: AppColors.blue300.withValues(alpha: 0.24),
|
||||
color: colorScheme.primary.withValues(alpha: 0.24),
|
||||
blurRadius: 18,
|
||||
offset: const Offset(0, 10),
|
||||
),
|
||||
@@ -87,19 +86,17 @@ class AppButton extends StatelessWidget {
|
||||
elevation: const WidgetStatePropertyAll(0),
|
||||
backgroundColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.disabled)) {
|
||||
return AppColors.authPrimaryButtonDisabled;
|
||||
return colorScheme.surfaceContainerHighest;
|
||||
}
|
||||
if (states.contains(WidgetState.pressed)) {
|
||||
return AppColors.authPrimaryButtonPressed;
|
||||
return colorScheme.primary.withValues(alpha: 0.85);
|
||||
}
|
||||
return AppColors.authPrimaryButton;
|
||||
return colorScheme.primary;
|
||||
}),
|
||||
foregroundColor: const WidgetStatePropertyAll(
|
||||
AppColors.authPrimaryButtonText,
|
||||
),
|
||||
foregroundColor: WidgetStatePropertyAll(colorScheme.onPrimary),
|
||||
overlayColor: WidgetStateProperty.resolveWith((states) {
|
||||
if (states.contains(WidgetState.pressed)) {
|
||||
return AppColors.white.withValues(alpha: 0.08);
|
||||
return colorScheme.onPrimary.withValues(alpha: 0.08);
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
@@ -113,10 +110,10 @@ class AppButton extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
child: isLoading
|
||||
? const AppLoadingIndicator(
|
||||
? AppLoadingIndicator(
|
||||
variant: AppLoadingVariant.button,
|
||||
color: AppColors.authPrimaryButtonText,
|
||||
trackColor: AppColors.blue400,
|
||||
color: colorScheme.onPrimary,
|
||||
trackColor: colorScheme.primaryContainer,
|
||||
)
|
||||
: Text(
|
||||
text,
|
||||
@@ -125,8 +122,8 @@ class AppButton extends StatelessWidget {
|
||||
fontWeight: FontWeight.w700,
|
||||
letterSpacing: 0.2,
|
||||
color: isDisabled
|
||||
? AppColors.authLinkMuted
|
||||
: AppColors.authPrimaryButtonText,
|
||||
? colorScheme.outline
|
||||
: colorScheme.onPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user