FurnitureApp / Furniture App / ContentView.swift
ContentView.swift
Raw
//
//  ContentView.swift
//  Furniture App
//
//  Created by Milos Ilic on 11.3.23..
//

import SwiftUI

struct FurnitureItem: Identifiable, Hashable {
    
    let id = UUID()
    
    let title: String
    let imageName: String
    let entityName: String
}

struct ContentView: View {
    
    let items: [FurnitureItem]
    
    var body: some View {
        
        NavigationStack {
            
            List (items) { item in
                
                NavigationLink(value: item) {
                    
                    HStack {
                        
                        Image(item.imageName)
                            .resizable()
                            .scaledToFit()
                            .frame(width: 48, height: 48)
                        
                        Text(item.title)
                            .font(.headline)
                    }
                }
            }
            .navigationTitle("Furniture Preview")
            .navigationDestination(for: FurnitureItem.self) { item in
                
                FurnitureARViewRepresentable(item: item)
                    .navigationTitle(item.title)
                    .edgesIgnoringSafeArea(.bottom)
                
            }
        }
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView(items: [
            .init(title: "Chair", imageName: "chair", entityName: "chair"),
            .init(title: "Cup", imageName: "cup", entityName: "cup"),
            .init(title: "Tulip", imageName: "tulip", entityName: "tulip"),
            .init(title: "Gramophone", imageName: "gramophone", entityName: "gramophone"),
            .init(title: "Teapot", imageName: "teapot", entityName: "teapot"),
            .init(title: "TV", imageName: "tv", entityName: "tv")
            
        ])
    }
}