chain-studio/lib/widgets/chain_pill.dart
flemming-it 891acd2ba2
Some checks failed
Security / Security check (push) Failing after 2s
refactor: rename internal Fai* design system + fai_ helpers to chain
The Studio design system, widgets and helpers carried a Fai* / fai_
prefix (FaiSpace, FaiColors, FaiTheme, FaiLog, 17 fai_*.dart files, the
faiBinary* l10n keys). Studio is the Ch∆In product, so rename them to
Chain* / chain_ — carefully preserving English fail/failure/failed.
Also fix stale references: the 'fai' binary in l10n strings -> 'chain',
FAI_* env vars (FAI_BIN/DATA_DIR/MODULES_DIR/TODAY/BOOTSTRAP_TOKEN) ->
CHAIN_*, fai_platform -> fai_chain, fai_hub -> chain_hub. Vendor
security-hook tooling (FAI_BANNED_TERMS_FILE) + the .fai bundle ext left.
flutter analyze + test: clean (20 passed).

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
2026-06-16 17:53:17 +02:00

75 lines
2.2 KiB
Dart

// ChainPill — small inline label. Used for capabilities, versions,
// permission scopes, status text. Replaces ad-hoc Container chips.
import 'package:flutter/material.dart';
import '../theme/theme.dart';
import '../theme/tokens.dart';
enum ChainPillTone { neutral, accent, success, warning, danger }
class ChainPill extends StatelessWidget {
final String label;
final ChainPillTone tone;
final IconData? icon;
final bool monospace;
const ChainPill({
super.key,
required this.label,
this.tone = ChainPillTone.neutral,
this.icon,
this.monospace = false,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final (bg, fg) = _colors(theme.colorScheme);
final textStyle = monospace
? ChainTheme.mono(size: 11, weight: FontWeight.w500, color: fg)
: theme.textTheme.labelSmall?.copyWith(color: fg);
return Container(
padding: const EdgeInsets.symmetric(horizontal: ChainSpace.sm, vertical: 3),
decoration: BoxDecoration(
color: bg,
borderRadius: BorderRadius.circular(ChainRadius.sm),
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
if (icon != null) ...[
Icon(icon, size: 11, color: fg),
const SizedBox(width: 4),
],
Text(label, style: textStyle),
],
),
);
}
(Color, Color) _colors(ColorScheme scheme) {
switch (tone) {
case ChainPillTone.neutral:
return (scheme.surfaceContainerHighest, scheme.onSurfaceVariant);
case ChainPillTone.accent:
return (scheme.primary.withValues(alpha: 0.15), scheme.primary);
case ChainPillTone.success:
return (
ChainColors.success.withValues(alpha: 0.15),
scheme.brightness == Brightness.dark
? ChainColors.success
: const Color(0xFF15803D),
);
case ChainPillTone.warning:
return (
ChainColors.warning.withValues(alpha: 0.15),
scheme.brightness == Brightness.dark
? ChainColors.warning
: const Color(0xFFB45309),
);
case ChainPillTone.danger:
return (scheme.errorContainer, scheme.onErrorContainer);
}
}
}