Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios

This commit is contained in:
Ilya Laktyushin
2024-08-12 19:43:55 +02:00
15 changed files with 208 additions and 18 deletions

View File

@@ -958,6 +958,7 @@ private final class ChatSendStarsScreenComponent: Component {
private var topOffsetDistance: CGFloat?
private var balance: Int64?
private var amount: Int64 = 1
private var isAnonymous: Bool = false
private var cachedStarImage: (UIImage, PresentationTheme)?
@@ -965,6 +966,8 @@ private final class ChatSendStarsScreenComponent: Component {
private var isPastTopCutoff: Bool?
private var balanceDisposable: Disposable?
override init(frame: CGRect) {
self.bottomOverscrollLimit = 200.0
@@ -1019,6 +1022,10 @@ private final class ChatSendStarsScreenComponent: Component {
fatalError("init(coder:) has not been implemented")
}
deinit {
self.balanceDisposable?.dispose()
}
func scrollViewDidScroll(_ scrollView: UIScrollView) {
if !self.ignoreScrolling {
self.updateScrolling(transition: .immediate)
@@ -1127,10 +1134,26 @@ private final class ChatSendStarsScreenComponent: Component {
let sideInset: CGFloat = 16.0
if self.component == nil {
self.balance = component.balance
self.amount = 50
if let myTopPeer = component.myTopPeer {
self.isAnonymous = myTopPeer.isAnonymous
}
if let starsContext = component.context.starsContext {
self.balanceDisposable = (starsContext.state
|> deliverOnMainQueue).startStrict(next: { [weak self] state in
guard let self else {
return
}
if let state {
if self.balance != state.balance {
self.balance = state.balance
self.state?.updated(transition: .immediate)
}
}
})
}
}
self.component = component
@@ -1335,7 +1358,7 @@ private final class ChatSendStarsScreenComponent: Component {
context: component.context,
theme: environment.theme,
strings: environment.strings,
balance: component.balance
balance: self.balance
)),
environment: {},
containerSize: CGSize(width: 120.0, height: 100.0)
@@ -1751,7 +1774,7 @@ private final class ChatSendStarsScreenComponent: Component {
guard let self, let component = self.component else {
return
}
guard let balance = component.balance else {
guard let balance = self.balance else {
return
}