From faad5c81bc607013160ebc28e5558ddf5ef94666 Mon Sep 17 00:00:00 2001 From: HarryDeKat Date: Mon, 19 Jun 2023 17:25:11 +0200 Subject: [PATCH 1/2] Added average warnings --- lib/hive/extentions.dart | 7 +++++ lib/l10n/app_en.arb | 5 ++- lib/l10n/app_nl.arb | 5 ++- lib/screens/subjects.dart | 65 ++++++++++++++++++++++++++++++++++++++- lib/screens/year.dart | 10 +++++- 5 files changed, 88 insertions(+), 4 deletions(-) diff --git a/lib/hive/extentions.dart b/lib/hive/extentions.dart index 745e2a9..0f8b069 100755 --- a/lib/hive/extentions.dart +++ b/lib/hive/extentions.dart @@ -121,6 +121,13 @@ extension GradeCalculations on List { 100; } + ///This value give a rough estimate on how well you will be able to retain a sufficient mark. + /// + ///It calculates the minimun grade you will need to get in order to retain a sufficient average with the average weight. + double get sufficientSafety { + return getNewGrade(config.sufficientFrom, map((e) => e.weight).average); + } + Map getGradeFrequency() { Map gradefrequency = {}; for (var i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) { diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 98bc72c..eb8143a 100755 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -181,5 +181,8 @@ "showChangeInSubjectAverage": "Show change in subject average", "bugReport": "Suggestions and bugs", "bugReportExpl": "Make a suggestion or report a bug", - "monthlyAverage": "Monthly average" + "monthlyAverage": "Monthly average", + "sufficientSafety1": "With an average weight of ", + "sufficientSafety2": " you have to score a ", + "sufficientSafety3": " in order to get sufficient average" } \ No newline at end of file diff --git a/lib/l10n/app_nl.arb b/lib/l10n/app_nl.arb index cd14d3d..68c0ce3 100755 --- a/lib/l10n/app_nl.arb +++ b/lib/l10n/app_nl.arb @@ -181,5 +181,8 @@ "showChangeInSubjectAverage": "Toon verandering in het vak gemiddelde", "bugReport": "Suggesties en fouten", "bugReportExpl": "Maak een suggestie of rapporteer een fout", - "monthlyAverage": "Maandelijks gemiddelde" + "monthlyAverage": "Maandelijks gemiddelde", + "sufficientSafety1": "Bij een gemiddeld gewicht van ", + "sufficientSafety2": " moet je een ", + "sufficientSafety3": " halen om gemiddeld een voldoende te staan" } \ No newline at end of file diff --git a/lib/screens/subjects.dart b/lib/screens/subjects.dart index 00a4ad7..cef405e 100755 --- a/lib/screens/subjects.dart +++ b/lib/screens/subjects.dart @@ -1,3 +1,4 @@ +import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:carousel_slider/carousel_slider.dart'; @@ -44,7 +45,69 @@ class _SubjectsListView extends State { gradeString: e.grades.average.isNaN ? "-" : e.grades.average.toString(), ), - trailing: const Icon(Icons.navigate_next), + trailing: Wrap( + spacing: 8, + children: [ + if (e.grades.sufficientSafety > 1 && + e.grades.numericalGrades.isNotEmpty) + Tooltip( + triggerMode: TooltipTriggerMode.tap, + showDuration: const Duration(minutes: 60), + decoration: BoxDecoration( + border: Border.fromBorderSide(BorderSide( + color: Theme.of(context).colorScheme.outline, + width: 1)), + color: Theme.of(context).colorScheme.background, + borderRadius: + const BorderRadius.all(Radius.circular(4)), + ), + richMessage: TextSpan( + style: TextStyle( + color: + Theme.of(context).colorScheme.onBackground), + children: [ + TextSpan( + text: AppLocalizations.of(context)! + .sufficientSafety1), + TextSpan( + text: e.grades + .map((g) => g.weight) + .average + .displayNumber(decimalDigits: 2), + style: + const TextStyle(fontWeight: FontWeight.bold), + ), + TextSpan( + text: AppLocalizations.of(context)! + .sufficientSafety2), + TextSpan( + text: e.grades.sufficientSafety + .displayNumber(decimalDigits: 2), + style: const TextStyle( + fontWeight: FontWeight.bold)), + TextSpan( + text: AppLocalizations.of(context)! + .sufficientSafety3) + ]), + child: CircleAvatar( + backgroundColor: Colors.transparent, + foregroundColor: + Theme.of(context).colorScheme.onBackground, + child: Icon( + e.grades.sufficientSafety < config.sufficientFrom + ? Icons.info_outline + : Icons.warning_amber_outlined, + color: e.grades.sufficientSafety > e.grades.average + ? Theme.of(context).colorScheme.error + : null, + ), + )), + CircleAvatar( + backgroundColor: Colors.transparent, + foregroundColor: Theme.of(context).colorScheme.onBackground, + child: const Icon(Icons.navigate_next)), + ], + ), onTap: () { if (acP.schoolYear.grades.subjects .where((sub) => sub.id == e.id) diff --git a/lib/screens/year.dart b/lib/screens/year.dart index 7e7577d..9836caa 100755 --- a/lib/screens/year.dart +++ b/lib/screens/year.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart'; +import 'package:intl/intl.dart'; import 'package:silvio/widgets/announcements.dart'; import 'package:silvio/widgets/cards/list_test.dart'; import 'package:provider/provider.dart'; @@ -100,7 +101,14 @@ class _SchoolYearStatisticsView extends State { grades: grades, ), ))), - if (grades.numericalGrades.isNotEmpty) + if (grades.numericalGrades.isNotEmpty && + grades + .map((g) => DateTime.parse( + DateFormat('yyyy-MM-01').format(g.addedDate))) + .toList() + .unique() + .length > + 1) StaggeredGridTile.fit( crossAxisCellCount: 2, child: SilvioCard( From 6d51cdc7b44631b33a3a234147303c0944405733 Mon Sep 17 00:00:00 2001 From: HarryDeKat Date: Tue, 20 Jun 2023 19:42:14 +0200 Subject: [PATCH 2/2] Hotfix: "Continue" button missing after login --- lib/screens/settings.dart | 66 ++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/lib/screens/settings.dart b/lib/screens/settings.dart index 171370d..9eb380e 100755 --- a/lib/screens/settings.dart +++ b/lib/screens/settings.dart @@ -120,7 +120,7 @@ class _SettingsView extends State { onChanged: hasMaterialYou ? (bool value) { config.useMaterialYou = value; - config.save; + config.save(); setState(() {}); Silvio.of(context).update(); } @@ -620,43 +620,45 @@ class _PersonConfigCarouselState extends State { )))), ], ), - (widget.profiles.length > 1) + (widget.profiles.length > 1 || + widget.widgetsNextToIndicator.isNotEmpty) ? Center( child: SizedBox( height: 50, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: widget.profiles.map((entry) { - return InkWell( - onTap: () => controller.animateToPage( - duration: const Duration(milliseconds: 500), - curve: Curves.bounceInOut, - widget.profiles.indexWhere((widget) => - widget.hashCode == entry.hashCode)), - child: Container( - width: 8, - height: 8, - margin: const EdgeInsets.symmetric( - vertical: 6.0, horizontal: 4.0), - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Theme.of(context) - .colorScheme - .primary - .withOpacity(current == - widget.profiles.indexWhere( - (widget) => - widget.hashCode == - entry.hashCode) - ? 0.9 - : 0.4)), - ), - ); - }).toList(), - ), + if (widget.profiles.length > 1) + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: widget.profiles.map((entry) { + return InkWell( + onTap: () => controller.animateToPage( + duration: const Duration(milliseconds: 500), + curve: Curves.bounceInOut, + widget.profiles.indexWhere((widget) => + widget.hashCode == entry.hashCode)), + child: Container( + width: 8, + height: 8, + margin: const EdgeInsets.symmetric( + vertical: 6.0, horizontal: 4.0), + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Theme.of(context) + .colorScheme + .primary + .withOpacity(current == + widget.profiles.indexWhere( + (widget) => + widget.hashCode == + entry.hashCode) + ? 0.9 + : 0.4)), + ), + ); + }).toList(), + ), ...widget.widgetsNextToIndicator ], ),