Files
divkit/client/ios/DivKit/LayoutProvider/SizeProviderBlock.swift
T
pkurchatov 61e4d752c7 Added div-base.layout_provider
71d4d5a24df7378ccb81a8bcbda80a2c7af900f2
2024-07-09 10:45:14 +03:00

45 lines
1.0 KiB
Swift

import LayoutKit
final class SizeProviderBlock: WrapperBlock, LayoutCachingDefaultImpl {
typealias ValueUpdater = (Int) -> Void
let child: Block
let widthUpdater: ValueUpdater?
let heightUpdater: ValueUpdater?
init(
child: Block,
widthUpdater: ValueUpdater?,
heightUpdater: ValueUpdater?
) {
self.child = child
self.widthUpdater = widthUpdater
self.heightUpdater = heightUpdater
}
func makeCopy(wrapping: Block) -> SizeProviderBlock {
SizeProviderBlock(
child: wrapping,
widthUpdater: widthUpdater,
heightUpdater: heightUpdater
)
}
func equals(_ other: Block) -> Bool {
guard let other = other as? SizeProviderBlock else {
return false
}
return self == other
}
}
extension SizeProviderBlock: Equatable {
static func ==(lhs: SizeProviderBlock, rhs: SizeProviderBlock) -> Bool {
lhs.child == rhs.child
}
}
extension SizeProviderBlock: CustomDebugStringConvertible {
var debugDescription: String { "SizeProviderBlock" }
}