Merge branch 'master' of github.com:refilc/naplo

This commit is contained in:
Kima
2023-08-23 00:04:36 +02:00
36 changed files with 1982 additions and 789 deletions

View File

@@ -169,13 +169,13 @@ class _PersonalityCardState extends State<PersonalityCard> {
} else if (mostCommonGrade.keys.toList()[0] == 1 &&
mostCommonGrade.values.toList()[0] > 1) {
finalPersonality = PersonalityType.fallible;
} else if (absences.length < 10) {
} else if (absences.length <= 12) {
finalPersonality = PersonalityType.healthy;
} else if (unexcusedAbsences >= 10) {
} else if (unexcusedAbsences >= 8) {
finalPersonality = PersonalityType.quitter;
} else if (totalDelays > 50) {
finalPersonality = PersonalityType.late;
} else if (absences.length >= 100) {
} else if (absences.length >= 120) {
finalPersonality = PersonalityType.sick;
} else if (mostCommonGrade.keys.toList()[0] == 2) {
finalPersonality = PersonalityType.acceptable;

View File

@@ -8,7 +8,9 @@ import 'package:flutter/material.dart';
import 'absence_group_tile.i18n.dart';
class AbsenceGroupTile extends StatelessWidget {
const AbsenceGroupTile(this.absences, {Key? key, this.showDate = false, this.padding}) : super(key: key);
const AbsenceGroupTile(this.absences,
{Key? key, this.showDate = false, this.padding})
: super(key: key);
final List<AbsenceViewable> absences;
final bool showDate;
@@ -16,10 +18,12 @@ class AbsenceGroupTile extends StatelessWidget {
@override
Widget build(BuildContext context) {
Justification state = getState(absences.map((e) => e.absence.state).toList());
Justification state =
getState(absences.map((e) => e.absence.state).toList());
Color color = AbsenceTile.justificationColor(state, context: context);
absences.sort((a, b) => a.absence.lessonIndex?.compareTo(b.absence.lessonIndex ?? 0) ?? -1);
absences.sort((a, b) =>
a.absence.lessonIndex?.compareTo(b.absence.lessonIndex ?? 0) ?? -1);
return ClipRRect(
borderRadius: BorderRadius.circular(14.0),
@@ -29,6 +33,8 @@ class AbsenceGroupTile extends StatelessWidget {
padding: padding ?? const EdgeInsets.symmetric(horizontal: 8.0),
child: AbsenceGroupContainer(
child: ExpansionTile(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10)),
tilePadding: const EdgeInsets.symmetric(horizontal: 8.0),
backgroundColor: Colors.transparent,
leading: Container(
@@ -38,22 +44,33 @@ class AbsenceGroupTile extends StatelessWidget {
shape: BoxShape.circle,
color: color.withOpacity(.25),
),
child: Center(child: Icon(AbsenceTile.justificationIcon(state), color: color)),
child: Center(
child: Icon(AbsenceTile.justificationIcon(state),
color: color)),
),
title: Text.rich(TextSpan(
text: "${absences.where((a) => a.absence.state == state).length} ",
style: TextStyle(fontWeight: FontWeight.w700, color: AppColors.of(context).text),
text:
"${absences.where((a) => a.absence.state == state).length} ",
style: TextStyle(
fontWeight: FontWeight.w700,
color: AppColors.of(context).text),
children: [
TextSpan(
text: AbsenceTile.justificationName(state).fill(["absence".i18n]),
style: TextStyle(fontWeight: FontWeight.w600, color: AppColors.of(context).text),
text: AbsenceTile.justificationName(state)
.fill(["absence".i18n]),
style: TextStyle(
fontWeight: FontWeight.w600,
color: AppColors.of(context).text),
),
],
)),
subtitle: showDate
? Text(
absences.first.absence.date.format(context, weekday: true),
style: TextStyle(fontWeight: FontWeight.w500, color: AppColors.of(context).text.withOpacity(0.8)),
absences.first.absence.date
.format(context, weekday: true),
style: TextStyle(
fontWeight: FontWeight.w500,
color: AppColors.of(context).text.withOpacity(0.8)),
)
: null,
children: absences,

View File

@@ -118,10 +118,13 @@ class _AllSumBodyState extends State<AllSumBody> {
void getDelays() {
var allDelays = absenceProvider.absences.where((a) => a.delay > 0);
var totalDelayTime = (allDelays.map((a) {
var delayTimeList = (allDelays.map((a) {
return a.delay;
}).toList())
.reduce((a, b) => a + b);
}).toList());
var totalDelayTime = 0;
if (delayTimeList.isNotEmpty) {
totalDelayTime = delayTimeList.reduce((a, b) => a + b);
}
var unexcusedDelays = absenceProvider.absences
.where((a) => a.state == Justification.unexcused && a.delay > 0);