Skip to content

Commit

Permalink
Merge pull request #120 from CosmicRaptor/main
Browse files Browse the repository at this point in the history
Improved the logic of the bottom nav bar.
  • Loading branch information
CosmicRaptor authored Jun 12, 2024
2 parents 038c284 + 6eb3eb1 commit 55c916d
Show file tree
Hide file tree
Showing 4 changed files with 319 additions and 69 deletions.
8 changes: 7 additions & 1 deletion lib/new_ui/colors.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import 'dart:ui';

import 'package:flutter/material.dart';

const commonbgblack = Color(0xff18191b);
const cardcolorblue = Color(0xff0077b6);
const cardlightblue = Color(0xff90e0ef);
const cardlightblue = Color(0xff90e0ef);
// const commonbgwhite = Color(0xfff1f5f8);
const greencontainercolor = Color(0xff2e9d59);
//the red container uses a gradient, unsure of its start and end values
const darkTextFieldBgColor = Color(0xff323232);
118 changes: 66 additions & 52 deletions lib/new_ui/screens/home_screen/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,58 +90,72 @@ class _HomeScreenState extends ConsumerState<HomeScreen> {
showUnselectedLabels: false,
unselectedItemColor: Colors.white,
selectedItemColor: Colors.white,
items: user.isStudent
? [
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
activeIcon: Icon(Icons.home),
icon: Icon(Icons.home_outlined),
label: "Home",
),
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
icon: Icon(Icons.people_outline),
activeIcon: Icon(Icons.people_rounded),
label: "Library",
),
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
activeIcon: Icon(Icons.calendar_today),
icon: Icon(Icons.calendar_today_outlined),
label: "Time Table",
),
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
icon: Icon(Icons.directions_railway_outlined),
activeIcon: Icon(Icons.directions_railway_filled),
label: "Railway",
),
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
icon: Icon(Icons.person_outline),
activeIcon: Icon(Icons.person),
label: "Profile",
),
]
: [
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
activeIcon: Icon(Icons.home),
icon: Icon(Icons.home_outlined),
label: "Home",
),
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
icon: Icon(Icons.people_outline),
activeIcon: Icon(Icons.people_rounded),
label: "Library",
),
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
icon: Icon(Icons.person_outline),
activeIcon: Icon(Icons.person),
label: "Profile",
),
items: [
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
activeIcon: Icon(Icons.home),
icon: Icon(Icons.home_outlined),
label: "Home",
),
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
icon: Icon(Icons.people_outline),
activeIcon: Icon(Icons.people_rounded),
label: "Library",
),
if(user.isStudent) ...[
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
activeIcon: Icon(Icons.calendar_today),
icon: Icon(Icons.calendar_today_outlined),
label: "Time Table",
),
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
icon: Icon(Icons.directions_railway_outlined),
activeIcon: Icon(Icons.directions_railway_filled),
label: "Railway",
),
],
BottomNavigationBarItem(
backgroundColor: Colors.transparent,
icon: Icon(Icons.person_outline),
activeIcon: Icon(Icons.person),
label: "Profile",
),
// BottomNavigationBarItem(
// backgroundColor: Colors.transparent,
// activeIcon: Icon(Icons.home),
// icon: Icon(Icons.home_outlined),
// label: "Home",
// ),
// BottomNavigationBarItem(
// backgroundColor: Colors.transparent,
// icon: Icon(Icons.people_outline),
// activeIcon: Icon(Icons.people_rounded),
// label: "Library",
// ),
// BottomNavigationBarItem(
// backgroundColor: Colors.transparent,
// activeIcon: Icon(Icons.calendar_today),
// icon: Icon(Icons.calendar_today_outlined),
// label: "Time Table",
// ),
// BottomNavigationBarItem(
// backgroundColor: Colors.transparent,
// icon: Icon(Icons.directions_railway_outlined),
// activeIcon: Icon(Icons.directions_railway_filled),
// label: "Railway",
// ),
// BottomNavigationBarItem(
// backgroundColor: Colors.transparent,
// icon: Icon(Icons.person_outline),
// activeIcon: Icon(Icons.person),
// label: "Profile",
// ),
// ]
// : [

],
currentIndex: widgetMap.keys.toList().indexOf(currentPage),
onTap: (index) {
Expand Down
89 changes: 73 additions & 16 deletions lib/new_ui/screens/main_screen/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:tsec_app/models/user_model/user_model.dart';
import 'package:tsec_app/new_ui/screens/erp_screen/erp_screen.dart';
import 'package:tsec_app/new_ui/screens/home_screen/home_screen.dart';
import 'package:tsec_app/new_ui/screens/home_screen/widgets/home_widget.dart';
import 'package:tsec_app/new_ui/screens/main_screen/widgets/main_bottom_nav_bar.dart';
import 'package:tsec_app/new_ui/screens/profile_screen/profile_screen.dart';
import 'package:tsec_app/new_ui/screens/railway_screen/railway_screen.dart';
import 'package:tsec_app/new_ui/screens/timetable_screen/timetable_screen.dart';
import 'package:tsec_app/provider/auth_provider.dart';
import 'package:tsec_app/provider/railway_concession_provider.dart';
import 'package:tsec_app/new_ui/screens/committees_screen/committees_screen.dart';
Expand All @@ -30,29 +36,70 @@ class _MainScreenState extends ConsumerState<MainScreen> {

String currentBottomNavPage = "home";
int currentPage = 0;
int currentDrawerPage = 0;

void _getIndex(int index){
setState(() {
print(index.toString());
currentPage = index;
});
}

late List<Widget> pages;
late Map<String, Widget> widgetMap;
@override
void initState() {
UserModel? user = ref.read(userModelProvider);
if (user != null && user.isStudent) {
widgetMap = {
"home": HomeWidget(
changeCurrentPage: (page) {
setState(() {
currentBottomNavPage = page;
});
},
),
"attendance": ERPScreen(),
"timetable": const TimeTable(),
"concession": const RailwayConcessionScreen(),
"profile": ProfilePage(
justLoggedIn: false,
)
};
} else {
widgetMap = {
"home": HomeWidget(
changeCurrentPage: (page) {
setState(() {
currentBottomNavPage = page;
});
},
),
"attendance": ERPScreen(),
"profile": ProfilePage(
justLoggedIn: false,
)
};
}
super.initState();
}

@override
Widget build(BuildContext context) {
pages = [
HomeScreen(
currentBottomNavPage: currentBottomNavPage,
changeCurrentBottomNavPage: (String page) {
HomeWidget(
changeCurrentPage: (page) {
setState(() {
currentBottomNavPage = page;
});
},
),
// Container(child: Text("TPC")),
ERPScreen(),
const TimeTable(),
const RailwayConcessionScreen(),
ProfilePage(justLoggedIn: false),
const TPCScreen(),
const CommitteesScreen(),
// Container(child: Text("Commi")),
// Container(),
const DepartmentListScreen(),
Container(),
// ProfilePage(
Expand All @@ -73,7 +120,7 @@ class _MainScreenState extends ConsumerState<MainScreen> {
// debugPrint("current page ${currentBottomNavPage} ${concessionOpen}");
return SafeArea(
child: Scaffold(
resizeToAvoidBottomInset: false,
resizeToAvoidBottomInset: true,
key: _scaffoldKey,
appBar: currentBottomNavPage != "concession" || !concessionOpen
? AppBar(
Expand Down Expand Up @@ -113,7 +160,7 @@ class _MainScreenState extends ConsumerState<MainScreen> {
Container(
padding: EdgeInsets.only(left: 10),
child: Text(
currentPage == 0
currentPage <5
? (currentBottomNavPage == "home"
? "Home"
: currentBottomNavPage == "attendance"
Expand All @@ -124,9 +171,9 @@ class _MainScreenState extends ConsumerState<MainScreen> {
"concession"
? "Railway Concession"
: "")
: currentPage == 1
: currentPage == 5
? "TPC"
: currentPage == 2
: currentPage == 6
? "Committees"
: "Departments",
style: Theme.of(context)
Expand Down Expand Up @@ -287,14 +334,14 @@ class _MainScreenState extends ConsumerState<MainScreen> {
.headlineSmall!
.copyWith(
fontSize: 22,
color: currentPage == 1
color: currentPage == 5
? Theme.of(context).colorScheme.onBackground
: Colors.white,
),
),
onTap: () {
setState(() {
currentPage = 1;
currentPage = 5;
});

Navigator.pop(context);
Expand All @@ -309,14 +356,14 @@ class _MainScreenState extends ConsumerState<MainScreen> {
.headlineSmall!
.copyWith(
fontSize: 22,
color: currentPage == 2
color: currentPage == 6
? Theme.of(context).colorScheme.onBackground
: Colors.white,
),
),
onTap: () {
setState(() {
currentPage = 2;
currentPage = 6;
});
Navigator.pop(context);
},
Expand All @@ -330,14 +377,14 @@ class _MainScreenState extends ConsumerState<MainScreen> {
.headlineMedium!
.copyWith(
fontSize: 22,
color: currentPage == 3
color: currentPage == 7
? Theme.of(context).colorScheme.onBackground
: Colors.white,
),
),
onTap: () {
setState(() {
currentPage = 3;
currentPage = 7;
});
Navigator.pop(context);
},
Expand Down Expand Up @@ -414,6 +461,16 @@ class _MainScreenState extends ConsumerState<MainScreen> {
),
)
: null,
bottomNavigationBar: MainBottomNavBar(
onTileTap: _getIndex,
currentBottomNavPage: currentBottomNavPage,
changeCurrentBottomNavPage: (String page) {
setState(() {
currentBottomNavPage = page;
// currentPage = widgetMap.keys.toList()[index]
});
},
),
body: pages[currentPage],
),
);
Expand Down
Loading

0 comments on commit 55c916d

Please sign in to comment.