From 8819dd8a72b9c389ac44d10cc27536143ad148bb Mon Sep 17 00:00:00 2001 From: SLH335 <114884726+SLH335@users.noreply.github.com> Date: Sun, 27 Nov 2022 10:52:13 +0100 Subject: [PATCH] Redesign timetable --- lib/theme/theme_constants.dart | 3 -- lib/theme/theme_manager.dart | 4 -- lib/widgets/timetable.dart | 76 +++++++++++++++++++--------------- 3 files changed, 43 insertions(+), 40 deletions(-) diff --git a/lib/theme/theme_constants.dart b/lib/theme/theme_constants.dart index 809a1ad..db0071e 100644 --- a/lib/theme/theme_constants.dart +++ b/lib/theme/theme_constants.dart @@ -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, diff --git a/lib/theme/theme_manager.dart b/lib/theme/theme_manager.dart index 5f6e442..c8b13fc 100644 --- a/lib/theme/theme_manager.dart +++ b/lib/theme/theme_manager.dart @@ -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 _getThemeMode() async { final SharedPreferences prefs = await _prefs; @@ -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; } } diff --git a/lib/widgets/timetable.dart b/lib/widgets/timetable.dart index 4cc0600..d9ae1c8 100644 --- a/lib/widgets/timetable.dart +++ b/lib/widgets/timetable.dart @@ -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 { @@ -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)), + ], + ), ), ); } @@ -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), - ], - ); - } - ); + }); } } @@ -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), ), ], ),