Skip to content

Commit a7a2f17

Browse files
committed
休講・補講・教室変更の背景色を変更
1 parent 71da17f commit a7a2f17

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

lib/domain/lecture_status.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
enum LectureStatus { normal, cancelled, madeUp }
1+
enum LectureStatus { normal, cancelled, madeUp, roomChanged }

lib/feature/course/personal_timetable_calendar_view.dart

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,13 @@ final class PersonalTimetableCalendarView extends HookConsumerWidget {
334334
child: TextButton(
335335
style: TextButton.styleFrom(
336336
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 16),
337-
backgroundColor: SemanticColor.light.backgroundSecondary,
337+
backgroundColor: switch (item?.lectureStatus) {
338+
LectureStatus.cancelled => SemanticColor.light.accentError.withValues(alpha: 0.1),
339+
LectureStatus.madeUp => SemanticColor.light.accentWarning.withValues(alpha: 0.1),
340+
LectureStatus.roomChanged => SemanticColor.light.accentInfo.withValues(alpha: 0.1),
341+
LectureStatus.normal => SemanticColor.light.backgroundSecondary,
342+
null => SemanticColor.light.backgroundSecondary,
343+
},
338344
disabledBackgroundColor: SemanticColor.light.backgroundTertiary,
339345
overlayColor: SemanticColor.light.accentPrimary,
340346
side: BorderSide(color: SemanticColor.light.borderPrimary),
@@ -357,7 +363,26 @@ final class PersonalTimetableCalendarView extends HookConsumerWidget {
357363
style: Theme.of(context).textTheme.bodyLarge?.copyWith(color: SemanticColor.light.labelPrimary),
358364
),
359365
),
360-
if (item != null) _lectureStatusLabel(item.lectureStatus),
366+
if (item != null)
367+
switch (item.lectureStatus) {
368+
LectureStatus.cancelled => Text(
369+
'休講',
370+
style: Theme.of(
371+
context,
372+
).textTheme.labelMedium?.copyWith(color: SemanticColor.light.accentError),
373+
),
374+
LectureStatus.madeUp => Text(
375+
'補講',
376+
style: Theme.of(
377+
context,
378+
).textTheme.labelMedium?.copyWith(color: SemanticColor.light.accentWarning),
379+
),
380+
LectureStatus.roomChanged => Text(
381+
'教室変更',
382+
style: Theme.of(context).textTheme.labelMedium?.copyWith(color: SemanticColor.light.accentInfo),
383+
),
384+
LectureStatus.normal => const SizedBox.shrink(),
385+
},
361386
],
362387
),
363388
),
@@ -372,26 +397,6 @@ final class PersonalTimetableCalendarView extends HookConsumerWidget {
372397
);
373398
}
374399

375-
Widget _lectureStatusLabel(LectureStatus status) {
376-
return switch (status) {
377-
LectureStatus.cancelled => Row(
378-
spacing: 2,
379-
children: [
380-
Icon(Icons.cancel_outlined, size: 16, color: SemanticColor.light.accentError),
381-
Text('休講', style: TextStyle(color: SemanticColor.light.accentError)),
382-
],
383-
),
384-
LectureStatus.madeUp => Row(
385-
spacing: 2,
386-
children: [
387-
Icon(Icons.info_outline, size: 16, color: SemanticColor.light.accentWarning),
388-
Text('補講', style: TextStyle(color: SemanticColor.light.accentWarning)),
389-
],
390-
),
391-
LectureStatus.normal => const SizedBox.shrink(),
392-
};
393-
}
394-
395400
bool _isSameDate(DateTime a, DateTime b) {
396401
return a.year == b.year && a.month == b.month && a.day == b.day;
397402
}

lib/repository/personal_calendar_repository.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,12 @@ final class PersonalCalendarRepositoryImpl implements PersonalCalendarRepository
8585
@visibleForTesting
8686
static LectureStatus toLectureStatus(DottoFoundationV1PersonalCalendarItemStatus status) {
8787
return switch (status) {
88+
DottoFoundationV1PersonalCalendarItemStatus.normal => LectureStatus.normal,
8889
DottoFoundationV1PersonalCalendarItemStatus.cancelled => LectureStatus.cancelled,
8990
DottoFoundationV1PersonalCalendarItemStatus.makeup => LectureStatus.madeUp,
90-
_ => LectureStatus.normal,
91+
DottoFoundationV1PersonalCalendarItemStatus.roomChanged => LectureStatus.roomChanged,
92+
// TODO: API側でstatusの値が増えたときに例外を投げるようにするため、デフォルトはnormalにしておく
93+
DottoFoundationV1PersonalCalendarItemStatus() => LectureStatus.normal,
9194
};
9295
}
9396
}

0 commit comments

Comments
 (0)