Files
tthandClaude Opus 5.5 675342e745
build / ci-image (push) Successful in 9s
build / build (push) Successful in 11m47s
Merge upstream/dev: custom and holiday themes, chat backgrounds
Upstream's theme system (two-color custom themes, holiday themes, picture
icons, chat backgrounds) next to the tth terminal theme:
- a user's custom theme wins; without one, themeMode 'terminal' is still
  the dark theme (main.dart);
- MeshTheme.buildFrom (terminal base) builds with the stock bubble, icon
  and map extensions, like dark()/light();
- terminal avatars also show a theme slot's glyph; the bottom bar stays
  44 px without labels in the terminal theme, 76/60 otherwise;
- map overlays: terminal panels stay square and black, otherwise
  upstream's palette/follow-theme logic; channel list keeps the terminal
  padding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-02 16:12:14 +01:00

157 lines
6.1 KiB
Dart

import 'dart:ui';
import 'package:flutter/material.dart';
import '../l10n/l10n.dart';
import '../theme/mesh_theme.dart';
import '../theme/terminal_theme.dart';
import '../theme/theme_icons.dart';
class QuickSwitchBar extends StatelessWidget {
final int selectedIndex;
final ValueChanged<int> onDestinationSelected;
final int contactsUnreadCount;
final int channelsUnreadCount;
final bool highContrast;
const QuickSwitchBar({
super.key,
required this.selectedIndex,
required this.onDestinationSelected,
this.contactsUnreadCount = 0,
this.channelsUnreadCount = 0,
this.highContrast = false,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final labelStyle = theme.textTheme.labelMedium ?? const TextStyle();
// Custom themes style the bar on map screens like everywhere else; only
// the stock theme uses the fixed high-contrast map palette.
final highContrast =
this.highContrast && !MeshMapTheme.of(context).followsTheme;
final background = highContrast ? MapPalette.panelDark : Colors.transparent;
// The selected icon sits on the primary indicator pill, so it uses
// onPrimary. The label sits below on the bar background, so it must use a
// foreground color that contrasts with the surface (not onPrimary, which
// is white-on-white in the light theme).
final selectedIconColor = highContrast
? MapPalette.textPrimary
: colorScheme.onPrimary;
final selectedLabelColor = highContrast
? MapPalette.textPrimary
: colorScheme.onSurface;
final unselectedColor = highContrast
? MapPalette.textSecondary
: colorScheme.onSurfaceVariant;
final indicator = highContrast ? MapPalette.selected : colorScheme.primary;
// tth fork, terminal theme: a square strip of icons, no labels.
final terminal = MeshStyle.of(context).terminal;
return SizedBox(
width: double.infinity,
child: ClipRRect(
borderRadius: terminal ? BorderRadius.zero : BorderRadius.circular(20),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 14, sigmaY: 14),
child: DecoratedBox(
decoration: BoxDecoration(
color: background,
border: Border.all(
color: highContrast
? MapPalette.border
: colorScheme.outlineVariant.withValues(alpha: 0.4),
),
),
child: NavigationBarTheme(
data: NavigationBarThemeData(
backgroundColor: Colors.transparent,
surfaceTintColor: Colors.transparent,
shadowColor: Colors.transparent,
indicatorColor: indicator,
indicatorShape: terminal
? const RoundedRectangleBorder()
: null,
labelTextStyle: WidgetStateProperty.resolveWith((states) {
final isSelected = states.contains(WidgetState.selected);
return labelStyle.copyWith(
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500,
color: isSelected ? selectedLabelColor : unselectedColor,
);
}),
iconTheme: WidgetStateProperty.resolveWith((states) {
final isSelected = states.contains(WidgetState.selected);
return IconThemeData(
color: isSelected ? selectedIconColor : unselectedColor,
);
}),
),
child: NavigationBar(
// Picture icons are drawn larger than plain ones; give them
// room above the labels. The tth terminal theme stays compact.
height: terminal
? 44
: MeshIconTheme.of(context).hasPictureFor(const [
ThemeIconSlot.contacts,
ThemeIconSlot.channels,
ThemeIconSlot.map,
])
? 76
: 60,
labelBehavior: terminal
? NavigationDestinationLabelBehavior.alwaysHide
: null,
selectedIndex: selectedIndex,
onDestinationSelected: onDestinationSelected,
destinations: [
NavigationDestination(
icon: _buildIconWithBadge(
context,
const ThemedIcon(ThemeIconSlot.contacts),
contactsUnreadCount,
),
selectedIcon: _buildIconWithBadge(
context,
const ThemedIcon(ThemeIconSlot.contacts, selected: true),
contactsUnreadCount,
),
label: context.l10n.nav_contacts,
),
NavigationDestination(
icon: _buildIconWithBadge(
context,
const ThemedIcon(ThemeIconSlot.channels),
channelsUnreadCount,
),
selectedIcon: _buildIconWithBadge(
context,
const ThemedIcon(ThemeIconSlot.channels, selected: true),
channelsUnreadCount,
),
label: context.l10n.nav_channels,
),
NavigationDestination(
icon: const ThemedIcon(ThemeIconSlot.map),
selectedIcon: const ThemedIcon(
ThemeIconSlot.map,
selected: true,
),
label: context.l10n.nav_map,
),
],
),
),
),
),
),
);
}
Widget _buildIconWithBadge(BuildContext context, Widget icon, int count) {
if (count <= 0) return icon;
final label = count > 99 ? '99+' : '$count';
return Badge(label: Text(label), child: icon);
}
}