Advertisement
Davefurn

the home page with the bottomnavbar

Feb 8th, 2023
961
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.37 KB | None | 0 0
  1. import 'package:badges/badges.dart';
  2. import 'package:bubu_market/constants/utils.dart';
  3. import 'package:bubu_market/router/route_generator.dart';
  4. import 'package:bubu_market/screens/home/favourite_screen.dart';
  5. import 'package:bubu_market/screens/home/person_screen.dart';
  6.  
  7. import 'package:bubu_market/widgets/home_widgets/search_box.dart';
  8.  
  9. import 'package:flutter/material.dart';
  10. import 'package:go_router/go_router.dart';
  11. import 'package:google_fonts/google_fonts.dart';
  12.  
  13. import 'category_deals.dart';
  14. import 'home_body.dart';
  15.  
  16. class HomeScreen extends StatefulWidget {
  17.   final Widget child;
  18.   const HomeScreen({Key? key, required this.child}) : super(key: key);
  19.  
  20.   @override
  21.   State<HomeScreen> createState() => _HomeScreenState();
  22. }
  23.  
  24. class _HomeScreenState extends State<HomeScreen> {
  25.   late PageController pageController;
  26.   int _currentIndex = 0;
  27.   final List<Widget> _children = [
  28.     const Home(),
  29.     const FavouriteScreen(),
  30.     const PersonScreen(),
  31.   ];
  32.   void onTapTapped(int index) {
  33.     setState(() {
  34.       _currentIndex = index;
  35.     });
  36.   }
  37.  
  38.   void navigateCategoryPage(BuildContext context, String category) {
  39.     context.goNamed(
  40.       "Catergories",
  41.       params: {"category": "category"},
  42.     );
  43.   }
  44.  
  45.   @override
  46.   Widget build(BuildContext context) {
  47.     SizeConfig().init(context);
  48.  
  49.     return GestureDetector(
  50.       onTap: () => FocusManager.instance.primaryFocus?.unfocus(),
  51.       child: Scaffold(
  52.         appBar: AppBar(
  53.             centerTitle: true,
  54.             iconTheme: const IconThemeData(color: Colors.black),
  55.             title: Image.asset(
  56.               'assets/images/logo-on-white.8352d7ab.png',
  57.               width: 150,
  58.               height: 150,
  59.             ),
  60.             elevation: 0,
  61.             actions: [
  62.               Padding(
  63.                 padding: const EdgeInsets.only(right: 10),
  64.                 child: Badge(
  65.                   padding: const EdgeInsets.all(8),
  66.                   elevation: 0,
  67.                   badgeContent: Text(
  68.                     "4",
  69.                     style: GoogleFonts.nunito(
  70.                       fontSize: 17,
  71.                       decorationStyle: TextDecorationStyle.wavy,
  72.                       fontWeight: FontWeight.bold,
  73.                     ),
  74.                   ),
  75.                   badgeColor: Colors.transparent,
  76.                   child: const Icon(
  77.                     Icons.shopping_cart_checkout_outlined,
  78.                     size: 30,
  79.                   ),
  80.                 ),
  81.               ),
  82.             ],
  83.             flexibleSpace: Container(
  84.               decoration: const BoxDecoration(
  85.                 color: Color(0xffEEEEEE),
  86.               ),
  87.             ),
  88.             bottom: const PreferredSize(
  89.               preferredSize: Size.fromHeight(42),
  90.               child: SearchBox(),
  91.             )),
  92.         drawer: const Drawer(),
  93.         bottomNavigationBar: BottomNavigationBar(
  94.             iconSize: 30,
  95.             onTap: onTapTapped,
  96.             currentIndex: _currentIndex,
  97.             elevation: 10,
  98.             selectedItemColor: Colors.black,
  99.             unselectedItemColor: Colors.black,
  100.             backgroundColor: const Color(0xffF4DC51),
  101.             showSelectedLabels: false,
  102.             showUnselectedLabels: false,
  103.             items: [
  104.               BottomNavigationBarItem(
  105.                   icon: Icon(
  106.                     _currentIndex == 0 ? Icons.home : Icons.home_outlined,
  107.                     color: Colors.black,
  108.                   ),
  109.                   label: 'Home'),
  110.               BottomNavigationBarItem(
  111.                   icon: Icon(
  112.                     _currentIndex == 1 ? Icons.favorite : Icons.favorite_border,
  113.                     color: Colors.black,
  114.                   ),
  115.                   label: 'Favourite'),
  116.               BottomNavigationBarItem(
  117.                   icon: Icon(
  118.                     _currentIndex == 2 ? Icons.person : Icons.person_outline,
  119.                     color: Colors.black,
  120.                   ),
  121.                   label: 'Contact'),
  122.               // BottomNavigationBarItem(
  123.  
  124.               //     icon: Icon(
  125.               //       _currentIndex == 3 ? Icons.notifications : Icons.notifications_outlined,
  126.               //       color: Colors.black,
  127.               //     ),
  128.               //     label: 'Notifications'),
  129.             ]),
  130.         body: widget.child,
  131.       ),
  132.     );
  133.   }
  134. }
  135.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement