I want the image I clicked in the first view to the last view as main image.
First View
Clicked on image
Last View
Code for it is below: //This is the First View import SwiftUI
struct kidtshirt: View {
var clothimages:[UIImage] =
[UIImage(named:"IMG_9981")!,
UIImage(named:"IMG_9985")!,
UIImage(named:"IMG_9987")!]
var tshirt:[String]=["PLAIN T-SHIRT\n₹590.00","PRINTED T-SHIRT\n₹790.00","JACQUARD DAISY PRINT T-SHIRT\n₹1,090.00"]
let layout=[GridItem(.flexible()),GridItem(.flexible())]
var body: some View
{
// NavigationView
// {
ScrollView(.vertical)
{
LazyVGrid(columns: layout,spacing: 2)
{
ForEach(Array(zip(clothimages,tshirt)), id: .0)
{
(imager,texter) in
NavigationLink(destination:lastview()){maincustom(content: Image(uiImage:imager), text: texter)
}
}
.navigationBarTitle("Kid Tshirt")
}
}
.navigationBarBackButtonHidden(true)
.navigationBarItems(leading:
NavigationLink(
destination: clothlist()){
navcustom(content:
Image(systemName: "line.horizontal.3"),col: .white)
})
}
//}
}
struct kidtshirt_Previews: PreviewProvider {
static var previews: some View {
kidtshirt()
}
}
//This is the Last View
import SwiftUI
struct lastview: View {
var body: some View {
Image("IMG_9981")
.resizable()
.frame(width: 500, height: 500, alignment: .center)
}
}
struct lastview_Previews: PreviewProvider {
static var previews: some View {
lastview()
}
}