meshcore-open/lib/widgets/quick_switch_bar.dart

85 lines
2.9 KiB
Dart
Raw Permalink Normal View History

2025-12-27 15:32:32 -07:00
import 'dart:ui';
import 'package:flutter/material.dart';
import '../l10n/l10n.dart';
2025-12-27 15:32:32 -07:00
class QuickSwitchBar extends StatelessWidget {
final int selectedIndex;
final ValueChanged<int> onDestinationSelected;
const QuickSwitchBar({
super.key,
required this.selectedIndex,
required this.onDestinationSelected,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
final colorScheme = theme.colorScheme;
final labelStyle = theme.textTheme.labelMedium ?? const TextStyle();
return SizedBox(
width: double.infinity,
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 14, sigmaY: 14),
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(
color: colorScheme.outlineVariant.withValues(alpha: 0.4),
),
),
child: NavigationBarTheme(
data: NavigationBarThemeData(
backgroundColor: Colors.transparent,
surfaceTintColor: Colors.transparent,
shadowColor: Colors.transparent,
indicatorColor: colorScheme.primaryContainer,
2025-12-31 22:19:48 -07:00
labelTextStyle: WidgetStateProperty.resolveWith((states) {
final isSelected = states.contains(WidgetState.selected);
2025-12-27 15:32:32 -07:00
return labelStyle.copyWith(
fontWeight: isSelected ? FontWeight.w700 : FontWeight.w500,
color: isSelected
? colorScheme.onPrimaryContainer
: colorScheme.onSurfaceVariant,
);
}),
2025-12-31 22:19:48 -07:00
iconTheme: WidgetStateProperty.resolveWith((states) {
final isSelected = states.contains(WidgetState.selected);
2025-12-27 15:32:32 -07:00
return IconThemeData(
color: isSelected
? colorScheme.onPrimaryContainer
: colorScheme.onSurfaceVariant,
);
}),
),
child: NavigationBar(
height: 60,
selectedIndex: selectedIndex,
onDestinationSelected: onDestinationSelected,
destinations: [
2025-12-27 15:32:32 -07:00
NavigationDestination(
icon: const Icon(Icons.people_outline),
label: context.l10n.nav_contacts,
2025-12-27 15:32:32 -07:00
),
NavigationDestination(
icon: const Icon(Icons.tag),
label: context.l10n.nav_channels,
2025-12-27 15:32:32 -07:00
),
NavigationDestination(
icon: const Icon(Icons.map_outlined),
label: context.l10n.nav_map,
2025-12-27 15:32:32 -07:00
),
],
),
),
),
),
),
);
}
}