fix:导航栏交互和UI
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../theme/yanting_text.dart';
|
||||
import '../theme/yanting_tokens.dart';
|
||||
|
||||
class AppButton extends StatelessWidget {
|
||||
@@ -10,6 +11,7 @@ class AppButton extends StatelessWidget {
|
||||
this.icon,
|
||||
this.kind = AppButtonKind.primary,
|
||||
this.expand = false,
|
||||
this.compact = false,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@@ -18,45 +20,49 @@ class AppButton extends StatelessWidget {
|
||||
final IconData? icon;
|
||||
final AppButtonKind kind;
|
||||
final bool expand;
|
||||
final bool compact;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final leading = icon == null ? null : Icon(icon, size: 16);
|
||||
final width = expand ? double.infinity : null;
|
||||
final child = Text(label);
|
||||
|
||||
return switch (kind) {
|
||||
AppButtonKind.primary => ShadButton(
|
||||
width: width,
|
||||
onPressed: onPressed,
|
||||
leading: leading,
|
||||
child: child,
|
||||
),
|
||||
AppButtonKind.dark => ShadButton(
|
||||
width: width,
|
||||
onPressed: onPressed,
|
||||
leading: leading,
|
||||
backgroundColor: YantingColors.foreground,
|
||||
foregroundColor: YantingColors.background,
|
||||
hoverBackgroundColor: YantingColors.foreground.withValues(alpha: 0.9),
|
||||
child: child,
|
||||
),
|
||||
AppButtonKind.accent => ShadButton.secondary(
|
||||
width: width,
|
||||
onPressed: onPressed,
|
||||
leading: leading,
|
||||
backgroundColor: YantingColors.brandSoft,
|
||||
foregroundColor: YantingColors.primaryForeground,
|
||||
hoverBackgroundColor: YantingColors.brandSoftBorder,
|
||||
child: child,
|
||||
),
|
||||
AppButtonKind.ghost => ShadButton.outline(
|
||||
width: width,
|
||||
onPressed: onPressed,
|
||||
leading: leading,
|
||||
child: child,
|
||||
),
|
||||
final variant = switch (kind) {
|
||||
AppButtonKind.primary => ShadButtonVariant.primary,
|
||||
AppButtonKind.dark => ShadButtonVariant.primary,
|
||||
AppButtonKind.accent => ShadButtonVariant.secondary,
|
||||
AppButtonKind.ghost => ShadButtonVariant.outline,
|
||||
};
|
||||
final colors = switch (kind) {
|
||||
AppButtonKind.primary => (null, null, null),
|
||||
AppButtonKind.dark => (
|
||||
YantingColors.foreground,
|
||||
YantingColors.background,
|
||||
YantingColors.foreground.withValues(alpha: 0.9),
|
||||
),
|
||||
AppButtonKind.accent => (
|
||||
YantingColors.brandSoft,
|
||||
YantingColors.primaryForeground,
|
||||
YantingColors.brandSoftBorder,
|
||||
),
|
||||
AppButtonKind.ghost => (null, null, null),
|
||||
};
|
||||
final button = ShadButton.raw(
|
||||
variant: variant,
|
||||
enabled: onPressed != null,
|
||||
onPressed: onPressed,
|
||||
width: expand ? double.infinity : null,
|
||||
height: compact ? 36 : 44,
|
||||
padding: EdgeInsets.symmetric(horizontal: compact ? 16 : 20),
|
||||
backgroundColor: colors.$1,
|
||||
foregroundColor: colors.$2,
|
||||
hoverBackgroundColor: colors.$3,
|
||||
leading: icon == null ? null : Icon(icon, size: compact ? 15 : 16),
|
||||
gap: compact ? 5 : 7,
|
||||
textStyle: (compact ? YantingText.badge : YantingText.body).copyWith(
|
||||
color: colors.$2,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
child: Text(label),
|
||||
);
|
||||
return expand ? SizedBox(width: double.infinity, child: button) : button;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user