First View:-
import SwiftUI
struct menjeans: View {
var menje:[UIImage] =
[UIImage(named:"IMG_9917")!,
UIImage(named:"IMG_9920")!,
UIImage(named:"IMG_9923")!]
var menjen:[String]=["CROPPED SKINNY JEANS\n₹2,990.00","SKINNY JEANS WITH CHAIN\n₹4,990.00","LOW-RISE SLIM JEANS\n₹2,990.00"]
var menjen2:[UIImage] =
[UIImage(named: "IMG_9918")!,
UIImage(named: "IMG_9922")!,
UIImage(named: "IMG_9925")!]
var menjen3:[UIImage] =
[UIImage(named: "IMG_9919")!,
UIImage(named: "IMG_9921")!,
UIImage(named: "IMG_9924")!]
let layout=[GridItem(.flexible()),GridItem(.flexible())]
var i=0 var body: some View
{ ScrollView(.vertical)
{
LazyVGrid(columns: layout,spacing: 2)
{
ForEach(Array(zip(menje,menjen)), id: .0)
{
(imager,texter) in
NavigationLink(destination:lastview(img:imager, texty: texter))
{
maincustom(content: Image(uiImage:imager), text: texter)
}
}
.navigationBarTitle("Men Jeans")
}
}
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading:
NavigationLink(
destination: clothlist()){
navcustom(content:
Image(systemName: "line.horizontal.3"),col: .white)
})
}
struct menjeans_Previews: PreviewProvider {
static var previews: some View {
menjeans()
.environment(.colorScheme, .dark)
}
}
Last View:-
import SwiftUI
struct lastview: View {
var img:UIImage
var texty:String
var body: some View {
ScrollView(.vertical){
ScrollView(.horizontal){
HStack{
Image(uiImage: img)
.resizable()
.frame(width: 500, height: 500, alignment: .center)
Image(uiImage: img)
.resizable()
.frame(width: 500, height: 500, alignment: .center)
Image(uiImage: img)
.resizable()
.frame(width: 500, height: 500, alignment: .center)
}
}
VStack(alignment: .leading) {
Text(texty)
} }
}
}
And the images are in old post of view.
And the menje,menjen2,mejen3 contains images and menjen contains text related to the image in menje.
menjen2 and menjen3 contain images related to images in menje or you can say it has relation with the images in menje so I need to print the images in menje,menjen2 and menje3 in last view after the user clicks on the image of menje in first view.