I need to know the current view width and height, I managed to get it using the following code but it works only if I manually select the NavigationView.
I also tried to include the GeometryReader { ... }
part in another view but it modifies the position of other elements.
My question to you, is there a way to call NavigationView automatically (just in order to get the view sizes) and return to the main view without manual action?
Or is there another way to get the current view width and height?
struct NavigationView : View {
@ObservedObject var myMaze = Maze.sharedInstance
var body : some View {
GeometryReader { geometry in
Path { path in
myMaze.viewWidth = geometry.size.width
myMaze.viewHeight = geometry.size.height
}
}
}
}