WIP high education graduation calculator

This commit is contained in:
2024-03-23 15:42:31 +01:00
parent e7192008c0
commit c4f5be2205
5 changed files with 179 additions and 5 deletions

View File

@ -0,0 +1,48 @@
import 'package:flutter/material.dart';
import 'package:marianum_mobile/widget/centeredLeading.dart';
enum SubjectState {
none,
isLk,
isGk,
}
class HighEduGraduationConstants {
static const int maxLks = 2;
static const int maxGks = 9;
}
class SubjectCollection {
List<Subject> subjects;
SubjectCollection(this.subjects);
}
class Subject {
String displayName;
bool lkApplicable;
SubjectState _subjectState = SubjectState.none;
bool isLk() => _subjectState == SubjectState.isLk;
bool isGk() => _subjectState == SubjectState.isGk;
bool canLk(List<Subject> other) => lkApplicable && other.where((s) => s.isLk()).length < HighEduGraduationConstants.maxLks;
bool canGk(List<Subject> other) => !isLk() && other.where((s) => s.isGk()).length < HighEduGraduationConstants.maxGks;
set unsafeSubjectSet(SubjectState newState) => _subjectState = newState;
set unsafeLkToggle(bool isLk) {
_subjectState = isLk ? SubjectState.isLk : SubjectState.none;
}
ListTile get asTile => ListTile(
leading: const CenteredLeading(Icon(Icons.subject_outlined)),
title: Text(displayName),
trailing: Checkbox(
value: isGk(),
onChanged: (e) => {},
),
);
Subject({required this.displayName, required this.lkApplicable});
}