diff --git a/lib/constants/color.dart b/lib/constants/color.dart index b1815cb3..21768701 100644 --- a/lib/constants/color.dart +++ b/lib/constants/color.dart @@ -1,12 +1,5 @@ import 'package:flutter/material.dart'; -@Deprecated('old color styles') -const DIVIDER_COLOR = Color(0xFFEDD1DC); -@Deprecated('old color styles') -const BORDER_COLOR = Color(0xFFE8E8E8); -@Deprecated('old color styles') -const BORDER_BOLD_COLOR = Color(0xFFC9C9C9); - class OTLColor { static const gray0 = Color(0xFF000000); static const gray3 = Color(0xFF333333); diff --git a/lib/pages/lecture_detail_page.dart b/lib/pages/lecture_detail_page.dart index 98e34f2a..f99dbbed 100644 --- a/lib/pages/lecture_detail_page.dart +++ b/lib/pages/lecture_detail_page.dart @@ -53,9 +53,7 @@ class LectureDetailPage extends StatelessWidget { : '', style: titleBold), body: Card( - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.vertical(top: Radius.circular(16.0)), - ), + shape: const RoundedRectangleBorder(), child: context.select((model) => model.hasData) ? _buildBody(context) @@ -63,6 +61,13 @@ class LectureDetailPage extends StatelessWidget { child: const CircularProgressIndicator(), ), ), + trailing: (context.select( + (model) => model.hasData) && + context.select( + (model) => model.isUpdateEnabled) && + context.read().selectedIndex != 0) + ? _buildUpdateButton(context) + : null, ), ); } @@ -78,26 +83,19 @@ class LectureDetailPage extends StatelessWidget { _buildButtons(context, lecture), const SizedBox(height: 8.0), Expanded(child: _buildScrollView(context, lecture)), - if (context.select( - (model) => model.isUpdateEnabled) && - context.read().selectedIndex != 0) ...[ - const Divider(color: DIVIDER_COLOR), - Align( - alignment: Alignment.centerRight, - child: _buildUpdateButton(context, lecture), - ), - ] ], ), ); } - Widget _buildUpdateButton(BuildContext context, Lecture lecture) { + Widget _buildUpdateButton(BuildContext context) { + final lecture = + context.select((model) => model.lecture); final isAdded = context.select( (model) => model.currentTimetable.lectures.contains(lecture)); return IconTextButton( - padding: const EdgeInsets.all(0), + padding: const EdgeInsets.all(16), onTap: () { final timetableModel = context.read(); @@ -143,13 +141,9 @@ class LectureDetailPage extends StatelessWidget { ); } }, - text: isAdded - ? "timetable.remove_lecture".tr() - : "timetable.add_lecture".tr(), - textStyle: const TextStyle(fontSize: 12.0), - icon: isAdded ? Icons.close : Icons.add, - iconSize: 14, - spaceBetween: 4.0, + icon: isAdded + ? Icons.remove_circle_outline_rounded + : Icons.add_circle_outline_rounded, ); } diff --git a/lib/widgets/timetable_block.dart b/lib/widgets/timetable_block.dart index 55df053c..9a1c2142 100644 --- a/lib/widgets/timetable_block.dart +++ b/lib/widgets/timetable_block.dart @@ -2,7 +2,6 @@ import 'package:easy_localization/easy_localization.dart' as loc; import 'package:flutter/material.dart'; import 'package:otlplus/constants/color.dart'; import 'package:otlplus/constants/text_styles.dart'; -import 'package:otlplus/extensions/lecture.dart'; import 'package:otlplus/models/lecture.dart'; import 'package:otlplus/utils/get_text_height.dart'; import 'package:otlplus/widgets/responsive_button.dart'; @@ -17,8 +16,6 @@ class TimetableBlock extends StatelessWidget { final bool isTemp; final bool isExamTime; final bool showTitle; - @Deprecated('There is no case to show the professor') - final bool showProfessor; final bool showClassroom; TimetableBlock( @@ -32,7 +29,6 @@ class TimetableBlock extends StatelessWidget { this.isTemp = false, this.isExamTime = false, this.showTitle = true, - this.showProfessor = false, this.showClassroom = true}) : super(key: key); @@ -59,10 +55,6 @@ class TimetableBlock extends StatelessWidget { )); } - if (showProfessor) { - contents.add(Text(lecture.professorsStrShort)); - } - if (showClassroom) { maxLines = (validHeight - getTextSize(context, diff --git a/lib/widgets/today_timetable.dart b/lib/widgets/today_timetable.dart index b921754c..1277cfb2 100644 --- a/lib/widgets/today_timetable.dart +++ b/lib/widgets/today_timetable.dart @@ -22,10 +22,7 @@ class TodayTimetable extends StatelessWidget { required this.builder, required this.now, this.fontSize = 10.0, - this.dividerPadding = const EdgeInsets.symmetric( - horizontal: 12.0, - vertical: 1.0, - ), + this.dividerPadding = const EdgeInsets.fromLTRB(5, 0, 6, 0), this.daysCount}) { lectures.forEach((lecture) => lecture.classtimes.forEach((classtime) { if (classtime.day == now.weekday - 1) _lectures[classtime] = lecture; @@ -73,10 +70,7 @@ class TodayTimetable extends StatelessWidget { ); } - return Padding( - padding: dividerPadding, - child: Container(color: BORDER_COLOR, width: 1), - ); + return SizedBox(width: _dividerWidth * 3 + 2); } Widget _buildHeaders() { @@ -85,20 +79,22 @@ class TodayTimetable extends StatelessWidget { child: Row( crossAxisAlignment: CrossAxisAlignment.end, children: List.generate( - ((2400 - 900) / 50 + 1).toInt(), (i) => _buildHeader(i * 50 + 900)), + ((2400 - 800) / 50 + 1).toInt(), (i) => _buildHeader(i * 50 + 800)), ), ); } Widget _buildLectureBlock({required Lecture lecture, required Time time}) { - final begin = time.begin / 30 - 18; - final end = time.end / 30 - 18; + final begin = time.begin / 30 - 16; + final end = time.end / 30 - 16; + final left = _dividerWidth * (2 * begin + 0.5) + begin + 1; + final right = _dividerWidth * (2 * end + 0.5) + end - 2; return Positioned( top: 0, - left: _dividerWidth * (begin + 0.5) + 1, + left: left, bottom: 0, - width: _dividerWidth * (end - begin) - 2, + width: right - left, child: Padding( padding: EdgeInsets.symmetric( vertical: dividerPadding.vertical / 3, @@ -110,28 +106,31 @@ class TodayTimetable extends StatelessWidget { } Widget _buildCell(int i) { - if (i % 600 == 0) return Container(color: BORDER_BOLD_COLOR, width: 1); - if (i % 100 == 0) return Container(color: BORDER_COLOR, width: 1); - return Column( - children: List.generate( - 15, - (i) => Expanded( - child: Padding( - padding: const EdgeInsets.symmetric(vertical: 1.0), - child: Container(color: BORDER_COLOR, width: 1), + if (i % 100 == 0) + return Container(color: OTLColor.gray0.withOpacity(0.25), width: 1); + if (i % 50 == 0) + return Column( + children: List.generate( + 15, + (i) => Expanded( + child: Padding( + padding: const EdgeInsets.symmetric(vertical: 1.0), + child: + Container(color: OTLColor.gray0.withOpacity(0.25), width: 1), + ), ), ), - ), - ); + ); + return SizedBox(width: 2); } Widget _buildCells() { return Row( children: List.generate( - ((2400 - 900) / 50 + 1).toInt(), + ((2400 - 800) / 25 + 1).toInt(), (i) => Padding( padding: dividerPadding, - child: _buildCell(i * 50 + 900), + child: _buildCell(i * 25 + 800), )), ); } @@ -145,7 +144,9 @@ class TodayTimetable extends StatelessWidget { .map((e) => _buildLectureBlock(lecture: e.value, time: e.key)), Positioned( top: 0, - left: _dividerWidth * ((now.hour + now.minute / 60) * 2 - 17.5), + left: (_dividerWidth * 4 + 2) * ((now.hour + now.minute / 60) - 8) + + _dividerWidth * 0.5 - + 1, bottom: 0, width: 1, child: Container(key: _timebarKey, color: OTLColor.pinksMain),