mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
[WIP] Star refs
This commit is contained in:
@@ -7,13 +7,19 @@ import ComponentDisplayAdapters
|
||||
public final class ToastContentComponent: Component {
|
||||
public let icon: AnyComponent<Empty>
|
||||
public let content: AnyComponent<Empty>
|
||||
public let insets: UIEdgeInsets
|
||||
public let iconSpacing: CGFloat
|
||||
|
||||
public init(
|
||||
icon: AnyComponent<Empty>,
|
||||
content: AnyComponent<Empty>
|
||||
content: AnyComponent<Empty>,
|
||||
insets: UIEdgeInsets = UIEdgeInsets(top: 10.0, left: 10.0, bottom: 10.0, right: 10.0),
|
||||
iconSpacing: CGFloat = 10.0
|
||||
) {
|
||||
self.icon = icon
|
||||
self.content = content
|
||||
self.insets = insets
|
||||
self.iconSpacing = iconSpacing
|
||||
}
|
||||
|
||||
public static func ==(lhs: ToastContentComponent, rhs: ToastContentComponent) -> Bool {
|
||||
@@ -23,6 +29,12 @@ public final class ToastContentComponent: Component {
|
||||
if lhs.content != rhs.content {
|
||||
return false
|
||||
}
|
||||
if lhs.insets != rhs.insets {
|
||||
return false
|
||||
}
|
||||
if lhs.iconSpacing != rhs.iconSpacing {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -54,10 +66,11 @@ public final class ToastContentComponent: Component {
|
||||
func update(component: ToastContentComponent, availableSize: CGSize, state: EmptyComponentState, environment: Environment<Empty>, transition: ComponentTransition) -> CGSize {
|
||||
var contentHeight: CGFloat = 0.0
|
||||
|
||||
let leftInset: CGFloat = 9.0
|
||||
let rightInset: CGFloat = 6.0
|
||||
let verticalInset: CGFloat = 10.0
|
||||
let spacing: CGFloat = 9.0
|
||||
let leftInset: CGFloat = component.insets.left
|
||||
let rightInset: CGFloat = component.insets.right
|
||||
let topInset: CGFloat = component.insets.top
|
||||
let bottomInset: CGFloat = component.insets.bottom
|
||||
let spacing: CGFloat = component.iconSpacing
|
||||
|
||||
let iconSize = self.icon.update(
|
||||
transition: transition,
|
||||
@@ -72,7 +85,7 @@ public final class ToastContentComponent: Component {
|
||||
containerSize: CGSize(width: availableSize.width - leftInset - rightInset - spacing - iconSize.width, height: availableSize.height)
|
||||
)
|
||||
|
||||
contentHeight += verticalInset * 2.0 + max(iconSize.height, contentSize.height)
|
||||
contentHeight += topInset + bottomInset + max(iconSize.height, contentSize.height)
|
||||
|
||||
if let iconView = self.icon.view {
|
||||
if iconView.superview == nil {
|
||||
@@ -89,7 +102,7 @@ public final class ToastContentComponent: Component {
|
||||
|
||||
let size = CGSize(width: availableSize.width, height: contentHeight)
|
||||
self.backgroundView.updateColor(color: UIColor(white: 0.0, alpha: 0.7), transition: .immediate)
|
||||
self.backgroundView.update(size: size, cornerRadius: 10.0, transition: transition.containedViewLayoutTransition)
|
||||
self.backgroundView.update(size: size, cornerRadius: 14.0, transition: transition.containedViewLayoutTransition)
|
||||
transition.setFrame(view: self.backgroundView, frame: CGRect(origin: CGPoint(), size: size))
|
||||
|
||||
return size
|
||||
|
||||
Reference in New Issue
Block a user