20a50d66f7
- many hardcoded placeholders - TODO: - update README - update license & copyright info - cleanup code - merge code parts to server side - muuuuuuuch more...
174 lines
6.1 KiB
Dart
174 lines
6.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
|
class ClassTimetableBuilder {
|
|
final ListView view;
|
|
ClassTimetableBuilder({required this.view});
|
|
factory ClassTimetableBuilder.buildView(Map<String, dynamic> json) {
|
|
List<Widget> children = [];
|
|
ClassTimetable.fromJson(json).timetable.forEach((element) {
|
|
List<Widget> cardChildren = [];
|
|
cardChildren.add(ListTile(
|
|
title: Text(element.count.toString() + '.' + ' ' + element.name,
|
|
style: TextStyle(color: element.fontColor)),
|
|
subtitle: Row(
|
|
children: [
|
|
Icon(CupertinoIcons.person, color: element.fontColor),
|
|
SizedBox(width: 5),
|
|
Text(element.teacher,
|
|
style: TextStyle(color: element.fontColor)),
|
|
Spacer(),
|
|
Icon(CupertinoIcons.home, color: element.fontColor),
|
|
SizedBox(width: 5),
|
|
Text(element.room, style: TextStyle(color: element.fontColor))
|
|
]
|
|
),
|
|
leading:
|
|
Icon(CupertinoIcons.time, color: element.fontColor)
|
|
));
|
|
if (element.info != '') {
|
|
cardChildren.add(ListTile(title: Text(
|
|
element.info, style: TextStyle(color: element.fontColor))));
|
|
}
|
|
Card card = Card(
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(15.0),
|
|
),
|
|
color: element.color,
|
|
child: Column(
|
|
children: cardChildren,
|
|
)
|
|
);
|
|
children.add(card);
|
|
});
|
|
return ClassTimetableBuilder(
|
|
view: ListView(
|
|
physics: const AlwaysScrollableScrollPhysics(),
|
|
children: children
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
class ClassTimetable {
|
|
final List timetable;
|
|
ClassTimetable({required this.timetable});
|
|
factory ClassTimetable.fromJson(Map<String, dynamic> json){
|
|
print(json);
|
|
List<TimetableLesson> lessons = [];
|
|
json['courses'].forEach((value){
|
|
var color;
|
|
var name;
|
|
var teacher;
|
|
var room;
|
|
dynamic teachers = {'Poli':'Herr Polity', 'Zura':'Frau Zuralski', 'Enzi': 'Frau Enzian', 'Bütt':'Frau Büttner', 'Brod':'Herr Brode', 'Rink':'Frau Rinke', 'Schk':'Frau Schmidt', 'Rudo':'Frau Rudolph', 'Kipp':'Frau Kipping', 'Bach':'Frau Bachran', 'Bad':'Herr Bader', 'Prei':'Frau Preiß', 'Scha':'Frau Schapitz', ' ':'', 'Link':'Herr Linke', 'Stei':'Herr Stein', 'Tupp':'Frau Tuppack', 'Hoff':'Frau Hoffman', 'Knol':'Frau Knoll', 'Bet':'Frau Bethin', 'Schu':'Frau Schulz', 'Seid':'Frau Seidel', 'Krug':'Frau Krug', 'Laer':'Frau Langer', 'Youn':'Frau Younso', 'Härt':'Frau Härtig', 'Bros':'Frau Brosig', 'Ber':'Frau Bernhardt', 'Stüb':'Frau Stüber', 'Bor':'Frau Borchert', 'Dubb':'Frau Dubberstein', 'Tren':'Frau Trentsch', 'Meit':'Herr Meitzner', 'Stol':'Frau Stolpe', 'Jac':'Frau Jacob', 'Jüne':'Herr Jünemann', 'Bert':'Frau Berthelmann', 'Felk':'Frau Felke', 'Kimm':'Herr Kimmel', 'PM1': 'Pädagosische(r) Mitarbeiter(in) 1', 'Schet':'Herr Schetler', 'Mani':'Herr Manigk', 'Segg':'Frau Seggern', 'Opel':'Frau Opel-Fritzler'};
|
|
if(value['Fa'].runtimeType != String){
|
|
name = value['Fa']['#text'];
|
|
}
|
|
else {
|
|
name = value['Fa'];
|
|
}
|
|
if(value['Le'].runtimeType != String){
|
|
teacher = value['Le']['#text'];
|
|
}
|
|
else {
|
|
teacher = value['Le'];
|
|
}
|
|
print(value['Ra']);
|
|
if(value['Ra'].runtimeType != String && value['Ra'].runtimeType != int){
|
|
if(value['Ra']['#text'] == ' ') {
|
|
room = '';
|
|
} else {
|
|
room = value['Ra']['#text'];
|
|
}
|
|
} else if(value['Ra'] == ' ') {
|
|
room = '';
|
|
} else {
|
|
room = value['Ra'];
|
|
}
|
|
var fontColor;
|
|
if(name == '---') {
|
|
fontColor = Colors.red;
|
|
} else {
|
|
fontColor = Colors.white;
|
|
}
|
|
var info;
|
|
if(value['If'].runtimeType != String) {
|
|
info = '';
|
|
} else {
|
|
info = value['If'];
|
|
}
|
|
if(name == 'Mat'){
|
|
color = Colors.indigo;
|
|
}
|
|
else if(name == 'Deu'){
|
|
color = Colors.red;
|
|
}
|
|
else if(name == 'Kun'){
|
|
color = Colors.deepPurple;
|
|
}
|
|
else if(name == 'Bio'){
|
|
color = Colors.green;
|
|
}
|
|
else if(name == 'Geo'){
|
|
color = Colors.brown;
|
|
}
|
|
else if(name == 'Lat'){
|
|
color = Colors.teal;
|
|
}
|
|
else if(name == 'Che'){
|
|
color = Colors.lightGreen;
|
|
}
|
|
else if(name == 'Eng'){
|
|
color = Colors.amber;
|
|
}
|
|
else if(name == 'Phy'){
|
|
color = Colors.cyan;
|
|
}
|
|
else if(name == 'Inf'){
|
|
color = Colors.tealAccent[400];
|
|
}
|
|
else if(name == 'Mus'){
|
|
color = Colors.deepOrange;
|
|
}
|
|
else if(name == 'Lme'){
|
|
color = Colors.amber[700];
|
|
}
|
|
else if(name == 'Ges'){
|
|
color = Colors.grey;
|
|
}
|
|
else if(name == 'Spa'){
|
|
color = Colors.redAccent;
|
|
}
|
|
else if(name == 'Frz'){
|
|
color = Colors.amberAccent[700];
|
|
}
|
|
else if(name == '---') {
|
|
color = Colors.white;
|
|
}
|
|
else {
|
|
color = Colors.grey[700];
|
|
}
|
|
dynamic names = {'Bio':'Biologie', 'Mat':'Mathematik', 'Kun':'Kunst', 'Mus':'Musik', 'Geo':'Geographie', 'Ges':'Geschichte', 'Che':'Chemie', 'Lat':'Latein', 'Inf':'Informatik', 'Eng':'Englisch', 'Frz':'Französisch', 'Phy':'Physik', '---':'---', 'Spo':'Sport', 'Deu':'Deutsch', 'Lme':'Lernmethoden', 'Eth':'Ethik', 'EvR':'Evangelische Religion', 'Spa':'Spanisch', 'Soz':'Sozialkunde', 'Ast':'Astronomie'};
|
|
dynamic colors = {'Bio':Colors.green, 'Mat':Colors.blue};
|
|
lessons.add(TimetableLesson(value['St'], names[name].toString(), teachers[teacher].toString(), room.toString(), value['If'].toString(), color, fontColor, info));
|
|
});
|
|
|
|
return ClassTimetable(
|
|
timetable: lessons
|
|
);
|
|
}
|
|
}
|
|
|
|
class TimetableLesson {
|
|
final int count;
|
|
final String name;
|
|
final String teacher;
|
|
final String room;
|
|
final String comment;
|
|
final Color color;
|
|
final Color fontColor;
|
|
final String info;
|
|
const TimetableLesson(this.count, this.name, this.teacher, this.room, this.comment, this.color, this.fontColor, this.info);
|
|
} |