Improve upload sheet
This commit is contained in:
parent
01c49433cd
commit
fe4ff93e98
@ -13,7 +13,7 @@ struct UploadSheet: View {
|
||||
private var dismiss
|
||||
|
||||
@State
|
||||
private var output = ""
|
||||
private var output: [String] = ["Ready to upload"]
|
||||
|
||||
private var uploadSymbol: SFSymbol {
|
||||
if upload.isTransmittingToRemote {
|
||||
@ -28,8 +28,8 @@ struct UploadSheet: View {
|
||||
var header: String {
|
||||
let user = content.settings.general.remoteUserForUpload
|
||||
let port = content.settings.general.remotePortForUpload
|
||||
let url = content.settings.general.remotePathForUpload.withHttpPrefixRemoved
|
||||
let path = content.settings.general.remotePathForUpload
|
||||
let url = content.settings.general.url.withHttpPrefixRemoved
|
||||
let path = content.settings.general.remotePathForUpload.withLeadingSlashRemoved
|
||||
return "\(user)@\(url):\(port)/\(path)"
|
||||
}
|
||||
|
||||
@ -43,28 +43,29 @@ struct UploadSheet: View {
|
||||
Button("Close", action: { dismiss() })
|
||||
}
|
||||
ScrollView {
|
||||
Text(output)
|
||||
Text(output.joined(separator: "\n"))
|
||||
.font(.body.monospaced())
|
||||
.foregroundStyle(.primary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
}
|
||||
.padding()
|
||||
.frame(minWidth: 500, idealWidth: 600, idealHeight: 500)
|
||||
.frame(minWidth: 500, idealWidth: 600)
|
||||
}
|
||||
|
||||
private func startUpload() {
|
||||
guard let folder = content.storage.outputScope?.url.path() else {
|
||||
print("No output folder to start upload")
|
||||
output = ["No output folder to start upload"]
|
||||
return
|
||||
}
|
||||
output = ""
|
||||
output = ["Starting upload..."]
|
||||
|
||||
upload.transmitToRemote(
|
||||
settings: content.settings.general,
|
||||
outputFolder: folder) { newContent in
|
||||
DispatchQueue.main.async {
|
||||
self.output += newContent
|
||||
let newLines = newContent.components(separatedBy: "\n").suffix(4)
|
||||
self.output = (self.output + newLines).suffix(4)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user