Embed Suno handoff web surface
This commit is contained in:
@@ -4,20 +4,11 @@ import SwiftUI
|
||||
|
||||
struct FinalReviewView: View {
|
||||
@Binding var project: SongProject
|
||||
@Environment(\.openURL) private var openURL
|
||||
private let sunoFieldFiller: any SunoFieldFilling
|
||||
|
||||
@State private var newFieldKey = ""
|
||||
@State private var newFieldValue = ""
|
||||
@State private var handoffStatus: HandoffStatus?
|
||||
|
||||
init(
|
||||
project: Binding<SongProject>,
|
||||
sunoFieldFiller: any SunoFieldFilling = MacOSSunoAccessibilityFieldFiller()
|
||||
) {
|
||||
_project = project
|
||||
self.sunoFieldFiller = sunoFieldFiller
|
||||
}
|
||||
@State private var sunoPayload: SunoHandoffPayload?
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
@@ -119,6 +110,16 @@ struct FinalReviewView: View {
|
||||
.help("Add field")
|
||||
}
|
||||
}
|
||||
.sheet(isPresented: Binding(
|
||||
get: { sunoPayload != nil },
|
||||
set: { if !$0 { sunoPayload = nil } }
|
||||
)) {
|
||||
if let sunoPayload {
|
||||
SunoHandoffSheet(payload: sunoPayload) { report in
|
||||
handoffStatus = .fieldFill(report)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var additionalFieldKeys: [String] {
|
||||
@@ -216,21 +217,11 @@ struct FinalReviewView: View {
|
||||
return
|
||||
}
|
||||
|
||||
openURL(SunoHandoffDestination.createPageURL) { accepted in
|
||||
guard accepted else {
|
||||
handoffStatus = .failed("Unable to open the Suno Create page.")
|
||||
return
|
||||
}
|
||||
|
||||
let payload = SunoHandoffPayload(
|
||||
title: project.title,
|
||||
lyrics: output.lyricsText,
|
||||
stylePrompt: output.stylePrompt
|
||||
)
|
||||
Task {
|
||||
handoffStatus = .fieldFill(await sunoFieldFiller.fill(payload))
|
||||
}
|
||||
}
|
||||
sunoPayload = SunoHandoffPayload(
|
||||
title: project.title,
|
||||
lyrics: output.lyricsText,
|
||||
stylePrompt: output.stylePrompt
|
||||
)
|
||||
}
|
||||
|
||||
private var fieldsToCopy: [SunoHandoffField]? {
|
||||
|
||||
Reference in New Issue
Block a user