Refactoring

This commit is contained in:
Leon Böttger committed 2025-09-09 14:35:25 +02:00
1 parent fcc0ce0818
commit 6def7dbc9f
5 files changed
+24 -17

No files matched your search

+2
View File
@@ -10,6 +10,8 @@ import LUI
let configuration = LUIConfiguration(
appName: "QuickDrop",
inAppPurchaseName: "plusversion",
hasRoundedFont: false,
copyrightInformation: licenseText,
+5 -14
View File
@@ -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
+14
View File
@@ -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