Skip to content

Commit

Permalink
Add bottom navbar to secondary page and fix profile routing
Browse files Browse the repository at this point in the history
  • Loading branch information
Process-ing committed Jan 18, 2024
1 parent 15686f6 commit 95bb8bf
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 18 deletions.
9 changes: 9 additions & 0 deletions uni/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,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/useful_info/useful_info.dart';
Expand Down Expand Up @@ -242,6 +244,13 @@ class ApplicationState extends State<Application> {
page: const UsefulInfoPageView(),
settings: settings,
),
'/${DrawerItem.navProfile.title}':
MaterialPageRoute<ProfilePageView>(
builder: (__) => const ProfilePageView(),
),
'/${DrawerItem.navSettings.title}': MaterialPageRoute<SettingsPage>(
builder: (_) => const SettingsPage(),
),
};
return transitions[settings.name];
},
Expand Down
4 changes: 3 additions & 1 deletion uni/lib/utils/drawer_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ enum DrawerItem {
navRestaurants('restaurantes'),
navCalendar('calendario'),
navLibrary('biblioteca', faculties: {'feup'}),
navUsefulInfo('uteis', faculties: {'feup'});
navUsefulInfo('uteis', faculties: {'feup'}),
navProfile('perfil'),
navSettings('definicoes');

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

Expand Down
5 changes: 1 addition & 4 deletions uni/lib/utils/navbar_items.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ enum NavbarItem {
Icons.school_outlined,
['horario', 'exames', 'cadeiras'],
),
navTransports(
Icons.directions_bus_filled_outlined,
['autocarros']
),
navTransports(Icons.directions_bus_filled_outlined, ['autocarros']),
navFaculty(
Icons.domain_outlined,
['locais', 'biblioteca', 'uteis'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:uni/model/providers/startup/session_provider.dart';
import 'package:uni/utils/drawer_items.dart';
import 'package:uni/view/common_widgets/pages_layouts/general/widgets/bottom_navigation_bar.dart';
import 'package:uni/view/common_widgets/pages_layouts/general/widgets/navigation_drawer.dart';
import 'package:uni/view/profile/profile.dart';

/// Page with a hamburger menu and the user profile picture
abstract class GeneralPageViewState<T extends StatefulWidget> extends State<T> {
Expand Down Expand Up @@ -187,11 +186,9 @@ abstract class GeneralPageViewState<T extends StatefulWidget> extends State<T> {
) {
return TextButton(
onPressed: () => {
Navigator.push(
Navigator.pushNamed(
context,
MaterialPageRoute<ProfilePageView>(
builder: (__) => const ProfilePageView(),
),
'/${DrawerItem.navProfile.title}',
),
},
child: Container(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,16 @@ class AppBottomNavbarState extends State<AppBottomNavbar> {
final currentIndex = _getCurrentIndex();
return BottomNavigationBar(
items: navbarItems,
type: currentIndex == -1 ? BottomNavigationBarType.fixed
: BottomNavigationBarType.shifting,
onTap: _onItemTapped,
currentIndex: currentIndex == -1 ? 0 : currentIndex,
type: BottomNavigationBarType.fixed,
iconSize: 32,
selectedItemColor: currentIndex == -1
? Theme.of(context).colorScheme.onSurface
: Theme.of(context).primaryColor,
unselectedItemColor: Theme.of(context).colorScheme.onSurface,
showSelectedLabels: false,
showUnselectedLabels: false,
onTap: _onItemTapped,
);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:uni/view/common_widgets/pages_layouts/general/general.dart';
import 'package:uni/view/common_widgets/pages_layouts/general/widgets/bottom_navigation_bar.dart';

/// Page with a back button on top
abstract class SecondaryPageViewState<T extends StatefulWidget>
Expand All @@ -8,6 +9,9 @@ abstract class SecondaryPageViewState<T extends StatefulWidget>
Scaffold getScaffold(BuildContext context, Widget body) {
return Scaffold(
appBar: buildAppBar(context),
bottomNavigationBar: AppBottomNavbar(
parentContext: context,
),
body: refreshState(context, body),
);
}
Expand Down
8 changes: 3 additions & 5 deletions uni/lib/view/profile/profile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import 'package:flutter/material.dart';
import 'package:provider/provider.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/view/common_widgets/pages_layouts/secondary/secondary.dart';
import 'package:uni/view/lazy_consumer.dart';
import 'package:uni/view/profile/widgets/account_info_card.dart';
import 'package:uni/view/profile/widgets/course_info_card.dart';
import 'package:uni/view/profile/widgets/print_info_card.dart';
import 'package:uni/view/profile/widgets/profile_overview.dart';
import 'package:uni/view/settings/settings.dart';

class ProfilePageView extends StatefulWidget {
const ProfilePageView({super.key});
Expand Down Expand Up @@ -60,11 +60,9 @@ class ProfilePageViewState extends SecondaryPageViewState<ProfilePageView> {
padding: const EdgeInsets.fromLTRB(0, 10, 20, 10),
child: IconButton(
icon: const Icon(Icons.settings),
onPressed: () => Navigator.push(
onPressed: () => Navigator.pushNamed(
context,
MaterialPageRoute<SettingsPage>(
builder: (_) => const SettingsPage(),
),
'/${DrawerItem.navSettings.title}',
),
),
);
Expand Down

0 comments on commit 95bb8bf

Please sign in to comment.