Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MyApp extends StatefulWidget {
- @override
- State<StatefulWidget> createState() {
- return MyAppState();
- }
- }
- class MyAppState extends State<MyApp> with WidgetsBindingObserver {
- var lastloaded;
- bool isInactive;
- int _selectedPage = 0;
- final _pageOptions = [
- HomePage(),
- CategoriesPage(),
- Deals(),
- ProfileAccount(),
- CartPage(),
- ];
- @override
- void initState() {
- super.initState();
- WidgetsBinding.instance.addObserver(this);
- }
- @override
- void dispose() {
- WidgetsBinding.instance.removeObserver(this);
- super.dispose();
- }
- @override
- void didChangeAppLifecycleState(AppLifecycleState state) {
- super.didChangeAppLifecycleState(state);
- switch(state){
- case AppLifecycleState.paused:
- print("p");
- break;
- case AppLifecycleState.resumed:
- print("r");
- break;
- case AppLifecycleState.inactive:
- print("I");
- break;
- case AppLifecycleState.detached:
- print("D");
- break;
- }
- }
- @override
- Widget build(BuildContext context) {
- return MaterialApp(
- debugShowCheckedModeBanner: false,
- title: 'Sync Shop',
- theme: ThemeData(
- primarySwatch: Colors.blue,
- ),
- home: Scaffold(
- body: IndexedStack(
- index: _selectedPage,
- children: _pageOptions,
- ),
- bottomNavigationBar: BottomNavigationBar(
- type: BottomNavigationBarType.fixed,
- currentIndex: _selectedPage,
- onTap: (int index) {
- setState((){
- _selectedPage = index;
- });
- },
- items: [
- BottomNavigationBarItem(icon: Image.asset("assets/home.png",
- height: 25,
- width: 25,
- ),
- title: Text("Home",),
- activeIcon:
- Image.asset("assets/home-active.png",
- height: 25,
- width: 25,
- )
- ),
- BottomNavigationBarItem(icon: Image.asset("assets/categories.png",
- height: 22,
- width: 22,
- ),
- title: Text("Categories",),
- activeIcon:
- Image.asset("assets/categories-active.png",
- height: 22,
- width: 22,
- ),
- ),
- BottomNavigationBarItem(icon: Image.asset("assets/deals.png",
- height: 25,
- width: 25,
- ),
- title: Text("Deals",),
- activeIcon:
- Image.asset("assets/deals-active.png",
- height: 25,
- width: 25,
- )
- ),
- BottomNavigationBarItem(icon: Image.asset("assets/profile.png",
- height: 25,
- width: 25,
- ), title: Text("Profile",),
- activeIcon:
- Image.asset("assets/profile-active.png",
- height: 25,
- width: 25,
- )
- ),
- BottomNavigationBarItem(icon: Image.asset("assets/cart.png",
- height: 25,
- width: 25,
- ), title: Text("Cart"),
- activeIcon:
- Image.asset("assets/cart-active.png",
- height: 25,
- width: 25,
- ),
- ),
- ],
- unselectedLabelStyle: TextStyle(color: Colors.grey[600], fontSize: 11),
- selectedItemColor: Color(0xFFEF5021),
- selectedLabelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 12),
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement