mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various improvements
This commit is contained in:
parent
e12b20be74
commit
43d6e7e81c
@ -92,7 +92,7 @@ public final class ChatUserInfoItem: ListViewItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class ChatUserInfoItemNode: ListViewItemNode {
|
public final class ChatUserInfoItemNode: ListViewItemNode, ASGestureRecognizerDelegate {
|
||||||
public var controllerInteraction: ChatControllerInteraction?
|
public var controllerInteraction: ChatControllerInteraction?
|
||||||
|
|
||||||
public let offsetContainer: ASDisplayNode
|
public let offsetContainer: ASDisplayNode
|
||||||
@ -210,6 +210,29 @@ public final class ChatUserInfoItemNode: ListViewItemNode {
|
|||||||
self.groupsButtonNode.addTarget(self, action: #selector(self.groupsPressed), forControlEvents: .touchUpInside)
|
self.groupsButtonNode.addTarget(self, action: #selector(self.groupsPressed), forControlEvents: .touchUpInside)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override public func didLoad() {
|
||||||
|
super.didLoad()
|
||||||
|
|
||||||
|
let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))
|
||||||
|
tapRecognizer.delegate = self.wrappedGestureRecognizerDelegate
|
||||||
|
self.offsetContainer.view.addGestureRecognizer(tapRecognizer)
|
||||||
|
}
|
||||||
|
|
||||||
|
public override func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
|
||||||
|
let location = gestureRecognizer.location(in: self.offsetContainer.view)
|
||||||
|
if let backgroundContent = self.backgroundContent, backgroundContent.frame.contains(location) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func tapGesture(_ gestureRecognizer: UITapGestureRecognizer) {
|
||||||
|
guard let item = self.item else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
item.controllerInteraction.openPeer(item.peer, .info(nil), nil, .default)
|
||||||
|
}
|
||||||
|
|
||||||
override public func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) {
|
override public func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize) {
|
||||||
super.updateAbsoluteRect(rect, within: containerSize)
|
super.updateAbsoluteRect(rect, within: containerSize)
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
|
|
||||||
let context: AccountContext
|
let context: AccountContext
|
||||||
let starsContext: StarsContext
|
let starsContext: StarsContext
|
||||||
|
let starsRevenueStatsContext: StarsRevenueStatsContext
|
||||||
let subscriptionsContext: StarsSubscriptionsContext
|
let subscriptionsContext: StarsSubscriptionsContext
|
||||||
let openTransaction: (StarsContext.State.Transaction) -> Void
|
let openTransaction: (StarsContext.State.Transaction) -> Void
|
||||||
let openSubscription: (StarsContext.State.Subscription) -> Void
|
let openSubscription: (StarsContext.State.Subscription) -> Void
|
||||||
@ -42,6 +43,7 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
init(
|
init(
|
||||||
context: AccountContext,
|
context: AccountContext,
|
||||||
starsContext: StarsContext,
|
starsContext: StarsContext,
|
||||||
|
starsRevenueStatsContext: StarsRevenueStatsContext,
|
||||||
subscriptionsContext: StarsSubscriptionsContext,
|
subscriptionsContext: StarsSubscriptionsContext,
|
||||||
openTransaction: @escaping (StarsContext.State.Transaction) -> Void,
|
openTransaction: @escaping (StarsContext.State.Transaction) -> Void,
|
||||||
openSubscription: @escaping (StarsContext.State.Subscription) -> Void,
|
openSubscription: @escaping (StarsContext.State.Subscription) -> Void,
|
||||||
@ -51,6 +53,7 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
) {
|
) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.starsContext = starsContext
|
self.starsContext = starsContext
|
||||||
|
self.starsRevenueStatsContext = starsRevenueStatsContext
|
||||||
self.subscriptionsContext = subscriptionsContext
|
self.subscriptionsContext = subscriptionsContext
|
||||||
self.openTransaction = openTransaction
|
self.openTransaction = openTransaction
|
||||||
self.openSubscription = openSubscription
|
self.openSubscription = openSubscription
|
||||||
@ -134,6 +137,9 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
private var stateDisposable: Disposable?
|
private var stateDisposable: Disposable?
|
||||||
private var starsState: StarsContext.State?
|
private var starsState: StarsContext.State?
|
||||||
|
|
||||||
|
private var revenueStateDisposable: Disposable?
|
||||||
|
private var revenueState: StarsRevenueStatsContextState?
|
||||||
|
|
||||||
private var previousBalance: StarsAmount?
|
private var previousBalance: StarsAmount?
|
||||||
|
|
||||||
private var subscriptionsStateDisposable: Disposable?
|
private var subscriptionsStateDisposable: Disposable?
|
||||||
@ -190,6 +196,8 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
self.stateDisposable?.dispose()
|
self.stateDisposable?.dispose()
|
||||||
|
self.revenueStateDisposable?.dispose()
|
||||||
|
self.subscriptionsStateDisposable?.dispose()
|
||||||
}
|
}
|
||||||
|
|
||||||
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
||||||
@ -376,6 +384,18 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
self.revenueStateDisposable = (component.starsRevenueStatsContext.state
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] state in
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
self.revenueState = state
|
||||||
|
|
||||||
|
if !self.isUpdating {
|
||||||
|
self.state?.updated()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
self.subscriptionsStateDisposable = (component.subscriptionsContext.state
|
self.subscriptionsStateDisposable = (component.subscriptionsContext.state
|
||||||
|> deliverOnMainQueue).start(next: { [weak self] state in
|
|> deliverOnMainQueue).start(next: { [weak self] state in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
@ -607,13 +627,7 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
contentHeight += descriptionSize.height
|
contentHeight += descriptionSize.height
|
||||||
contentHeight += 29.0
|
contentHeight += 29.0
|
||||||
|
|
||||||
let withdrawAvailable: Bool
|
let withdrawAvailable = self.revenueState?.stats?.balances.withdrawEnabled ?? false
|
||||||
#if DEBUG
|
|
||||||
withdrawAvailable = "".isEmpty
|
|
||||||
#else
|
|
||||||
withdrawAvailable = "".isEmpty
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: component.context.currentAppConfiguration.with { $0 })
|
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: component.context.currentAppConfiguration.with { $0 })
|
||||||
let balanceSize = self.balanceView.update(
|
let balanceSize = self.balanceView.update(
|
||||||
@ -1064,6 +1078,7 @@ final class StarsTransactionsScreenComponent: Component {
|
|||||||
public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
||||||
private let context: AccountContext
|
private let context: AccountContext
|
||||||
private let starsContext: StarsContext
|
private let starsContext: StarsContext
|
||||||
|
private let starsRevenueStatsContext: StarsRevenueStatsContext
|
||||||
private let subscriptionsContext: StarsSubscriptionsContext
|
private let subscriptionsContext: StarsSubscriptionsContext
|
||||||
|
|
||||||
private let options = Promise<[StarsTopUpOption]>()
|
private let options = Promise<[StarsTopUpOption]>()
|
||||||
@ -1074,6 +1089,7 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
|||||||
self.context = context
|
self.context = context
|
||||||
self.starsContext = starsContext
|
self.starsContext = starsContext
|
||||||
|
|
||||||
|
self.starsRevenueStatsContext = context.engine.payments.peerStarsRevenueContext(peerId: context.account.peerId)
|
||||||
self.subscriptionsContext = context.engine.payments.peerStarsSubscriptionsContext(starsContext: starsContext)
|
self.subscriptionsContext = context.engine.payments.peerStarsSubscriptionsContext(starsContext: starsContext)
|
||||||
|
|
||||||
var buyImpl: (() -> Void)?
|
var buyImpl: (() -> Void)?
|
||||||
@ -1082,8 +1098,9 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
|||||||
var openTransactionImpl: ((StarsContext.State.Transaction) -> Void)?
|
var openTransactionImpl: ((StarsContext.State.Transaction) -> Void)?
|
||||||
var openSubscriptionImpl: ((StarsContext.State.Subscription) -> Void)?
|
var openSubscriptionImpl: ((StarsContext.State.Subscription) -> Void)?
|
||||||
super.init(context: context, component: StarsTransactionsScreenComponent(
|
super.init(context: context, component: StarsTransactionsScreenComponent(
|
||||||
context: context,
|
context: self.context,
|
||||||
starsContext: starsContext,
|
starsContext: self.starsContext,
|
||||||
|
starsRevenueStatsContext: self.starsRevenueStatsContext,
|
||||||
subscriptionsContext: self.subscriptionsContext,
|
subscriptionsContext: self.subscriptionsContext,
|
||||||
openTransaction: { transaction in
|
openTransaction: { transaction in
|
||||||
openTransactionImpl?(transaction)
|
openTransactionImpl?(transaction)
|
||||||
@ -1205,6 +1222,12 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
|||||||
case .serverProvided:
|
case .serverProvided:
|
||||||
return
|
return
|
||||||
case .requestPassword:
|
case .requestPassword:
|
||||||
|
let _ = (self.starsRevenueStatsContext.state
|
||||||
|
|> take(1)
|
||||||
|
|> deliverOnMainQueue).start(next: { [weak self] state in
|
||||||
|
guard let self else {
|
||||||
|
return
|
||||||
|
}
|
||||||
let controller = self.context.sharedContext.makeStarsWithdrawalScreen(context: context, completion: { [weak self] amount in
|
let controller = self.context.sharedContext.makeStarsWithdrawalScreen(context: context, completion: { [weak self] amount in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
@ -1222,6 +1245,7 @@ public final class StarsTransactionsScreen: ViewControllerComponentContainer {
|
|||||||
self.present(controller, in: .window(.root))
|
self.present(controller, in: .window(.root))
|
||||||
})
|
})
|
||||||
self.push(controller)
|
self.push(controller)
|
||||||
|
})
|
||||||
default:
|
default:
|
||||||
let controller = starsRevenueWithdrawalController(context: context, peerId: context.account.peerId, amount: 0, initialError: error, present: { [weak self] c, a in
|
let controller = starsRevenueWithdrawalController(context: context, peerId: context.account.peerId, amount: 0, initialError: error, present: { [weak self] c, a in
|
||||||
self?.present(c, in: .window(.root))
|
self?.present(c, in: .window(.root))
|
||||||
|
@ -162,6 +162,21 @@ func preparedChatHistoryViewTransition(from fromView: ChatHistoryView?, to toVie
|
|||||||
}
|
}
|
||||||
index -= 1
|
index -= 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let currentScrollToItem = scrollToItem {
|
||||||
|
index = 0
|
||||||
|
for entry in toView.filteredEntries.reversed() {
|
||||||
|
if index > currentScrollToItem.index {
|
||||||
|
if entry.index.timestamp > 10 {
|
||||||
|
break
|
||||||
|
} else if case .ChatInfoEntry = entry {
|
||||||
|
scrollToItem = ListViewScrollToItem(index: index, position: .bottom(0.0), animated: false, curve: curve, directionHint: .Down)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if scrollToItem == nil {
|
if scrollToItem == nil {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user