refactor: create separate BLoCs for each screen with comprehensive tests
- Created 8 separate BLoCs (Home, Library, BookDetails, AddBook, Scanner, Categories, Wishlist, Settings) - Each BLoC has its own event, state, and bloc files - Added 70 comprehensive tests covering all BLoC functionality - All tests passing (70/70) - Fixed linting issues and updated deprecated APIs - Improved code organization and maintainability
This commit is contained in:
71
bookshelf_flutter/lib/widgets/bottom_nav.dart
Normal file
71
bookshelf_flutter/lib/widgets/bottom_nav.dart
Normal file
@@ -0,0 +1,71 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../bloc/app_bloc.dart';
|
||||
import '../bloc/app_event.dart';
|
||||
import '../models/models.dart';
|
||||
|
||||
class BottomNav extends StatelessWidget {
|
||||
final AppScreen currentScreen;
|
||||
|
||||
const BottomNav({super.key, required this.currentScreen});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final navItems = [
|
||||
(id: AppScreen.library, label: 'Полка', icon: Icons.menu_book),
|
||||
(id: AppScreen.categories, label: 'Категории', icon: Icons.category),
|
||||
(id: AppScreen.wishlist, label: 'Вишлист', icon: Icons.bookmark),
|
||||
(id: AppScreen.settings, label: 'Настройки', icon: Icons.settings),
|
||||
];
|
||||
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withValues(alpha: 0.85),
|
||||
border: Border(
|
||||
top: BorderSide(color: Colors.white.withValues(alpha: 0.05), width: 1),
|
||||
),
|
||||
),
|
||||
child: SafeArea(
|
||||
child: SizedBox(
|
||||
height: 64,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
children: navItems.map((item) {
|
||||
final isSelected = currentScreen == item.id;
|
||||
return Expanded(
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
context.read<AppBloc>().add(ScreenChanged(item.id));
|
||||
},
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(
|
||||
item.icon,
|
||||
color: isSelected
|
||||
? const Color(0xFF17CF54)
|
||||
: Colors.grey.withValues(alpha: 0.6),
|
||||
size: 24,
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
item.label,
|
||||
style: TextStyle(
|
||||
fontSize: 10,
|
||||
fontWeight: FontWeight.w500,
|
||||
color: isSelected
|
||||
? const Color(0xFF17CF54)
|
||||
: Colors.grey.withValues(alpha: 0.6),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user