mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
94 lines
3.4 KiB
Dart
94 lines
3.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart';
|
|
|
|
import 'main_screen.dart';
|
|
|
|
class HomeScreen extends StatefulWidget {
|
|
const HomeScreen({ Key? key }) : super(key: key);
|
|
|
|
@override
|
|
_HomeScreenState createState() => _HomeScreenState();
|
|
}
|
|
|
|
class _HomeScreenState extends State<HomeScreen> {
|
|
late PersistentTabController _controller;
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = PersistentTabController();
|
|
}
|
|
List<Widget> _buildScreens() => [
|
|
const MainScreen(),
|
|
const MainScreen(),
|
|
const MainScreen(),
|
|
const MainScreen(),
|
|
];
|
|
|
|
List<PersistentBottomNavBarItem> _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.
|
|
);
|
|
}
|
|
} |