我有一个深层链接的应用程序,所以首先我渲染了一个加载或主页视图:
@main
struct AppMain: App {
var body: some Scene {
WindowGroup {
LoadingView()
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb, perform: handleUserActivity)
}
}
}
但是,在我handleUserActivity响应活动的情况下,如何根据活动参数更新屏幕?例如,我提取了一个值并想从这里渲染视图:
private extension AppMain {
func handleUserActivity(_ userActivity: NSUserActivity) {
guard let url = userActivity.webpageURL,
let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true),
let queryItems = components.queryItems
else {
return
}
if let modelID = queryItems.first(where: { $0.name == "id" })?.value {
SmoothieView(id: modelID) // TODO: How to I render view??
}
}
}
如何替换LoadingView并显示SmoothieView?