Embed Suno handoff web surface

This commit is contained in:
diyaa
2026-09-14 22:51:16 +02:00
parent 3ed4046d73
commit cd066d0a82
4 changed files with 158 additions and 146 deletions
@@ -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]? {