Skip to content

Commit

Permalink
修复没有开始时间导致的计算下节课错误
Browse files Browse the repository at this point in the history
  • Loading branch information
lollipopkit committed Apr 27, 2023
1 parent c2e7cc1 commit a4494e7
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 27 deletions.
24 changes: 12 additions & 12 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/CustedNG.entitlements;
CURRENT_PROJECT_VERSION = 751;
CURRENT_PROJECT_VERSION = 752;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -512,7 +512,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.751;
MARKETING_VERSION = 1.0.752;
PRODUCT_BUNDLE_IDENTIFIER = com.tusi.app;
PRODUCT_NAME = CustedNG;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -534,7 +534,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = CustedHomeWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 751;
CURRENT_PROJECT_VERSION = 752;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = CustedHomeWidget/Info.plist;
Expand All @@ -544,7 +544,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.751;
MARKETING_VERSION = 1.0.752;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.tusi.app.CustedHomeWidget;
Expand All @@ -569,7 +569,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = CustedHomeWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 751;
CURRENT_PROJECT_VERSION = 752;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = CustedHomeWidget/Info.plist;
Expand All @@ -579,7 +579,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.751;
MARKETING_VERSION = 1.0.752;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.tusi.app.CustedHomeWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -601,7 +601,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = CustedHomeWidgetExtension.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 751;
CURRENT_PROJECT_VERSION = 752;
DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = CustedHomeWidget/Info.plist;
Expand All @@ -611,7 +611,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 1.0.751;
MARKETING_VERSION = 1.0.752;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.tusi.app.CustedHomeWidget;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down Expand Up @@ -740,7 +740,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/CustedNG.entitlements;
CURRENT_PROJECT_VERSION = 751;
CURRENT_PROJECT_VERSION = 752;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -758,7 +758,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.751;
MARKETING_VERSION = 1.0.752;
PRODUCT_BUNDLE_IDENTIFIER = com.tusi.app;
PRODUCT_NAME = CustedNG;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand All @@ -777,7 +777,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/CustedNG.entitlements;
CURRENT_PROJECT_VERSION = 751;
CURRENT_PROJECT_VERSION = 752;
DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
Expand All @@ -795,7 +795,7 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
MARKETING_VERSION = 1.0.751;
MARKETING_VERSION = 1.0.752;
PRODUCT_BUNDLE_IDENTIFIER = com.tusi.app;
PRODUCT_NAME = CustedNG;
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
Expand Down
23 changes: 21 additions & 2 deletions lib/core/util/time_point.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class TimePoint {
int minutes;

TimePoint(int hour, int minute) : minutes = hour * 60 + minute;

TimePoint.minutes(this.minutes);
Expand All @@ -9,12 +11,14 @@ class TimePoint {
minutes = hour * 60 + int.parse(part[1]);
}

TimePoint.fromInt(int start) {
TimePoint.fromString(sectionStartMap[int]);
}

TimePoint.fromDateTime(DateTime dateTime) {
minutes = dateTime.hour * 60 + dateTime.minute;
}

int minutes;

int get hour => minutes ~/ 60;
int get minute => minutes % 60;

Expand Down Expand Up @@ -50,3 +54,18 @@ class TimePoint {
return '$hour:$minute';
}
}

final sectionStartMap = {
1: '8:00',
2: '8:50',
3: '10:05',
4: '10:50',
5: '13:30',
6: '14:20',
7: '15:35',
8: '16:25',
9: '18:00',
10: '18:50',
11: '19:45',
12: '20:35',
};
3 changes: 1 addition & 2 deletions lib/data/models/schedule.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class Schedule extends HiveObject {
int week;
while (true) {
final lessons = activeLessonsIn(date).toList();
lessons.removeWhere((lesson) =>
lesson.startTime == null || lesson.parseStart().isBefore(date));
lessons.removeWhere((lesson) => lesson.parseStart().isBefore(date));
lessons.sort((a, b) => a.startTime.compareTo(b.startTime));
yield* lessons;

Expand Down
6 changes: 4 additions & 2 deletions lib/data/models/schedule_lesson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ class ScheduleLesson extends HiveObject {

bool isActiveInWeek(int week) => weeks.contains(week);

TimePoint parseStart() => TimePoint?.fromString(startTime);
TimePoint parseEnd() => TimePoint?.fromString(endTime);
TimePoint parseStart() =>
TimePoint?.fromString(startTime) ?? TimePoint?.fromInt(startSection);
TimePoint parseEnd() =>
TimePoint?.fromString(endTime) ?? TimePoint?.fromInt(endSection);

bool get isCustom => type == ScheduleLessonType.custom;

Expand Down
6 changes: 3 additions & 3 deletions lib/res/build_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

class BuildData {
static const String name = "CustedNG";
static const int build = 751;
static const int build = 752;
static const String engine = "2.10.5";
static const String buildAt = "2023-04-18 17:29:44.619584";
static const int modifications = 2;
static const String buildAt = "2023-04-27 11:08:57.274033";
static const int modifications = 9;
}
1 change: 1 addition & 0 deletions lib/ui/schedule_tab/add_custom_schedule_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class _AddCustomSchedulePageState extends State<AddCustomSchedulePage> {
}
} catch (e) {
_showBadNotice(reason: '解析失败:$e');
rethrow;
} finally {
setState(() {
_isLoading = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/ui/schedule_tab/lesson_preview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class LessonInfo extends StatelessWidget {
}

Widget _buildData(BuildContext context, double width) {
final tercherNameSplited = lesson.teacherName.split(' ');
final tercherNameSplited = (lesson.teacherName ?? '').split(' ');
var teacherName = '';
if (tercherNameSplited.length > 2) {
teacherName = tercherNameSplited[0] + ' 等';
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/schedule_tab/schedule_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class _ScheduleTabState extends State<ScheduleTab>
usingCustomProfile ? profile.name + ' ' + profile.studentNumber : null;

List<String> display;
final updateTime = scheduleProvider.schedule.createdAt;
final now = DateTime.now();
final updateTime = scheduleProvider.schedule?.createdAt ?? now;

if (scheduleProvider.isBusy) {
display = ['更新中'];
Expand All @@ -128,8 +129,7 @@ class _ScheduleTabState extends State<ScheduleTab>
];
}
}
final isOutdate =
updateTime.isBefore(DateTime.now().subtract(_outdateDuration));
final isOutdate = updateTime.isBefore(now.subtract(_outdateDuration));

// return Text(title);
return AnimatedSwitcher(
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/schedule_tab/schedule_table.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ class ScheduleTable extends StatelessWidget {
final displayDate =
shouldShowMonth ? '${date.month}/${date.day}' : '${date.day}';

final dateOverride = showFestivalAndHoliday
? ScheduleDates.getHoliday(date) : null;
final dateOverride =
showFestivalAndHoliday ? ScheduleDates.getHoliday(date) : null;

items.add(Container(
padding: EdgeInsets.symmetric(vertical: 5),
Expand Down

0 comments on commit a4494e7

Please sign in to comment.