Skip to content

Commit

Permalink
Release v1.9.5 (#1354)
Browse files Browse the repository at this point in the history
  • Loading branch information
DGoiana authored Oct 11, 2024
2 parents 7a51b5b + 5045832 commit cf96484
Show file tree
Hide file tree
Showing 13 changed files with 353 additions and 210 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class NotificationManager {
_localNotificationsPlugin.resolvePlatformSpecificImplementation<
AndroidFlutterLocalNotificationsPlugin>()!;
try {
final permissionGranted = await androidPlugin.requestPermission();
final permissionGranted =
await androidPlugin.requestNotificationsPermission();
if (permissionGranted != true) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ class PreferencesController {
static const String _favoriteRestaurants = 'favorite_restaurants';
static const String _filteredExamsTypes = 'filtered_exam_types';
static final List<String> _defaultFilteredExamTypes = Exam.displayedTypes;
static const String _semesterValue = 'semester_value';
static const String _schoolYearValue = 'school_year_value';

static final _statsToggleStreamController =
StreamController<bool>.broadcast();
Expand Down Expand Up @@ -261,4 +263,26 @@ class PreferencesController {
await prefs.setBool(_usageStatsToggleKey, value);
_statsToggleStreamController.add(value);
}

static Future<void> setSemesterValue(String? value) async {
await prefs.setString(_semesterValue, value ?? '');
if (value == null) {
await prefs.remove(_semesterValue);
}
}

static String? getSemesterValue() {
return prefs.getString(_semesterValue);
}

static Future<void> setSchoolYearValue(String? value) async {
await prefs.setString(_schoolYearValue, value ?? '');
if (value == null) {
await prefs.remove(_schoolYearValue);
}
}

static String? getSchoolYearValue() {
return prefs.getString(_schoolYearValue);
}
}
10 changes: 5 additions & 5 deletions packages/uni_app/lib/controller/parsers/parser_restaurants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import 'package:uni/model/entities/meal.dart';
import 'package:uni/model/entities/restaurant.dart';
import 'package:uni/model/utils/day_of_week.dart';

// ignore_for_file: avoid_dynamic_calls

/// Reads restaurants's menu from /feup/pt/CANTINA.EMENTASHOW
List<Restaurant> getRestaurantsFromHtml(Response response) {
final document = parse(response.body);
Expand Down Expand Up @@ -93,13 +91,15 @@ Restaurant getRestaurantFromGSheets(
response.body.indexOf('(') + 1,
response.body.lastIndexOf(')'),
);
final parsedJson = jsonDecode(jsonString);
final parsedJson =
jsonDecode(jsonString) as Map<String, Map<String, dynamic>>;

final mealsList = <Meal>[];

final format = DateFormat('d/M/y');
for (final row in parsedJson['table']['rows'] as List<dynamic>) {
final cellList = row['c'];
for (final row
in parsedJson['table']?['rows'] as List<Map<String, dynamic>>) {
final cellList = row['c'] as List<Map<String, dynamic>>;
if ((cellList[1]['v'] == 'Almoço' && isDinner) ||
(cellList[1]['v'] != 'Almoço' && !isDinner)) {
continue;
Expand Down
191 changes: 98 additions & 93 deletions packages/uni_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ 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';
import 'package:upgrader/upgrader.dart';
import 'package:workmanager/workmanager.dart';

SentryEvent? beforeSend(SentryEvent event) {
Expand Down Expand Up @@ -217,100 +218,104 @@ class ApplicationState extends State<Application> {
DeviceOrientation.portraitUp,
]);
return Consumer2<ThemeNotifier, LocaleNotifier>(
builder: (context, themeNotifier, localeNotifier, _) => MaterialApp(
title: 'uni',
builder: (context, themeNotifier, localeNotifier, _) => UpgradeAlert(
navigatorKey: Application.navigatorKey,
theme: applicationLightTheme,
darkTheme: applicationDarkTheme,
themeMode: themeNotifier.getTheme(),
locale: localeNotifier.getLocale().localeCode,
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
initialRoute: widget.initialRoute,
navigatorObservers: navigatorObservers,
onGenerateRoute: (settings) {
final transitions = {
'/${NavigationItem.navLogin.route}':
PageTransition.makePageTransition(
page: const LoginPageView(),
settings: settings,
),
'/${NavigationItem.navPersonalArea.route}':
PageTransition.makePageTransition(
page: const HomePageView(),
settings: settings,
),
'/${NavigationItem.navSchedule.route}':
PageTransition.makePageTransition(
page: SchedulePage(),
settings: settings,
),
'/${NavigationItem.navExams.route}':
PageTransition.makePageTransition(
page: const ExamsPageView(),
settings: settings,
),
'/${NavigationItem.navStops.route}':
PageTransition.makePageTransition(
page: const BusStopNextArrivalsPage(),
settings: settings,
),
'/${NavigationItem.navCourseUnits.route}':
PageTransition.makePageTransition(
page: const CourseUnitsPageView(),
settings: settings,
),
'/${NavigationItem.navLocations.route}':
PageTransition.makePageTransition(
page: const LocationsPage(),
settings: settings,
),
'/${NavigationItem.navRestaurants.route}':
PageTransition.makePageTransition(
page: const RestaurantPageView(),
settings: settings,
),
'/${NavigationItem.navCalendar.route}':
PageTransition.makePageTransition(
page: const CalendarPageView(),
settings: settings,
),
'/${NavigationItem.navLibrary.route}':
PageTransition.makePageTransition(
page: const LibraryPage(),
settings: settings,
),
'/${NavigationItem.navFaculty.route}':
PageTransition.makePageTransition(
page: const FacultyPageView(),
settings: settings,
),
'/${NavigationItem.navAcademicPath.route}':
PageTransition.makePageTransition(
page: const AcademicPathPageView(),
settings: settings,
),
'/${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];
},
showIgnore: false,
child: MaterialApp(
title: 'uni',
navigatorKey: Application.navigatorKey,
theme: applicationLightTheme,
darkTheme: applicationDarkTheme,
themeMode: themeNotifier.getTheme(),
locale: localeNotifier.getLocale().localeCode,
localizationsDelegates: const [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
initialRoute: widget.initialRoute,
navigatorObservers: navigatorObservers,
onGenerateRoute: (settings) {
final transitions = {
'/${NavigationItem.navLogin.route}':
PageTransition.makePageTransition(
page: const LoginPageView(),
settings: settings,
),
'/${NavigationItem.navPersonalArea.route}':
PageTransition.makePageTransition(
page: const HomePageView(),
settings: settings,
),
'/${NavigationItem.navSchedule.route}':
PageTransition.makePageTransition(
page: SchedulePage(),
settings: settings,
),
'/${NavigationItem.navExams.route}':
PageTransition.makePageTransition(
page: const ExamsPageView(),
settings: settings,
),
'/${NavigationItem.navStops.route}':
PageTransition.makePageTransition(
page: const BusStopNextArrivalsPage(),
settings: settings,
),
'/${NavigationItem.navCourseUnits.route}':
PageTransition.makePageTransition(
page: const CourseUnitsPageView(),
settings: settings,
),
'/${NavigationItem.navLocations.route}':
PageTransition.makePageTransition(
page: const LocationsPage(),
settings: settings,
),
'/${NavigationItem.navRestaurants.route}':
PageTransition.makePageTransition(
page: const RestaurantPageView(),
settings: settings,
),
'/${NavigationItem.navCalendar.route}':
PageTransition.makePageTransition(
page: const CalendarPageView(),
settings: settings,
),
'/${NavigationItem.navLibrary.route}':
PageTransition.makePageTransition(
page: const LibraryPage(),
settings: settings,
),
'/${NavigationItem.navFaculty.route}':
PageTransition.makePageTransition(
page: const FacultyPageView(),
settings: settings,
),
'/${NavigationItem.navAcademicPath.route}':
PageTransition.makePageTransition(
page: const AcademicPathPageView(),
settings: settings,
),
'/${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
21 changes: 14 additions & 7 deletions packages/uni_app/lib/model/entities/location.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ abstract class Location {

Map<String, dynamic> toMap({int? groupId});

// ignore_for_file: argument_type_not_assignable
static Location fromJSON(Map<String, dynamic> json, int floor) {
final args = json['args'] as Map<String, dynamic>;
switch (json['type']) {
Expand All @@ -69,23 +68,31 @@ abstract class Location {
case 'VENDING_MACHINE':
return VendingMachine(floor);
case 'ROOM':
return RoomLocation(floor, args['room']);
return RoomLocation(floor, args['room'].toString());
case 'SPECIAL_ROOM':
return SpecialRoomLocation(floor, args['room'], args['name']);
return SpecialRoomLocation(
floor,
args['room'].toString(),
args['name'].toString(),
);
case 'ROOMS':
return RoomGroupLocation(floor, args['firstRoom'], args['lastRoom']);
return RoomGroupLocation(
floor,
args['firstRoom'].toString(),
args['lastRoom'].toString(),
);
case 'ATM':
return Atm(floor);
case 'PRINTER':
return Printer(floor);
case 'RESTAURANT':
return RestaurantLocation(floor, args['name']);
return RestaurantLocation(floor, args['name'].toString());
case 'STORE':
return StoreLocation(floor, args['name']);
return StoreLocation(floor, args['name'].toString());
case 'WC':
return WcLocation(floor);
default:
return UnknownLocation(floor, json['type']);
return UnknownLocation(floor, json['type'].toString());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,11 @@ abstract class StateProviderNotifier<T> extends ChangeNotifier {
if (!context.mounted || _state != null) {
return;
}
await _loadFromStorage(context)
.then((value) => _loadFromRemoteFromContext(context));
await _loadFromStorage(context).then((value) {
if (context.mounted) {
_loadFromRemoteFromContext(context);
}
});
},
timeout: _lockTimeout,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ class RefreshState extends StatelessWidget {
ProfileProvider.fetchOrGetCachedProfilePicture(
Provider.of<SessionProvider>(context, listen: false).state!,
forceRetrieval: true,
).then((value) => onRefresh(context)),
).then((value) {
if (context.mounted) {
onRefresh(context);
}
}),
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: viewportConstraints.maxHeight,
Expand Down
5 changes: 4 additions & 1 deletion packages/uni_app/lib/view/common_widgets/toast_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ class ToastMessage {
context: context,
builder: (toastContext) {
Future.delayed(const Duration(milliseconds: 2000), () {
Navigator.of(toastContext).pop();
if (toastContext.mounted) {
Navigator.of(toastContext).pop();
}
});

return mToast;
},
);
Expand Down
Loading

0 comments on commit cf96484

Please sign in to comment.