finished new absences page

This commit is contained in:
Kima 2024-04-23 19:56:35 +02:00
parent f0b9dfa1e6
commit c0589cba5c
4 changed files with 78 additions and 58 deletions

View File

@ -32,7 +32,7 @@ class AbsenceDisplay extends StatelessWidget {
if (excused > 0 && pending > 0) const SizedBox(width: 6.0), if (excused > 0 && pending > 0) const SizedBox(width: 6.0),
if (pending > 0) if (pending > 0)
Icon( Icon(
FeatherIcons.slash, Icons.hourglass_bottom,
size: 14.0, size: 14.0,
color: AppColors.of(context).orange, color: AppColors.of(context).orange,
), ),

View File

@ -3,18 +3,21 @@ import 'package:refilc/models/settings.dart';
import 'package:refilc/theme/colors/colors.dart'; import 'package:refilc/theme/colors/colors.dart';
import 'package:refilc/utils/format.dart'; import 'package:refilc/utils/format.dart';
import 'package:refilc_kreta_api/models/subject.dart'; import 'package:refilc_kreta_api/models/subject.dart';
import 'package:refilc_mobile_ui/common/round_border_icon.dart';
import 'package:refilc_mobile_ui/common/widgets/absence/absence_display.dart'; import 'package:refilc_mobile_ui/common/widgets/absence/absence_display.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
class AbsenceSubjectTile extends StatelessWidget { class AbsenceSubjectTile extends StatelessWidget {
const AbsenceSubjectTile(this.subject, const AbsenceSubjectTile(
{super.key, this.subject, {
this.percentage = 0.0, super.key,
this.excused = 0, this.percentage = 0.0,
this.unexcused = 0, this.excused = 0,
this.pending = 0, this.unexcused = 0,
this.onTap}); this.pending = 0,
this.onTap,
});
final GradeSubject subject; final GradeSubject subject;
final void Function()? onTap; final void Function()? onTap;
@ -28,54 +31,65 @@ class AbsenceSubjectTile extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context); SettingsProvider settingsProvider = Provider.of<SettingsProvider>(context);
return Material( return Material(
type: MaterialType.transparency, type: MaterialType.card,
child: ListTile( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16.0)),
// minLeadingWidth: 32.0, child: Padding(
dense: true, padding: const EdgeInsets.all(4.0),
contentPadding: const EdgeInsets.only(left: 8.0, right: 6.0), child: ListTile(
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8.0)), // minLeadingWidth: 32.0,
visualDensity: VisualDensity.compact, dense: true,
onTap: onTap, contentPadding: const EdgeInsets.only(left: 12.0, right: 12.0),
leading: Icon( shape:
SubjectIcon.resolveVariant(subject: subject, context: context), RoundedRectangleBorder(borderRadius: BorderRadius.circular(12.0)),
size: 32.0), visualDensity: VisualDensity.compact,
title: Text( onTap: onTap,
subject.renamedTo ?? subject.name.capital(), leading: RoundBorderIcon(
maxLines: 2, padding: 8.0,
overflow: TextOverflow.ellipsis, icon: Icon(
style: TextStyle( SubjectIcon.resolveVariant(subject: subject, context: context),
fontWeight: FontWeight.w600, size: 20.0,
fontSize: 15.0, ),
fontStyle: ),
subject.isRenamed && settingsProvider.renamedSubjectsItalics title: Text(
? FontStyle.italic subject.renamedTo ?? subject.name.capital(),
: null), maxLines: 2,
), overflow: TextOverflow.ellipsis,
subtitle: AbsenceDisplay(excused, unexcused, pending), style: TextStyle(
trailing: Row( fontWeight: FontWeight.w600,
mainAxisSize: MainAxisSize.min, fontSize: 15.0,
children: [ fontStyle:
const SizedBox(width: 8.0), subject.isRenamed && settingsProvider.renamedSubjectsItalics
if (percentage >= 0) ? FontStyle.italic
Stack( : null),
alignment: Alignment.centerRight, ),
children: [ subtitle: AbsenceDisplay(excused, unexcused, pending),
const Opacity( trailing: Row(
opacity: 0, mainAxisSize: MainAxisSize.min,
child: Text("100%", children: [
style: TextStyle(fontFamily: "monospace"))), const SizedBox(width: 8.0),
Text( if (percentage >= 0)
"${percentage.round()}%", Stack(
style: TextStyle( alignment: Alignment.centerRight,
// fontFamily: "monospace", children: [
color: getColorByPercentage(percentage, context: context), const Opacity(
fontWeight: FontWeight.w700, opacity: 0,
fontSize: 24.0, child: Text("100%",
style: TextStyle(fontFamily: "monospace"))),
Text(
"${percentage.round()}%",
style: TextStyle(
// fontFamily: "monospace",
color:
getColorByPercentage(percentage, context: context)
.withOpacity(0.8),
fontSize: 16.0,
fontWeight: FontWeight.w500,
),
), ),
), ],
], ),
), ],
], ),
), ),
), ),
); );

View File

@ -143,7 +143,7 @@ class AbsenceTile extends StatelessWidget {
case Justification.excused: case Justification.excused:
return FeatherIcons.check; return FeatherIcons.check;
case Justification.pending: case Justification.pending:
return FeatherIcons.slash; return Icons.hourglass_bottom;
case Justification.unexcused: case Justification.unexcused:
return FeatherIcons.x; return FeatherIcons.x;
} }

View File

@ -276,6 +276,9 @@ class AbsencesPageState extends State<AbsencesPage>
Padding( Padding(
padding: const EdgeInsets.only(bottom: 24.0), padding: const EdgeInsets.only(bottom: 24.0),
child: Panel( child: Panel(
padding: EdgeInsets.zero,
isTransparent: true,
hasShadow: false,
title: Row( title: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -318,11 +321,14 @@ class AbsencesPageState extends State<AbsencesPage>
return FadeThroughTransition( return FadeThroughTransition(
animation: primaryAnimation, animation: primaryAnimation,
secondaryAnimation: secondaryAnimation, secondaryAnimation: secondaryAnimation,
fillColor: Theme.of(context).colorScheme.background, fillColor: Colors.transparent,
child: child, child: child,
); );
}, },
child: Column( child: SplittedPanel(
padding: EdgeInsets.zero,
isSeparated: true,
isTransparent: true,
children: absWidgets, children: absWidgets,
), ),
), ),