Newer
Older
import 'package:flutter_custom_toolbox/flutter_toolbox.dart';
import 'package:flutter_swipe/flutter_swipe.dart';
import 'package:scrobbles/config/activity_page.dart';
import 'package:scrobbles/cubit/nav_cubit_pages.dart';
class BottomNavBar extends StatelessWidget {
const BottomNavBar({super.key, required this.swipeController});
final SwiperController swipeController;
@override
Widget build(BuildContext context) {
return Card(
margin: const EdgeInsets.all(0),
elevation: 4,
shadowColor: Theme.of(context).colorScheme.shadow,
color: Theme.of(context).colorScheme.surfaceContainerHighest,
shape: const ContinuousRectangleBorder(),
child: BlocBuilder<NavCubitPage, int>(
builder: (BuildContext context, int pageIndex) {
final List<ActivityPageItem> pageItems = [
ActivityPage.pageHome,
ActivityPage.pageDiscoveries,
ActivityPage.pageStatistics,
];
final List<BottomNavigationBarItem> items = pageItems.map((ActivityPageItem item) {
return BottomNavigationBarItem(
icon: item.icon,
label: tr(item.code),
);
}).toList();
return BottomNavigationBar(
currentIndex: pageIndex,
onTap: (int index) {
BlocProvider.of<NavCubitPage>(context).updateIndex(index);
swipeController.move(index);
},
type: BottomNavigationBarType.fixed,
elevation: 0,
backgroundColor: Colors.transparent,
selectedItemColor: Theme.of(context).colorScheme.primary,
unselectedItemColor: Theme.of(context).textTheme.bodySmall!.color,
items: items,
);
},
),
);
}
}