Skip to content

Commit

Permalink
Merge pull request #145 from sparcs-kaist/feat@delete-deprecated-color
Browse files Browse the repository at this point in the history
Delete deprecated variables and modify the associated designs
  • Loading branch information
sboh1214 authored Sep 2, 2023
2 parents 1fb0e2d + 0242d97 commit 6171519
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 63 deletions.
7 changes: 0 additions & 7 deletions lib/constants/color.dart
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
36 changes: 15 additions & 21 deletions lib/pages/lecture_detail_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ 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<LectureDetailModel, bool>((model) => model.hasData)
? _buildBody(context)
: Center(
child: const CircularProgressIndicator(),
),
),
trailing: (context.select<LectureDetailModel, bool>(
(model) => model.hasData) &&
context.select<LectureDetailModel, bool>(
(model) => model.isUpdateEnabled) &&
context.read<TimetableModel>().selectedIndex != 0)
? _buildUpdateButton(context)
: null,
),
);
}
Expand All @@ -78,26 +83,19 @@ class LectureDetailPage extends StatelessWidget {
_buildButtons(context, lecture),
const SizedBox(height: 8.0),
Expanded(child: _buildScrollView(context, lecture)),
if (context.select<LectureDetailModel, bool>(
(model) => model.isUpdateEnabled) &&
context.read<TimetableModel>().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<LectureDetailModel, Lecture>((model) => model.lecture);
final isAdded = context.select<TimetableModel, bool>(
(model) => model.currentTimetable.lectures.contains(lecture));

return IconTextButton(
padding: const EdgeInsets.all(0),
padding: const EdgeInsets.all(16),
onTap: () {
final timetableModel = context.read<TimetableModel>();

Expand Down Expand Up @@ -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,
);
}

Expand Down
8 changes: 0 additions & 8 deletions lib/widgets/timetable_block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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(
Expand All @@ -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);

Expand All @@ -59,10 +55,6 @@ class TimetableBlock extends StatelessWidget {
));
}

if (showProfessor) {
contents.add(Text(lecture.professorsStrShort));
}

if (showClassroom) {
maxLines = (validHeight -
getTextSize(context,
Expand Down
55 changes: 28 additions & 27 deletions lib/widgets/today_timetable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand All @@ -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,
Expand All @@ -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),
)),
);
}
Expand All @@ -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),
Expand Down

0 comments on commit 6171519

Please sign in to comment.