From 6def7dbc9fc630cf6c88cf3bb78cd1696cfa18f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20B=C3=B6ttger?= Date: Tue, 9 Sep 2025 14:35:25 +0200 Subject: [PATCH] Refactoring --- QuickDrop.xcodeproj/project.pbxproj | 4 ++-- .../xcshareddata/swiftpm/Package.resolved | 2 +- QuickDropiOS/Configuration.swift | 2 ++ QuickDropiOS/ContentView.swift | 19 +++++-------------- QuickDropiOS/SendModel.swift | 14 ++++++++++++++ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/QuickDrop.xcodeproj/project.pbxproj b/QuickDrop.xcodeproj/project.pbxproj index 27fea5d..2770196 100644 --- a/QuickDrop.xcodeproj/project.pbxproj +++ b/QuickDrop.xcodeproj/project.pbxproj @@ -1221,7 +1221,7 @@ MTL_FAST_MATH = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; - SHARED_BUILD = 70; + SHARED_BUILD = 71; SHARED_VERSION = 2.3; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_EMIT_LOC_STRINGS = YES; @@ -1283,7 +1283,7 @@ MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; SDKROOT = macosx; - SHARED_BUILD = 70; + SHARED_BUILD = 71; SHARED_VERSION = 2.3; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_EMIT_LOC_STRINGS = YES; diff --git a/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 9cc001d..40aedf7 100644 --- a/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -43,7 +43,7 @@ "location" : "https://github.com/leonboe1/LUI.git", "state" : { "branch" : "main", - "revision" : "23696658386572725bc8a8e38ad3675829185921" + "revision" : "85f746ee449d85a36722c3cafe9403525ef3a719" } }, { diff --git a/QuickDropiOS/Configuration.swift b/QuickDropiOS/Configuration.swift index 73581fa..5108cd7 100644 --- a/QuickDropiOS/Configuration.swift +++ b/QuickDropiOS/Configuration.swift @@ -10,6 +10,8 @@ import LUI let configuration = LUIConfiguration( appName: "QuickDrop", + inAppPurchaseName: "plusversion", + hasRoundedFont: false, copyrightInformation: licenseText, diff --git a/QuickDropiOS/ContentView.swift b/QuickDropiOS/ContentView.swift index 3194274..2d2bbb4 100644 --- a/QuickDropiOS/ContentView.swift +++ b/QuickDropiOS/ContentView.swift @@ -12,6 +12,7 @@ import StoreKit struct ContentView: View { @ObservedObject var luiSettings = LUISettings.sharedInstance + @ObservedObject var settings = Settings.shared var body: some View { AppRootView(isPlus: .constant(true), phoneView: { @@ -44,7 +45,6 @@ struct DeviceListView: View { #endif @Environment(\.scenePhase) var scenePhase - @AppStorage("requestedReview") private var requestedReview = false @ObservedObject var nearbyConnectionManager = NearbyConnectionManager.shared var body: some View { @@ -156,23 +156,14 @@ struct DeviceListView: View { if newValue == .active { - log("App became active") + log("[ScenePhase] App became active") NearbyConnectionManager.shared.startDeviceDiscovery() #if !EXTENSION NearbyConnectionManager.shared.becomeVisible() - if Settings.shared.incomingTransmissionCount > 0 && !requestedReview { + if Settings.shared.incomingTransmissionCount > 0 { runAfter(seconds: 0.3) { - if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene { - - log("Requesting Review...") - - SKStoreReviewController.requestReview(in: scene) - requestedReview = true - } - else { - log("Error Requesting Review!") - } + requestReviewOnce() } } #endif @@ -180,7 +171,7 @@ struct DeviceListView: View { if newValue == .background { - log("App went to background") + log("[ScenePhase] App went to background") #if !EXTENSION NearbyConnectionManager.shared.becomeInvisible() #endif diff --git a/QuickDropiOS/SendModel.swift b/QuickDropiOS/SendModel.swift index 09d2607..31fb586 100644 --- a/QuickDropiOS/SendModel.swift +++ b/QuickDropiOS/SendModel.swift @@ -24,29 +24,34 @@ class SendModel: ObservableObject, OutboundAppDelegate { private var connectionEstablished = false private var timeoutDispatchWorkItem: DispatchWorkItem? = nil + init() { NearbyConnectionManager.shared.startDeviceDiscovery() NearbyConnectionManager.shared.addShareExtensionDelegate(self) } + func addDevice(device: RemoteDeviceInfo) { withAnimation(.smooth) { foundDevices.append(device) } } + func removeDevice(id: String) { withAnimation(.smooth) { foundDevices.removeAll { $0.id == id } } } + func connectionWasEstablished(pinCode: String) { connectionEstablished = true progressState = String(format: "PinCode".localized(), arguments: [pinCode]) progressValue = 0 } + func connectionFailed(error: any Error) { #if os(iOS) @@ -59,14 +64,17 @@ class SendModel: ObservableObject, OutboundAppDelegate { selectedDevice = nil } + func transferAccepted() { progressState = "Sending".localized() } + func transferProgress(progress: Double) { progressValue = progress } + func transferFinished() { #if os(iOS) @@ -78,12 +86,18 @@ class SendModel: ObservableObject, OutboundAppDelegate { progressState = "TransferFinished".localized() NearbyConnectionManager.shared.attachments?.closeView?() + + #if !EXTENSION + requestReviewOnce() + #endif } + func startTransferWithQrCode(device: RemoteDeviceInfo) { selectDevice(device: device) } + func selectDevice(device: RemoteDeviceInfo) { // already selected, cancel transfer