// ChainSealedIdentityBar — the identity strip shown under the AppBar // while Studio is connected to a sealed area. // // Painted in the area's accent colour so "which area am I in?" is // answerable at a glance (one window, one truth). The area colour is // marking, not theming — Studio's blue stays the app accent // everywhere else. Offers a one-click way back to the shared hub. // Renders nothing when Studio is on the shared hub. import 'package:flutter/material.dart'; import '../data/workspace.dart'; import '../l10n/app_localizations.dart'; import '../theme/tokens.dart'; import 'chain_workspace_switcher.dart' show parseAreaColor; class ChainSealedIdentityBar extends StatelessWidget { const ChainSealedIdentityBar({super.key}); @override Widget build(BuildContext context) { return ListenableBuilder( listenable: Workspace.instance, builder: (context, _) { final area = Workspace.instance.activeSealed; if (area == null) return const SizedBox.shrink(); final theme = Theme.of(context); final l = AppLocalizations.of(context)!; final accent = parseAreaColor(area.color) ?? theme.colorScheme.primary; // A readable foreground on the tinted bar in both themes. final onAccent = accent.computeLuminance() > 0.5 ? Colors.black87 : Colors.white; return Material( color: accent, child: Padding( padding: const EdgeInsets.symmetric( horizontal: ChainSpace.lg, vertical: 6, ), child: Row( children: [ Icon(Icons.lock_outline, size: 15, color: onAccent), const SizedBox(width: ChainSpace.sm), Text( area.name, style: theme.textTheme.labelLarge?.copyWith( color: onAccent, fontWeight: FontWeight.w600, ), ), const SizedBox(width: ChainSpace.md), Expanded( child: Text( l.sealedIdentityBar, style: theme.textTheme.bodySmall?.copyWith( color: onAccent.withValues(alpha: 0.85), ), overflow: TextOverflow.ellipsis, ), ), const SizedBox(width: ChainSpace.sm), TextButton.icon( onPressed: () => Workspace.instance.switchToShared(), style: TextButton.styleFrom(foregroundColor: onAccent), icon: const Icon(Icons.logout, size: 15), label: Text(l.sealedLeave), ), ], ), ), ); }, ); } }