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

+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