Post

Replies

Boosts

Views

Activity

It doesn't work with the code to bind the buttons to the following Views.
I'm having trouble with the code to link the buttons to the following View. ZStack(){ Color(.systemGray6).ignoresSafeArea() VStack() { ScrollView(.horizontal, showsIndicators: false) { HStack() { ForEach(MockData.items) { item in ZStack { Button(action:{ }) { NavigationLink(destination: selectedView(name: item.name)) { EmptyView()} RoundedRectangle(cornerRadius: 10) .foregroundStyle(item.color.self) .frame(width: 70, height: 70) } Image(systemName: item.image) .foregroundColor(.white) .font(.system(size: 30)) .padding(25) } } }//scrollview //opciones }//cierre del VStack .padding(.top, 20) .padding(.leading) Spacer() }//cierre Zstack } //cierre de Zstack .navigationTitle("Caracteristicas") .toolbar{ ToolbarItem(placement: .navigationBarLeading) { Button(action:{}, label: { Image(systemName: "switch.2")}) } ToolbarItem(placement: .navigationBarTrailing) { Button(action:{}, label: {Image(systemName: "person.circle")}) } }//toolBar .accentColor(.red) } } } struct Item: Identifiable { var id = UUID() var name: String var color: Color var image: String } struct MockData { static var items = [Item(name: "Medical" ,color: .red, image:"heart"), Item(name: "Illnes" ,color: .blue, image:"pill"), Item( name:"Vaccune" ,color: .orange, image: "syringe"), Item(name: "Dewor" ,color: .green, image: "microbe"), Item(name: "Allergie" ,color:.purple, image: "allergens")] } @ViewBuilder private func selectedView (name: String) -> some View { switch name { case "Medical": MedicalView() case "Illness": IllnessView() case "Vaccune": VaccuneView() case "Dewor": DeworView() case "Allergie": AllergieView() default: EmptyView() } }
1
0
463
Apr ’24
How can I link to multiple views using Foreach. When I have five options with icons. Each option goes to a different link View
I have a foreach with five options to link different View how to do it with button or NavigationLink using switch Case. HStack() { ForEach(MockData.items) { item in ZStack { Button(action: {}) { NavigationLink("") { switch item { case "MedicalView": MedicalView() case "IllnesView": IllnessView() case "VaccuneView": VaccuneView() case "DeworView": DeworView() case "AllergieView": AllergieView() } } } { RoundedRectangle(cornerRadius: 10) .foregroundStyle(item.color.self) .frame(width: 70, height: 70) .disabled(false) } Image(systemName: item.image) .foregroundColor(.white) .font(.system(size: 30)) } }//scrollview //opciones }//cierre del VStack .padding(.top, 20) .padding(.leading) Spacer() }//cierre Zstack } //cierre de Zstack .navigationTitle("Caracteristicas") .toolbar{ ToolbarItem(placement: .navigationBarLeading) { Button(action:{}, label: { Image(systemName: "switch.2")}) } ToolbarItem(placement: .navigationBarTrailing) { Button(action:{}, label: {Image(systemName: "person.circle")}) } }//toolBar .accentColor(.red) } } } } struct Item: Identifiable { let id = UUID() let color: Color let image: String } struct MockData { static var items = [Item(color: .red, image: "heart"), Item(color: .blue, image:"pill"), Item(color: .orange, image: "syringe"), Item(color: .green, image: "microbe"), Item(color:.purple, image: "allergens")] }
2
0
614
Apr ’24
I want to use Foreach and NavigationLink with SfSymbol for menu
I want to use Foreach and NavigationLink with SfSymbol for menu where each rectangle comes out SFSymbol differently and be able to link to the different View. HStack() { ForEach(MockData.items) {item in //NavigationLink( RoundedRectangle(cornerRadius: 10 ) .frame(width: 70, height: 70) .foregroundStyle(item.color.gradient) } }//scrollview //opciones }//cierre del VStack .padding(.top, 20) .padding(.leading) Spacer() }//cierre Zstack } //cierre de Zstack .navigationTitle("Caracteristicas") .toolbar{ ToolbarItem(placement: .navigationBarLeading) { Button(action:{}, label: { Image(systemName: "switch.2")}) } ToolbarItem(placement: .navigationBarTrailing) { Button(action:{}, label: {Image(systemName: "person.circle")}) } }//toolBar .accentColor(.red) } } } struct Item: Identifiable { let id = UUID() let color: Color let image: String } struct MockData { static var items = [Item(color: .red, image:"heart" ), Item(color: .blue, image:"pill"), Item(color: .orange, image: "syringe"), Item(color: .green, image:"microbe"), Item(color:.purple, image: "allergens")] } I need help figuring out how to do it.
1
0
486
Mar ’24
Using Foreach
I'm using foreach to make some options in a horizontal scrollview then I want to link the next page view. The problem is putting Symbol SF in the code. How can I put this according to the code? ScrollView(.horizontal, showsIndicators: false) { HStack() { ForEach(MockData.items) {item in RoundedRectangle(cornerRadius: 10 ) .frame(width: 80, height: 80) .foregroundStyle(item.color.gradient) } } struct Item: Identifiable { let id = UUID() let color: Color //var image: Image } struct MockData { static var items = [Item(color: .red), Item(color: .blue), Item(color: .orange), Item(color: .green), Item(color:.purple)] }
0
0
332
Jan ’24
scrollview with options
I want to make a scrollview that has different óptimos and different . colors and also links to Scrollview. Distances as i can do it like this example. Where eachn option links to sswiftview. the problem is that you don`t button
3
0
555
Dec ’23
As I can include several buttons that swipe from right to left at the top of the screen
As I can include several buttons that swipe from right to left at the top of the screen. Having this code. @Binding var selected: Int var body: some View { NavigationView{ VStack(){ } .navigationTitle("Carecteries") .toolbar{ ToolbarItem(placement: .navigationBarLeading ) { Button(action:{ }, label: {Image(systemName: "person.circle")}) } ToolbarItem(placement: .navigationBarTrailing) { Button(action:{ }, label: {Image(systemName: "i.circle")}) } } .accentColor(.red) }//close Navigation } } struct HomeView_Previews: PreviewProvider { static var previews: some View { HomeView(selected: .constant(0)) } }
0
0
349
Dec ’23
Implement Tabview and SideMenu
I want implement the lower TabView with the SideMenu in the App. I have a TabviewCustom. when I implement Tabview , the sideMenu disappears how to implement it. How to implement it ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
2
Boosts
0
Views
425
Activity
Jun ’24
It doesn't work with the code to bind the buttons to the following Views.
I'm having trouble with the code to link the buttons to the following View. ZStack(){ Color(.systemGray6).ignoresSafeArea() VStack() { ScrollView(.horizontal, showsIndicators: false) { HStack() { ForEach(MockData.items) { item in ZStack { Button(action:{ }) { NavigationLink(destination: selectedView(name: item.name)) { EmptyView()} RoundedRectangle(cornerRadius: 10) .foregroundStyle(item.color.self) .frame(width: 70, height: 70) } Image(systemName: item.image) .foregroundColor(.white) .font(.system(size: 30)) .padding(25) } } }//scrollview //opciones }//cierre del VStack .padding(.top, 20) .padding(.leading) Spacer() }//cierre Zstack } //cierre de Zstack .navigationTitle("Caracteristicas") .toolbar{ ToolbarItem(placement: .navigationBarLeading) { Button(action:{}, label: { Image(systemName: "switch.2")}) } ToolbarItem(placement: .navigationBarTrailing) { Button(action:{}, label: {Image(systemName: "person.circle")}) } }//toolBar .accentColor(.red) } } } struct Item: Identifiable { var id = UUID() var name: String var color: Color var image: String } struct MockData { static var items = [Item(name: "Medical" ,color: .red, image:"heart"), Item(name: "Illnes" ,color: .blue, image:"pill"), Item( name:"Vaccune" ,color: .orange, image: "syringe"), Item(name: "Dewor" ,color: .green, image: "microbe"), Item(name: "Allergie" ,color:.purple, image: "allergens")] } @ViewBuilder private func selectedView (name: String) -> some View { switch name { case "Medical": MedicalView() case "Illness": IllnessView() case "Vaccune": VaccuneView() case "Dewor": DeworView() case "Allergie": AllergieView() default: EmptyView() } }
Replies
1
Boosts
0
Views
463
Activity
Apr ’24
How can I link to multiple views using Foreach. When I have five options with icons. Each option goes to a different link View
I have a foreach with five options to link different View how to do it with button or NavigationLink using switch Case. HStack() { ForEach(MockData.items) { item in ZStack { Button(action: {}) { NavigationLink("") { switch item { case "MedicalView": MedicalView() case "IllnesView": IllnessView() case "VaccuneView": VaccuneView() case "DeworView": DeworView() case "AllergieView": AllergieView() } } } { RoundedRectangle(cornerRadius: 10) .foregroundStyle(item.color.self) .frame(width: 70, height: 70) .disabled(false) } Image(systemName: item.image) .foregroundColor(.white) .font(.system(size: 30)) } }//scrollview //opciones }//cierre del VStack .padding(.top, 20) .padding(.leading) Spacer() }//cierre Zstack } //cierre de Zstack .navigationTitle("Caracteristicas") .toolbar{ ToolbarItem(placement: .navigationBarLeading) { Button(action:{}, label: { Image(systemName: "switch.2")}) } ToolbarItem(placement: .navigationBarTrailing) { Button(action:{}, label: {Image(systemName: "person.circle")}) } }//toolBar .accentColor(.red) } } } } struct Item: Identifiable { let id = UUID() let color: Color let image: String } struct MockData { static var items = [Item(color: .red, image: "heart"), Item(color: .blue, image:"pill"), Item(color: .orange, image: "syringe"), Item(color: .green, image: "microbe"), Item(color:.purple, image: "allergens")] }
Replies
2
Boosts
0
Views
614
Activity
Apr ’24
I want to use Foreach and NavigationLink with SfSymbol for menu
I want to use Foreach and NavigationLink with SfSymbol for menu where each rectangle comes out SFSymbol differently and be able to link to the different View. HStack() { ForEach(MockData.items) {item in //NavigationLink( RoundedRectangle(cornerRadius: 10 ) .frame(width: 70, height: 70) .foregroundStyle(item.color.gradient) } }//scrollview //opciones }//cierre del VStack .padding(.top, 20) .padding(.leading) Spacer() }//cierre Zstack } //cierre de Zstack .navigationTitle("Caracteristicas") .toolbar{ ToolbarItem(placement: .navigationBarLeading) { Button(action:{}, label: { Image(systemName: "switch.2")}) } ToolbarItem(placement: .navigationBarTrailing) { Button(action:{}, label: {Image(systemName: "person.circle")}) } }//toolBar .accentColor(.red) } } } struct Item: Identifiable { let id = UUID() let color: Color let image: String } struct MockData { static var items = [Item(color: .red, image:"heart" ), Item(color: .blue, image:"pill"), Item(color: .orange, image: "syringe"), Item(color: .green, image:"microbe"), Item(color:.purple, image: "allergens")] } I need help figuring out how to do it.
Replies
1
Boosts
0
Views
486
Activity
Mar ’24
Using Foreach
I'm using foreach to make some options in a horizontal scrollview then I want to link the next page view. The problem is putting Symbol SF in the code. How can I put this according to the code? ScrollView(.horizontal, showsIndicators: false) { HStack() { ForEach(MockData.items) {item in RoundedRectangle(cornerRadius: 10 ) .frame(width: 80, height: 80) .foregroundStyle(item.color.gradient) } } struct Item: Identifiable { let id = UUID() let color: Color //var image: Image } struct MockData { static var items = [Item(color: .red), Item(color: .blue), Item(color: .orange), Item(color: .green), Item(color:.purple)] }
Replies
0
Boosts
0
Views
332
Activity
Jan ’24
scrollview with options
I want to make a scrollview that has different óptimos and different . colors and also links to Scrollview. Distances as i can do it like this example. Where eachn option links to sswiftview. the problem is that you don`t button
Replies
3
Boosts
0
Views
555
Activity
Dec ’23
As I can include several buttons that swipe from right to left at the top of the screen
As I can include several buttons that swipe from right to left at the top of the screen. Having this code. @Binding var selected: Int var body: some View { NavigationView{ VStack(){ } .navigationTitle("Carecteries") .toolbar{ ToolbarItem(placement: .navigationBarLeading ) { Button(action:{ }, label: {Image(systemName: "person.circle")}) } ToolbarItem(placement: .navigationBarTrailing) { Button(action:{ }, label: {Image(systemName: "i.circle")}) } } .accentColor(.red) }//close Navigation } } struct HomeView_Previews: PreviewProvider { static var previews: some View { HomeView(selected: .constant(0)) } }
Replies
0
Boosts
0
Views
349
Activity
Dec ’23