Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #6 from HarryDeKat/development
Browse files Browse the repository at this point in the history
Custom subject names
Custom amount of decimal points for specific subjects
Option to disable warnings for an entire school years or just a specific subject
Decimals can now be entered correctly on iOS devices Bug - Komma is geen juiste invoer bij optie "voldoende grens" #5
Redesigned grade and test information sheets
The "Monthly average" graph is now also available for search statistics
Fixed a bug where a second date range filter could not be set
Grade calculation cards now show the difference between the new and current average when tapped on
  • Loading branch information
HarryDeKat authored Jun 29, 2023
2 parents 6c1a887 + 2b8e34a commit 628a77c
Show file tree
Hide file tree
Showing 26 changed files with 888 additions and 382 deletions.
1 change: 1 addition & 0 deletions lib/apis/magister.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:silvio/apis/abstact_api.dart';
import 'package:silvio/apis/account_manager.dart';
import 'package:silvio/hive/adapters.dart';
import 'package:silvio/hive/extentions.dart';
import 'package:silvio/main.dart';
import 'package:silvio/screens/post_login.dart';
import 'package:silvio/widgets/card.dart';
import 'package:silvio/widgets/facts_header.dart';
Expand Down
4 changes: 4 additions & 0 deletions lib/apis/magister/api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class MagisterApi extends Magister {
onError: (e, handler) async {
if (e.response?.data != null &&
e.response?.data["error"] == "invalid_grant") {
rootScaffoldMessengerKey.currentState?.removeCurrentSnackBar();
rootScaffoldMessengerKey.currentState?.showSnackBar(const SnackBar(
content: Text("No connection to Magister could be made"),
));
return handler.reject(DioException(
requestOptions: e.requestOptions,
error:
Expand Down
11 changes: 6 additions & 5 deletions lib/apis/magister/screens/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,14 @@ class FetchAccountInformation extends StatelessWidget {
future: account,
builder: (context, snapshot) {
if (snapshot.hasData) {
WidgetsBinding.instance.addPostFrameCallback((_) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Navigator.popUntil(context, (r) => r.isFirst);
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => GetGrades(account: snapshot.data!),
));});
context,
MaterialPageRoute(
builder: (context) => GetGrades(account: snapshot.data!),
));
});
} else if (snapshot.hasError) {
if (snapshot.error is Account) {
return Center(
Expand Down
19 changes: 10 additions & 9 deletions lib/apis/magister/screens/terms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ class _Terms extends State<Terms> {
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child:
Text.rich(TextSpan(
style: Theme.of(context).textTheme.headlineSmall,
children: <TextSpan>[
TextSpan(
text: AppLocalizations.of(context)!
.termsContent(company),
style: Theme.of(context).textTheme.bodyMedium)]),)
),
child: Text.rich(
TextSpan(
style: Theme.of(context).textTheme.headlineSmall,
children: <TextSpan>[
TextSpan(
text: AppLocalizations.of(context)!
.termsContent(company),
style: Theme.of(context).textTheme.bodyMedium)
]),
)),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expand Down
28 changes: 15 additions & 13 deletions lib/apis/magister/translate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Grade? magisterGrade(SchoolQuarter? schoolQuarter, [Map? gotGrade]) {
Subject? magisterSubject([Map? subject]) {
if (subject != null) {
return Subject(
code: subject["Afkorting"] ?? subject["code"],
rawCode: subject["Afkorting"] ?? subject["code"],
id: subject["Id"],
name: (subject["Omschrijving"] ??
rawName: (subject["Omschrijving"] ??
subject["omschrijving"] ??
subject["Naam"] ??
"leeg")
Expand Down Expand Up @@ -69,17 +69,19 @@ SchoolQuarter? magisterSchoolQuarter([Map? per]) {
SchoolYear? magisterSchoolYear([Map? year]) {
if (year != null) {
return SchoolYear(
start: DateTime.parse(
year["begin"] ?? "1970-01-01T00:00:00.0000000Z",
).toUtc(),
end: DateTime.parse(year["einde"] ?? "1970-01-01T00:00:00.0000000Z")
.toUtc(),
id: year["id"],
groupCode: year["groep"]["code"],
groupName: year["groep"]["omschrijving"],
studyCode: year["studie"]["code"],
isEnabled: year["isHoofdAanmelding"],
);
start: DateTime.parse(
year["begin"] ?? "1970-01-01T00:00:00.0000000Z",
).toUtc(),
end: DateTime.parse(year["einde"] ?? "1970-01-01T00:00:00.0000000Z")
.toUtc(),
id: year["id"],
groupCode: year["groep"]["code"],
groupName: year["groep"]["omschrijving"],
studyCode: year["studie"]["code"],
isEnabled: year["isHoofdAanmelding"],
warningEnabled: DateTime.now().isBefore(
DateTime.parse(year["einde"] ?? "1970-01-01T00:00:00.0000000Z")
.toUtc()));
}
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/apis/random.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ class RandomAccount implements Api {

Subject randomSubject() {
return Subject(
code: _generateRandomString(3),
name: _generateRandomString(6),
rawCode: _generateRandomString(3),
rawName: _generateRandomString(6),
id: random.nextInt(99999));
}

Expand Down
4 changes: 2 additions & 2 deletions lib/apis/somtoday/screens/terms.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class _Terms extends State<Terms> {
style: Theme.of(context).textTheme.headlineSmall,
children: <TextSpan>[
TextSpan(
text: AppLocalizations.of(context)!
.termsContent(company),
text:
AppLocalizations.of(context)!.termsContent(company),
style: Theme.of(context).textTheme.bodyMedium),
]))),
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
Expand Down
44 changes: 38 additions & 6 deletions lib/hive/adapters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ class Filter {
dynamic filter;
bool isGlobal;

Filter({required this.name, required this.type, required this.filter, this.isGlobal = false});
Filter(
{required this.name,
required this.type,
required this.filter,
this.isGlobal = false});
}

@HiveType(typeId: 7)
Expand Down Expand Up @@ -225,17 +229,42 @@ enum GradeType {
@HiveType(typeId: 9)
class Subject {
@HiveField(0)
String code;
String rawCode;
@HiveField(1)
String name;
String rawName;
String get code => customCode != null ? customCode! : rawCode;
String get name => customName != null ? customName! : rawName;
@HiveField(3)
String? customCode;
@HiveField(4)
String? customName;
@HiveField(2)
int? id;
@HiveField(5)
int? roundOnDecimals;
@HiveField(6, defaultValue: true)
bool warningEnabled;
List<Grade> grades = [];

Subject({required this.code, this.id, required this.name});
Subject(
{required this.rawCode,
this.id,
required this.rawName,
this.customCode,
this.customName,
this.warningEnabled = true,
this.roundOnDecimals});

Subject get copy {
return Subject(code: code, name: name, id: id)..grades = grades;
return Subject(
customCode: customCode,
customName: customName,
rawCode: rawCode,
rawName: rawName,
id: id,
warningEnabled: warningEnabled,
roundOnDecimals: roundOnDecimals)
..grades = grades;
}
}

Expand Down Expand Up @@ -281,6 +310,8 @@ class SchoolYear {
List<SchoolQuarter> schoolQuarters = [];
@HiveField(8)
bool isEnabled;
@HiveField(9, defaultValue: true)
bool warningEnabled;

SchoolYear(
{required this.start,
Expand All @@ -289,7 +320,8 @@ class SchoolYear {
required this.groupName,
required this.id,
this.isEnabled = true,
required this.studyCode});
required this.studyCode,
this.warningEnabled = true});
}

@HiveType(typeId: 12)
Expand Down
31 changes: 23 additions & 8 deletions lib/hive/adapters.g.dart

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

21 changes: 20 additions & 1 deletion lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,24 @@
"monthlyAverage": "Monthly average",
"sufficientSafety1": "With an average weight of ",
"sufficientSafety2": " you have to score a ",
"sufficientSafety3": " in order to get sufficient average"
"sufficientSafety3": " in order to get sufficient average",
"schoolYearSettings": "Schoolyear Settings",
"turnOnThisSchoolYear": "Turn this schoolyear on or off",
"avarageWarning": "Warning",
"avarageWarningExpl": "See warning icons in the subjects list when an average is not stable",
"subjectSettings": "Subject Settings",
"subjectName": "Subject name",
"subjectNameExpl": "Change the name of this subject",
"subjectNameShort": "Subject abbreviation",
"subjectNameShortExpl": "Change the abbreviation of this subject",
"avarageWarningExplSubject": "See a warning icon in the subjects list when this subject's average is not stable",
"decimals": "Decimals",
"decimalsExpl": "Set a specific amount of decimals for the average of this subject in the subjects list",
"information" : "Information",
"gradeAddedDate": "Added date",
"period": "Period",
"teacher": "Teacher",
"dateOfTest": "Date of the test",
"typeTest": "Type test",
"description": "Description"
}
21 changes: 20 additions & 1 deletion lib/l10n/app_nl.arb
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,24 @@
"monthlyAverage": "Maandelijks gemiddelde",
"sufficientSafety1": "Bij een gemiddeld gewicht van ",
"sufficientSafety2": " moet je een ",
"sufficientSafety3": " halen om gemiddeld een voldoende te staan"
"sufficientSafety3": " halen om gemiddeld een voldoende te staan",
"schoolYearSettings": "Schooljaar instellingen",
"turnOnThisSchoolYear": "Zet dit schooljaar aan of uit",
"avarageWarning": "Waarschuwing",
"avarageWarningExpl": "Zie waarschuwingspictogrammen in de vakkenlijst wanneer een gemiddelde niet stabiel is",
"subjectSettings": "Vak-specifieke instellingen",
"subjectName": "Vak naam",
"subjectNameExpl": "Verander de naam van dit vak",
"subjectNameShort": "Vak afkorting",
"subjectNameShortExpl": "Verander de afkorting van dit vak",
"avarageWarningExplSubject": "Zie een waarschuwingspictogram in de vakkenlijst wanneer het gemiddelde van dit vak niet stabiel is",
"decimals": "Decimalen",
"decimalsExpl": "Stel een bepaald aantal decimalen in voor het gemiddelde van dit vak in de vakkenlijst",
"information" : "Informatie",
"gradeAddedDate": "Datum van toevoeging",
"period": "Periode",
"teacher": "Docent",
"dateOfTest": "Datum van afname",
"typeTest": "Type toets",
"description": "Beschrijving"
}
13 changes: 13 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ void main() async {
BackgroundFetch.registerHeadlessTask(backgroundFetchHeadlessTask);
}

final GlobalKey<ScaffoldMessengerState> rootScaffoldMessengerKey =
GlobalKey<ScaffoldMessengerState>();

class Silvio extends StatefulWidget {
const Silvio({Key? key}) : super(key: key);

Expand Down Expand Up @@ -129,6 +132,15 @@ class SilvioState extends State<Silvio> {
brightness: useDarkMode ? Brightness.dark : Brightness.light,
colorScheme: colorScheme,
useMaterial3: true,
tooltipTheme: TooltipThemeData(
textStyle: TextStyle(color: colorScheme.onBackground),
decoration: BoxDecoration(
border: Border.fromBorderSide(
BorderSide(color: colorScheme.outline, width: 1)),
color: colorScheme.background,
borderRadius: const BorderRadius.all(Radius.circular(4)),
),
),
badgeTheme: BadgeThemeData(
textColor: colorScheme.onPrimaryContainer,
backgroundColor: colorScheme.primaryContainer));
Expand All @@ -137,6 +149,7 @@ class SilvioState extends State<Silvio> {
return ChangeNotifierProvider(
create: (context) => AccountProvider(),
child: MaterialApp(
scaffoldMessengerKey: rootScaffoldMessengerKey,
title: 'Silvio',
debugShowCheckedModeBanner: false,
localizationsDelegates: AppLocalizations.localizationsDelegates,
Expand Down
Loading

0 comments on commit 628a77c

Please sign in to comment.