Refactor UIAlertController Logic

This commit is contained in:
Leon Böttger committed 2025-11-10 19:44:15 +01:00
1 parent 21f0f865b6
commit 4e73fced74
8 files changed
+63 -42

No files matched your search

+1 -1
View File
@@ -129,7 +129,7 @@ struct CapsuleProgress: View {
struct QuickDropToastView_Previews: PreviewProvider {
struct Demo: View {
@State var model = ReceiveModel()
@State var model = ReceiveModel(controlPlusScreen: { _ in })
var body: some View {
QuickDropToastView(
+5 -10
View File
@@ -17,7 +17,6 @@ import LUI
class ReceiveModel: ObservableObject, InboundAppDelegate {
/// For each connection ID, store the last reported progress value
private var processes: [String: Double] = [:]
@@ -29,7 +28,8 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
let controlPlusScreen: (Bool) -> Void
init(controlPlusScreen: @escaping (Bool) -> Void = { _ in }) {
init(controlPlusScreen: @escaping (Bool) -> Void) {
self.controlPlusScreen = controlPlusScreen
NearbyConnectionManager.shared.addInboundAppDelegate(self)
NearbyConnectionManager.shared.becomeVisible()
@@ -103,8 +103,6 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
case .Decline:
secondaryButtonAction()
}
} onCancel: {
NearbyConnectionManager.shared.cancelTransfer(id: transferID)
}
#endif
}
@@ -146,11 +144,6 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
if transfer.type == .text {
showAlert(title: "QuickDrop", message: mainMessage)
}
else {
ProgressAlert.shared.showProgressAlert(onCancel: {
NearbyConnectionManager.shared.cancelTransfer(id: transfer.id)
})
}
#endif
}
@@ -165,7 +158,9 @@ class ReceiveModel: ObservableObject, InboundAppDelegate {
let averageProgress = totalProgress / Double(processes.count)
#if os(iOS)
ProgressAlert.shared.updateProgress(averageProgress)
ProgressAlert.shared.updateProgress(averageProgress, onCancel: {
NearbyConnectionManager.shared.cancelTransfer(id: connectionID)
})
#else
DispatchQueue.main.async {
self.progress = averageProgress