WIP fix view constructed when not used...?

main
Mathieu GROUSSEAU 3 weeks ago
parent d89e882e2e
commit c3db0a8e86

@ -48,15 +48,29 @@ struct NewGameView: View {
Section(header: Label("newGame.timeLimit", systemImage: "stopwatch")) {
}
NavigationLink(destination: IngameView(settings: vm, player1: p1, player2: p2)/*.navigationTitle("inGame.title")*/) {
Label("newGame.play", systemImage: "play")
}
}
}.toolbar {
NavigationLink {
NavigationLazyView(IngameView(settings: vm, player1: p1, player2: p2))
// .navigationTitle(Text("Titre" as String))
} label: {
Label("newGame.play", systemImage: "play")
}
}
}
}
// https://stackoverflow.com/questions/57594159/swiftui-navigationlink-loads-destination-view-immediately-without-clicking/61234030#61234030
struct NavigationLazyView<Content: View>: View {
let build: () -> Content
init(_ build: @autoclosure @escaping () -> Content) {
self.build = build
}
var body: Content {
build()
}
}
private struct PlayerSectionView: View {
@ObservedObject
private var settings: PlayerSettingsVM

Loading…
Cancel
Save