Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Feature #60 #64

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 87 additions & 42 deletions lib/views/pages/main_home/homepage.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'package:donorconnect/language/helper/language_extention.dart';
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 @@ -15,58 +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 _text = context.localizedString;
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: [
NavigationDestination(
icon: const Icon(Icons.home),
label: _text.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(
),
CustomNavigationBarItem(
icon: const Icon(Icons.search),
label: _text.search,
),
NavigationDestination(
title: const Text(
"Search",
style: TextStyle(fontSize: 12),
)),
CustomNavigationBarItem(
icon: const Icon(Icons.event),
label: _text.camps,
),
NavigationDestination(
title: const Text(
"Camps",
style: TextStyle(fontSize: 12),
)),
CustomNavigationBarItem(
icon: const Icon(Icons.person),
label: _text.profile,
),
],
),
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];
}),
);
}
}
40 changes: 24 additions & 16 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,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"
dart_style:
dependency: transitive
description:
Expand Down Expand Up @@ -282,10 +290,10 @@ packages:
dependency: transitive
description:
name: file
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
sha256: a3b4f84adafef897088c160faf7dfffb7696046cb13ae90b508c2cbc95d3b8d4
url: "https://pub.dev"
source: hosted
version: "7.0.0"
version: "7.0.1"
file_selector_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -758,10 +766,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7"
sha256: c464428172cb986b758c6d1724c603097febb8fb855aa265aeecc9280c294d4a
url: "https://pub.dev"
source: hosted
version: "2.2.10"
version: "2.2.12"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -854,26 +862,26 @@ packages:
dependency: "direct main"
description:
name: shared_preferences
sha256: d3bbe5553a986e83980916ded2f0b435ef2e1893dfaa29d5a7a790d0eca12180
sha256: "746e5369a43170c25816cc472ee016d3a66bc13fcf430c0bc41ad7b4b2922051"
url: "https://pub.dev"
source: hosted
version: "2.2.3"
version: "2.3.2"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "1ee8bf911094a1b592de7ab29add6f826a7331fb854273d55918693d5364a1f2"
sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab"
url: "https://pub.dev"
source: hosted
version: "2.2.2"
version: "2.3.3"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: c4b35f6cb8f63c147312c054ce7c2254c8066745125264f0c88739c417fc9d9f
sha256: "07e050c7cd39bad516f8d64c455f04508d09df104be326d8c02551590a0d513d"
url: "https://pub.dev"
source: hosted
version: "2.5.2"
version: "2.5.3"
shared_preferences_linux:
dependency: transitive
description:
Expand All @@ -894,10 +902,10 @@ packages:
dependency: transitive
description:
name: shared_preferences_web
sha256: "59dc807b94d29d52ddbb1b3c0d3b9d0a67fc535a64e62a5542c8db0513fcb6c2"
sha256: d2ca4132d3946fec2184261726b355836a82c33d7d5b67af32692aff18a4684e
url: "https://pub.dev"
source: hosted
version: "2.4.1"
version: "2.4.2"
shared_preferences_windows:
dependency: transitive
description:
Expand Down Expand Up @@ -1019,10 +1027,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.4"
version: "14.2.5"
watcher:
dependency: transitive
description:
Expand Down Expand Up @@ -1059,10 +1067,10 @@ packages:
dependency: transitive
description:
name: xdg_directories
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
version: "1.1.0"
xml:
dependency: transitive
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
# riverpod: ^2.5.3
# riverpod_annotation: ^2.5.3
flutter_localizations:
Expand Down