Improve content saving, label editing
This commit is contained in:
@ -12,8 +12,14 @@ struct UploadSheet: View {
|
||||
@Environment(\.dismiss)
|
||||
private var dismiss
|
||||
|
||||
private let lineLimit = 4
|
||||
|
||||
@State
|
||||
private var output: [String] = ["Ready to upload"]
|
||||
private var output: [String]
|
||||
|
||||
init(output: [String] = ["Ready to upload", "", "", ""]) {
|
||||
self.output = output
|
||||
}
|
||||
|
||||
private var uploadSymbol: SFSymbol {
|
||||
if upload.isTransmittingToRemote {
|
||||
@ -34,7 +40,7 @@ struct UploadSheet: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Button("Upload", action: startUpload)
|
||||
.disabled(upload.isTransmittingToRemote)
|
||||
@ -42,12 +48,26 @@ struct UploadSheet: View {
|
||||
Spacer()
|
||||
Button("Close", action: { dismiss() })
|
||||
}
|
||||
ScrollView {
|
||||
Text(output.joined(separator: "\n"))
|
||||
.font(.body.monospaced())
|
||||
.foregroundStyle(.primary)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
VStack(alignment: .leading) {
|
||||
Text(output[0])
|
||||
Text(output[1])
|
||||
Text(output[2])
|
||||
Text(output[3])
|
||||
}
|
||||
.font(.body.monospaced())
|
||||
.lineLimit(1)
|
||||
// TextField("", text: .constant(output.joined(separator: "\n")))
|
||||
// .font(.body.monospaced())
|
||||
// .textFieldStyle(.plain)
|
||||
// .lineLimit(lineLimit)
|
||||
// .disabled(true)
|
||||
// .frame(minHeight: 150)
|
||||
// ScrollView {
|
||||
// Text(output.joined(separator: "\n"))
|
||||
// .font(.body.monospaced())
|
||||
// .foregroundStyle(.primary)
|
||||
// .frame(maxWidth: .infinity, alignment: .leading)
|
||||
// }
|
||||
}
|
||||
.padding()
|
||||
.frame(minWidth: 500, idealWidth: 600)
|
||||
@ -55,18 +75,28 @@ struct UploadSheet: View {
|
||||
|
||||
private func startUpload() {
|
||||
guard let folder = content.storage.outputScope?.url.path() else {
|
||||
output = ["No output folder to start upload"]
|
||||
output = ["No output folder to start upload", "", "", ""]
|
||||
return
|
||||
}
|
||||
output = ["Starting upload..."]
|
||||
output = ["Starting upload...", "", "", ""]
|
||||
|
||||
upload.transmitToRemote(
|
||||
settings: content.settings.general,
|
||||
outputFolder: folder) { newContent in
|
||||
DispatchQueue.main.async {
|
||||
let newLines = newContent.components(separatedBy: "\n").suffix(4)
|
||||
self.output = (self.output + newLines).suffix(4)
|
||||
let newLines = newContent.components(separatedBy: "\n").suffix(lineLimit)
|
||||
if newLines.count >= lineLimit {
|
||||
self.output = newLines.suffix(lineLimit)
|
||||
} else {
|
||||
self.output = (self.output + newLines).suffix(lineLimit)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
UploadSheet(output: [
|
||||
"Some very long text that should cause the view to scroll", "More", "Some", "Yes"
|
||||
])
|
||||
}
|
||||
|
Reference in New Issue
Block a user