mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Initial implementation of channel overscroll navigation
This commit is contained in:
41
submodules/ComponentFlow/Source/Components/Rectangle.swift
Normal file
41
submodules/ComponentFlow/Source/Components/Rectangle.swift
Normal file
@@ -0,0 +1,41 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public final class Rectangle: Component {
|
||||
private let color: UIColor
|
||||
private let width: CGFloat?
|
||||
private let height: CGFloat?
|
||||
|
||||
public init(color: UIColor, width: CGFloat? = nil, height: CGFloat? = nil) {
|
||||
self.color = color
|
||||
self.width = width
|
||||
self.height = height
|
||||
}
|
||||
|
||||
public static func ==(lhs: Rectangle, rhs: Rectangle) -> Bool {
|
||||
if !lhs.color.isEqual(rhs.color) {
|
||||
return false
|
||||
}
|
||||
if lhs.width != rhs.width {
|
||||
return false
|
||||
}
|
||||
if lhs.height != rhs.height {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
public func update(view: UIView, availableSize: CGSize, transition: Transition) -> CGSize {
|
||||
var size = availableSize
|
||||
if let width = self.width {
|
||||
size.width = min(size.width, width)
|
||||
}
|
||||
if let height = self.height {
|
||||
size.height = min(size.height, height)
|
||||
}
|
||||
|
||||
view.backgroundColor = self.color
|
||||
|
||||
return size
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user