//
// ContentView.swift
// shop
//
// Created by Cloud Patel on 26/12/21.
//
import SwiftUI
func trying()
{
for el in clothimages
{
print(el)
}
}
struct ContentView: View {
var clothimages:[UIImage] =
[UIImage(named:"menjacket")!,
UIImage(named:"menjeans")!,
UIImage(named:"mentshirt")!]
var body: some View {
NavigationView{
ScrollView{
Text("Men")
.font(.system(size: 30, weight:.bold))
.padding(.trailing, 320.0)
ScrollView(.horizontal){
HStack{ //this is where I get error //Type '()' cannot conform to 'View'
trying()
// custom(content:Image("mentshirt"),over:"T-shirt",col: .black)
// custom(content:Image("menjeans"),over:"Jeans",col: .black)
// custom(content:Image("menjacket"),over: "Jacket",col: .black)
}
}
Text("Women")
.font(.system(size: 30,weight: .bold))
.padding(.trailing,280.0)
ScrollView(.horizontal){
HStack{
custom(content:Image("womentshirt"),over:"T-shirt",col: .black)
custom(content:Image("womenjeans"),over:"Jeans",col: .black)
custom(content:Image("womenjacket"),over:"Jacket",col: .black)
}
}
Text("Kids")
.font(.system(size: 30,weight: .bold))
.padding(.trailing,320.0)
ScrollView(.horizontal){
HStack{
NavigationLink(destination:login()){
custom(content:Image("kidtshirt"),over:"T-shirt",col:.black)
}
custom(content:Image("kidjeans"),over:"Jeans",col: .black)
custom(content:Image("kidjacket"),over:"Jacket",col:.black)
}
}
}
.navigationBarItems(leading:
NavigationLink(
destination: edit()){
navcustom(content:
Image(systemName: "line.horizontal.3"),col: .white)
},
trailing:
HStack{
navcustom(content:
Image(systemName: "indianrupeesign.circle.fill"),col: .white)
Spacer(minLength: 80)
NavigationLink(destination: cart()){
navcustom(content:
Image(systemName: "cart"),col: .white)
}
Spacer(minLength: 15)
NavigationLink(destination: logger()){
navcustom(content:Image(systemName: "person.crop.circle.fill"), col: .white)
}
}
)
}
}
}
func logger() -> some View{
var userlogg=false
if userlogg{
return AnyView(settings())
}
else{
return AnyView(login())
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
Group {
ContentView()
// .environment(.colorScheme, .dark)
}
}
}
func custom(content:Image,over:String,col:Color) -> some View {
content
.resizable()
.overlay(Text(over).font(.system(size: 20,weight: .bold)).foregroundColor(col),alignment: .bottomLeading)
.frame(width: 400, height: 500, alignment: .center)
.padding(5)
}
func navcustom(content:Image,col:Color)-> some View {
content
.resizable()
.frame(width: 30, height: 30, alignment: /@START_MENU_TOKEN@/.center/@END_MENU_TOKEN@/)
.foregroundColor(col)
}
//class watchlog:ObservableObject{
// @Published var userlogg=false
//}
//struct logging{
// func logger() -> some View{
// var userlogg=true
// if userlogg{
// return AnyView(settings())
// }
// else{
// return AnyView(login())
// }
// }
//}
// even if I use the function a structure I get this error
struct nonsense:View{ var body: some View { func trying(). //Closure containing a declaration cannot be used with result builder 'ViewBuilder' { for el in clothimages { print(el) } } } }