fix:按照shadcn_ui对着demo_shadcn对齐
This commit is contained in:
+49
-77
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shadcn_ui/shadcn_ui.dart';
|
||||
|
||||
import '../theme/yanting_text.dart';
|
||||
import '../theme/yanting_tokens.dart';
|
||||
|
||||
class AppBadge extends StatelessWidget {
|
||||
@@ -17,60 +17,45 @@ class AppBadge extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colors = switch (kind) {
|
||||
BadgeKind.brand => (
|
||||
YantingColors.primary,
|
||||
YantingColors.primaryForeground,
|
||||
Colors.transparent,
|
||||
final child = Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[Icon(icon, size: 12), const SizedBox(width: 4)],
|
||||
Text(text),
|
||||
],
|
||||
);
|
||||
final shape = RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(YantingRadius.sm),
|
||||
side: kind == BadgeKind.tier || kind == BadgeKind.warning
|
||||
? const BorderSide(color: YantingColors.border)
|
||||
: BorderSide.none,
|
||||
);
|
||||
|
||||
return switch (kind) {
|
||||
BadgeKind.brand => ShadBadge(
|
||||
shape: shape,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3),
|
||||
child: child,
|
||||
),
|
||||
BadgeKind.audio => (
|
||||
YantingColors.secondary,
|
||||
YantingColors.secondaryForeground,
|
||||
Colors.transparent,
|
||||
BadgeKind.audio || BadgeKind.neutral => ShadBadge.secondary(
|
||||
shape: shape,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3),
|
||||
child: child,
|
||||
),
|
||||
BadgeKind.tier => (
|
||||
YantingColors.background,
|
||||
YantingColors.mutedForeground,
|
||||
YantingColors.border,
|
||||
BadgeKind.tier => ShadBadge.outline(
|
||||
shape: shape,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3),
|
||||
foregroundColor: YantingColors.mutedForeground,
|
||||
child: child,
|
||||
),
|
||||
BadgeKind.warning => (
|
||||
YantingColors.background,
|
||||
YantingColors.destructive,
|
||||
YantingColors.border,
|
||||
),
|
||||
BadgeKind.neutral => (
|
||||
YantingColors.secondary,
|
||||
YantingColors.secondaryForeground,
|
||||
Colors.transparent,
|
||||
BadgeKind.warning => ShadBadge.destructive(
|
||||
shape: shape,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3),
|
||||
backgroundColor: YantingColors.background,
|
||||
foregroundColor: YantingColors.destructive,
|
||||
child: child,
|
||||
),
|
||||
};
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
color: colors.$1,
|
||||
border: colors.$3 == Colors.transparent
|
||||
? null
|
||||
: Border.all(color: colors.$3),
|
||||
borderRadius: BorderRadius.circular(YantingRadius.sm),
|
||||
),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 3),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
if (icon != null) ...[
|
||||
Icon(icon, size: 14, color: colors.$2),
|
||||
const SizedBox(width: 4),
|
||||
],
|
||||
Text(
|
||||
text,
|
||||
style:
|
||||
(Theme.of(context).textTheme.labelSmall ?? YantingText.badge)
|
||||
.copyWith(color: colors.$2, letterSpacing: 0),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,33 +75,20 @@ class AppChip extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final background = selected
|
||||
? YantingColors.foreground
|
||||
: YantingColors.secondary;
|
||||
final foreground = selected
|
||||
? YantingColors.background
|
||||
: YantingColors.secondaryForeground;
|
||||
return Material(
|
||||
color: Colors.transparent,
|
||||
child: Ink(
|
||||
decoration: BoxDecoration(
|
||||
color: background,
|
||||
borderRadius: BorderRadius.circular(YantingRadius.pill),
|
||||
),
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(YantingRadius.pill),
|
||||
onTap: onTap,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 9),
|
||||
child: Text(
|
||||
label,
|
||||
style:
|
||||
(Theme.of(context).textTheme.labelLarge ?? YantingText.chip)
|
||||
.copyWith(color: foreground, letterSpacing: 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
return ShadBadge.secondary(
|
||||
onPressed: onTap,
|
||||
shape: const StadiumBorder(),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 17, vertical: 9),
|
||||
backgroundColor: selected
|
||||
? YantingColors.foreground
|
||||
: YantingColors.secondary,
|
||||
hoverBackgroundColor: selected
|
||||
? YantingColors.foreground.withValues(alpha: 0.9)
|
||||
: YantingColors.border,
|
||||
foregroundColor: selected
|
||||
? YantingColors.background
|
||||
: YantingColors.secondaryForeground,
|
||||
child: Text(label),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user