import 'package:flutter/material.dart'; import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart'; import 'package:ruswipeshare/buy.dart'; import 'package:ruswipeshare/sell.dart'; import 'profile_screen_custom.dart'; import 'main_screen.dart'; class HomeScreen extends StatefulWidget { const HomeScreen({Key? key}) : super(key: key); @override _HomeScreenState createState() => _HomeScreenState(); } class _HomeScreenState extends State { late PersistentTabController _controller; @override void initState() { super.initState(); _controller = PersistentTabController(); } List _buildScreens() => [ const BuyScreen(), const SellScreen(), const ProfileScreenCustom(), const MainScreen(), ]; List _navBarsItems() => [ PersistentBottomNavBarItem( icon: const Icon(Icons.shopping_cart), title: "Buy", activeColorPrimary: Colors.blue, inactiveColorPrimary: Colors.grey, inactiveColorSecondary: Colors.purple), PersistentBottomNavBarItem( icon: const Icon(Icons.attach_money), title: "Sell", activeColorPrimary: Colors.teal, inactiveColorPrimary: Colors.grey, routeAndNavigatorSettings: const RouteAndNavigatorSettings( initialRoute: "/", ), ), PersistentBottomNavBarItem( icon: const Icon(Icons.person), title: "Profile", activeColorPrimary: Colors.blueAccent, inactiveColorPrimary: Colors.grey, routeAndNavigatorSettings: const RouteAndNavigatorSettings( initialRoute: "/", ), ), PersistentBottomNavBarItem( icon: const Icon(Icons.settings), title: "Settings", activeColorPrimary: Colors.indigo, inactiveColorPrimary: Colors.grey, routeAndNavigatorSettings: const RouteAndNavigatorSettings( initialRoute: "/", ), ), ]; @override Widget build(BuildContext context) { return PersistentTabView( context, controller: _controller, screens: _buildScreens(), items: _navBarsItems(), confineInSafeArea: true, backgroundColor: Colors.white, // Default is Colors.white. handleAndroidBackButtonPress: true, // Default is true. resizeToAvoidBottomInset: true, // This needs to be true if you want to move up the screen when keyboard appears. Default is true. stateManagement: true, // Default is true. hideNavigationBarWhenKeyboardShows: true, // Recommended to set 'resizeToAvoidBottomInset' as true while using this argument. Default is true. decoration: NavBarDecoration( borderRadius: BorderRadius.circular(10.0), colorBehindNavBar: Colors.white, ), popAllScreensOnTapOfSelectedTab: true, popActionScreens: PopActionScreensType.all, itemAnimationProperties: const ItemAnimationProperties( // Navigation Bar's items animation properties. duration: Duration(milliseconds: 200), curve: Curves.ease, ), screenTransitionAnimation: const ScreenTransitionAnimation( // Screen transition animation on change of selected tab. animateTabTransition: true, curve: Curves.ease, duration: Duration(milliseconds: 200), ), navBarStyle: NavBarStyle.style13, // Choose the nav bar style with this property. ); } }