diff --git a/JellyfinPlayer tvOS/Views/BasicAppSettingsView.swift b/JellyfinPlayer tvOS/Views/BasicAppSettingsView.swift index 241557f9..4f4265ec 100644 --- a/JellyfinPlayer tvOS/Views/BasicAppSettingsView.swift +++ b/JellyfinPlayer tvOS/Views/BasicAppSettingsView.swift @@ -26,9 +26,7 @@ struct BasicAppSettingsView: View { ForEach(self.viewModel.appearances, id: \.self) { appearance in Text(appearance.localizedName).tag(appearance.rawValue) } - }.onChange(of: appAppearance, perform: { _ in - UIApplication.shared.windows.first?.overrideUserInterfaceStyle = appAppearance.style - }) + } } header: { L10n.accessibility.text } diff --git a/JellyfinPlayer.xcodeproj/project.pbxproj b/JellyfinPlayer.xcodeproj/project.pbxproj index 6a711e6e..ecab7ffb 100644 --- a/JellyfinPlayer.xcodeproj/project.pbxproj +++ b/JellyfinPlayer.xcodeproj/project.pbxproj @@ -253,7 +253,6 @@ E131691726C583BC0074BFEE /* LogConstructor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E131691626C583BC0074BFEE /* LogConstructor.swift */; }; E131691826C583BC0074BFEE /* LogConstructor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E131691626C583BC0074BFEE /* LogConstructor.swift */; }; E131691926C583BC0074BFEE /* LogConstructor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E131691626C583BC0074BFEE /* LogConstructor.swift */; }; - E13DD3BD27163C63009D4DAF /* EmailHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = E13DD3BC27163C63009D4DAF /* EmailHelper.swift */; }; E13DD3BF27163DD7009D4DAF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E13DD3BE27163DD7009D4DAF /* AppDelegate.swift */; }; E13DD3C227164941009D4DAF /* SwiftfinStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = E13DD3C127164941009D4DAF /* SwiftfinStore.swift */; }; E13DD3C327164941009D4DAF /* SwiftfinStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = E13DD3C127164941009D4DAF /* SwiftfinStore.swift */; }; @@ -571,7 +570,6 @@ E11D224127378428003F9CB3 /* ServerDetailCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServerDetailCoordinator.swift; sourceTree = ""; }; E1267D3D271A1F46003C492E /* PreferenceUIHostingController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreferenceUIHostingController.swift; sourceTree = ""; }; E131691626C583BC0074BFEE /* LogConstructor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogConstructor.swift; sourceTree = ""; }; - E13DD3BC27163C63009D4DAF /* EmailHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmailHelper.swift; sourceTree = ""; }; E13DD3BE27163DD7009D4DAF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; E13DD3C127164941009D4DAF /* SwiftfinStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftfinStore.swift; sourceTree = ""; }; E13DD3C727164B1E009D4DAF /* UIDeviceExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIDeviceExtensions.swift; sourceTree = ""; }; @@ -1232,7 +1230,6 @@ isa = PBXGroup; children = ( E13DD3BE27163DD7009D4DAF /* AppDelegate.swift */, - E13DD3BC27163C63009D4DAF /* EmailHelper.swift */, 5377CBF4263B596A003A4E83 /* JellyfinPlayerApp.swift */, 5D64683B277B15E4009E09AE /* PreferenceUIHosting */, ); @@ -2017,7 +2014,6 @@ 531AC8BF26750DE20091C7EB /* ImageView.swift in Sources */, E13DD3E927177ED6009D4DAF /* ServerListCoordinator.swift in Sources */, E1C812BD277A8E5D00918266 /* PlayerOverlayDelegate.swift in Sources */, - E13DD3BD27163C63009D4DAF /* EmailHelper.swift in Sources */, E13DD3C227164941009D4DAF /* SwiftfinStore.swift in Sources */, E1AD104A26D94822003E4A08 /* DetailItem.swift in Sources */, 62E632E0267D30CA0063E547 /* LibraryViewModel.swift in Sources */, diff --git a/JellyfinPlayer/App/EmailHelper.swift b/JellyfinPlayer/App/EmailHelper.swift deleted file mode 100644 index 87fd8523..00000000 --- a/JellyfinPlayer/App/EmailHelper.swift +++ /dev/null @@ -1,82 +0,0 @@ -// - /* - * SwiftFin is subject to the terms of the Mozilla Public - * License, v2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * Copyright 2021 Aiden Vigue & Jellyfin Contributors - */ - -import SwiftUI -import MessageUI - -class EmailHelper: NSObject, MFMailComposeViewControllerDelegate { - - public static let shared = EmailHelper() - - override private init() { } - - func sendLogs(logURL: URL) { - if !MFMailComposeViewController.canSendMail() { - // Utilities.showErrorBanner(title: "No mail account found", subtitle: "Please setup a mail account") - return // EXIT - } - - let picker = MFMailComposeViewController() - - let fileManager = FileManager() - let data = fileManager.contents(atPath: logURL.path) - - picker.setSubject("[DEV-BUG] SwiftFin") - picker - .setMessageBody("Please don't edit this email.\n Please don't change the subject. \nUDID: \(UIDevice.current.identifierForVendor?.uuidString ?? "NIL")\n", - isHTML: false) - picker.setToRecipients(["SwiftFin Bug Reports "]) - picker.addAttachmentData(data!, mimeType: "text/plain", fileName: logURL.lastPathComponent) - picker.mailComposeDelegate = self - - EmailHelper.getRootViewController()?.present(picker, animated: true, completion: nil) - } - - func mailComposeController(_ controller: MFMailComposeViewController, didFinishWith result: MFMailComposeResult, error: Error?) { - EmailHelper.getRootViewController()?.dismiss(animated: true, completion: nil) - } - - static func getRootViewController() -> UIViewController? { - UIApplication.shared.windows.first?.rootViewController - } -} - -// A view modifier that detects shaking and calls a function of our choosing. -struct DeviceShakeViewModifier: ViewModifier { - let action: () -> Void - - func body(content: Self.Content) -> some View { - content - .onAppear() - .onReceive(NotificationCenter.default.publisher(for: UIDevice.deviceDidShakeNotification)) { _ in - action() - } - } -} - -// A View extension to make the modifier easier to use. -extension View { - func onShake(perform action: @escaping () -> Void) -> some View { - modifier(DeviceShakeViewModifier(action: action)) - } -} - -// The notification we'll send when a shake gesture happens. -extension UIDevice { - static let deviceDidShakeNotification = Notification.Name(rawValue: "deviceDidShakeNotification") -} - -// Override the default behavior of shake gestures to send our notification instead. -extension UIWindow { - override open func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { - if motion == .motionShake { - NotificationCenter.default.post(name: UIDevice.deviceDidShakeNotification, object: nil) - } - } -} diff --git a/JellyfinPlayer/App/JellyfinPlayerApp.swift b/JellyfinPlayer/App/JellyfinPlayerApp.swift index 2d58ea07..c0fa6b35 100644 --- a/JellyfinPlayer/App/JellyfinPlayerApp.swift +++ b/JellyfinPlayer/App/JellyfinPlayerApp.swift @@ -19,17 +19,11 @@ struct JellyfinPlayerApp: App { var body: some Scene { WindowGroup { - EmptyView() + MainCoordinator().view() .ignoresSafeArea() .onAppear { setupAppearance() } - .withHostingWindow { window in - window?.rootViewController = PreferenceUIHostingController(wrappedView: MainCoordinator().view()) - } - .onShake { - EmailHelper.shared.sendLogs(logURL: LogManager.shared.logFileURL()) - } .onOpenURL { url in AppURLHandler.shared.processDeepLink(url: url) } diff --git a/JellyfinPlayer/Views/BasicAppSettingsView.swift b/JellyfinPlayer/Views/BasicAppSettingsView.swift index 711454b2..71fe5a0b 100644 --- a/JellyfinPlayer/Views/BasicAppSettingsView.swift +++ b/JellyfinPlayer/Views/BasicAppSettingsView.swift @@ -27,9 +27,7 @@ struct BasicAppSettingsView: View { ForEach(self.viewModel.appearances, id: \.self) { appearance in Text(appearance.localizedName).tag(appearance.rawValue) } - }.onChange(of: appAppearance, perform: { _ in - UIApplication.shared.windows.first?.overrideUserInterfaceStyle = appAppearance.style - }) + } } header: { L10n.accessibility.text } diff --git a/JellyfinPlayer/Views/SettingsView.swift b/JellyfinPlayer/Views/SettingsView.swift index f5f405d4..63819e44 100644 --- a/JellyfinPlayer/Views/SettingsView.swift +++ b/JellyfinPlayer/Views/SettingsView.swift @@ -135,9 +135,7 @@ struct SettingsView: View { ForEach(self.viewModel.appearances, id: \.self) { appearance in Text(appearance.localizedName).tag(appearance.rawValue) } - }.onChange(of: appAppearance, perform: { _ in - UIApplication.shared.windows.first?.overrideUserInterfaceStyle = appAppearance.style - }) + } } } .navigationBarTitle("Settings", displayMode: .inline)