WIP lk select dialog
This commit is contained in:
@ -0,0 +1,56 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.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 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);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
int get getStep => _currentStep;
|
||||
set setStep(int step) {
|
||||
_currentStep = step;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_currentStep = 0;
|
||||
_collection = subjects;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
AbiturCalculatorModel() {
|
||||
reset();
|
||||
}
|
||||
}
|
42
lib/view/pages/more/abiturCalculator/models/subject.dart
Normal file
42
lib/view/pages/more/abiturCalculator/models/subject.dart
Normal file
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum SubjectState {
|
||||
none,
|
||||
isLk,
|
||||
isGk,
|
||||
}
|
||||
|
||||
class HighEduGraduationConstants {
|
||||
static const int maxLks = 2;
|
||||
static const int maxGks = 9;
|
||||
}
|
||||
|
||||
class SubjectCollection {
|
||||
List<Subject> collection;
|
||||
|
||||
SubjectCollection(this.collection);
|
||||
}
|
||||
|
||||
class Subject {
|
||||
String displayName;
|
||||
IconData icon;
|
||||
bool lkApplicable;
|
||||
|
||||
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 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;
|
||||
}
|
||||
set unsafeGkToggle(bool isGk) {
|
||||
_subjectState = isGk ? SubjectState.isGk : SubjectState.none;
|
||||
}
|
||||
|
||||
Subject({required this.displayName, required this.icon, required this.lkApplicable});
|
||||
}
|
Reference in New Issue
Block a user