import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import '../models/models.dart'; import '../bloc/navigation_bloc.dart'; class BottomNav extends StatelessWidget { const BottomNav({super.key}); @override Widget build(BuildContext context) { final colorScheme = Theme.of(context).colorScheme; return BlocBuilder( builder: (context, state) { final currentIndex = switch (state.screen) { AppScreen.library || AppScreen.details || AppScreen.addBook || AppScreen.scanner => 0, AppScreen.categories => 1, AppScreen.wishlist => 2, AppScreen.settings => 3, }; return Container( decoration: BoxDecoration( color: colorScheme.surface, border: Border( top: BorderSide(color: colorScheme.outlineVariant, width: 1), ), boxShadow: [ BoxShadow( color: colorScheme.shadow, blurRadius: 8, offset: const Offset(0, -2), ), ], ), child: BottomNavigationBar( currentIndex: currentIndex, backgroundColor: Colors.transparent, elevation: 0, selectedItemColor: colorScheme.primary, unselectedItemColor: colorScheme.onSurface.withValues(alpha: 0.6), onTap: (index) { final screen = [ AppScreen.library, AppScreen.categories, AppScreen.wishlist, AppScreen.settings, ][index]; context.read().add(NavigateTo(screen)); }, items: const [ BottomNavigationBarItem( icon: Icon(Icons.local_library), label: 'Библиотека', ), BottomNavigationBarItem( icon: Icon(Icons.category), label: 'Категории', ), BottomNavigationBarItem( icon: Icon(Icons.bookmark), label: 'Избранное', ), BottomNavigationBarItem( icon: Icon(Icons.settings), label: 'Настройки', ), ], ), ); }, ); } }