1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-11 16:16:48 +01:00
mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonUI/SwiftUI/MetaLabelRepresentable.swift

48 lines
1.0 KiB
Swift
Raw Normal View History

//
// MetaLabelRepresentable.swift
//
//
// Created by MainasuK on 22/10/11.
//
import UIKit
import SwiftUI
import MastodonCore
import MetaTextKit
public struct MetaLabelRepresentable: UIViewRepresentable {
public let textStyle: MetaLabel.Style
public let metaContent: MetaContent
public init(
textStyle: MetaLabel.Style,
metaContent: MetaContent
) {
self.textStyle = textStyle
self.metaContent = metaContent
}
public func makeUIView(context: Context) -> MetaLabel {
let view = MetaLabel(style: textStyle)
view.isUserInteractionEnabled = false
return view
}
public func updateUIView(_ view: MetaLabel, context: Context) {
view.configure(content: metaContent)
}
}
#if DEBUG
struct MetaLabelRepresentable_Preview: PreviewProvider {
static var previews: some View {
MetaLabelRepresentable(
textStyle: .statusUsername,
metaContent: PlaintextMetaContent(string: "Name")
)
}
}
#endif