Skip to content

Commit

Permalink
Redesign timetable
Browse files Browse the repository at this point in the history
  • Loading branch information
SLH335 committed Nov 27, 2022
1 parent 11e1700 commit 8819dd8
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 40 deletions.
3 changes: 0 additions & 3 deletions lib/theme/theme_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ Color colorStrokeDark = Colors.white;
Color colorSecondaryLight = Colors.green.shade300;
Color colorSecondaryDark = Colors.green.shade800;

Color colorTimetableRowLight = Colors.grey.shade400;
Color colorTimetableRowDark = Colors.grey.shade800;

ThemeData lightTheme = ThemeData(
brightness: Brightness.light,
primaryColor: colorPrimaryLight,
Expand Down
4 changes: 0 additions & 4 deletions lib/theme/theme_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@ class ThemeManager with ChangeNotifier {
ThemeMode _themeMode = ThemeMode.light;
Color _colorStroke = colorStrokeLight;
Color _colorSecondary = colorSecondaryLight;
Color _colorTimetableRow = colorTimetableRowLight;

get themeMode => _themeMode;

get colorStroke => _colorStroke;
get colorSecondary => _colorSecondary;
get colorTimetableRow => _colorTimetableRow;

Future<ThemeMode> _getThemeMode() async {
final SharedPreferences prefs = await _prefs;
Expand All @@ -39,12 +37,10 @@ class ThemeManager with ChangeNotifier {
_themeMode = ThemeMode.dark;
_colorStroke = colorStrokeDark;
_colorSecondary = colorSecondaryDark;
_colorTimetableRow = colorTimetableRowDark;
} else {
_themeMode = ThemeMode.light;
_colorStroke = colorStrokeLight;
_colorSecondary = colorSecondaryLight;
_colorTimetableRow = colorTimetableRowLight;
}
}

Expand Down
76 changes: 43 additions & 33 deletions lib/widgets/timetable.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:flutter/material.dart';
import 'package:mcgapp/main.dart';
import 'package:mcgapp/widgets/bottom_sheet.dart';

import '../classes/course.dart';
import '../classes/room.dart';

double height = 60;
double height = 80;
double headerHeight = 42;
double headerWidth = 42;
double padding = 1;

class Timetable extends StatelessWidget {
Expand All @@ -15,21 +16,26 @@ class Timetable extends StatelessWidget {

Widget _dayHeader(String day) {
return Expanded(
child: Container(
height: 32,
color: themeManager.colorTimetableRow,
child: SizedBox(
height: headerHeight,
child: Center(child: Text(day, style: const TextStyle(fontWeight: FontWeight.bold))),
),
);
}

Widget _lessonHeader(String lesson) {
return Container(
Widget _lessonHeader(int lesson) {
return SizedBox(
height: height + padding * 2,
width: 28,
color: themeManager.colorTimetableRow,
width: headerWidth,
child: Center(
child: Text(lesson, style: const TextStyle(fontWeight: FontWeight.bold)),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(_getTimesFromLesson(lesson).split(' - ')[0], style: const TextStyle(fontSize: 12, color: Colors.grey)),
Text('$lesson', style: const TextStyle(fontWeight: FontWeight.bold)),
Text(_getTimesFromLesson(lesson).split(' - ')[1], style: const TextStyle(fontSize: 12, color: Colors.grey)),
],
),
),
);
}
Expand All @@ -46,32 +52,31 @@ class Timetable extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView.builder(
itemCount: 5,
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
itemCount: 5,
itemBuilder: (BuildContext context, int index) {
if (index == 0) {
return Row(
children: [
SizedBox(height: headerHeight, width: headerWidth),
_dayHeader('Mo'),
_dayHeader('Di'),
_dayHeader('Mi'),
_dayHeader('Do'),
_dayHeader('Fr'),
],
);
}
return Row(
children: [
Container(height: 32, width: 28, color: themeManager.colorTimetableRow),
_dayHeader('Mo'),
_dayHeader('Di'),
_dayHeader('Mi'),
_dayHeader('Do'),
_dayHeader('Fr'),
_lessonHeader(index),
TimetableEntry(course: _getCourse('${week}Mo$index'), week: week, weekday: 'Montag', lesson: index),
TimetableEntry(course: _getCourse('${week}Di$index'), week: week, weekday: 'Dienstag', lesson: index),
TimetableEntry(course: _getCourse('${week}Mi$index'), week: week, weekday: 'Mittwoch', lesson: index),
TimetableEntry(course: _getCourse('${week}Do$index'), week: week, weekday: 'Donnerstag', lesson: index),
TimetableEntry(course: _getCourse('${week}Fr$index'), week: week, weekday: 'Freitag', lesson: index),
],
);
}
return Row(
children: [
_lessonHeader('$index'),
TimetableEntry(course: _getCourse('${week}Mo$index'), week: week, weekday: 'Montag', lesson: index),
TimetableEntry(course: _getCourse('${week}Di$index'), week: week, weekday: 'Dienstag', lesson: index),
TimetableEntry(course: _getCourse('${week}Mi$index'), week: week, weekday: 'Mittwoch', lesson: index),
TimetableEntry(course: _getCourse('${week}Do$index'), week: week, weekday: 'Donnerstag', lesson: index),
TimetableEntry(course: _getCourse('${week}Fr$index'), week: week, weekday: 'Freitag', lesson: index),
],
);
}
);
});
}
}

Expand Down Expand Up @@ -162,16 +167,21 @@ class TimetableEntry extends StatelessWidget {
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
course!.teacher.short,
style: TextStyle(fontSize: 10, color: course!.subject.foregroundColor),
),
Text(
course!.subject.short,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: course!.subject.foregroundColor,
),
),
Text(
_room?.number ?? '',
style: TextStyle(color: course!.subject.foregroundColor),
style: TextStyle(fontSize: 10, color: course!.subject.foregroundColor),
),
],
),
Expand Down

0 comments on commit 8819dd8

Please sign in to comment.