Код: Выделить всё
struct FullScreenCoverItemOnDismissContent: View {
@State private var coverData: CoverData?
var body: some View {
Button("Present Full-Screen Cover With Data") {
coverData = CoverData(body: "Custom Data")
}
.fullScreenCover(item: $coverData,
onDismiss: didDismiss) { details in
VStack(spacing: 20) {
Text("\(details.body)")
}
.onTapGesture {
coverData = nil
}
}
}
func didDismiss() {
// Handle the dismissing action.
}
}
struct CoverData: Identifiable {
var id: String {
return body
}
let body: String
}
< /code>
Когда я пытаюсь установить значение внутри NavigationLink, я получаю ошибку:
'buildExpression' has been explicitly marked unavailable here (SwiftUICore.ViewBuilder)Код: Выделить всё
struct FullScreenCoverItemOnDismissContent: View {
@State private var coverData: CoverData?
var body: some View {
NavigationLink {
coverData = CoverData(body: "Custom Data")
} label: {
Text("Present Full-Screen Cover With Data")
}
.fullScreenCover(item: $coverData,
onDismiss: didDismiss) { details in
VStack(spacing: 20) {
Text("\(details.body)")
}
.onTapGesture {
coverData = nil
}
}
}
func didDismiss() {
// Handle the dismissing action.
}
}
struct CoverData: Identifiable {
var id: String {
return body
}
let body: String
}
Подробнее здесь: https://stackoverflow.com/questions/795 ... fullscreen