mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
[WIP] Premium setup
This commit is contained in:
@@ -5,11 +5,13 @@ public final class Rectangle: Component {
|
||||
private let color: UIColor
|
||||
private let width: CGFloat?
|
||||
private let height: CGFloat?
|
||||
private let tag: NSObject?
|
||||
|
||||
public init(color: UIColor, width: CGFloat? = nil, height: CGFloat? = nil) {
|
||||
public init(color: UIColor, width: CGFloat? = nil, height: CGFloat? = nil, tag: NSObject? = nil) {
|
||||
self.color = color
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.tag = tag
|
||||
}
|
||||
|
||||
public static func ==(lhs: Rectangle, rhs: Rectangle) -> Bool {
|
||||
@@ -25,7 +27,33 @@ public final class Rectangle: Component {
|
||||
return true
|
||||
}
|
||||
|
||||
public func update(view: UIView, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
public final class View: UIView, ComponentTaggedView {
|
||||
fileprivate var componentTag: NSObject?
|
||||
|
||||
override public init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
}
|
||||
|
||||
required public init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
public func matches(tag: Any) -> Bool {
|
||||
if let componentTag = self.componentTag {
|
||||
let tag = tag as AnyObject
|
||||
if componentTag === tag {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
public func makeView() -> View {
|
||||
return View(frame: CGRect())
|
||||
}
|
||||
|
||||
public func update(view: View, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: Transition) -> CGSize {
|
||||
var size = availableSize
|
||||
if let width = self.width {
|
||||
size.width = min(size.width, width)
|
||||
@@ -35,6 +63,7 @@ public final class Rectangle: Component {
|
||||
}
|
||||
|
||||
view.backgroundColor = self.color
|
||||
view.componentTag = self.tag
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user