mirror of
https://github.com/SoPat712/RUSwipeShare.git
synced 2025-08-22 03:18:44 -04:00
This commit is contained in:
148
lib/home.dart
148
lib/home.dart
@@ -1,72 +1,94 @@
|
|||||||
import 'package:firebase_auth/firebase_auth.dart';
|
|
||||||
import 'package:ruswipeshare/main.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:persistent_bottom_nav_bar/persistent_tab_view.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatelessWidget {
|
import 'main_screen.dart';
|
||||||
const HomeScreen({super.key});
|
|
||||||
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return PersistentTabView(
|
||||||
appBar: AppBar(
|
context,
|
||||||
title: const Text('FlutterFire UI'),
|
controller: _controller,
|
||||||
),
|
screens: _buildScreens(),
|
||||||
body: Center(
|
items: _navBarsItems(),
|
||||||
child: Column(
|
confineInSafeArea: true,
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
backgroundColor: Colors.white, // Default is Colors.white.
|
||||||
children: [
|
handleAndroidBackButtonPress: true, // Default is true.
|
||||||
const Text('You are logged in!'),
|
resizeToAvoidBottomInset: true, // This needs to be true if you want to move up the screen when keyboard appears. Default is true.
|
||||||
ElevatedButton(
|
stateManagement: true, // Default is true.
|
||||||
onPressed: () {
|
hideNavigationBarWhenKeyboardShows: true, // Recommended to set 'resizeToAvoidBottomInset' as true while using this argument. Default is true.
|
||||||
FirebaseAuth.instance.signOut();
|
decoration: NavBarDecoration(
|
||||||
},
|
borderRadius: BorderRadius.circular(10.0),
|
||||||
child: const Text('Sign out'),
|
colorBehindNavBar: Colors.white,
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
popAllScreensOnTapOfSelectedTab: true,
|
||||||
bottomNavigationBar: MyNavBar(),
|
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.
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// class _HomeScreenState extends State<HomeScreen> {
|
|
||||||
// int _selectedIndex = 0;
|
|
||||||
|
|
||||||
// void _onItemTapped(int index) {
|
|
||||||
// if (_selectedIndex == index) return;
|
|
||||||
|
|
||||||
// setState(() {
|
|
||||||
// _selectedIndex = index;
|
|
||||||
// });
|
|
||||||
|
|
||||||
// Navigator.push(
|
|
||||||
// context,
|
|
||||||
// MaterialPageRoute(builder: (context) => pages.elementAt(index)),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @override
|
|
||||||
// Widget build(BuildContext context) {
|
|
||||||
// return Scaffold(
|
|
||||||
// appBar: AppBar(
|
|
||||||
// title: const Text('FlutterFire UI'),
|
|
||||||
// ),
|
|
||||||
// body: Center(
|
|
||||||
// child: Column(
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
// children: [
|
|
||||||
// const Text('You are logged in!'),
|
|
||||||
// ElevatedButton(
|
|
||||||
// onPressed: () {
|
|
||||||
// FirebaseAuth.instance.signOut();
|
|
||||||
// },
|
|
||||||
// child: const Text('Sign out'),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// bottomNavigationBar: const MyNavBar(),
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
106
lib/main.dart
106
lib/main.dart
@@ -1,87 +1,49 @@
|
|||||||
import 'package:firebase_core/firebase_core.dart';
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:firebase_ui_auth/firebase_ui_auth.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:ruswipeshare/home.dart';
|
|
||||||
import 'package:ruswipeshare/sell.dart';
|
|
||||||
|
|
||||||
import 'firebase_options.dart';
|
import 'firebase_options.dart';
|
||||||
import 'auth_gate.dart';
|
import 'auth_gate.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||||
|
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
}
|
}
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
class MyApp extends StatelessWidget {
|
||||||
const MyApp({super.key});
|
|
||||||
@override
|
const MyApp({super.key});
|
||||||
Widget build(BuildContext context) {
|
@override
|
||||||
return MaterialApp(
|
Widget build(BuildContext context) {
|
||||||
theme: ThemeData(
|
return MaterialApp(
|
||||||
primarySwatch: Colors.blue,
|
theme: ThemeData(
|
||||||
),
|
primarySwatch: CustomMaterialColor(200,61,61).mdColor,
|
||||||
home: const HomeScreen(),
|
),
|
||||||
);
|
home: const AuthGate(),
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
class MyNavBar extends StatefulWidget {
|
class CustomMaterialColor {
|
||||||
MyNavBar({super.key});
|
final int r;
|
||||||
|
final int g;
|
||||||
@override
|
final int b;
|
||||||
State<MyNavBar> createState() => MyNavBarState();
|
|
||||||
}
|
CustomMaterialColor(this.r, this.g, this.b);
|
||||||
|
|
||||||
class MyNavBarState extends State<MyNavBar> {
|
MaterialColor get mdColor {
|
||||||
final pages = [
|
Map<int, Color> color = {
|
||||||
const SellScreen(),
|
50: Color.fromRGBO(r, g, b, .1),
|
||||||
const SellScreen(),
|
100: Color.fromRGBO(r, g, b, .2),
|
||||||
];
|
200: Color.fromRGBO(r, g, b, .3),
|
||||||
|
300: Color.fromRGBO(r, g, b, .4),
|
||||||
int _selectedIndex = 0;
|
400: Color.fromRGBO(r, g, b, .5),
|
||||||
|
500: Color.fromRGBO(r, g, b, .6),
|
||||||
void _onItemTapped(int index) {
|
600: Color.fromRGBO(r, g, b, .7),
|
||||||
if (runtimeType == pages.elementAt(index).runtimeType) return;
|
700: Color.fromRGBO(r, g, b, .8),
|
||||||
|
800: Color.fromRGBO(r, g, b, .9),
|
||||||
setState(() {
|
900: Color.fromRGBO(r, g, b, 1),
|
||||||
_selectedIndex = index;
|
};
|
||||||
});
|
return MaterialColor(Color.fromRGBO(r, g, b, 1).value, color);
|
||||||
|
|
||||||
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,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
22
lib/main_screen.dart
Normal file
22
lib/main_screen.dart
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
|
class MainScreen extends StatefulWidget {
|
||||||
|
const MainScreen({ Key? key }) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_MainScreenState createState() => _MainScreenState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MainScreenState extends State<MainScreen> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
title: const Text("Main Screen"),
|
||||||
|
),
|
||||||
|
body: const Center(
|
||||||
|
child: Text("Main Screen"),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,18 +0,0 @@
|
|||||||
import 'package:firebase_auth/firebase_auth.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:ruswipeshare/home.dart';
|
|
||||||
import 'package:ruswipeshare/main.dart';
|
|
||||||
|
|
||||||
class SellScreen extends StatelessWidget {
|
|
||||||
const SellScreen({super.key});
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return Scaffold(
|
|
||||||
body: Center(
|
|
||||||
child: const Text("Hi"),
|
|
||||||
),
|
|
||||||
bottomNavigationBar: MyNavBar(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
34
pubspec.lock
34
pubspec.lock
@@ -201,30 +201,6 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.2.3+30"
|
version: "0.2.3+30"
|
||||||
firebase_ui_auth:
|
|
||||||
dependency: "direct main"
|
|
||||||
description:
|
|
||||||
name: firebase_ui_auth
|
|
||||||
sha256: "67b52b2f7d607355a07bae28d67f28e7b52a1e555a7f7cd1455f2e95be4d0816"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.14"
|
|
||||||
firebase_ui_localizations:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: firebase_ui_localizations
|
|
||||||
sha256: "8ab06ef14bbad6c2f8af63aa2995016996c205fd05db7912df18838a51d023e4"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.2.0"
|
|
||||||
firebase_ui_oauth:
|
|
||||||
dependency: transitive
|
|
||||||
description:
|
|
||||||
name: firebase_ui_oauth
|
|
||||||
sha256: "77faba56761198f57b8939e4a93ef6dbabc1b972a22ff90ec1033dcff981a071"
|
|
||||||
url: "https://pub.dev"
|
|
||||||
source: hosted
|
|
||||||
version: "1.1.14"
|
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@@ -302,7 +278,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.4.3+20"
|
version: "0.4.3+20"
|
||||||
google_sign_in:
|
google_sign_in:
|
||||||
dependency: "direct main"
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
name: google_sign_in
|
name: google_sign_in
|
||||||
sha256: "821f354c053d51a2d417b02d42532a19a6ea8057d2f9ebb8863c07d81c98aaf9"
|
sha256: "821f354c053d51a2d417b02d42532a19a6ea8057d2f9ebb8863c07d81c98aaf9"
|
||||||
@@ -429,6 +405,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
|
persistent_bottom_nav_bar:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: persistent_bottom_nav_bar
|
||||||
|
sha256: e2e031e3366fde01511e372a9a19d720a9b252bb456e5c8d77a30d7a4a2ddfb0
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.0.2"
|
||||||
petitparser:
|
petitparser:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@@ -38,9 +38,8 @@ dependencies:
|
|||||||
firebase_core: ^2.7.0
|
firebase_core: ^2.7.0
|
||||||
firebase_auth: ^4.2.9
|
firebase_auth: ^4.2.9
|
||||||
flutterfire_ui: ^0.4.3+20
|
flutterfire_ui: ^0.4.3+20
|
||||||
google_sign_in: ^5.4.4
|
|
||||||
flutter_dotenv: ^5.0.2
|
flutter_dotenv: ^5.0.2
|
||||||
firebase_ui_auth: ^1.1.14
|
persistent_bottom_nav_bar: any
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Reference in New Issue
Block a user