Skip to content

Commit

Permalink
release: v1.9.7 (#1410)
Browse files Browse the repository at this point in the history
  • Loading branch information
limwa authored Dec 9, 2024
2 parents 549a43e + 2ab22e4 commit d432533
Show file tree
Hide file tree
Showing 64 changed files with 1,349 additions and 240 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
build/
*.bin
.flutter-plugins*
packages/uni_ui/pubspec.lock

# IDE files
.DS_Store
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
description = "A very basic flake";

inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};

outputs = { self, nixpkgs }:
let
system = "x86_64-linux";

pkgs = import nixpkgs {
inherit system;
config = {
allowUnfree = true;
android_sdk.accept_license = true;
};
};

androidComposition = pkgs.androidenv.composeAndroidPackages {
platformVersions = [ "31" "33" "34" ];
buildToolsVersions = [ "34.0.0" ];
includeNDK = true;
includeEmulator = true;
includeSystemImages = true;
};

androidSdk = androidComposition.androidsdk;
in {

devShell.${system} = pkgs.mkShell {
packages = with pkgs; [
flutter
jdk17
androidSdk
];

shellHook = ''
export ANDROID_HOME="${androidSdk}/libexec/android-sdk"
export JAVA_HOME="${pkgs.jdk17}"
'';
};
};
}
2 changes: 1 addition & 1 deletion packages/uni_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ To use the translation import `'package:uni/generated/l10n.dart'` and use `S.of(
For this project, we separate the code into *model, *view* and *controller*.
By making sure view-only components are clear from the rest of the code, we can assure safe reuse of widgets as well as separated testing and development.

![MVC Scheme](../readme-src/MVC.png "MVC Scheme")
![MVC Scheme](../../readme-src/MVC.png "MVC Scheme")

### Model
The *model* represents the entities that are used in the app, including the session, the classes, the exams. They should be generated from the controller's methods and passed to the view. The model should not contain logic, but only the data that is needed to display the information.
Expand Down
3 changes: 3 additions & 0 deletions packages/uni_app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ android {
"proguard-rules.pro"
)
}
debug {
applicationIdSuffix ".dev"
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions packages/uni_app/android/app/src/debug/res/values/string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">uni (dev)</string>
</resources>
8 changes: 5 additions & 3 deletions packages/uni_app/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
<application
android:label="uni"
<application
android:label="@string/app_name"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"
android:usesCleartextTraffic="true">
android:usesCleartextTraffic="true"
android:allowBackup="false"
>
<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
4 changes: 4 additions & 0 deletions packages/uni_app/android/app/src/main/res/values/string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">uni</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import 'package:logger/logger.dart';
import 'package:tuple/tuple.dart';
import 'package:uni/controller/background_workers/notifications.dart';
import 'package:workmanager/workmanager.dart';

/// This map contains the functions that a certain task type will run.
/// the bool is all functions that are ran by backgroundfetch in iOS
/// (they must not take any arguments, not checked)
const taskMap = {
'pt.up.fe.ni.uni.notificationworker':
Tuple2(NotificationManager.updateAndTriggerNotifications, true),
'pt.up.fe.ni.uni.notificationworker': (
NotificationManager.updateAndTriggerNotifications,
true
),
};

@pragma('vm:entry-point')
Expand All @@ -25,16 +26,16 @@ Future<void> workerStartCallback() async {
// by the iOS scheduler.
if (taskName == Workmanager.iOSBackgroundTask) {
taskMap.forEach((key, value) async {
if (value.item2) {
if (value.$2) {
Logger().d('''[$key]: Start executing job...''');
await value.item1();
await value.$1();
}
});
return true;
}
// try to keep the usage of this function BELOW +-30 seconds
// to not be punished by the scheduler in future runs.
await taskMap[taskName]!.item1();
await taskMap[taskName]!.$1();
} catch (err, st) {
Logger().e(
'Error while running $taskName job:',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:flutter/services.dart';
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:logger/logger.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:tuple/tuple.dart';
import 'package:uni/controller/background_workers/notifications/tuition_notification.dart';
import 'package:uni/controller/local_storage/notification_timeout_storage.dart';
import 'package:uni/controller/local_storage/preferences_controller.dart';
Expand All @@ -28,12 +27,12 @@ abstract class Notification {
String uniqueID;
Duration timeout;

Future<Tuple2<String, String>> buildNotificationContent(Session session);
Future<(String, String)> buildNotificationContent(Session session);

Future<bool> shouldDisplay(Session session);

void displayNotification(
Tuple2<String, String> content,
(String, String) content,
FlutterLocalNotificationsPlugin localNotificationsPlugin,
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
import 'package:tuple/tuple.dart';
import 'package:uni/controller/background_workers/notifications.dart';
import 'package:uni/controller/fetchers/fees_fetcher.dart';
import 'package:uni/controller/local_storage/preferences_controller.dart';
Expand All @@ -13,20 +12,20 @@ class TuitionNotification extends Notification {
late DateTime _dueDate;

@override
Future<Tuple2<String, String>> buildNotificationContent(
Future<(String, String)> buildNotificationContent(
Session session,
) async {
// We must add one day because the time limit is actually at 23:59 and
// not at 00:00 of the same day
if (_dueDate.add(const Duration(days: 1)).isBefore(DateTime.now())) {
final duration = DateTime.now().difference(_dueDate);
if (duration.inDays == 0) {
return const Tuple2(
return const (
'⚠️ Ainda não pagaste as propinas ⚠️',
'O prazo para pagar as propinas acabou ontem',
);
}
return Tuple2(
return (
'⚠️ Ainda não pagaste as propinas ⚠️',
duration.toFormattedString(
'Já passou {} desde a data limite',
Expand All @@ -36,12 +35,12 @@ class TuitionNotification extends Notification {
}
final duration = _dueDate.difference(DateTime.now());
if (duration.inDays == 0) {
return const Tuple2(
return const (
'O prazo limite para as propinas está a acabar',
'Hoje acaba o prazo para pagamento das propinas!',
);
}
return Tuple2(
return (
'O prazo limite para as propinas está a acabar',
duration.toFormattedString(
'Falta {} para a data limite',
Expand Down Expand Up @@ -72,7 +71,7 @@ class TuitionNotification extends Notification {

@override
void displayNotification(
Tuple2<String, String> content,
(String, String) content,
FlutterLocalNotificationsPlugin localNotificationsPlugin,
) {
const androidNotificationDetails = AndroidNotificationDetails(
Expand All @@ -95,8 +94,8 @@ class TuitionNotification extends Notification {

localNotificationsPlugin.show(
2,
content.item1,
content.item2,
content.$1,
content.$2,
notificationDetails,
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@ import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:http/http.dart' as http;
import 'package:http/http.dart';
import 'package:tuple/tuple.dart';
import 'package:uni/model/entities/library_occupation.dart';

/// Fetch the library occupation from Google Sheets
class LibraryOccupationFetcher {
String baseUrl = 'https://webapi.affluences.com/api/fillRate?';

static const List<Tuple2<String, int>> floorMaxSeats = [
Tuple2('BruV6IlujdwAe1', 72),
Tuple2('cEhyzJZvC5nHSr', 114),
Tuple2('iceVfgwZWaZRhV', 114),
Tuple2('1yLPz9X0CNsg27', 114),
Tuple2('keu1j5zERlQn90', 40),
Tuple2('bY7K1v43HiAq55', 90),
static const List<(String, int)> floorMaxSeats = [
('BruV6IlujdwAe1', 72),
('cEhyzJZvC5nHSr', 114),
('iceVfgwZWaZRhV', 114),
('1yLPz9X0CNsg27', 114),
('keu1j5zERlQn90', 40),
('bY7K1v43HiAq55', 90),
];

Future<LibraryOccupation> getLibraryOccupation() async {
Expand All @@ -26,19 +25,19 @@ class LibraryOccupationFetcher {
floorMaxSeats.mapIndexed((i, entry) async {
final url = Uri.parse(baseUrl).replace(
queryParameters: {
'token': entry.item1,
'token': entry.$1,
},
);

final response = await http.get(url);

final floorOccupation =
processFloorOccupation(response, entry.item2, i);
final floorOccupation = processFloorOccupation(response, entry.$2, i);

libraryOccupation.addFloor(floorOccupation);
}),
);

libraryOccupation.sortFloors();
return libraryOccupation;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AppUserDataDatabase extends AppDatabase<Profile> {
for (final keymap in data.keymapValues()) {
await insertInDatabase(
'userdata',
{'name': keymap.item1, 'value': keymap.item2},
{'name': keymap.$1, 'value': keymap.$2},
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'dart:convert';
import 'package:html/parser.dart';
import 'package:http/http.dart';
import 'package:intl/intl.dart';
import 'package:tuple/tuple.dart';
import 'package:uni/model/entities/meal.dart';
import 'package:uni/model/entities/restaurant.dart';
import 'package:uni/model/utils/day_of_week.dart';
Expand All @@ -18,15 +17,15 @@ List<Restaurant> getRestaurantsFromHtml(Response response) {
final restaurantsTuple = restaurantsHtml.map((restaurantHtml) {
final name = restaurantHtml.text;
final ref = restaurantHtml.attributes['href']?.replaceAll('#', '');
return Tuple2(ref ?? '', name);
return (ref ?? '', name);
}).toList();

// Get restaurant meals and create the Restaurant class
final restaurants = restaurantsTuple.map((restaurantTuple) {
final meals = <Meal>[];

final referenceA =
document.querySelector('a[name="${restaurantTuple.item1}"]');
document.querySelector('a[name="${restaurantTuple.$1}"]');
var next = referenceA?.nextElementSibling;

final format = DateFormat('d-M-y');
Expand Down Expand Up @@ -70,8 +69,8 @@ List<Restaurant> getRestaurantsFromHtml(Response response) {
}
return Restaurant(
null,
restaurantTuple.item2,
restaurantTuple.item1,
restaurantTuple.$2,
restaurantTuple.$1,
meals: meals,
);
}).toList();
Expand Down
22 changes: 18 additions & 4 deletions packages/uni_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ 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/navigation_items.dart';
import 'package:uni/view/about/about.dart';
import 'package:uni/view/academic_path/academic_path.dart';
import 'package:uni/view/bug_report/bug_report.dart';
import 'package:uni/view/bus_stop_next_arrivals/bus_stop_next_arrivals.dart';
import 'package:uni/view/calendar/calendar.dart';
import 'package:uni/view/common_widgets/page_transition.dart';
Expand Down Expand Up @@ -305,12 +307,24 @@ class ApplicationState extends State<Application> {
settings: settings,
),
'/${NavigationItem.navProfile.route}':
MaterialPageRoute<ProfilePageView>(
builder: (__) => const ProfilePageView(),
PageTransition.makePageTransition(
page: const ProfilePageView(),
settings: settings,
),
'/${NavigationItem.navSettings.route}':
MaterialPageRoute<SettingsPage>(
builder: (_) => const SettingsPage(),
PageTransition.makePageTransition(
page: const SettingsPage(),
settings: settings,
),
'/${NavigationItem.navBugreport.route}':
PageTransition.makePageTransition(
page: const BugReportPageView(),
settings: settings,
),
'/${NavigationItem.navAboutus.route}':
PageTransition.makePageTransition(
page: const AboutPageView(),
settings: settings,
),
};
return transitions[settings.name];
Expand Down
Loading

0 comments on commit d432533

Please sign in to comment.