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

Bottom navbar and new top navbar #902

Merged
merged 31 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
48d2b35
Add Navbar.
Process-ing Aug 8, 2023
dc44ad2
Run dart format.
Process-ing Aug 9, 2023
6a667f3
Change "Úteis" navbar item to "Faculdade".
Process-ing Aug 11, 2023
38772c3
Remove "Conta corrente" navbar item.
Process-ing Aug 11, 2023
70050be
Update bottom navbar design
Process-ing Jan 18, 2024
28426dc
Fix initial bottom bar layout
Process-ing Jan 18, 2024
80b2350
Add bottom navbar to secondary page and fix profile routing
Process-ing Jan 18, 2024
84f9598
Fix bottom navbar route handling
Process-ing Jan 18, 2024
90cc6a4
Refactor AppTopNavbar; Refactor home page top navbar
Process-ing Feb 3, 2024
8d169f8
Refactor other pages; Change bottom navbar layout
Process-ing Feb 3, 2024
09f7b45
Add calendar page to faculty bottom navbar button
Process-ing Feb 3, 2024
c7a0563
Refactor remaining pages
Process-ing Feb 3, 2024
753743a
Change select item color in bottom navbar
Process-ing Feb 5, 2024
4a40b55
Fix page routing on bottom navbar click
Process-ing Feb 5, 2024
51b93f5
Fix locations search bar positioning
Process-ing Feb 5, 2024
22ef10d
Remove AppNavigationDrawer
Process-ing Feb 5, 2024
e4f198b
Use PageTitle in AppTopNavbar
Process-ing Feb 7, 2024
21eca37
Refactor DrawerItem to NavigationItem
Process-ing Feb 7, 2024
8f769ee
Fix rebase
Process-ing Feb 7, 2024
900a89f
Fix padding on the buttons in top navbar
Process-ing Feb 7, 2024
161917b
Integrate academic and faculty pages
Process-ing Feb 8, 2024
3c538b9
Fix rebase
Process-ing Feb 8, 2024
e2186c6
Integrate transports page on bottom navbar
Process-ing Feb 8, 2024
63f9b15
Fix initial route; fix bottom navbar navigation
Process-ing Feb 8, 2024
be2887a
Convert bottom navbar to stateful widget
Process-ing Feb 9, 2024
5618e95
Use NavigationItem in NavbarItem.
Process-ing Feb 9, 2024
69261fd
Use navPersonalArea in the app initial route.
Process-ing Feb 9, 2024
8695ed6
Make navbar items filled when selected
Process-ing Feb 9, 2024
b200bff
Fix linter
Process-ing Feb 9, 2024
5f08afc
Change uni button to icon
Process-ing Feb 14, 2024
142741e
Fix linter
Process-ing Feb 15, 2024
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
39 changes: 26 additions & 13 deletions uni/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import 'package:uni/model/providers/plausible/plausible_provider.dart';
import 'package:uni/model/providers/startup/profile_provider.dart';
import 'package:uni/model/providers/startup/session_provider.dart';
import 'package:uni/model/providers/state_providers.dart';
import 'package:uni/utils/drawer_items.dart';
import 'package:uni/utils/navigation_items.dart';
import 'package:uni/view/academic_path/academic_path.dart';
import 'package:uni/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart';
import 'package:uni/view/calendar/calendar.dart';
Expand All @@ -42,8 +42,10 @@ import 'package:uni/view/library/library.dart';
import 'package:uni/view/locale_notifier.dart';
import 'package:uni/view/locations/locations.dart';
import 'package:uni/view/login/login.dart';
import 'package:uni/view/profile/profile.dart';
import 'package:uni/view/restaurant/restaurant_page_view.dart';
import 'package:uni/view/schedule/schedule.dart';
import 'package:uni/view/settings/settings.dart';
import 'package:uni/view/theme.dart';
import 'package:uni/view/theme_notifier.dart';
import 'package:uni/view/transports/transports.dart';
Expand Down Expand Up @@ -226,68 +228,79 @@ class ApplicationState extends State<Application> {
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
initialRoute: '/${NavigationItem.navPersonalArea.route}',
home: widget.initialWidget,
navigatorObservers: navigatorObservers,
onGenerateRoute: (RouteSettings settings) {
final transitions = {
'/${DrawerItem.navPersonalArea.title}':
'/${NavigationItem.navPersonalArea.route}':
PageTransition.makePageTransition(
page: const HomePageView(),
settings: settings,
),
'/${DrawerItem.navSchedule.title}':
'/${NavigationItem.navSchedule.route}':
PageTransition.makePageTransition(
page: const SchedulePage(),
settings: settings,
),
'/${DrawerItem.navExams.title}': PageTransition.makePageTransition(
'/${NavigationItem.navExams.route}':
PageTransition.makePageTransition(
page: const ExamsPageView(),
settings: settings,
),
'/${DrawerItem.navStops.title}': PageTransition.makePageTransition(
'/${NavigationItem.navStops.route}':
PageTransition.makePageTransition(
page: const BusStopNextArrivalsPage(),
settings: settings,
),
'/${DrawerItem.navCourseUnits.title}':
'/${NavigationItem.navCourseUnits.route}':
PageTransition.makePageTransition(
page: const CourseUnitsPageView(),
settings: settings,
),
'/${DrawerItem.navLocations.title}':
'/${NavigationItem.navLocations.route}':
PageTransition.makePageTransition(
page: const LocationsPage(),
settings: settings,
),
'/${DrawerItem.navRestaurants.title}':
'/${NavigationItem.navRestaurants.route}':
PageTransition.makePageTransition(
page: const RestaurantPageView(),
settings: settings,
),
'/${DrawerItem.navCalendar.title}':
'/${NavigationItem.navCalendar.route}':
PageTransition.makePageTransition(
page: const CalendarPageView(),
settings: settings,
),
'/${DrawerItem.navLibrary.title}':
'/${NavigationItem.navLibrary.route}':
PageTransition.makePageTransition(
page: const LibraryPage(),
settings: settings,
),
'/${DrawerItem.navFaculty.title}':
'/${NavigationItem.navFaculty.route}':
PageTransition.makePageTransition(
page: const FacultyPageView(),
settings: settings,
),
'/${DrawerItem.navAcademicPath.title}':
'/${NavigationItem.navAcademicPath.route}':
PageTransition.makePageTransition(
page: const AcademicPathPageView(),
settings: settings,
),
'/${DrawerItem.navTransports.title}':
'/${NavigationItem.navTransports.route}':
PageTransition.makePageTransition(
page: const TransportsPageView(),
settings: settings,
),
'/${NavigationItem.navProfile.route}':
MaterialPageRoute<ProfilePageView>(
builder: (__) => const ProfilePageView(),
),
'/${NavigationItem.navSettings.route}':
MaterialPageRoute<SettingsPage>(
builder: (_) => const SettingsPage(),
),
};
return transitions[settings.name];
},
Expand Down
46 changes: 46 additions & 0 deletions uni/lib/utils/navbar_items.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import 'package:flutter/material.dart';
import 'package:uni/utils/navigation_items.dart';

enum NavbarItem {
navPersonalArea(
Icons.home_outlined,
Icons.home,
NavigationItem.navPersonalArea,
),
navAcademicPath(
Icons.school_outlined,
Icons.school,
NavigationItem.navAcademicPath,
),
navRestaurants(
Icons.local_cafe_outlined,
Icons.local_cafe,
NavigationItem.navRestaurants,
),
navFaculty(Icons.domain_outlined, Icons.domain, NavigationItem.navFaculty),
navTransports(Icons.map_outlined, Icons.map, NavigationItem.navTransports);

const NavbarItem(this.unselectedIcon, this.selectedIcon, this.item);

final IconData unselectedIcon;
final IconData selectedIcon;
final NavigationItem item;

BottomNavigationBarItem toUnselectedBottomNavigationBarItem() {
return BottomNavigationBarItem(
icon: Icon(unselectedIcon),
label: '',
);
}

BottomNavigationBarItem toSelectedBottomNavigationBarItem() {
return BottomNavigationBarItem(
icon: Icon(selectedIcon),
label: '',
);
}

String get route {
return item.route;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
enum DrawerItem {
enum NavigationItem {
navPersonalArea('area'),
navSchedule('horario'),
navExams('exames'),
Expand All @@ -10,11 +10,13 @@ enum DrawerItem {
navLibrary('biblioteca', faculties: {'feup'}),
navFaculty('faculdade'),
navAcademicPath('percurso_academico'),
navProfile('perfil'),
navSettings('definicoes'),
navTransports('transportes');

const DrawerItem(this.title, {this.faculties});
const NavigationItem(this.route, {this.faculties});

final String title;
final String route;
final Set<String>? faculties;

bool isVisible(List<String> userFaculties) {
Expand Down
5 changes: 5 additions & 0 deletions uni/lib/view/about/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ class AboutPageViewState extends SecondaryPageViewState<AboutPageView> {

@override
Future<void> onRefresh(BuildContext context) async {}

@override
String? getTitle() {
return null;
}
}
12 changes: 1 addition & 11 deletions uni/lib/view/academic_path/academic_path.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import 'package:flutter/material.dart';
import 'package:uni/generated/l10n.dart';
import 'package:uni/utils/drawer_items.dart';
import 'package:uni/view/academic_path/widgets/course_units_card.dart';
import 'package:uni/view/common_widgets/generic_card.dart';
import 'package:uni/view/common_widgets/page_title.dart';
import 'package:uni/view/common_widgets/pages_layouts/general/general.dart';
import 'package:uni/view/home/widgets/exam_card.dart';
import 'package:uni/view/home/widgets/schedule_card.dart';
Expand All @@ -26,14 +23,7 @@ class AcademicPathPageViewState extends GeneralPageViewState {
@override
Widget getBody(BuildContext context) {
return ListView(
children: [
PageTitle(
name: S.of(context).nav_title(DrawerItem.navAcademicPath.title),
),
Column(
children: academicPathCards,
),
],
children: academicPathCards,
);
}

Expand Down
6 changes: 3 additions & 3 deletions uni/lib/view/academic_path/widgets/course_units_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'package:uni/generated/l10n.dart';
import 'package:uni/model/entities/course_units/course_unit.dart';
import 'package:uni/model/entities/profile.dart';
import 'package:uni/model/providers/startup/profile_provider.dart';
import 'package:uni/utils/drawer_items.dart';
import 'package:uni/utils/navigation_items.dart';
import 'package:uni/view/common_widgets/generic_card.dart';
import 'package:uni/view/course_units/widgets/course_unit_card.dart';
import 'package:uni/view/lazy_consumer.dart';
Expand Down Expand Up @@ -73,9 +73,9 @@ class CourseUnitsCard extends GenericCard {

@override
String getTitle(BuildContext context) =>
S.of(context).nav_title(DrawerItem.navCourseUnits.title);
S.of(context).nav_title(NavigationItem.navCourseUnits.route);

@override
Future<Object?> onClick(BuildContext context) =>
Navigator.pushNamed(context, '/${DrawerItem.navCourseUnits.title}');
Navigator.pushNamed(context, '/${NavigationItem.navCourseUnits.route}');
}
5 changes: 5 additions & 0 deletions uni/lib/view/bug_report/bug_report.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ class BugReportPageViewState extends SecondaryPageViewState<BugReportPageView> {

@override
Future<void> onRefresh(BuildContext context) async {}

@override
String? getTitle() {
return null;
}
}
16 changes: 6 additions & 10 deletions uni/lib/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import 'package:provider/provider.dart';
import 'package:uni/generated/l10n.dart';
import 'package:uni/model/entities/bus_stop.dart';
import 'package:uni/model/providers/lazy/bus_stop_provider.dart';
import 'package:uni/utils/drawer_items.dart';
import 'package:uni/utils/navigation_items.dart';
import 'package:uni/view/bus_stop_next_arrivals/widgets/bus_stop_row.dart';
import 'package:uni/view/bus_stop_selection/bus_stop_selection.dart';
import 'package:uni/view/common_widgets/expanded_image_label.dart';
import 'package:uni/view/common_widgets/last_update_timestamp.dart';
import 'package:uni/view/common_widgets/page_title.dart';
import 'package:uni/view/common_widgets/pages_layouts/general/general.dart';
import 'package:uni/view/common_widgets/pages_layouts/secondary/secondary.dart';
import 'package:uni/view/lazy_consumer.dart';

class BusStopNextArrivalsPage extends StatefulWidget {
Expand All @@ -23,18 +22,12 @@ class BusStopNextArrivalsPage extends StatefulWidget {

/// Manages the 'Bus arrivals' section inside the user's personal area
class BusStopNextArrivalsPageState
extends GeneralPageViewState<BusStopNextArrivalsPage> {
extends SecondaryPageViewState<BusStopNextArrivalsPage> {
@override
Widget getBody(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: [
Container(
padding: const EdgeInsets.only(bottom: 12),
child: PageTitle(
name: S.of(context).nav_title(DrawerItem.navStops.title),
),
),
Container(
padding: const EdgeInsets.all(8),
child: Row(
Expand Down Expand Up @@ -104,6 +97,9 @@ class BusStopNextArrivalsPageState
return Provider.of<BusStopProvider>(context, listen: false)
.forceRefresh(context);
}

@override
String? getTitle() => S.of(context).nav_title(NavigationItem.navStops.route);
}

class NextArrivals extends StatefulWidget {
Expand Down
5 changes: 3 additions & 2 deletions uni/lib/view/bus_stop_selection/bus_stop_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:uni/model/entities/bus_stop.dart';
import 'package:uni/model/providers/lazy/bus_stop_provider.dart';
import 'package:uni/view/bus_stop_selection/widgets/bus_stop_search.dart';
import 'package:uni/view/bus_stop_selection/widgets/bus_stop_selection_row.dart';
import 'package:uni/view/common_widgets/page_title.dart';
import 'package:uni/view/common_widgets/pages_layouts/secondary/secondary.dart';

class BusStopSelectionPage extends StatefulWidget {
Expand Down Expand Up @@ -49,7 +48,6 @@ class BusStopSelectionPageState
bottom: 20,
),
children: <Widget>[
PageTitle(name: S.of(context).configured_buses),
Container(
padding: const EdgeInsets.all(20),
child: Text(
Expand Down Expand Up @@ -85,4 +83,7 @@ class BusStopSelectionPageState

@override
Future<void> onRefresh(BuildContext context) async {}

@override
String? getTitle() => S.of(context).configured_buses;
}
Loading
Loading