import SwiftUI

struct LocalizedTagDetailView: View {
    
    @ObservedObject
    var tag: LocalizedTag
    
    @EnvironmentObject
    private var content: Content
    
    @State
    private var showImagePicker = false

    let transferImage: (language: ContentLanguage, image: FileResource)?

    var body: some View {
        VStack(alignment: .leading) {
            StringPropertyView(
                title: "Name",
                text: $tag.name,
                footer: "The displayed name of the tag")
            
            IdPropertyView(
                id: $tag.urlComponent,
                title: "Page URL String",
                footer: "The url component to use in the url for this tag",
                validation: tag.isValid,
                update: { tag.urlComponent = $0 })

            if let url = tag.originalUrl {
                GenericPropertyView(title: "Original URL") {
                    Text(url)
                }
            }

            LinkPreviewDetailView(
                linkPreview: tag.linkPreview,
                fallbackTitle: tag.name,
                transferImage: transferImage)
        }
    }
}

#Preview {
    LocalizedTagDetailView(tag: Tag.Mock.electronics.english, transferImage: nil)
}
