diff --git a/ios/OTLWidgets/WeekClassesWidget.swift b/ios/OTLWidgets/WeekClassesWidget.swift index a04e0d7f..7ec60a0a 100644 --- a/ios/OTLWidgets/WeekClassesWidget.swift +++ b/ios/OTLWidgets/WeekClassesWidget.swift @@ -50,7 +50,7 @@ struct WeekClassesWidgetEntryView : View { } , alignment: .top ) - .offset(y: getOffsetByDate(date: entry.date)) + .offset(y: getOffsetByDate(timetable: entry.timetableData?[Int(entry.configuration.nextClassTimetable?.identifier ?? "0") ?? 0], date: entry.date)) } }.padding(16) GeometryReader { proxy in @@ -93,15 +93,28 @@ struct WeekClassesWidgetEntryView : View { } } - func getOffsetByDate(date: Date) -> CGFloat { + func getOffsetByDate(timetable: Timetable?, date: Date) -> CGFloat { + if (timetable == nil || timetable?.lectures.count == 0) { + return 0 + } + var tmp = 0 - let hour = Calendar.current.component(.hour, from: date) >= 2 ? Calendar.current.component(.hour, from: date)-2 : Calendar.current.component(.hour, from: date) + let calendar = Calendar.current + let hour = calendar.component(.hour, from: date) >= 2 ? calendar.component(.hour, from: date)-2 : calendar.component(.hour, from: date) + let minutes = calendar.component(.minute, from: date) + calendar.component(.hour, from: date) * 60 if hour > 9 { tmp = hour >= 18 ? -387 : -43*(hour-9) } - return CGFloat(tmp) + var end = 0 + for lecture in timetable!.lectures { + for classtime in lecture.classtimes { + end = (classtime.end > end) ? classtime.end : end + } + } + + return (end >= minutes) ? CGFloat(tmp) : 0 } func getLecturesData(data: [(Int, Lecture)]) -> [WeekClassesWidgetData] { diff --git a/ios/OTLWidgets/WidgetBase.swift b/ios/OTLWidgets/WidgetBase.swift index 295c9624..5a5236e0 100644 --- a/ios/OTLWidgets/WidgetBase.swift +++ b/ios/OTLWidgets/WidgetBase.swift @@ -92,30 +92,6 @@ func getDayInString(day: Int) -> String { } } -func getTodayLectures(timetable: Timetable?, date: Date) -> [(Int, Lecture)] { - var tmp: [(Int, Lecture)] = [(Int, Lecture)]() - if (timetable == nil) { - return tmp - } - - let calendar = Calendar.current - var day = getDayWithWeekDay(weekday: calendar.component(.weekday, from: date)) - - while tmp.count == 0 { - for l in timetable!.lectures { - for i in 0..= 7) ? 0 : day + 1 - } - - return tmp -} - func getLecturesForDay(timetable: Timetable?, day: Int) -> [(Int, Lecture)] { var tmp: [(Int, Lecture)] = [(Int, Lecture)]() if (timetable == nil) { diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 776a3aa4..fd797b8a 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -358,7 +358,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 1430; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = "The Chromium Authors"; TargetAttributes = { 8BB3457F2A012C99008A0E30 = { @@ -384,7 +384,7 @@ ); mainGroup = 97C146E51CF9000F007C117D; packageReferences = ( - 8BB397432A8E003300DD352E /* XCRemoteSwiftPackageReference "Alamofire" */, + 8BB397432A8E003300DD352E /* XCRemoteSwiftPackageReference "Alamofire.git" */, ); productRefGroup = 97C146EF1CF9000F007C117D /* Products */; projectDirPath = ""; @@ -523,6 +523,7 @@ "${BUILT_PRODUCTS_DIR}/GoogleUtilities/GoogleUtilities.framework", "${BUILT_PRODUCTS_DIR}/PromisesObjC/FBLPromises.framework", "${BUILT_PRODUCTS_DIR}/PromisesSwift/Promises.framework", + "${BUILT_PRODUCTS_DIR}/flutter_native_splash/flutter_native_splash.framework", "${BUILT_PRODUCTS_DIR}/flutter_web_browser/flutter_web_browser.framework", "${BUILT_PRODUCTS_DIR}/flutter_widgetkit/flutter_widgetkit.framework", "${BUILT_PRODUCTS_DIR}/nanopb/nanopb.framework", @@ -545,6 +546,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/GoogleUtilities.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/FBLPromises.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Promises.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_native_splash.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_web_browser.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/flutter_widgetkit.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/nanopb.framework", @@ -1201,7 +1203,7 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ - 8BB397432A8E003300DD352E /* XCRemoteSwiftPackageReference "Alamofire" */ = { + 8BB397432A8E003300DD352E /* XCRemoteSwiftPackageReference "Alamofire.git" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/Alamofire/Alamofire.git"; requirement = { @@ -1214,7 +1216,7 @@ /* Begin XCSwiftPackageProductDependency section */ 8BB397442A8E003300DD352E /* Alamofire */ = { isa = XCSwiftPackageProductDependency; - package = 8BB397432A8E003300DD352E /* XCRemoteSwiftPackageReference "Alamofire" */; + package = 8BB397432A8E003300DD352E /* XCRemoteSwiftPackageReference "Alamofire.git" */; productName = Alamofire; }; /* End XCSwiftPackageProductDependency section */ diff --git a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index c87d15a3..a6b826db 100644 --- a/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@