forked from firka/student-legacy
fixed summary crash error
This commit is contained in:
parent
8e9713e436
commit
1f46a0509f
@ -37,8 +37,9 @@ class _PersonalityCardState extends State<PersonalityCard> {
|
|||||||
late List<Grade> classWorkGrades;
|
late List<Grade> classWorkGrades;
|
||||||
late Map<int, int> mostCommonGrade;
|
late Map<int, int> mostCommonGrade;
|
||||||
late List<Absence> absences = [];
|
late List<Absence> absences = [];
|
||||||
late List<Absence> delays = [];
|
|
||||||
final Map<Subject, Lesson> _lessonCount = {};
|
final Map<Subject, Lesson> _lessonCount = {};
|
||||||
|
late int totalDelays;
|
||||||
|
late int unexcusedAbsences;
|
||||||
|
|
||||||
late PersonalityType finalPersonality;
|
late PersonalityType finalPersonality;
|
||||||
|
|
||||||
@ -133,11 +134,19 @@ class _PersonalityCardState extends State<PersonalityCard> {
|
|||||||
|
|
||||||
void getAbsences() {
|
void getAbsences() {
|
||||||
absences = absenceProvider.absences.where((a) => a.delay == 0).toList();
|
absences = absenceProvider.absences.where((a) => a.delay == 0).toList();
|
||||||
|
|
||||||
|
unexcusedAbsences = absences
|
||||||
|
.where((a) => a.state == Justification.unexcused && a.delay == 0)
|
||||||
|
.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getAndSortDelays() {
|
void getAndSortDelays() {
|
||||||
delays = absenceProvider.absences;
|
Iterable<int> unexcusedDelays = absences
|
||||||
delays.sort((a, b) => -a.delay.compareTo(b.delay));
|
.where((a) => a.state == Justification.unexcused && a.delay > 0)
|
||||||
|
.map((e) => e.delay);
|
||||||
|
totalDelays = unexcusedDelays.isNotEmpty
|
||||||
|
? unexcusedDelays.reduce((a, b) => a + b)
|
||||||
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doEverything() {
|
void doEverything() {
|
||||||
@ -157,16 +166,9 @@ class _PersonalityCardState extends State<PersonalityCard> {
|
|||||||
finalPersonality = PersonalityType.fallible;
|
finalPersonality = PersonalityType.fallible;
|
||||||
} else if (absences.length < 10) {
|
} else if (absences.length < 10) {
|
||||||
finalPersonality = PersonalityType.healthy;
|
finalPersonality = PersonalityType.healthy;
|
||||||
} else if ((absences.where(
|
} else if (unexcusedAbsences >= 10) {
|
||||||
(a) => a.state == Justification.unexcused && a.delay == 0))
|
|
||||||
.length >=
|
|
||||||
10) {
|
|
||||||
finalPersonality = PersonalityType.quitter;
|
finalPersonality = PersonalityType.quitter;
|
||||||
} else if ((absences.where(
|
} else if (totalDelays > 50) {
|
||||||
(a) => a.state == Justification.unexcused && a.delay > 0))
|
|
||||||
.map((e) => e.delay)
|
|
||||||
.reduce((a, b) => a + b) >
|
|
||||||
50) {
|
|
||||||
finalPersonality = PersonalityType.late;
|
finalPersonality = PersonalityType.late;
|
||||||
} else if (absences.length >= 100) {
|
} else if (absences.length >= 100) {
|
||||||
finalPersonality = PersonalityType.sick;
|
finalPersonality = PersonalityType.sick;
|
||||||
@ -205,21 +207,14 @@ class _PersonalityCardState extends State<PersonalityCard> {
|
|||||||
'description':
|
'description':
|
||||||
'Kilukadt a villamos kereke. Kisiklott a repülő. A kutyád megette a cipőd. Elhisszük.',
|
'Kilukadt a villamos kereke. Kisiklott a repülő. A kutyád megette a cipőd. Elhisszük.',
|
||||||
'subtitle': 'Késésed (perc)',
|
'subtitle': 'Késésed (perc)',
|
||||||
'subvalue': (absences.where(
|
'subvalue': totalDelays.toString(),
|
||||||
(a) => a.state == Justification.unexcused && a.delay > 0))
|
|
||||||
.map((e) => e.delay)
|
|
||||||
.reduce((a, b) => a + b)
|
|
||||||
.toString(),
|
|
||||||
},
|
},
|
||||||
PersonalityType.quitter: {
|
PersonalityType.quitter: {
|
||||||
'emoji': '❓',
|
'emoji': '❓',
|
||||||
'title': 'Lógós',
|
'title': 'Lógós',
|
||||||
'description': 'Osztályzóvizsga incoming.',
|
'description': 'Osztályzóvizsga incoming.',
|
||||||
'subtitle': 'Igazolatlan hiányzások',
|
'subtitle': 'Igazolatlan hiányzások',
|
||||||
'subvalue': (absences.where(
|
'subvalue': unexcusedAbsences.toString(),
|
||||||
(a) => a.state == Justification.unexcused && a.delay == 0))
|
|
||||||
.length
|
|
||||||
.toString(),
|
|
||||||
},
|
},
|
||||||
PersonalityType.healthy: {
|
PersonalityType.healthy: {
|
||||||
'emoji': '😷',
|
'emoji': '😷',
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
import 'package:i18n_extension/i18n_extension.dart';
|
||||||
|
|
||||||
|
extension Localization on String {
|
||||||
|
static final _t =
|
||||||
|
Translations.byLocale("hu_hu") + {"en_en": {}, "hu_hu": {}, "de_de": {}};
|
||||||
|
|
||||||
|
String get i18n => localize(this, _t);
|
||||||
|
String fill(List<Object> params) => localizeFill(this, params);
|
||||||
|
String plural(int value) => localizePlural(value, this, _t);
|
||||||
|
String version(Object modifier) => localizeVersion(modifier, this, _t);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user