half done absences page

This commit is contained in:
Kima 2024-04-22 22:01:13 +02:00
parent 697ed43e5a
commit 73db67c4e3
3 changed files with 197 additions and 45 deletions

View File

@ -15,6 +15,7 @@ class StatisticsTile extends StatelessWidget {
this.valueSuffix = '',
this.fill = false,
this.outline = false,
this.showZero,
});
final double value;
@ -24,6 +25,7 @@ class StatisticsTile extends StatelessWidget {
final String valueSuffix;
final bool fill;
final bool outline;
final bool? showZero;
@override
Widget build(BuildContext context) {
@ -37,7 +39,7 @@ class StatisticsTile extends StatelessWidget {
valueText = valueText.replaceAll(".", ",");
}
if (value.isNaN || value == 0) {
if ((value.isNaN || value == 0) && showZero != true) {
valueText = "?";
}

View File

@ -5,6 +5,7 @@ import 'dart:math';
import 'package:animations/animations.dart';
import 'package:auto_size_text/auto_size_text.dart';
import 'package:refilc/api/providers/update_provider.dart';
import 'package:refilc/theme/colors/utils.dart';
import 'package:refilc/ui/date_widget.dart';
import 'package:refilc_kreta_api/models/absence.dart';
import 'package:refilc_kreta_api/models/lesson.dart';
@ -21,6 +22,7 @@ import 'package:refilc_mobile_ui/common/filter_bar.dart';
import 'package:refilc_mobile_ui/common/panel/panel.dart';
import 'package:refilc_mobile_ui/common/profile_image/profile_button.dart';
import 'package:refilc_mobile_ui/common/profile_image/profile_image.dart';
import 'package:refilc_mobile_ui/common/splitted_panel/splitted_panel.dart';
import 'package:refilc_mobile_ui/common/widgets/absence/absence_subject_tile.dart';
import 'package:refilc_mobile_ui/common/widgets/absence/absence_viewable.dart';
import 'package:refilc_mobile_ui/common/widgets/statistics_tile.dart';
@ -348,6 +350,7 @@ class AbsencesPageState extends State<AbsencesPage>
(index == 0 && activeData == 0)) {
int value1 = 0;
int value2 = 0;
int value3 = 0;
String title1 = "";
String title2 = "";
String suffix = "";
@ -361,6 +364,10 @@ class AbsencesPageState extends State<AbsencesPage>
.where((e) =>
e.delay == 0 && e.state == Justification.unexcused)
.length;
value3 = absenceProvider.absences
.where((e) =>
e.delay == 0 && e.state == Justification.pending)
.length;
title1 = "stat_1".i18n;
title2 = "stat_2".i18n;
suffix = " ${"hr".i18n}";
@ -375,6 +382,11 @@ class AbsencesPageState extends State<AbsencesPage>
e.delay != 0 && e.state == Justification.unexcused)
.map((e) => e.delay)
.fold(0, (a, b) => a + b);
value3 = absenceProvider.absences
.where((e) =>
e.delay != 0 && e.state == Justification.pending)
.map((e) => e.delay)
.fold(0, (a, b) => a + b);
title1 = "stat_3".i18n;
title2 = "stat_4".i18n;
suffix = " ${"min".i18n}";
@ -382,44 +394,169 @@ class AbsencesPageState extends State<AbsencesPage>
return Padding(
padding: const EdgeInsets.only(
bottom: 24.0, left: 24.0, right: 24.0),
bottom: 20.0, left: 24.0, right: 24.0),
child: Row(children: [
Expanded(
child: StatisticsTile(
title: AutoSizeText(
title1,
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
child: SplittedPanel(
padding: EdgeInsets.zero,
cardPadding: const EdgeInsets.symmetric(
vertical: 16.0,
horizontal: 18.0,
),
valueSuffix: suffix,
value: value1.toDouble(),
decimal: false,
spacing: 8.0,
children: [
Column(
children: [
Row(
children: [
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
value1.toString() + suffix,
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w700,
color: AppColors.of(context).green,
),
),
const SizedBox(width: 24.0),
Expanded(
child: StatisticsTile(
title: AutoSizeText(
title2,
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
Text(
title1,
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w500,
height: 1.1,
color: ColorsUtils().darken(
AppColors.of(context).green,
amount: 0.5,
),
valueSuffix: suffix,
value: value2.toDouble(),
decimal: false,
),
),
],
),
const SizedBox(
width: 18.0,
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
Text(
value2.toString() + suffix,
style: TextStyle(
fontSize: 18.0,
fontWeight: FontWeight.w700,
color: AppColors.of(context).red,
),
),
Text(
title2,
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w500,
height: 1.1,
color: ColorsUtils().darken(
AppColors.of(context).red,
amount: 0.4,
),
),
),
],
)
],
),
// Column(
// children: [
// // ide kell valami csik widget diagram idk
// // es ala ez
// Row(
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Text(
// "sept".i18n,
// ),
// Text("now".i18n),
// ],
// ),
// ],
// ),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
const Icon(
Icons.av_timer_rounded,
),
const SizedBox(
width: 10.0,
),
Text(
"pending".i18n,
style: const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w600,
),
),
],
),
Text(
value3.toString() + suffix,
style: TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.w500,
color: AppColors.of(context)
.text
.withOpacity(0.8),
),
),
],
),
],
),
),
// Expanded(
// child: StatisticsTile(
// title: AutoSizeText(
// title1,
// textAlign: TextAlign.center,
// maxLines: 2,
// overflow: TextOverflow.ellipsis,
// ),
// valueSuffix: suffix,
// value: value1.toDouble(),
// decimal: false,
// showZero: true,
// color: AppColors.of(context).green,
// ),
// ),
// const SizedBox(width: 24.0),
// Expanded(
// child: StatisticsTile(
// title: AutoSizeText(
// title2,
// textAlign: TextAlign.center,
// maxLines: 2,
// overflow: TextOverflow.ellipsis,
// ),
// valueSuffix: suffix,
// value: value2.toDouble(),
// decimal: false,
// showZero: true,
// color: AppColors.of(context).red,
// ),
// ),
]),
);
}
return Padding(
padding:
const EdgeInsets.symmetric(horizontal: 24.0, vertical: 6.0),
padding: const EdgeInsets.only(
left: 24.0, right: 24.0, bottom: 12.0),
child: filterWidgets[index - (activeData <= 1 ? 1 : 0)],
);
} else {

View File

@ -9,16 +9,20 @@ extension ScreensLocalization on String {
"Misses": "Misses",
"emptyDelays": "You have no delays.",
"emptyMisses": "You have no missing homeworks or equipments.",
"stat_1": "Excused Absences",
"stat_2": "Unexcused Absences",
"stat_3": "Excused Delay",
"stat_4": "Unexcused Delay",
"stat_1": "Excused",
"stat_2": "Unexcused",
"stat_3": "Excused",
"stat_4": "Unexcused",
"min": "min",
"hr": "hrs",
"Subjects": "Subjects",
"attention": "Attention!",
"attention_body": "Percentage calculations are only an approximation so they may not be accurate.",
"attention_body":
"Percentage calculations are only an approximation so they may not be accurate.",
"lesson_not_found": "Cannot find lesson",
"pending": "Pending",
"sept": "September",
"now": "Now",
},
"hu_hu": {
"Absences": "Hiányzások",
@ -26,33 +30,42 @@ extension ScreensLocalization on String {
"Misses": "Hiányok",
"emptyDelays": "Nincsenek késéseid.",
"emptyMisses": "Nincsenek hiányzó házi feladataid, felszereléseid.",
"stat_1": "Igazolt hiányzások",
"stat_2": "Igazolatlan hiányzások",
"stat_3": "Igazolt Késés",
"stat_4": "Igazolatlan Késés",
"stat_1": "Igazolt",
"stat_2": "Igazolatlan",
"stat_3": "Igazolt",
"stat_4": "Igazolatlan",
"min": "perc",
"hr": "óra",
"Subjects": "Tantárgyak",
"attention": "Figyelem!",
"attention_body": "A százalékos számítások csak közelítések, ezért előfordulhat, hogy nem pontosak.",
"attention_body":
"A százalékos számítások csak közelítések, ezért előfordulhat, hogy nem pontosak.",
"lesson_not_found": "Nem található óra",
"pending": "Függőben",
"sept": "Szeptember",
"now": "Most",
},
"de_de": {
"Absences": "Fehlen",
"Delays": "Verspätung",
"Misses": "Fehlt",
"emptyDelays": "Sie haben keine Abwesenheiten.",
"emptyMisses": "Sie haben noch keine fehlende Hausaufgaben oder Austattung.",
"stat_1": "Entschuldigte Fehlen",
"stat_2": "Unentschuldigte Fehlen",
"stat_3": "Entschuldigte Verspätung",
"stat_4": "Unentschuldigte Verspätung",
"emptyMisses":
"Sie haben noch keine fehlende Hausaufgaben oder Austattung.",
"stat_1": "Entschuldigte",
"stat_2": "Unentschuldigte",
"stat_3": "Entschuldigte",
"stat_4": "Unentschuldigte",
"min": "min",
"hr": "hrs",
"Subjects": "Fächer",
"attention": "Achtung!",
"attention_body": "Prozentberechnungen sind nur eine Annäherung und können daher ungenau sein.",
"attention_body":
"Prozentberechnungen sind nur eine Annäherung und können daher ungenau sein.",
"lesson_not_found": "Lektion kann nicht gefunden werden",
"pending": "Anhängig",
"sept": "September",
"now": "Jetzt",
},
};