mirror of
https://github.com/divkit/divkit.git
synced 2026-06-06 20:07:59 +00:00
38 lines
737 B
Swift
38 lines
737 B
Swift
import BaseUIPublic
|
|
import CommonCorePublic
|
|
import DivKit
|
|
import LayoutKit
|
|
|
|
public final class TextExtensionHandler: DivExtensionHandler {
|
|
public let id: String
|
|
private let text: String?
|
|
|
|
public init(
|
|
id: String,
|
|
text: String?
|
|
) {
|
|
self.id = id
|
|
self.text = text
|
|
}
|
|
|
|
public var accessibilityElement: AccessibilityElement? {
|
|
.none(label: text)
|
|
}
|
|
|
|
public func applyBeforeBaseProperties(
|
|
to block: Block,
|
|
div _: DivBase,
|
|
context _: DivBlockModelingContext
|
|
) -> Block {
|
|
guard
|
|
let textBlock = block as? TextBlock,
|
|
let text = text,
|
|
let newTextBlock = TextBlock(copyingAttributesFrom: textBlock, text: text)
|
|
else {
|
|
return block
|
|
}
|
|
|
|
return newTextBlock
|
|
}
|
|
}
|