Post

Replies

Boosts

Views

Activity

Reply to I am getting an error and cannot figure out how to fix it. Everything looks correct to me. Please help!
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) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23
Reply to I am getting an error and cannot figure out how to fix it. Everything looks correct to me. Please help!
Here is the ProfileView struct: import SwiftUI struct ProfileView: View { @EnvironmentObject var user: UserViewModel var body: some View { VStack { Text("Employee Name: \(user.user?.firstName ?? "") \(user.user?.lastName ?? "")") Text("Store Number: \(user.user?.storeNumber ?? 0)") Text("Team Member Number: \(user.user?.teamMemberNumber ?? 0)") } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
May ’23