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

Implementing HomePage #1442

Draft
wants to merge 43 commits into
base: ui/redesign
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
c47a6b8
beginning homepage
DGoiana Jan 14, 2025
99e94f9
Merge branch 'ui/redesign' into redesign/homepage
DGoiana Jan 19, 2025
ba8dc99
Merge branch 'ui/redesign' into redesign/homepage
DGoiana Jan 19, 2025
97d2bb8
adding some initial files
DGoiana Jan 19, 2025
05a11dd
adding exam card
DGoiana Jan 19, 2025
c7843c7
adding schedule card
DGoiana Jan 19, 2025
776b2dd
adding library card
DGoiana Jan 20, 2025
f28c551
adding calendar
DGoiana Jan 20, 2025
84c99e7
average bar implementation
DGoiana Aug 21, 2024
510194b
adding label string
DGoiana Oct 16, 2024
0c9df17
adding tooltip and removing text
DGoiana Dec 3, 2024
808184a
changing hardcoded text
DGoiana Jan 19, 2025
aa1c766
little error fix
DGoiana Jan 19, 2025
f498d75
Bump app version [no ci]
thePeras Jan 19, 2025
48a8c84
Fix navbar background not transparent
Process-ing Jan 22, 2025
45d13f5
Fix bottom navigation icons being too small
Process-ing Jan 22, 2025
b622b91
Fix misalignment of navbar icons
Process-ing Jan 22, 2025
ff5853b
Insert clarifying comments
Process-ing Jan 22, 2025
ea15333
starting edit
DGoiana Jan 27, 2025
7beb551
putting drag to work
DGoiana Jan 29, 2025
a7a5936
Merge branch 'ui/redesign' into redesign/homepage
DGoiana Jan 29, 2025
ae7978f
adding drop feedback
DGoiana Jan 29, 2025
29d6b0b
adding another drop feedback
DGoiana Jan 29, 2025
dafed17
integrating local storage to keep favorites' state
DGoiana Jan 31, 2025
847984a
fixing edit icon
DGoiana Feb 3, 2025
b674e73
adding next class logic (to test)
DGoiana Feb 3, 2025
6734022
adding icons to uniIcons
DGoiana Feb 3, 2025
f2343dd
changing drag and drop logic
DGoiana Feb 3, 2025
201aedc
merging
DGoiana Feb 6, 2025
f68aa6e
adding restaurant card
DGoiana Feb 9, 2025
616cb61
removing mock lectures
DGoiana Feb 10, 2025
942c9b4
finishing restaurant card slider
DGoiana Feb 11, 2025
f892167
Merge branch 'ui/redesign' into redesign/homepage
DGoiana Feb 11, 2025
1152785
adding onclicks to appropriate cards
DGoiana Feb 11, 2025
ff70105
deleting unused code
DGoiana Feb 11, 2025
6d5a811
correcting code
DGoiana Feb 11, 2025
54976e3
Merge branch 'ui/redesign' into redesign/homepage
DGoiana Feb 25, 2025
8739421
changing lectures acronym and events date
DGoiana Feb 27, 2025
1095517
disabling calendar card
DGoiana Feb 27, 2025
9b11f3b
fixing overflow in restaurant card
DGoiana Feb 28, 2025
e87805c
fixing top appbar
DGoiana Feb 28, 2025
b12d80b
fixing exam timeline
DGoiana Feb 28, 2025
c3c261f
fixing theme imports
DGoiana Feb 28, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ class PreferencesController {
static const String _locale = 'app_locale';
static const String _lastCacheCleanUpDate = 'last_clean';
static const String _favoriteCards = 'favorite_cards';
static final List<FavoriteWidgetType> _defaultFavoriteCards = [
static final List<FavoriteWidgetType> _homeDefaultcards = [
FavoriteWidgetType.schedule,
FavoriteWidgetType.exams,
FavoriteWidgetType.busStops,
];
static const String _hiddenExams = 'hidden_exams';
static const String _favoriteRestaurants = 'favorite_restaurants';
Expand Down Expand Up @@ -173,31 +172,26 @@ class PreferencesController {
await _secureStorage.delete(key: _userSession);
}

/// Replaces the user's favorite widgets with [newFavorites].
static Future<void> saveFavoriteCards(
List<FavoriteWidgetType> newFavorites,
) async {
await prefs.setStringList(
_favoriteCards,
newFavorites.map((a) => a.index.toString()).toList(),
newFavorites.map((elem) => elem.name).toList(),
);
}

/// Returns a list containing the user's favorite widgets.
static List<FavoriteWidgetType> getFavoriteCards() {
final storedFavorites = prefs
.getStringList(_favoriteCards)
?.where(
(element) => int.parse(element) < FavoriteWidgetType.values.length,
)
.toList();
final storedFavorites = prefs.getStringList(_favoriteCards);

if (storedFavorites == null) {
return _defaultFavoriteCards;
return _homeDefaultcards;
}

return storedFavorites
.map((i) => FavoriteWidgetType.values[int.parse(i)])
.map(
(elem) => FavoriteWidgetType.values.firstWhere((e) => e.name == elem),
)
.toList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Future<List<Lecture>> parseSchedule(

final lec = Lecture.fromApi(
'',
subject,
_filterSubjectName(subject),
typeClass,
startTime,
blocks,
Expand All @@ -78,3 +78,8 @@ Future<List<Lecture>> parseSchedule(

return lectures.toList()..sort((a, b) => a.compare(b));
}

String _filterSubjectName(String subject) {
return RegExp(r' - ([^()]*)(?: \(|$)').firstMatch(subject)?.group(1) ??
subject;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ List<Lecture> getLecturesFromApiResponse(
.map(
(lecture) => Lecture(
lecture.units.first.acronym,
lecture.units.first.name,
_filterSubjectName(lecture.units.first.name),
lecture.typology.acronym,
lecture.start,
lecture.end,
Expand All @@ -45,3 +45,8 @@ List<Lecture> getLecturesFromApiResponse(
)
.toList();
}

String _filterSubjectName(String subject) {
return RegExp(r' - ([^()]*)(?: \(|$)').firstMatch(subject)?.group(1) ??
subject;
}
6 changes: 6 additions & 0 deletions packages/uni_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import 'package:uni/view/common_widgets/page_transition.dart';
import 'package:uni/view/course_units/course_units.dart';
import 'package:uni/view/exams/exams.dart';
import 'package:uni/view/faculty/faculty.dart';
import 'package:uni/view/home/edit_home.dart';
import 'package:uni/view/home/home.dart';
import 'package:uni/view/library/library.dart';
import 'package:uni/view/locale_notifier.dart';
Expand Down Expand Up @@ -248,6 +249,11 @@ class ApplicationState extends State<Application> {
page: const SplashScreenView(),
settings: settings,
),
'/${NavigationItem.navEditPersonalArea.route}':
PageTransition.splashTransitionRoute(
page: const EditHomeView(),
settings: settings,
),
'/${NavigationItem.navLogin.route}':
PageTransition.splashTransitionRoute(
page: const LoginPageView(),
Expand Down
22 changes: 1 addition & 21 deletions packages/uni_app/lib/utils/favorite_widget_type.dart
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
enum FavoriteWidgetType {
exams,
schedule,
printBalance,
account,
libraryOccupation(faculties: {'feup'}),
busStops,
restaurant;

const FavoriteWidgetType({this.faculties});

final Set<String>? faculties;

bool isVisible(List<String> userFaculties) {
if (faculties == null) {
return true;
}

return userFaculties.any((element) => faculties!.contains(element));
}
}
enum FavoriteWidgetType { schedule, exams, library, restaurants }
1 change: 1 addition & 0 deletions packages/uni_app/lib/utils/navigation_items.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
enum NavigationItem {
navEditPersonalArea('edit'),
navPersonalArea('area'),
navSchedule('horario'),
navExams('exames'),
Expand Down
3 changes: 1 addition & 2 deletions packages/uni_app/lib/view/academic_path/exam_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:uni/view/lazy_consumer.dart';
import 'package:uni/view/locale_notifier.dart';
import 'package:uni_ui/cards/exam_card.dart';
import 'package:uni_ui/cards/timeline_card.dart';
import 'package:uni_ui/theme.dart';
import 'package:uni_ui/timeline/timeline.dart';

class ExamsPage extends StatefulWidget {
Expand Down Expand Up @@ -71,7 +70,7 @@ class _ExamsPageState extends State<ExamsPage> {
Provider.of<LocaleNotifier>(context).getLocale(),
)
.capitalize(),
style: lightTheme.textTheme.headlineLarge,
style: Theme.of(context).textTheme.headlineLarge,
),
),
ListView.builder(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ScheduleDayTimeline extends StatelessWidget {
subtitle: DateFormat('HH:mm').format(lecture.endTime),
card: ScheduleCard(
isActive: _isLectureActive(lecture),
name: _filterSubjectName(lecture.subject),
name: lecture.subject,
acronym: lecture.acronym,
room: lecture.room,
type: lecture.typeClass,
Expand All @@ -59,12 +59,6 @@ class ScheduleDayTimeline extends StatelessWidget {
.toList();
}

// maybe should be changed to the backend, just extract the filtered name directly
String _filterSubjectName(String subject) {
return RegExp(r' - ([^()]*)(?: \(|$)').firstMatch(subject)?.group(1) ??
subject;
}

bool _isLectureActive(Lecture lecture) {
return now.isAfter(lecture.startTime) && now.isBefore(lecture.endTime);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'package:uni/model/entities/course_units/course_unit_class.dart';
import 'package:uni/model/providers/startup/session_provider.dart';
import 'package:uni/utils/student_number_getter.dart';
import 'package:uni/view/course_unit_info/widgets/course_unit_student_tile.dart';
import 'package:uni_ui/theme.dart';

class CourseUnitClassesView extends StatefulWidget {
const CourseUnitClassesView(this.classes, {super.key});
Expand Down Expand Up @@ -108,8 +107,8 @@ class _CourseUnitClassesViewState extends State<CourseUnitClassesView> {
const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
decoration: BoxDecoration(
color: isSelected
? lightTheme.colorScheme.primary
: lightTheme.colorScheme.secondary,
? Theme.of(context).colorScheme.primary
: Theme.of(context).colorScheme.secondary,
borderRadius: BorderRadius.circular(25),
boxShadow: [
BoxShadow(
Expand All @@ -130,10 +129,10 @@ class _CourseUnitClassesViewState extends State<CourseUnitClassesView> {
? '${courseUnitClass.className} *'
: courseUnitClass.className,
style: isSelected
? lightTheme.textTheme.labelMedium?.copyWith(
color: lightTheme.colorScheme.onPrimary,
)
: lightTheme.textTheme.labelMedium,
? Theme.of(context).textTheme.labelMedium?.copyWith(
color: Theme.of(context).colorScheme.onPrimary,
)
: Theme.of(context).textTheme.labelMedium,
textAlign: TextAlign.center,
maxLines: 1,
overflow: TextOverflow.ellipsis,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter/material.dart';
import 'package:uni/model/entities/course_units/course_unit_class.dart';
import 'package:uni/model/providers/startup/profile_provider.dart';
import 'package:uni/session/flows/base/session.dart';
import 'package:uni_ui/theme.dart';

class CourseUnitStudentTile extends StatelessWidget {
const CourseUnitStudentTile(this.student, this.session, {super.key});
Expand Down Expand Up @@ -59,17 +58,17 @@ class CourseUnitStudentTile extends StatelessWidget {
Text(
firstName,
overflow: TextOverflow.fade,
style: lightTheme.textTheme.titleLarge?.copyWith(
color: grayText,
),
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: const Color.fromARGB(255, 48, 48, 48),
),
textAlign: TextAlign.center,
),
Text(
lastName,
overflow: TextOverflow.ellipsis,
style: lightTheme.textTheme.titleLarge?.copyWith(
color: grayText,
),
style: Theme.of(context).textTheme.titleLarge?.copyWith(
color: const Color.fromARGB(255, 48, 48, 48),
),
textAlign: TextAlign.center,
),
],
Expand Down
Loading