chain-studio/lib/widgets/fai_en_badge.dart
flemming-it c1c60d5434
Some checks failed
Security / Security check (push) Failing after 1s
feat(studio): rich theme picker (presets + custom colour) + editor 0.11.0
Settings dialog's Theme Plugin section is now a grid of
swatched tiles:

- Built-in (none) — falls back to FaiTheme.light/.dark
- One tile per installed studio.theme.* plugin, each
  showing the plugin's primary/secondary/tertiary as
  live colour dots. Tile loads its preview lazily so a
  dozen installed themes don't block the picker.
- Custom — opens a colour-picker dialog with 12 curated
  Material presets + a hex input + live preview. Selecting
  applies ColorScheme.fromSeed for both brightnesses.

main.dart's _pluginThemes parses a 'custom:#RRGGBB' sigil
in the same notifier slot as plugin capability ids, so the
existing persistence + restoration paths cover the custom
case with no new state.

Bumps editor to 0.11.0 (type-checked port connections +
dynamic card width fix + card-height border allowance) and
Studio to 0.58.0.

Signed-off-by: flemming-it <stefan.a.flemming@googlemail.com>
2026-06-02 01:29:34 +02:00

59 lines
2.1 KiB
Dart

// FaiEnBadge — small "[EN]" pill shown next to text that came
// from outside Studio's localization pipeline (MCP server tool
// names, n8n endpoint descriptions, native LLM responses).
//
// The honest move: when the active locale isn't English and we
// show a piece of text that we know is English, mark it so the
// operator doesn't blame Studio for a half-translated page.
// `studio.translate` plugin will eventually rewrite these in
// place — until then, the badge is the right amount of
// transparency.
import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../theme/tokens.dart';
class FaiEnBadge extends StatelessWidget {
/// When true, the badge renders. When false (e.g. the active
/// locale already is English), it returns
/// `SizedBox.shrink()` so callers can drop it inline without
/// guarding visibility themselves.
final bool visible;
const FaiEnBadge({super.key, required this.visible});
/// Convenience constructor: derives `visible` from the active
/// Localizations locale. Use this from inside a Build method
/// where you already have a BuildContext.
factory FaiEnBadge.forContext(BuildContext context) {
final lang = Localizations.localeOf(context).languageCode;
return FaiEnBadge(visible: lang != 'en');
}
@override
Widget build(BuildContext context) {
if (!visible) return const SizedBox.shrink();
final theme = Theme.of(context);
final l = AppLocalizations.of(context)!;
return Tooltip(
message: l.mcpServerEnLanguageBadge,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerHighest,
borderRadius: BorderRadius.circular(FaiRadius.sm),
border: Border.all(color: theme.colorScheme.outlineVariant),
),
child: Text(
'EN',
style: theme.textTheme.labelSmall?.copyWith(
fontSize: 9,
letterSpacing: 0.4,
color: theme.colorScheme.onSurfaceVariant,
),
),
),
);
}
}