wip
This commit is contained in:
@ -1,52 +1,77 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../abiturCalculatorStep.dart';
|
||||
import '../steps/resultStep.dart';
|
||||
import '../steps/selectGkStep.dart';
|
||||
import '../steps/selectLkStep.dart';
|
||||
import '../steps/selectPfStep.dart';
|
||||
import '../steps/welcomeStep.dart';
|
||||
import 'subject.dart';
|
||||
|
||||
class AbiturCalculatorModel extends ChangeNotifier {
|
||||
static SubjectCollection subjects = SubjectCollection([
|
||||
Subject(displayName: 'Deutsch', icon: Icons.translate_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Erste Fremdsprache', icon: Icons.translate_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Zweite Fremdsprache', icon: Icons.translate_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Zweite Fremdsprache ab Kl. 11', icon: Icons.translate_outlined, lkApplicable: false),
|
||||
Subject(displayName: 'Kunst', icon: Icons.brush_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Musik', icon: Icons.music_note_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Darstellendes Spiel', icon: Icons.theater_comedy_outlined, lkApplicable: false),
|
||||
Subject(displayName: 'PoWi', icon: Icons.book_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Geschichte', icon: Icons.history_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Religion', icon: Icons.church_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Erdkunde', icon: Icons.map_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Mathematik', icon: Icons.calculate_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Erste Naturwissenschaft', icon: Icons.science_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Zweite Naturwissenschaft', icon: Icons.science_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Dritte Naturwissenschaft', icon: Icons.science_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Biochemie', icon: Icons.biotech_outlined, lkApplicable: false),
|
||||
Subject(displayName: 'Informatik', icon: Icons.code_outlined, lkApplicable: true),
|
||||
Subject(displayName: 'Sport', icon: Icons.sports_basketball_outlined, lkApplicable: true),
|
||||
static final SubjectCollection _collection = SubjectCollection([
|
||||
Subject(displayName: 'Deutsch', icon: Icons.translate_outlined, canBeLk: true, importantLk: true),
|
||||
Subject(displayName: 'Erste Fremdsprache', icon: Icons.translate_outlined, canBeLk: true, importantLk: true),
|
||||
Subject(displayName: 'Zweite Fremdsprache', icon: Icons.translate_outlined, canBeLk: true, importantLk: true),
|
||||
Subject(displayName: 'Zweite Fremdsprache ab Kl. 11', icon: Icons.translate_outlined, canBeLk: false, importantLk: false),
|
||||
Subject(displayName: 'Kunst', icon: Icons.brush_outlined, canBeLk: true, importantLk: false),
|
||||
Subject(displayName: 'Musik', icon: Icons.music_note_outlined, canBeLk: true, importantLk: false),
|
||||
Subject(displayName: 'Darstellendes Spiel', icon: Icons.theater_comedy_outlined, canBeLk: false, importantLk: false),
|
||||
Subject(displayName: 'PoWi', icon: Icons.book_outlined, canBeLk: true, importantLk: false),
|
||||
Subject(displayName: 'Geschichte', icon: Icons.history_outlined, canBeLk: true, importantLk: false),
|
||||
Subject(displayName: 'Religion', icon: Icons.church_outlined, canBeLk: true, importantLk: false),
|
||||
Subject(displayName: 'Erdkunde', icon: Icons.map_outlined, canBeLk: true, importantLk: false),
|
||||
Subject(displayName: 'Mathematik', icon: Icons.calculate_outlined, canBeLk: true, importantLk: true),
|
||||
Subject(displayName: 'Chemie', icon: Icons.science_outlined, canBeLk: true, importantLk: true),
|
||||
Subject(displayName: 'Physik', icon: Icons.add, canBeLk: true, importantLk: true),
|
||||
Subject(displayName: 'Biologie', icon: Icons.add, canBeLk: true, importantLk: true),
|
||||
Subject(displayName: 'Biochemie', icon: Icons.biotech_outlined, canBeLk: false, importantLk: false),
|
||||
Subject(displayName: 'Informatik', icon: Icons.code_outlined, canBeLk: true, importantLk: false),
|
||||
Subject(displayName: 'Sport', icon: Icons.sports_basketball_outlined, canBeLk: true, importantLk: false),
|
||||
]);
|
||||
|
||||
static final List<AbiturCalculatorStep> _steps = [
|
||||
const WelcomeStep(),
|
||||
SelectLkStep(),
|
||||
SelectGkStep(),
|
||||
const SelectPfStep(),
|
||||
const ResultStep(),
|
||||
];
|
||||
|
||||
List<AbiturCalculatorStep> get getSteps => _steps;
|
||||
AbiturCalculatorStep getCurrentStep() => _steps[getCurrentStepIndex];
|
||||
|
||||
static AbiturCalculatorModel get(BuildContext context) {
|
||||
return Provider.of<AbiturCalculatorModel>(context, listen: false);
|
||||
}
|
||||
|
||||
late SubjectCollection _collection;
|
||||
int _currentStep = 0;
|
||||
|
||||
SubjectCollection get getSubjects => _collection;
|
||||
void updateSubjects(void Function(SubjectCollection collection) callback) {
|
||||
callback(_collection);
|
||||
SubjectCollection getSubjects({bool update = false}) {
|
||||
if(update) notifyListeners();
|
||||
return _collection;
|
||||
}
|
||||
|
||||
void update() {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int get getStep => _currentStep;
|
||||
set setStep(int step) {
|
||||
_currentStep = step;
|
||||
int get getCurrentStepIndex => _currentStep;
|
||||
void increaseStep() {
|
||||
if(getCurrentStep().canGoNextStep(getSubjects())) _currentStep++;
|
||||
notifyListeners();
|
||||
}
|
||||
void decreaseStep() {
|
||||
if(_currentStep >= 1) _currentStep--;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_currentStep = 0;
|
||||
_collection = subjects;
|
||||
for (var e in _collection.collection) {
|
||||
e.reset();
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
|
@ -19,24 +19,43 @@ class SubjectCollection {
|
||||
}
|
||||
|
||||
class Subject {
|
||||
String displayName;
|
||||
IconData icon;
|
||||
bool lkApplicable;
|
||||
final String displayName;
|
||||
final IconData icon;
|
||||
final bool canBeLk;
|
||||
final bool importantLk;
|
||||
|
||||
SubjectState _subjectState = SubjectState.none;
|
||||
|
||||
bool isLk() => _subjectState == SubjectState.isLk;
|
||||
bool isGk() => _subjectState == SubjectState.isGk;
|
||||
bool canLk(List<Subject> other) => lkApplicable && !isGk() && other.where((s) => s.isLk()).length < HighEduGraduationConstants.maxLks;
|
||||
|
||||
bool canLk(List<Subject> other) {
|
||||
Subject? otherLk() => other.where((s) => s.isLk()).firstOrNull;
|
||||
bool hasOtherLk() => otherLk() != null;
|
||||
|
||||
return
|
||||
((hasOtherLk() && otherLk()!.importantLk) || importantLk)
|
||||
&& canBeLk
|
||||
&& !isGk()
|
||||
&& 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) {
|
||||
if(isLk) {
|
||||
|
||||
}
|
||||
_subjectState = isLk ? SubjectState.isLk : SubjectState.none;
|
||||
}
|
||||
set unsafeGkToggle(bool isGk) {
|
||||
_subjectState = isGk ? SubjectState.isGk : SubjectState.none;
|
||||
}
|
||||
|
||||
Subject({required this.displayName, required this.icon, required this.lkApplicable});
|
||||
void reset() {
|
||||
_subjectState = SubjectState.none;
|
||||
}
|
||||
|
||||
Subject({required this.displayName, required this.icon, required this.canBeLk, required this.importantLk});
|
||||
}
|
Reference in New Issue
Block a user