import 'package:flutter/material.dart'; import '../theme/yanting_text.dart'; import '../theme/yanting_tokens.dart'; class AppBadge extends StatelessWidget { const AppBadge({ required this.text, this.icon, this.kind = BadgeKind.neutral, super.key, }); final String text; final IconData? icon; final BadgeKind kind; @override Widget build(BuildContext context) { final colors = switch (kind) { BadgeKind.brand => ( YantingColors.primary, YantingColors.primaryForeground, Colors.transparent, ), BadgeKind.audio => ( YantingColors.secondary, YantingColors.secondaryForeground, Colors.transparent, ), BadgeKind.tier => ( YantingColors.background, YantingColors.mutedForeground, YantingColors.border, ), BadgeKind.warning => ( YantingColors.background, YantingColors.destructive, YantingColors.border, ), BadgeKind.neutral => ( YantingColors.secondary, YantingColors.secondaryForeground, Colors.transparent, ), }; 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), ), ], ), ), ); } } enum BadgeKind { brand, audio, tier, warning, neutral } class AppChip extends StatelessWidget { const AppChip({ required this.label, this.selected = false, this.onTap, super.key, }); final String label; final bool selected; final VoidCallback? onTap; @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), ), ), ), ), ); } }