//
//  ReportStatusView.swift
//  Tusker
//
//  Created by Shadowfacts on 1/13/23.
//  Copyright © 2023 Shadowfacts. All rights reserved.
//

import SwiftUI
import SwiftSoup

private var converter = HTMLConverter()

struct ReportStatusView: View {
    let status: StatusMO
    let mastodonController: MastodonController
    
    private var text: AttributedString {
        let str = AttributedString(converter.convert(status.content))
        return str.transformingAttributes(\.link) { transformer in
            if transformer.value != nil {
                transformer.replace(with: \.foregroundColor, value: .accentColor)
            }
        }
    }
    
    var body: some View {
        VStack(alignment: .leading) {
            Text(text)
            
            if !status.attachments.isEmpty {
                Text("^[\(status.attachments.count) attachments](inflect: true)")
                    .foregroundColor(.secondary)
                    .font(.caption.bold())
            }
        }
    }
}
