diff --git a/PennMobile/Auth/OAuth2NetworkManager.swift b/PennMobile/Auth/OAuth2NetworkManager.swift index 15bbabffb..9a29b2f3c 100755 --- a/PennMobile/Auth/OAuth2NetworkManager.swift +++ b/PennMobile/Auth/OAuth2NetworkManager.swift @@ -177,7 +177,7 @@ extension OAuth2NetworkManager { let json = try decoder.decode(TokenResponse.self, from: data) let expiration = Date().add(seconds: json.expiresIn) let accessToken = AccessToken(value: json.accessToken, expiration: expiration) - let refreshToken = json.refreshToken +// let refreshToken = json.refreshToken if let refreshToken = json.refreshToken { saveRefreshToken(token: refreshToken) diff --git a/PennMobile/Clubs/Ticket Scanner/ScannerViewModel.swift b/PennMobile/Clubs/Ticket Scanner/ScannerViewModel.swift index 3a474b4b5..097155ae2 100644 --- a/PennMobile/Clubs/Ticket Scanner/ScannerViewModel.swift +++ b/PennMobile/Clubs/Ticket Scanner/ScannerViewModel.swift @@ -18,7 +18,7 @@ enum CameraState { case ready } -extension CVImageBuffer: @unchecked Sendable {} +extension CVImageBuffer: @unchecked @retroactive Sendable {} extension CHHapticEngine { func makePlayer(hapticName: String) throws -> CHHapticPatternPlayer { diff --git a/PennMobile/Dining/SwiftUI/DiningAnalyticsView.swift b/PennMobile/Dining/SwiftUI/DiningAnalyticsView.swift index e5af7a76f..b3ce35f5c 100644 --- a/PennMobile/Dining/SwiftUI/DiningAnalyticsView.swift +++ b/PennMobile/Dining/SwiftUI/DiningAnalyticsView.swift @@ -16,15 +16,15 @@ struct DiningAnalyticsView: View { @State var notLoggedInAlertShowing = false @State var showSettingsSheet = false @Environment(\.colorScheme) var colorScheme - @Environment(\.presentationMode) var presentationMode + @Environment(\.dismiss) var dismiss func showCorrectAlert() -> Alert { if !Account.isLoggedIn { - return Alert(title: Text("You must log in to access this feature."), message: Text("Please login on the \"More\" tab."), dismissButton: .default(Text("Ok"), action: { presentationMode.wrappedValue.dismiss() })) + return Alert(title: Text("You must log in to access this feature."), message: Text("Please login on the \"More\" tab."), dismissButton: .default(Text("Ok"), action: { dismiss() })) } else { return Alert(title: Text("\"Penn Mobile\" requires you to login to Campus Express to use this feature."), message: Text("Would you like to continue to campus express?"), primaryButton: .default(Text("Continue"), action: {showDiningLoginView = true}), - secondaryButton: .cancel({ presentationMode.wrappedValue.dismiss() })) + secondaryButton: .cancel({ dismiss() })) } } var body: some View { diff --git a/PennMobile/Dining/SwiftUI/DiningLoginNavigationView.swift b/PennMobile/Dining/SwiftUI/DiningLoginNavigationView.swift index f80c7939a..38ce3d779 100644 --- a/PennMobile/Dining/SwiftUI/DiningLoginNavigationView.swift +++ b/PennMobile/Dining/SwiftUI/DiningLoginNavigationView.swift @@ -14,7 +14,7 @@ struct DiningLoginNavigationView: View { @EnvironmentObject var diningAnalyticsViewModel: DiningAnalyticsViewModel var body: some View { - NavigationView { + NavigationStack { DiningLoginViewSwiftUI(onDismiss: { dismiss() }) .navigationBarTitle(Text("Login"), displayMode: .inline) .navigationBarItems(trailing: Button(action: { diff --git a/PennMobile/Dining/SwiftUI/DiningSettingsView.swift b/PennMobile/Dining/SwiftUI/DiningSettingsView.swift index 67652c259..195bf8da5 100644 --- a/PennMobile/Dining/SwiftUI/DiningSettingsView.swift +++ b/PennMobile/Dining/SwiftUI/DiningSettingsView.swift @@ -12,62 +12,36 @@ import PennMobileShared struct DiningSettingsView: View { @ObservedObject var viewModel: DiningAnalyticsViewModel - @Environment(\.presentationMode) var presentationMode + @Environment(\.dismiss) var dismiss @State private var totalData = false private let options = ["All data", "Smart calculation", "Weighted average"] var body: some View { - if #available(iOS 16.0, *) { - NavigationView { - Form { - Picker(selection: $viewModel.selectedOptionIndex, label: Text("Slope Calculation")) { - ForEach(0.. @EnvironmentObject var diningVM: DiningViewModelSwiftUI @State private var pickerIndex = 0 @State private var contentOffset: CGPoint = .zero diff --git a/PennMobile/Dining/SwiftUI/Views/Venue/DiningVenueView.swift b/PennMobile/Dining/SwiftUI/Views/Venue/DiningVenueView.swift index e94666a9b..22883cbe7 100644 --- a/PennMobile/Dining/SwiftUI/Views/Venue/DiningVenueView.swift +++ b/PennMobile/Dining/SwiftUI/Views/Venue/DiningVenueView.swift @@ -181,7 +181,7 @@ struct CustomHeader: View { @State var showMissingDiningTokenAlert = false @State var showDiningLoginView = false @State var buttonAngle: Angle = .zero - @Environment(\.presentationMode) var presentationMode + @Environment(\.dismiss) var dismiss @Environment(\.accessibilityReduceMotion) var reduceMotion @EnvironmentObject var diningAnalyticsViewModel: DiningAnalyticsViewModel func showCorrectAlert () -> Alert { @@ -191,7 +191,7 @@ struct CustomHeader: View { return Alert(title: Text("\"Penn Mobile\" requires you to login to Campus Express to use this feature."), message: Text("Would you like to continue to campus express?"), primaryButton: .default(Text("Continue"), action: {showDiningLoginView = true}), - secondaryButton: .cancel({ presentationMode.wrappedValue.dismiss() })) + secondaryButton: .cancel({ dismiss() })) } } @@ -260,27 +260,8 @@ struct CustomHeader: View { .onChange(of: isRefreshing) { refreshing in animateButton(refreshing: refreshing) } - - // Note: The Alert view is soon to be deprecated, but .alert(_:isPresented:presenting:actions:message:) is available in iOS15+ .alert(isPresented: $showMissingDiningTokenAlert) { showCorrectAlert() } - - // iOS 15+ implementation - /* .alert(Account.isLoggedIn ? "\"Penn Mobile\" requires you to login to Campus Express to use this feature." : "You must log in to access this feature.", isPresented: $showMissingDiningTokenAlert - ) { - if (!Account.isLoggedIn) { - Button("OK") {} - } else { - Button("Continue") { showDiningLoginView = true } - Button("Cancel") { presentationMode.wrappedValue.dismiss() } - } - } message: { - if (!Account.isLoggedIn) { - Text("Please login on the \"More\" tab.") - } else { - Text("Would you like to continue to Campus Express?") - } - } */ } } diff --git a/PennMobile/Events/Views/PennEventCellView.swift b/PennMobile/Events/Views/PennEventCellView.swift index bde52b5d7..819d053d6 100644 --- a/PennMobile/Events/Views/PennEventCellView.swift +++ b/PennMobile/Events/Views/PennEventCellView.swift @@ -22,7 +22,7 @@ struct PennEventCellView: View { var body: some View { ZStack { if let imageUrl = event.imageUrl { - KFImage(event.imageUrl) + KFImage(imageUrl) .resizable() .aspectRatio(contentMode: .fill) .frame(height: 190) diff --git a/PennMobile/General/UserDefaults + Helpers.swift b/PennMobile/General/UserDefaults + Helpers.swift index ba3356dad..1464636dd 100644 --- a/PennMobile/General/UserDefaults + Helpers.swift +++ b/PennMobile/General/UserDefaults + Helpers.swift @@ -562,7 +562,7 @@ extension UserDefaults { // MARK: - Current Dining Balance Object extension UserDefaults { @available(*, deprecated) - func setdiningBalance(_ diningBalance: DiningBalance) { + func setDiningBalance(_ diningBalance: DiningBalance) { let encoder = JSONEncoder() if let encoded = try? encoder.encode(diningBalance) { UserDefaults.standard.set(encoded, forKey: UserDefaultsKeys.diningBalance.rawValue) diff --git a/PennMobile/Login/PathAtPennNetworkManager.swift b/PennMobile/Login/PathAtPennNetworkManager.swift index 323fa57ef..f1385cab9 100644 --- a/PennMobile/Login/PathAtPennNetworkManager.swift +++ b/PennMobile/Login/PathAtPennNetworkManager.swift @@ -121,7 +121,7 @@ extension PathAtPennNetworkManager { request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") request.httpBody = twoFactorRequestBody - let (postData, postResponse) = try await URLSession.shared.data(for: request) + let (_, _) = try await URLSession.shared.data(for: request) return try await getTokenWithoutReauthenticating() } catch { diff --git a/PennMobile/Setup + Navigation/RootViewController.swift b/PennMobile/Setup + Navigation/RootViewController.swift index 9860e8132..ce7de9dea 100755 --- a/PennMobile/Setup + Navigation/RootViewController.swift +++ b/PennMobile/Setup + Navigation/RootViewController.swift @@ -38,35 +38,29 @@ class RootViewController: UIViewController, NotificationRequestable, ShowsAlert view.addSubview(current.view) current.didMove(toParent: self) - if #available(iOS 15, *) { - Task { - if let (data, _) = try? await URLSession.shared.data(from: URL(string: "https://itunes.apple.com/lookup?bundleId=org.pennlabs.PennMobile")!), - let data = try? JSON(data: data), - let version = data["results"][0]["version"].string, - let minimumOsVersion = data["results"][0]["minimumOsVersion"].int { - let appVersion = UserDefaults.standard.getAppVersion() - if appVersion.versionCompare(version) == .orderedAscending { - showOption(withMsg: "New version of PennMobile available for iOS version greater than \(minimumOsVersion). The app may not be fully functional on older versions.", title: "Update available", onAccept: { - guard let url = URL(string: "itms-apps://apps.apple.com/us/app/penn-mobile/id944829399") else { return } - UIApplication.shared.open(url) - }, onCancel: { - self.applicationWillEnterForeground() - }) - } else { - DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { - self.applicationWillEnterForeground() - } - } + Task { + if let (data, _) = try? await URLSession.shared.data(from: URL(string: "https://itunes.apple.com/lookup?bundleId=org.pennlabs.PennMobile")!), + let data = try? JSON(data: data), + let version = data["results"][0]["version"].string, + let minimumOsVersion = data["results"][0]["minimumOsVersion"].int { + let appVersion = UserDefaults.standard.getAppVersion() + if appVersion.versionCompare(version) == .orderedAscending { + showOption(withMsg: "New version of PennMobile available for iOS version greater than \(minimumOsVersion). The app may not be fully functional on older versions.", title: "Update available", onAccept: { + guard let url = URL(string: "itms-apps://apps.apple.com/us/app/penn-mobile/id944829399") else { return } + UIApplication.shared.open(url) + }, onCancel: { + self.applicationWillEnterForeground() + }) } else { - // No network request, simply go to home DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { self.applicationWillEnterForeground() } } - } - } else { - DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { - self.applicationWillEnterForeground() + } else { + // No network request, simply go to home + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { + self.applicationWillEnterForeground() + } } } } diff --git a/PennMobile/Setup + Navigation/TabBarController.swift b/PennMobile/Setup + Navigation/TabBarController.swift index 5b9db0f50..52442b8bd 100755 --- a/PennMobile/Setup + Navigation/TabBarController.swift +++ b/PennMobile/Setup + Navigation/TabBarController.swift @@ -18,9 +18,7 @@ final class TabBarController: UITabBarController { tabBar.standardAppearance = appearance // Required to prevent tab bar's appearance from switching between light and dark mode - if #available(iOS 15.0, *) { - tabBar.scrollEdgeAppearance = appearance - } + tabBar.scrollEdgeAppearance = appearance } override func viewWillAppear(_ animated: Bool) { diff --git a/PennMobileShared/General/Extensions.swift b/PennMobileShared/General/Extensions.swift index 3b2ffdd13..e349c77c4 100755 --- a/PennMobileShared/General/Extensions.swift +++ b/PennMobileShared/General/Extensions.swift @@ -709,7 +709,7 @@ public extension View { } } -extension CLLocationCoordinate2D: Identifiable { +extension CLLocationCoordinate2D: @retroactive Identifiable { public var id: String { return "\(latitude)-\(longitude)" } diff --git a/Widget/Fitness/FitnessProvider.swift b/Widget/Fitness/FitnessProvider.swift index de43a5f0d..83c0ca657 100644 --- a/Widget/Fitness/FitnessProvider.swift +++ b/Widget/Fitness/FitnessProvider.swift @@ -93,7 +93,7 @@ struct IntentFitnessProvider: IntentTimeli func getSnapshot(for intent: Intent, in context: Context, completion: @escaping (FitnessEntry) -> Void) { Task { - let roomID = intent.configuration.complex.rawValue + let _ = intent.configuration.complex.rawValue completion(await snapshot(configuration: intent.configuration, roomID: 7)) //getSnapshot is only called when widget is in drawer, and not when in home screen. Therefore, when in the drawer, set roomID to 7, which corresponds to 1st floor Fitness, to show a 'preview' of what the widget looks like. Then when the widget is actually placed on the home screen, it shows the instructions, because roomID is now set from getTimeline, where it defaults to 0 (which is the ID to show the instructions) } }