import 'package:flutter/material.dart'; import 'package:medcify/pages/main/home/home_page.dart'; import 'package:medcify/pages/main/orders/orders_page.dart'; import 'package:medcify/pages/main/products/products_page.dart'; import 'package:medcify/pages/main/settings/settings_page.dart'; import 'package:medcify/storage/storage.dart'; import '../../constants.dart'; import '../../network/api_provider.dart'; import 'firebase_push_notification.dart'; class MainPage extends StatefulWidget { const MainPage({Key? key}) : super(key: key); @override State createState() => _MainPageState(); } class _MainPageState extends State { int currentIndex = 0; Widget bodyWidget(){ if(currentIndex == 0){ return const HomePage(); }else if(currentIndex == 1){ return const OrdersPage(); }else if(currentIndex == 2){ return const ProductsPage(); } return const SettingsPage(); } Future initializeFirebase() async{ String token = await FirebaseX.instance.firebaseMessaging.getToken() ?? ""; await ApiProvider.instance.updateFcm(token); await FirebaseX.instance.onFirebaseMessagingInitialize(); FirebaseX.instance.onRegisterFirebaseNotificationTopics(["general"]); } @override initState(){ Storage.instance.fetchRazorPayData(); initializeFirebase(); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: BottomNavigationBarTheme( data: const BottomNavigationBarThemeData( backgroundColor: Colors.white ), child: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: currentIndex, selectedItemColor: Constants.primaryColor, unselectedItemColor: const Color(0xff8F9BB3), onTap: (int index){ setState(() { currentIndex = index; }); }, items: const [ BottomNavigationBarItem( icon: ImageIcon(AssetImage("assets/images/home.png")), label: "Home" ), BottomNavigationBarItem( icon: ImageIcon(AssetImage("assets/images/orders.png")), label: "Orders" ), BottomNavigationBarItem( icon: ImageIcon(AssetImage("assets/images/medicine.png")), label: "Products" ), BottomNavigationBarItem( icon: ImageIcon(AssetImage("assets/images/setting.png")), label: "Settings" ), ], ), ), body: bodyWidget(), ); } }