mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Various improvements
This commit is contained in:
@@ -23,6 +23,7 @@ final class StarsBalanceComponent: Component {
|
||||
let actionCooldownUntilTimestamp: Int32?
|
||||
let action: () -> Void
|
||||
let buyAds: (() -> Void)?
|
||||
let additionalAction: AnyComponent<Empty>?
|
||||
|
||||
init(
|
||||
theme: PresentationTheme,
|
||||
@@ -35,7 +36,8 @@ final class StarsBalanceComponent: Component {
|
||||
actionIsEnabled: Bool,
|
||||
actionCooldownUntilTimestamp: Int32? = nil,
|
||||
action: @escaping () -> Void,
|
||||
buyAds: (() -> Void)?
|
||||
buyAds: (() -> Void)?,
|
||||
additionalAction: AnyComponent<Empty>? = nil
|
||||
) {
|
||||
self.theme = theme
|
||||
self.strings = strings
|
||||
@@ -48,6 +50,7 @@ final class StarsBalanceComponent: Component {
|
||||
self.actionCooldownUntilTimestamp = actionCooldownUntilTimestamp
|
||||
self.action = action
|
||||
self.buyAds = buyAds
|
||||
self.additionalAction = additionalAction
|
||||
}
|
||||
|
||||
static func ==(lhs: StarsBalanceComponent, rhs: StarsBalanceComponent) -> Bool {
|
||||
@@ -88,6 +91,8 @@ final class StarsBalanceComponent: Component {
|
||||
private var button = ComponentView<Empty>()
|
||||
private var buyAdsButton = ComponentView<Empty>()
|
||||
|
||||
private var additionalButton = ComponentView<Empty>()
|
||||
|
||||
private var component: StarsBalanceComponent?
|
||||
private weak var state: EmptyComponentState?
|
||||
|
||||
@@ -275,9 +280,29 @@ final class StarsBalanceComponent: Component {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
contentHeight += buttonSize.height
|
||||
}
|
||||
|
||||
if let additionalAction = component.additionalAction {
|
||||
contentHeight += 18.0
|
||||
|
||||
let buttonSize = self.additionalButton.update(
|
||||
transition: transition,
|
||||
component: additionalAction,
|
||||
environment: {},
|
||||
containerSize: CGSize(width: availableSize.width, height: 50.0)
|
||||
)
|
||||
if let buttonView = self.additionalButton.view {
|
||||
if buttonView.superview == nil {
|
||||
self.addSubview(buttonView)
|
||||
}
|
||||
let buttonFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - buttonSize.width) / 2.0), y: contentHeight), size: buttonSize)
|
||||
buttonView.frame = buttonFrame
|
||||
}
|
||||
contentHeight += buttonSize.height
|
||||
contentHeight += 2.0
|
||||
}
|
||||
|
||||
contentHeight += sideInset
|
||||
|
||||
return CGSize(width: availableSize.width, height: contentHeight)
|
||||
|
||||
Reference in New Issue
Block a user