mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Initial reactions implementation
This commit is contained in:
@@ -104,6 +104,10 @@ public protocol _TypeErasedComponent {
|
||||
func _isEqual(to other: _TypeErasedComponent) -> Bool
|
||||
}
|
||||
|
||||
public protocol ComponentTaggedView: UIView {
|
||||
func matches(tag: Any) -> Bool
|
||||
}
|
||||
|
||||
public protocol Component: _TypeErasedComponent, Equatable {
|
||||
associatedtype EnvironmentType = Empty
|
||||
associatedtype View: UIView = UIView
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
private func findTaggedViewImpl(view: UIView, tag: Any) -> UIView? {
|
||||
if let view = view as? ComponentTaggedView {
|
||||
if view.matches(tag: tag) {
|
||||
return view
|
||||
}
|
||||
}
|
||||
|
||||
for subview in view.subviews {
|
||||
if let result = findTaggedViewImpl(view: subview, tag: tag) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
public final class ComponentHostView<EnvironmentType>: UIView {
|
||||
private var currentComponent: AnyComponent<EnvironmentType>?
|
||||
private var currentContainerSize: CGSize?
|
||||
@@ -78,4 +94,12 @@ public final class ComponentHostView<EnvironmentType>: UIView {
|
||||
let result = super.hitTest(point, with: event)
|
||||
return result
|
||||
}
|
||||
|
||||
public func findTaggedView(tag: Any) -> UIView? {
|
||||
guard let componentView = self.componentView else {
|
||||
return nil
|
||||
}
|
||||
|
||||
return findTaggedViewImpl(view: componentView, tag: tag)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user