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