import 'package:flutter/material.dart'; import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart'; import 'package:ruswipeshare/buy.dart'; import 'package:ruswipeshare/main.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: CustomMaterialColor(240, 240, 240).mdColor, inactiveColorPrimary: Colors.black38), PersistentBottomNavBarItem( icon: const Icon(Icons.attach_money), title: "Sell", activeColorPrimary: CustomMaterialColor(240, 240, 240).mdColor, inactiveColorPrimary: Colors.black38, routeAndNavigatorSettings: const RouteAndNavigatorSettings( initialRoute: "/", ), ), PersistentBottomNavBarItem( icon: const Icon(Icons.person), title: "Profile", activeColorPrimary: CustomMaterialColor(240, 240, 240).mdColor, inactiveColorPrimary: Colors.black38, routeAndNavigatorSettings: const RouteAndNavigatorSettings( initialRoute: "/", ), ), PersistentBottomNavBarItem( icon: const Icon(Icons.settings), title: "Settings", activeColorPrimary: CustomMaterialColor(240, 240, 240).mdColor, inactiveColorPrimary: Colors.black38, routeAndNavigatorSettings: const RouteAndNavigatorSettings( initialRoute: "/", ), ), ]; @override Widget build(BuildContext context) { return PersistentTabView( context, controller: _controller, screens: _buildScreens(), items: _navBarsItems(), confineInSafeArea: true, backgroundColor: Theme.of(context).primaryColor, // 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: const NavBarDecoration( // border: Border( // top: BorderSide(width: 2.0, color: Colors.white), // ), // 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. ); } }