mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-11 02:51:11 +00:00
Refactoring
This commit is contained in:
1 parent
fcc0ce0818
commit
6def7dbc9f
5 files changed
+24
-17
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user