mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Various improvements
This commit is contained in:
parent
82addaa434
commit
a443df81dd
9 changed files with 52 additions and 24 deletions
|
|
@ -1423,8 +1423,8 @@ public protocol SharedAccountContext: AnyObject {
|
|||
func makeGiftViewScreen(context: AccountContext, gift: StarGift.UniqueGift, shareStory: ((StarGift.UniqueGift) -> Void)?, openChatTheme: (() -> Void)?, dismissed: (() -> Void)?) -> ViewController
|
||||
func makeGiftWearPreviewScreen(context: AccountContext, gift: StarGift.UniqueGift) -> ViewController
|
||||
func makeGiftAuctionInfoScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: (() -> Void)?) -> ViewController
|
||||
func makeGiftAuctionBidScreen(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext) -> ViewController
|
||||
func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping () -> Void) -> ViewController
|
||||
func makeGiftAuctionBidScreen(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext, acquiredGifts: [GiftAuctionAcquiredGift]?) -> ViewController
|
||||
func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping ([GiftAuctionAcquiredGift]?) -> Void) -> ViewController
|
||||
func makeGiftAuctionActiveBidsScreen(context: AccountContext) -> ViewController
|
||||
|
||||
func makeStorySharingScreen(context: AccountContext, subject: StorySharingSubject, parentController: ViewController) -> ViewController
|
||||
|
|
|
|||
|
|
@ -565,7 +565,7 @@ open class TelegramBaseController: ViewController, KeyShortcutResponder {
|
|||
guard let self, let auction else {
|
||||
return
|
||||
}
|
||||
let controller = self.context.sharedContext.makeGiftAuctionBidScreen(context: self.context, toPeerId: auction.currentBidPeerId ?? self.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction)
|
||||
let controller = self.context.sharedContext.makeGiftAuctionBidScreen(context: self.context, toPeerId: auction.currentBidPeerId ?? self.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction, acquiredGifts: nil)
|
||||
self.push(controller)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -383,7 +383,8 @@ final class GiftOptionsScreenComponent: Component {
|
|||
text: nil,
|
||||
entities: nil,
|
||||
hideName: false,
|
||||
auctionContext: auctionContext
|
||||
auctionContext: auctionContext,
|
||||
acquiredGifts: nil
|
||||
)
|
||||
mainController.push(giftController)
|
||||
} else {
|
||||
|
|
@ -415,11 +416,12 @@ final class GiftOptionsScreenComponent: Component {
|
|||
let giftController = component.context.sharedContext.makeGiftAuctionViewScreen(
|
||||
context: component.context,
|
||||
auctionContext: auctionContext,
|
||||
completion: { [weak mainController] in
|
||||
completion: { [weak mainController] acquiredGifts in
|
||||
let controller = GiftSetupScreen(
|
||||
context: context,
|
||||
peerId: component.peerId,
|
||||
subject: .starGift(gift, nil),
|
||||
auctionAcquiredGifts: acquiredGifts,
|
||||
completion: nil
|
||||
)
|
||||
mainController?.push(controller)
|
||||
|
|
|
|||
|
|
@ -46,17 +46,20 @@ private final class GiftSetupScreenComponent: Component {
|
|||
let context: AccountContext
|
||||
let peerId: EnginePeer.Id
|
||||
let subject: GiftSetupScreen.Subject
|
||||
let auctionAcquiredGifts: [GiftAuctionAcquiredGift]?
|
||||
let completion: (() -> Void)?
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
peerId: EnginePeer.Id,
|
||||
subject: GiftSetupScreen.Subject,
|
||||
auctionAcquiredGifts: [GiftAuctionAcquiredGift]?,
|
||||
completion: (() -> Void)? = nil
|
||||
) {
|
||||
self.context = context
|
||||
self.peerId = peerId
|
||||
self.subject = subject
|
||||
self.auctionAcquiredGifts = auctionAcquiredGifts
|
||||
self.completion = completion
|
||||
}
|
||||
|
||||
|
|
@ -479,7 +482,8 @@ private final class GiftSetupScreenComponent: Component {
|
|||
text: textInputText.string,
|
||||
entities: entities,
|
||||
hideName: self.hideName,
|
||||
auctionContext: auctionContext
|
||||
auctionContext: auctionContext,
|
||||
acquiredGifts: component.auctionAcquiredGifts
|
||||
)
|
||||
environment.controller()?.dismiss()
|
||||
navigationController.pushViewController(controller)
|
||||
|
|
@ -2020,6 +2024,7 @@ public class GiftSetupScreen: ViewControllerComponentContainer {
|
|||
context: AccountContext,
|
||||
peerId: EnginePeer.Id,
|
||||
subject: Subject,
|
||||
auctionAcquiredGifts: [GiftAuctionAcquiredGift]? = nil,
|
||||
completion: (() -> Void)? = nil
|
||||
) {
|
||||
self.context = context
|
||||
|
|
@ -2028,6 +2033,7 @@ public class GiftSetupScreen: ViewControllerComponentContainer {
|
|||
context: context,
|
||||
peerId: peerId,
|
||||
subject: subject,
|
||||
auctionAcquiredGifts: auctionAcquiredGifts,
|
||||
completion: completion
|
||||
), navigationBarAppearance: .none, theme: .default)
|
||||
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ private final class GiftAuctionActiveBidsScreenComponent: Component {
|
|||
guard let self, let component = self.component, let auction, let controller = environment.controller(), let navigationController = controller.navigationController as? NavigationController else {
|
||||
return
|
||||
}
|
||||
let bidController = component.context.sharedContext.makeGiftAuctionBidScreen(context: component.context, toPeerId: auction.currentBidPeerId ?? component.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction)
|
||||
let bidController = component.context.sharedContext.makeGiftAuctionBidScreen(context: component.context, toPeerId: auction.currentBidPeerId ?? component.context.account.peerId, text: nil, entities: nil, hideName: false, auctionContext: auction, acquiredGifts: nil)
|
||||
navigationController.pushViewController(bidController)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -957,6 +957,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||
let hideName: Bool
|
||||
let gift: StarGift
|
||||
let auctionContext: GiftAuctionContext
|
||||
let acquiredGifts: [GiftAuctionAcquiredGift]?
|
||||
|
||||
init(
|
||||
context: AccountContext,
|
||||
|
|
@ -965,7 +966,8 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||
entities: [MessageTextEntity]?,
|
||||
hideName: Bool,
|
||||
gift: StarGift,
|
||||
auctionContext: GiftAuctionContext
|
||||
auctionContext: GiftAuctionContext,
|
||||
acquiredGifts: [GiftAuctionAcquiredGift]?
|
||||
) {
|
||||
self.context = context
|
||||
self.toPeerId = toPeerId
|
||||
|
|
@ -974,6 +976,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||
self.hideName = hideName
|
||||
self.gift = gift
|
||||
self.auctionContext = auctionContext
|
||||
self.acquiredGifts = acquiredGifts
|
||||
}
|
||||
|
||||
static func ==(lhs: GiftAuctionBidScreenComponent, rhs: GiftAuctionBidScreenComponent) -> Bool {
|
||||
|
|
@ -1827,7 +1830,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||
self.environment?.controller()?.present(controller, in: .window(.root))
|
||||
}
|
||||
|
||||
func resetSliderValue() {
|
||||
func resetSliderValue(component: GiftAuctionBidScreenComponent? = nil) {
|
||||
guard let state = self.giftAuctionState else {
|
||||
return
|
||||
}
|
||||
|
|
@ -1841,7 +1844,11 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||
}
|
||||
var currentValue = max(Int(minBidAmount), 100)
|
||||
if let myBidAmount = state.myState.bidAmount {
|
||||
currentValue = Int(myBidAmount)
|
||||
if let component, let bidPeerId = state.myState.bidPeerId, bidPeerId != component.toPeerId, let myMinBidAmount = state.myState.minBidAmount {
|
||||
currentValue = Int(myMinBidAmount)
|
||||
} else {
|
||||
currentValue = Int(myBidAmount)
|
||||
}
|
||||
}
|
||||
|
||||
var minAllowedRealValue: Int64 = minBidAmount
|
||||
|
|
@ -1919,6 +1926,8 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||
}
|
||||
|
||||
if self.component == nil {
|
||||
self.giftAuctionAcquiredGifts = component.acquiredGifts
|
||||
|
||||
if let starsContext = component.context.starsContext {
|
||||
self.balanceDisposable = (starsContext.state
|
||||
|> deliverOnMainQueue).startStrict(next: { [weak self] state in
|
||||
|
|
@ -1950,7 +1959,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||
|
||||
if isFirstTime {
|
||||
peerIds.append(context.account.peerId)
|
||||
self.resetSliderValue()
|
||||
self.resetSliderValue(component: component)
|
||||
transition = .immediate
|
||||
}
|
||||
|
||||
|
|
@ -1976,14 +1985,22 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||
}
|
||||
self.state?.updated(transition: transition)
|
||||
|
||||
if let acquiredCount = auctionState?.myState.acquiredCount, acquiredCount > (previousState?.myState.acquiredCount ?? 0) {
|
||||
self.loadAcquiredGifts()
|
||||
let previousAcquiredCount: Int32
|
||||
if let previousState {
|
||||
previousAcquiredCount = previousState.myState.acquiredCount
|
||||
} else {
|
||||
previousAcquiredCount = Int32(component.acquiredGifts?.count ?? 0)
|
||||
}
|
||||
if let acquiredCount = auctionState?.myState.acquiredCount, acquiredCount > previousAcquiredCount {
|
||||
Queue.mainQueue().justDispatch {
|
||||
self.loadAcquiredGifts()
|
||||
}
|
||||
}
|
||||
|
||||
if case .finished = auctionState?.auctionState, let controller = self.environment?.controller() {
|
||||
if let navigationController = controller.navigationController as? NavigationController {
|
||||
controller.dismiss()
|
||||
let auctionController = context.sharedContext.makeGiftAuctionViewScreen(context: context, auctionContext: auctionContext, completion: {})
|
||||
let auctionController = context.sharedContext.makeGiftAuctionViewScreen(context: context, auctionContext: auctionContext, completion: { _ in })
|
||||
navigationController.pushViewController(auctionController)
|
||||
}
|
||||
}
|
||||
|
|
@ -2922,7 +2939,7 @@ public class GiftAuctionBidScreen: ViewControllerComponentContainer {
|
|||
private var didPlayAppearAnimation: Bool = false
|
||||
private var isDismissed: Bool = false
|
||||
|
||||
public init(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext) {
|
||||
public init(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext, acquiredGifts: [GiftAuctionAcquiredGift]?) {
|
||||
self.context = context
|
||||
|
||||
super.init(context: context, component: GiftAuctionBidScreenComponent(
|
||||
|
|
@ -2932,7 +2949,8 @@ public class GiftAuctionBidScreen: ViewControllerComponentContainer {
|
|||
entities: entities,
|
||||
hideName: hideName,
|
||||
gift: auctionContext.gift,
|
||||
auctionContext: auctionContext
|
||||
auctionContext: auctionContext,
|
||||
acquiredGifts: acquiredGifts
|
||||
), navigationBarAppearance: .none, theme: .default)
|
||||
|
||||
self.statusBar.statusBarStyle = .Ignore
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ private final class GiftAuctionViewSheetContent: CombinedComponent {
|
|||
}
|
||||
self.dismiss(animated: true)
|
||||
|
||||
controller.completion()
|
||||
controller.completion(self.giftAuctionAcquiredGifts)
|
||||
}
|
||||
|
||||
func openPeer(_ peer: EnginePeer, dismiss: Bool = true) {
|
||||
|
|
@ -975,12 +975,12 @@ final class GiftAuctionViewSheetComponent: CombinedComponent {
|
|||
}
|
||||
|
||||
public final class GiftAuctionViewScreen: ViewControllerComponentContainer {
|
||||
fileprivate let completion: () -> Void
|
||||
fileprivate let completion: ([GiftAuctionAcquiredGift]?) -> Void
|
||||
|
||||
public init(
|
||||
context: AccountContext,
|
||||
auctionContext: GiftAuctionContext,
|
||||
completion: @escaping () -> Void
|
||||
completion: @escaping ([GiftAuctionAcquiredGift]?) -> Void
|
||||
) {
|
||||
self.completion = completion
|
||||
|
||||
|
|
|
|||
|
|
@ -1507,18 +1507,20 @@ func openResolvedUrlImpl(
|
|||
text: nil,
|
||||
entities: nil,
|
||||
hideName: false,
|
||||
auctionContext: auctionContext
|
||||
auctionContext: auctionContext,
|
||||
acquiredGifts: nil
|
||||
)
|
||||
navigationController?.pushViewController(controller)
|
||||
} else {
|
||||
let controller = context.sharedContext.makeGiftAuctionViewScreen(
|
||||
context: context,
|
||||
auctionContext: auctionContext,
|
||||
completion: { [weak navigationController] in
|
||||
completion: { [weak navigationController] acquiredGifts in
|
||||
let controller = GiftSetupScreen(
|
||||
context: context,
|
||||
peerId: context.account.peerId,
|
||||
subject: .starGift(gift, nil),
|
||||
auctionAcquiredGifts: acquiredGifts,
|
||||
completion: nil
|
||||
)
|
||||
navigationController?.pushViewController(controller)
|
||||
|
|
|
|||
|
|
@ -3846,11 +3846,11 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
|||
return GiftAuctionInfoScreen(context: context, auctionContext: auctionContext, completion: completion)
|
||||
}
|
||||
|
||||
public func makeGiftAuctionBidScreen(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext) -> ViewController {
|
||||
return GiftAuctionBidScreen(context: context, toPeerId: toPeerId, text: text, entities: entities, hideName: hideName, auctionContext: auctionContext)
|
||||
public func makeGiftAuctionBidScreen(context: AccountContext, toPeerId: EnginePeer.Id, text: String?, entities: [MessageTextEntity]?, hideName: Bool, auctionContext: GiftAuctionContext, acquiredGifts: [GiftAuctionAcquiredGift]?) -> ViewController {
|
||||
return GiftAuctionBidScreen(context: context, toPeerId: toPeerId, text: text, entities: entities, hideName: hideName, auctionContext: auctionContext, acquiredGifts: acquiredGifts)
|
||||
}
|
||||
|
||||
public func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping () -> Void) -> ViewController {
|
||||
public func makeGiftAuctionViewScreen(context: AccountContext, auctionContext: GiftAuctionContext, completion: @escaping ([GiftAuctionAcquiredGift]?) -> Void) -> ViewController {
|
||||
return GiftAuctionViewScreen(context: context, auctionContext: auctionContext, completion: completion)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue