Updated ContentView struct:
struct ContentView: View {
@EnvironmentObject var myData: MyData
@EnvironmentObject var userViewModel: UserViewModel
var body: some View {
VStack {
NavigationSplitView {
List {
NavigationLink {
MainApp()
.navigationTitle ("Counter")
} label: {
HStack {
Text("Counter")
.font(.largeTitle)
.foregroundColor(Color.red)
Spacer()
Image(systemName: "plus.forwardslash.minus")
.font(.largeTitle)
.foregroundColor(Color.red)
.onTapGesture {
myData.totalLeft = myData.total - myData.counter
}
}
}
NavigationLink {
Settings()
.navigationTitle("Settings")
} label: {
HStack {
Text("Settings")
.font(.largeTitle)
.foregroundColor(Color.red)
Spacer()
Image(systemName: "gear")
.font(.largeTitle)
.foregroundColor(Color.red)
}
}
NavigationLink {
Metrics()
.navigationTitle("Metrics")
} label: {
HStack {
Text("Metrics")
.font(.largeTitle)
.foregroundColor(Color.red)
Spacer()
Image(systemName: "chart.bar")
.font(.largeTitle)
.foregroundColor(Color.red)
}
}
NavigationLink {
ProfileView()
.navigationTitle ("Account")
} label: {
HStack {
Text("Account")
.font(.largeTitle)
.foregroundColor(Color.red)
Spacer()
Image(systemName: "person")
.font(.largeTitle)
.foregroundColor(Color.red)
}
}
}
} detail: {
Text("Select a Page")
}
.environmentObject(userViewModel)
}
}
}