Add Suno field copy fallback
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import AppKit
|
||||||
import MusicAssistantCore
|
import MusicAssistantCore
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
@@ -65,6 +66,17 @@ struct FinalReviewView: View {
|
|||||||
.foregroundStyle(handoffStatus.foregroundStyle)
|
.foregroundStyle(handoffStatus.foregroundStyle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let fieldsToCopy, let output = project.sunoOutput {
|
||||||
|
HStack(spacing: 8) {
|
||||||
|
ForEach(fieldsToCopy) { field in
|
||||||
|
Button("Copy \(field.displayName)") {
|
||||||
|
copy(field, from: output)
|
||||||
|
}
|
||||||
|
.buttonStyle(.bordered)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
TextField("Suno lyrics", text: sunoLyricsBinding, axis: .vertical)
|
TextField("Suno lyrics", text: sunoLyricsBinding, axis: .vertical)
|
||||||
.lineLimit(4...10)
|
.lineLimit(4...10)
|
||||||
TextField("Suno style prompt", text: sunoStylePromptBinding, axis: .vertical)
|
TextField("Suno style prompt", text: sunoStylePromptBinding, axis: .vertical)
|
||||||
@@ -220,6 +232,30 @@ struct FinalReviewView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var fieldsToCopy: [SunoHandoffField]? {
|
||||||
|
guard case let .fieldFill(report) = handoffStatus else { return nil }
|
||||||
|
let fields = SunoHandoffField.allCases.filter {
|
||||||
|
if case .copyRequired = report.results[$0] { return true }
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return fields.isEmpty ? nil : fields
|
||||||
|
}
|
||||||
|
|
||||||
|
private func copy(_ field: SunoHandoffField, from output: SunoOutput) {
|
||||||
|
let value: String
|
||||||
|
switch field {
|
||||||
|
case .title:
|
||||||
|
value = project.title
|
||||||
|
case .lyrics:
|
||||||
|
value = output.lyricsText
|
||||||
|
case .stylePrompt:
|
||||||
|
value = output.stylePrompt
|
||||||
|
}
|
||||||
|
|
||||||
|
NSPasteboard.general.clearContents()
|
||||||
|
NSPasteboard.general.setString(value, forType: .string)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum HandoffStatus: Equatable {
|
private enum HandoffStatus: Equatable {
|
||||||
|
|||||||
Reference in New Issue
Block a user