Rather than try to define all of your views upfront, define the models that power them. You can then easily iterate through your model to generate the desired views. Additionally, rather than create separate state for each possible sheet that can be presented, there is an alternate sheet modifier that accepts a binding to an Identifiable instance. This drastically reduces reduces boilerplate, and possible sources of bugs.
Finally AnyView should only ever be a last resort, as it removes the compiler and SwiftUI's ability to optimize possibly destroying performance. If you find yourself using AnyView there is almost always a better way.
struct Model: Identifiable {
		var id: String { title }
		let title: String
}
struct DetailView: View {
		let title: String
		var body: some View {
				Text(title)
		}
}
struct ContentView: View {
		@State private var selectedItem: Model?
		private var gridItemLayout = [GridItem(.flexible()), GridItem(.flexible())]
		private let items = [
				Model(title: "View1"),
				Model(title: "View2"),
				Model(title: "View3"),
				Model(title: "View4")
		]
		var textSize: CGFloat {
				if UIDevice.current.userInterfaceIdiom == .pad {
						return 48
				}
				return 23
		}
		var title: CGFloat {
				if UIDevice.current.userInterfaceIdiom == .pad {
						return 60
				}
				return 34
		}
		var height: CGFloat {
				if UIDevice.current.userInterfaceIdiom == .pad {
						return 0.15
				}
				return 0.15
		}
		var weight: CGFloat {
				if UIDevice.current.userInterfaceIdiom == .pad {
						return 0.44
				}
				return 0.43
		}
		var body: some View {
				NavigationView {
						GeometryReader { geometry in
								ScrollView(.vertical, showsIndicators: true) {
										LazyVGrid(columns: gridItemLayout, spacing: 18) {
												ForEach(items) { item in
														Text(item.title)
																.foregroundColor(.black)
																.frame(width: geometry.size.width * weight, height: geometry.size.height * height)
																.background(Color.white)
																.onTapGesture {
																		selectItem(item)
																}
												}
										}
										.padding()
								}
						}
						.navigationTitle("Title")
				}
				.sheet(item: $selectedItem, content: view(for:))
		}
		private func selectItem(_ item: Model) {
				withAnimation { self.selectedItem = item }
		}
		@ViewBuilder
		private func view(for item: Model) -> some View {
				DetailView(title: item.title)
				// switch item.id {
				// case "View1": View1()
				// case "View2": View2()
				// case "View3": View3()
				// case "View4": View4()
				// default: EmptyView()
				// }
		}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: