diff --git a/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/QuickDrop.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2006c69..65ade0c 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" : "0fa79d937a5948c59f44c64b12af21c7d3b408e5" + "revision" : "dc041b1fee0be5a8546044b219ac03d7580da6ad" } }, { diff --git a/QuickDrop.xcodeproj/xcshareddata/xcschemes/QuickDropiOS.xcscheme b/QuickDrop.xcodeproj/xcshareddata/xcschemes/QuickDropiOS.xcscheme new file mode 100644 index 0000000..e493fbd --- /dev/null +++ b/QuickDrop.xcodeproj/xcshareddata/xcschemes/QuickDropiOS.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QuickDrop.xcodeproj/xcshareddata/xcschemes/iOSShareExtension.xcscheme b/QuickDrop.xcodeproj/xcshareddata/xcschemes/iOSShareExtension.xcscheme new file mode 100644 index 0000000..ff58124 --- /dev/null +++ b/QuickDrop.xcodeproj/xcshareddata/xcschemes/iOSShareExtension.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/QuickDrop/Localizable.xcstrings b/QuickDrop/Localizable.xcstrings index 9ea92ae..5b94616 100644 --- a/QuickDrop/Localizable.xcstrings +++ b/QuickDrop/Localizable.xcstrings @@ -6094,6 +6094,113 @@ } } }, + "Preparing" : { + "extractionState" : "manual", + "localizations" : { + "ar" : { + "stringUnit" : { + "state" : "translated", + "value" : "جارٍ التحضير..." + } + }, + "de" : { + "stringUnit" : { + "state" : "translated", + "value" : "Bereite vor..." + } + }, + "en" : { + "stringUnit" : { + "state" : "translated", + "value" : "Preparing..." + } + }, + "es" : { + "stringUnit" : { + "state" : "translated", + "value" : "Preparando..." + } + }, + "fr" : { + "stringUnit" : { + "state" : "translated", + "value" : "Préparation..." + } + }, + "hu" : { + "stringUnit" : { + "state" : "translated", + "value" : "Előkészítés folyamatban..." + } + }, + "it" : { + "stringUnit" : { + "state" : "translated", + "value" : "Preparazione in corso..." + } + }, + "ja" : { + "stringUnit" : { + "state" : "translated", + "value" : "準備中..." + } + }, + "ko" : { + "stringUnit" : { + "state" : "translated", + "value" : "준비 중..." + } + }, + "nl" : { + "stringUnit" : { + "state" : "translated", + "value" : "Voorbereiden..." + } + }, + "pt-BR" : { + "stringUnit" : { + "state" : "translated", + "value" : "Preparando..." + } + }, + "pt-PT" : { + "stringUnit" : { + "state" : "translated", + "value" : "A preparar..." + } + }, + "ro" : { + "stringUnit" : { + "state" : "translated", + "value" : "Se pregătește..." + } + }, + "ru" : { + "stringUnit" : { + "state" : "translated", + "value" : "Подготовка..." + } + }, + "th" : { + "stringUnit" : { + "state" : "translated", + "value" : "กำลังเตรียม..." + } + }, + "uk" : { + "stringUnit" : { + "state" : "translated", + "value" : "Підготовка..." + } + }, + "zh-Hans" : { + "stringUnit" : { + "state" : "translated", + "value" : "准备中…" + } + } + } + }, "PrivacyPolicy" : { "extractionState" : "manual", "localizations" : { diff --git a/QuickDropiOS/ContentView.swift b/QuickDropiOS/ContentView.swift index faa7cd4..75ced08 100644 --- a/QuickDropiOS/ContentView.swift +++ b/QuickDropiOS/ContentView.swift @@ -112,17 +112,11 @@ struct DeviceListView: View { sendModel.textToSend = attachments.textToSend sendModel.selectDevice(device: device) } label: { - DeviceButton(device: device, isSelected: isSelected, progress: sendModel.progressState, progressValue: sendModel.progressValue) + DeviceButtonLabel(device: device, isSelected: isSelected, progress: sendModel.progressState, progressValue: sendModel.progressValue) } } else { - SendPickerButton { - DeviceButton(device: device, isSelected: isSelected, progress: sendModel.progressState, progressValue: sendModel.progressValue) - } onResult: { urls, text in - sendModel.urls = urls ?? [] - sendModel.textToSend = text - sendModel.selectDevice(device: device) - } + DeviceFilePickerButton(device: device, isSelected: isSelected, progressState: sendModel.progressState, progressValue: sendModel.progressValue, sendModel: sendModel) } } .animation(.easeInOut, value: sendModel.progressValue) @@ -153,7 +147,32 @@ struct DeviceListView: View { } -struct DeviceButton: View { +struct DeviceFilePickerButton: View { + + let device: RemoteDeviceInfo + let isSelected: Bool + let progressState: String? + let progressValue: Double? + let sendModel: SendModel + + @State private var isPreparing = false + + var body: some View { + SendPickerButton { + DeviceButtonLabel(device: device, isSelected: isPreparing || isSelected, progress: isPreparing ? "Preparing".localized() : progressState, progressValue: progressValue) + } onResult: { urls, text in + isPreparing = false + sendModel.urls = urls ?? [] + sendModel.textToSend = text + sendModel.selectDevice(device: device) + } onPrepare: { + isPreparing = true + } + } +} + + +struct DeviceButtonLabel: View { let device: RemoteDeviceInfo let isSelected: Bool diff --git a/QuickDropiOS/FilePicker.swift b/QuickDropiOS/FilePicker.swift index 4a71855..a15d3a6 100644 --- a/QuickDropiOS/FilePicker.swift +++ b/QuickDropiOS/FilePicker.swift @@ -13,6 +13,7 @@ import UniformTypeIdentifiers struct SendPickerButton: View { var label: () -> Label var onResult: (_ urls: [URL]?, _ text: String?) -> Void + var onPrepare: (() -> Void)? = nil @State private var showPhotoPicker = false @State private var selectedPhotoItems: [PhotosPickerItem] = [] @@ -45,6 +46,7 @@ struct SendPickerButton: View { ) .onChange(of: selectedPhotoItems) { newItems in guard !newItems.isEmpty else { return } + onPrepare?() updatedPhotoSelection(content: newItems) } // File picker @@ -83,37 +85,37 @@ struct SendPickerButton: View { if let dataUrl = try await item.loadTransferable(type: Data.self) { if let contentType = item.supportedContentTypes.first { - // Step 2: make the URL file name and a get a file extention. + // Step 2: make the URL file name and a get a file extention. let url = fileManager.temporaryDirectory.appendingPathComponent("\(UUID().uuidString).\(contentType.preferredFilenameExtension ?? "")") - - do { - // Step 3: write to temp App file directory and return in completionHandler - try dataUrl.write(to: url) - return url - } catch { - log("Faied to write data to file: \(error)") - throw error - } - - } + + do { + // Step 3: write to temp App file directory and return in completionHandler + try dataUrl.write(to: url) + return url + } catch { + log("Failed to write data to file: \(error)") + throw error + } + + } -// let destination = fileManager.temporaryDirectory.appendingPathComponent(dataUrl.url.lastPathComponent) -// -// // overwrite if file exists -// if fileManager.fileExists(atPath: destination.path) { -// try fileManager.removeItem(at: destination) -// } -// -// log("Copying photo at \(dataUrl.url) to \(destination)") -// -// do { -// try fileManager.copyItem(at: dataUrl.url, to: destination) -// } -// catch { -// log("Failed to copy photo: \(error)") -// throw error -// } -// return destination + // let destination = fileManager.temporaryDirectory.appendingPathComponent(dataUrl.url.lastPathComponent) + // + // // overwrite if file exists + // if fileManager.fileExists(atPath: destination.path) { + // try fileManager.removeItem(at: destination) + // } + // + // log("Copying photo at \(dataUrl.url) to \(destination)") + // + // do { + // try fileManager.copyItem(at: dataUrl.url, to: destination) + // } + // catch { + // log("Failed to copy photo: \(error)") + // throw error + // } + // return destination } return nil } @@ -135,7 +137,7 @@ struct SendPickerButton: View { /// File representation fileprivate struct DataUrl: Transferable { let url: URL - + static var transferRepresentation: some TransferRepresentation { FileRepresentation(contentType: .data) { data in