我必须执行类似操作:要在屏幕上创建登录屏幕,用户可以输入手机号码,然后单击登录按钮,模型表将打开,以便在必须关闭OTP验证表并浏览后进行顶部验证在仪表板上。
我在该contentView上创建了一个内容视图,点击打开模型按钮,点击完成后将打开模型表(sheetView)。与屏幕从 ContentView 导航到 DashboardView 相比,strong>按钮表将消失。
// ContentView
mv
// sheetView:-,它以工作表存在的形式显示为struct ContentView: View {
@State var isAction: Bool = false
@State var isDashboard: Bool = false
var body: some View {
NavigationView{
Button(action: {
self.isAction.toggle()
}) {
Text("Open Model")
}.sheet(isPresented: $isAction) {
sheetView(isDissmis: self.$isAction) { (isNavigateOnDashboard) in
print(isNavigateOnDashboard ?? false)
return self.isDashboard = isNavigateOnDashboard ?? false
}
}
NavigationLink(destination: DashboardView(), isActive: self.$isDashboard) {
EmptyView()
}
}
}
}
。
modalPresentationStyle
//仪表板:-:关闭模型(工作表)屏幕后,应在仪表板上导航。
struct sheetView: View {
@Binding var isDissmis: Bool
var isNavigateDashboard: ((Bool?)) -> Void?
var body: some View {
NavigationView{
Text("Here i have to verifiy Some details")
.navigationBarItems(trailing: doneButton)
}
}
var doneButton: some View {
Button(action: {
self.isDissmis = false
self.isNavigateDashboard(true)
}) {
Text("Done").bold()
}
}
}
有什么线索吗? ??
答案 0 :(得分:1)
您可以通过这种方式更改ContentView
body
,然后关闭工作表视图时,它将导航到DashboardView
此外,也无需在SheetView
var body: some View {
NavigationView{
VStack {
Button(action: {
self.isAction.toggle()
}) {
Text("Open Model")
}.sheet(isPresented: $isAction, onDismiss: {
self.isDashboard.toggle()
}) {
sheetView(isDissmis: self.$isAction)
}
NavigationLink(destination: DashboardView(), isActive: $isDashboard) {
EmptyView()
}
}
}
}