Skip to content

Commit

Permalink
Added Feature prajapatihet#60
Browse files Browse the repository at this point in the history
  • Loading branch information
ezsarthak committed Oct 14, 2024
1 parent a22de28 commit 8715603
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 42 deletions.
2 changes: 1 addition & 1 deletion lib/cubit/auth/auth_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class AuthCubit extends Cubit<AuthState> {
emit(const AuthError("User with this credential already exists"));
} else {
print(e.code);
emit(AuthError(e.toString()));
emit(AuthError(e.code));
}
}
}
Expand Down
131 changes: 90 additions & 41 deletions lib/views/pages/main_home/homepage.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import 'package:custom_navigation_bar/custom_navigation_bar.dart';
import 'package:donorconnect/views/pages/main_home/bottom_nav.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../profile/profile_screen.dart';
import 'home_pages/home_screen.dart';

class HomePage extends StatefulWidget {
final token;
Expand All @@ -14,55 +17,101 @@ class HomePage extends StatefulWidget {
}

class _HomePageState extends State<HomePage> {
@override
void dispose() {
Get.delete<NavigationController>();
super.dispose();
}
// @override
// void dispose() {
// Get.delete<NavigationController>();
// super.dispose();
// }
// late ScrollController controller;
//
/// variables
int _currentIndex = 0;
//
// @override
// void initState() {
// super.initState();
// controller = ScrollController();
// }
//
// @override
// void dispose() {
// controller.dispose;
// super.dispose();
// }

@override
Widget build(BuildContext context) {
final controller = Get.put(NavigationController(widget.name ?? "No Name", widget.email!));
final PageController pageController = PageController(initialPage: 0);
final pages = [
const HomeScreen(),
const HomeScreen(),
const HomeScreen(),
ProfileScreen(
name: widget.name ?? "No Name",
userId: widget.email!,
),
];

return Scaffold(
bottomNavigationBar: Obx(
() => NavigationBar(
height: 70,
elevation: 3,
surfaceTintColor: Colors.blue,
selectedIndex: controller.selectedIndex.value,
onDestinationSelected: (index) {
controller.selectedIndex.value = index;
},
destinations: const [
NavigationDestination(
icon: Icon(Icons.home),
label: "Home",
bottomNavigationBar: CustomNavigationBar(
scaleFactor: 0.2,
strokeColor: Colors.blueGrey,
iconSize: 24,
elevation: 0,
backgroundColor: Colors.transparent,
selectedColor: Colors.blue,
unSelectedColor: Colors.blue.withOpacity(0.4),
isFloating: false,
currentIndex: _currentIndex,
scaleCurve: Curves.bounceOut,
bubbleCurve: Curves.easeInOut,
onTap: (int newIndex) {
setState(() {
_currentIndex = newIndex;
pageController.animateToPage(newIndex,
duration: const Duration(milliseconds: 500),
curve: Curves.fastOutSlowIn);
});
},
items: [
CustomNavigationBarItem(
icon: const Icon(Icons.home),
title: const Text(
"Home",
style: TextStyle(fontSize: 12),
),
NavigationDestination(
icon: Icon(Icons.search),
label: "Search",
),
NavigationDestination(
icon: Icon(Icons.event),
label: "Camps",
),
NavigationDestination(
icon: Icon(Icons.person),
label: "Profile",
),
],
),
),
CustomNavigationBarItem(
icon: const Icon(Icons.search),
title: const Text(
"Search",
style: TextStyle(fontSize: 12),
)),
CustomNavigationBarItem(
icon: const Icon(Icons.event),
title: const Text(
"Camps",
style: TextStyle(fontSize: 12),
)),
CustomNavigationBarItem(
icon: const Icon(Icons.person),
title: const Text(
"Profile",
style: TextStyle(fontSize: 12),
)),
],
),
body: Obx(
() => AnimatedSwitcher(
duration: const Duration(milliseconds: 800), // Duration of the fade effect
transitionBuilder: (Widget child, Animation<double> animation) {
return FadeTransition(opacity: animation, child: child);
body: PageView.builder(
controller: pageController,
onPageChanged: (int newIndex) {
setState(() {
_currentIndex = newIndex;
});
},
child: controller.getScreens()[controller.selectedIndex.value],
),
),
itemCount: 4,
itemBuilder: (BuildContext context, int index) {
return pages[index];
}),
);
}
}
8 changes: 8 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.0.8"
custom_navigation_bar:
dependency: "direct main"
description:
name: custom_navigation_bar
sha256: "2e00e138a1eba71c288aadbcd728f1f8caebf659b95b793aae08a9c0d70ca941"
url: "https://pub.dev"
source: hosted
version: "0.8.2"
equatable:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ dependencies:
equatable: ^2.0.5
firebase_storage: ^12.3.3
image_picker: ^1.1.2
custom_navigation_bar: ^0.8.2

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 8715603

Please sign in to comment.