|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter_bloc/flutter_bloc.dart'; |
| 3 | + |
| 4 | +import '../../data/constants/assets.dart'; |
| 5 | +import '../../data/constants/colors.dart'; |
| 6 | +import 'bloc/home_bloc.dart'; |
| 7 | +import 'widgets/nav_bar_item.dart'; |
| 8 | + |
| 9 | +class HomeScreen extends StatelessWidget { |
| 10 | + const HomeScreen({Key? key}) : super(key: key); |
| 11 | + |
| 12 | + @override |
| 13 | + Widget build(BuildContext context) { |
| 14 | + return BlocBuilder<HomeBloc, HomeState>( |
| 15 | + builder: (context, state) { |
| 16 | + return Scaffold( |
| 17 | + body: state.screen, |
| 18 | + bottomNavigationBar: Container( |
| 19 | + decoration: const BoxDecoration( |
| 20 | + color: AppColors.white, |
| 21 | + boxShadow: [ |
| 22 | + BoxShadow( |
| 23 | + blurRadius: 16, |
| 24 | + color: Color.fromRGBO(193, 193, 193, 0.5), |
| 25 | + offset: Offset(0, -4), |
| 26 | + ), |
| 27 | + ], |
| 28 | + ), |
| 29 | + child: Row( |
| 30 | + mainAxisAlignment: MainAxisAlignment.spaceAround, |
| 31 | + children: [ |
| 32 | + NavBarItem( |
| 33 | + label: 'Feed', |
| 34 | + isActive: state.selectedIndex == 0, |
| 35 | + callback: () { |
| 36 | + context |
| 37 | + .read<HomeBloc>() |
| 38 | + .add(const BottomNavItemPressed(index: 0)); |
| 39 | + }, |
| 40 | + icon: AppAssets.feed, |
| 41 | + ), |
| 42 | + NavBarItem( |
| 43 | + label: 'Contests', |
| 44 | + isActive: state.selectedIndex == 1, |
| 45 | + callback: () { |
| 46 | + context |
| 47 | + .read<HomeBloc>() |
| 48 | + .add(const BottomNavItemPressed(index: 1)); |
| 49 | + }, |
| 50 | + icon: AppAssets.contest, |
| 51 | + ), |
| 52 | + NavBarItem( |
| 53 | + label: 'Search', |
| 54 | + isActive: state.selectedIndex == 2, |
| 55 | + callback: () { |
| 56 | + context |
| 57 | + .read<HomeBloc>() |
| 58 | + .add(const BottomNavItemPressed(index: 2)); |
| 59 | + }, |
| 60 | + icon: AppAssets.search, |
| 61 | + ), |
| 62 | + NavBarItem( |
| 63 | + label: 'Profile', |
| 64 | + isActive: state.selectedIndex == 3, |
| 65 | + callback: () { |
| 66 | + context |
| 67 | + .read<HomeBloc>() |
| 68 | + .add(const BottomNavItemPressed(index: 3)); |
| 69 | + }, |
| 70 | + icon: AppAssets.profile, |
| 71 | + ), |
| 72 | + ], |
| 73 | + ), |
| 74 | + ), |
| 75 | + ); |
| 76 | + }, |
| 77 | + ); |
| 78 | + } |
| 79 | +} |
0 commit comments