mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-21 19:08:46 -04:00
Persisent navbar
This commit is contained in:
@@ -1,27 +1,87 @@
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ruswipeshare/home.dart';
|
||||
import 'package:ruswipeshare/sell.dart';
|
||||
|
||||
import 'firebase_options.dart';
|
||||
import 'authGate.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Firebase.initializeApp(
|
||||
options: DefaultFirebaseOptions.android,
|
||||
);
|
||||
// WidgetsFlutterBinding.ensureInitialized();
|
||||
// await Firebase.initializeApp(
|
||||
// options: DefaultFirebaseOptions.android,
|
||||
// );
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: const AuthGate(),
|
||||
);
|
||||
}
|
||||
const MyApp({super.key});
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(
|
||||
primarySwatch: Colors.blue,
|
||||
),
|
||||
home: const HomeScreen(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class MyNavBar extends StatefulWidget {
|
||||
MyNavBar({super.key});
|
||||
|
||||
@override
|
||||
State<MyNavBar> createState() => MyNavBarState();
|
||||
}
|
||||
|
||||
class MyNavBarState extends State<MyNavBar> {
|
||||
final pages = [
|
||||
const SellScreen(),
|
||||
const SellScreen(),
|
||||
];
|
||||
|
||||
int _selectedIndex = 0;
|
||||
|
||||
void _onItemTapped(int index) {
|
||||
if (runtimeType == pages.elementAt(index).runtimeType) return;
|
||||
|
||||
setState(() {
|
||||
_selectedIndex = index;
|
||||
});
|
||||
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(builder: (context) => pages.elementAt(index)),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BottomNavigationBar(
|
||||
type: BottomNavigationBarType.fixed,
|
||||
backgroundColor: Colors.red,
|
||||
selectedItemColor: Colors.black,
|
||||
unselectedItemColor: Colors.black54,
|
||||
items: const <BottomNavigationBarItem>[
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.shopping_cart),
|
||||
label: 'Buy',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.attach_money),
|
||||
label: 'Sell',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.person),
|
||||
label: 'Profile',
|
||||
),
|
||||
BottomNavigationBarItem(
|
||||
icon: Icon(Icons.settings),
|
||||
label: 'Settings',
|
||||
),
|
||||
],
|
||||
currentIndex: _selectedIndex,
|
||||
onTap: _onItemTapped,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user