From cf7620613f44258061e19b92e9ba8adebae6f23c Mon Sep 17 00:00:00 2001 From: CLARATION Date: Sat, 9 May 2026 01:22:00 -0700 Subject: [PATCH 1/3] refactor: uikit tabbar --- Feather/{FeatherApp.swift => Entry.swift} | 235 ++++++++++------------ Feather/Views/TabController.swift | 73 +++++++ 2 files changed, 175 insertions(+), 133 deletions(-) rename Feather/{FeatherApp.swift => Entry.swift} (65%) create mode 100644 Feather/Views/TabController.swift diff --git a/Feather/FeatherApp.swift b/Feather/Entry.swift similarity index 65% rename from Feather/FeatherApp.swift rename to Feather/Entry.swift index 63ed30db7..eb496dd4f 100644 --- a/Feather/FeatherApp.swift +++ b/Feather/Entry.swift @@ -10,140 +10,17 @@ import Nuke import IDeviceSwift import OSLog -@main -struct FeatherApp: App { - @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate - - let heartbeat = HeartbeatManager.shared - - @StateObject var downloadManager = DownloadManager.shared - let storage = Storage.shared - - var body: some Scene { - WindowGroup { - VStack { - DownloadHeaderView(downloadManager: downloadManager) - .transition(.move(edge: .top).combined(with: .opacity)) - VariedTabbarView() - .environment(\.managedObjectContext, storage.context) - .onOpenURL(perform: _handleURL) - .transition(.move(edge: .top).combined(with: .opacity)) - } - .animation(.smooth, value: downloadManager.manualDownloads.description) - .onReceive(NotificationCenter.default.publisher(for: .heartbeatInvalidHost)) { _ in - DispatchQueue.main.async { - UIAlertController.showAlertWithOk( - title: "InvalidHostID", - message: .localized("Your pairing file is invalid and is incompatible with your device, please import a valid pairing file.") - ) - } - } - // dear god help me - .onAppear { - if let style = UIUserInterfaceStyle(rawValue: UserDefaults.standard.integer(forKey: "Feather.userInterfaceStyle")) { - UIApplication.topViewController()?.view.window?.overrideUserInterfaceStyle = style - } - - UIApplication.topViewController()?.view.window?.tintColor = UIColor(Color(hex: UserDefaults.standard.string(forKey: "Feather.userTintColor") ?? "#848ef9")) - } - } - } - - private func _handleURL(_ url: URL) { - if url.scheme == "feather" { - /// feather://import-certificate?p12=&mobileprovision=&password= - if url.host == "import-certificate" { - guard - let components = URLComponents(url: url, resolvingAgainstBaseURL: false), - let queryItems = components.queryItems - else { - return - } - - func queryValue(_ name: String) -> String? { - queryItems.first(where: { $0.name == name })?.value?.removingPercentEncoding - } - - guard - let p12Base64 = queryValue("p12"), - let provisionBase64 = queryValue("mobileprovision"), - let passwordBase64 = queryValue("password"), - let passwordData = Data(base64Encoded: passwordBase64), - let password = String(data: passwordData, encoding: .utf8) - else { - return - } - - let generator = UINotificationFeedbackGenerator() - generator.prepare() - - guard - let p12URL = FileManager.default.decodeAndWrite(base64: p12Base64, pathComponent: ".p12"), - let provisionURL = FileManager.default.decodeAndWrite(base64: provisionBase64, pathComponent: ".mobileprovision"), - FR.checkPasswordForCertificate(for: p12URL, with: password, using: provisionURL) - else { - generator.notificationOccurred(.error) - return - } - - FR.handleCertificateFiles( - p12URL: p12URL, - provisionURL: provisionURL, - p12Password: password - ) { error in - if let error = error { - UIAlertController.showAlertWithOk(title: .localized("Error"), message: error.localizedDescription) - } else { - generator.notificationOccurred(.success) - } - } - - return - } - /// feather://export-certificate?callback_template=