//
//  FrameView.swift
//  LiveApple
//
//  Created by Shadowfacts on 9/24/22.
//

import SwiftUI

struct FrameView: View {
    let frame: Frame
    @State var image: UIImage?
    let scale = UIScreen.main.scale
    
    var body: some View {
        if let image {
            Image(uiImage: image)
                .onChange(of: frame) { newValue in
                    self.image = UIImage(cgImage: newValue.createImage(), scale: scale, orientation: .up)
                }
        } else {
            Text("creating image")
                .onAppear {
                    self.image = UIImage(cgImage: frame.createImage(), scale: scale, orientation: .up)
                }
        }
    }
}
