Skip to content

Commit

Permalink
[timetable] patch set is no longer involved in TimetablePatchOutOfRan…
Browse files Browse the repository at this point in the history
…geIssue
  • Loading branch information
liplum committed May 3, 2024
1 parent b7c8573 commit 2739d34
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
21 changes: 2 additions & 19 deletions lib/timetable/entity/issue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ class TimetableCbeIssue implements TimetableIssue {
/// Credit by Examination
class TimetablePatchOutOfRangeIssue implements TimetableIssue {
final int patchIndex;
final int? inPatchSetIndex;

const TimetablePatchOutOfRangeIssue({
required this.patchIndex,
this.inPatchSetIndex,
});

static bool detect(SitTimetable timetable, TimetablePatch patch) {
Expand All @@ -52,14 +50,9 @@ class TimetablePatchOutOfRangeIssue implements TimetableIssue {
return false;
}

TimetablePatchEntry locate(SitTimetable timetable) {
TimetablePatch locate(SitTimetable timetable) {
final patch = timetable.patches[patchIndex];
final inPatchSetIndex = this.inPatchSetIndex;
if (inPatchSetIndex != null && patch is TimetablePatchSet) {
return patch.patches[inPatchSetIndex];
} else {
return patch;
}
return patch as TimetablePatch;
}
}

Expand Down Expand Up @@ -132,16 +125,6 @@ extension SitTimetable4IssueX on SitTimetable {
patchIndex: i,
));
}
} else if (patch is TimetablePatchSet) {
for (var j = 0; j < patch.patches.length; j++) {
final inner = patch.patches[j];
if (TimetablePatchOutOfRangeIssue.detect(this, inner)) {
issues.add(TimetablePatchOutOfRangeIssue(
patchIndex: i,
inPatchSetIndex: j,
));
}
}
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions lib/timetable/entity/patch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ sealed class TimetablePatchEntry {

String l10n();

String get name;

@override
String toString() => toDartCode();

Expand Down Expand Up @@ -163,9 +161,6 @@ sealed class TimetablePatch extends TimetablePatchEntry {
@JsonKey()
TimetablePatchType get type;

@override
String get name => type.l10n();

const TimetablePatch();

factory TimetablePatch.fromJson(Map<String, dynamic> json) {
Expand Down Expand Up @@ -196,7 +191,6 @@ sealed class TimetablePatch extends TimetablePatchEntry {
@JsonSerializable()
@CopyWith()
class TimetablePatchSet extends TimetablePatchEntry {
@override
final String name;
final List<TimetablePatch> patches;

Expand Down
4 changes: 2 additions & 2 deletions lib/timetable/widgets/issue.dart
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ class _TimetablePatchOutOfRangeIssueWidgetState extends State<TimetablePatchOutO
children: widget.issues.map((issue) {
final patch = issue.locate(timetable);
return ListTile(
leading: Icon(patch is TimetablePatch ? patch.type.icon : Icons.dashboard_customize),
title: patch.name.text(),
leading: Icon(patch.type.icon),
title: patch.type.l10n().text(),
subtitle: patch.l10n().text(),
trailing: PlatformTextButton(
child: i18n.issue.resolve.text(),
Expand Down

0 comments on commit 2739d34

Please sign in to comment.