mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-29 03:21:29 +00:00
Various improvements
This commit is contained in:
parent
b0f4ca9ad9
commit
1be0aaef7c
@ -15221,6 +15221,7 @@ Error: %8$@";
|
||||
"Gift.AuctionBid.AddMoreStars.Stars_1" = "%@ Star";
|
||||
"Gift.AuctionBid.AddMoreStars.Stars_any" = "%@ Stars";
|
||||
"Gift.AuctionBid.Top" = "TOP %@";
|
||||
"Gift.AuctionBid.Custom" = "Custom";
|
||||
|
||||
"Gift.Auction.Context.About" = "About";
|
||||
"Gift.Auction.Context.CopyLink" = "Copy Link";
|
||||
|
||||
@ -350,7 +350,7 @@ public class GiftAuctionsManager {
|
||||
for (giftId, update) in updates {
|
||||
if let auctionContext = self.auctionContexts[giftId] {
|
||||
auctionContext.updateAuctionState(update)
|
||||
} else {
|
||||
} else if case .ongoing = update {
|
||||
reload = true
|
||||
break
|
||||
}
|
||||
|
||||
@ -98,6 +98,7 @@ final class BadgeLabelView: UIView {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func update(value: String, transition: ComponentTransition) -> CGSize {
|
||||
if value.contains(" ") {
|
||||
for (_, view) in self.itemViews {
|
||||
|
||||
@ -952,7 +952,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
||||
|
||||
private static func makeSliderSteps(minRealValue: Int, maxRealValue: Int, isLogarithmic: Bool) -> [Int] {
|
||||
if isLogarithmic {
|
||||
var sliderSteps: [Int] = [1, 10, 50, 100, 500, 1_000, 2_000, 5_000, 7_500, 10_000, 20_000, 30_000]
|
||||
var sliderSteps: [Int] = [1, 10, 50, 100, 500, 1_000, 2_000, 5_000, 7_500, 15_000, 20_000, 30_000, 40_000, 50_000]
|
||||
sliderSteps.removeAll(where: { $0 <= minRealValue })
|
||||
sliderSteps.insert(minRealValue, at: 0)
|
||||
sliderSteps.removeAll(where: { $0 >= maxRealValue })
|
||||
@ -1028,6 +1028,10 @@ private final class GiftAuctionBidScreenComponent: Component {
|
||||
func withMinAllowedRealValue(_ minAllowedRealValue: Int) -> Amount {
|
||||
return Amount(realValue: self.realValue, minRealValue: self.minRealValue, minAllowedRealValue: minAllowedRealValue, maxRealValue: self.maxRealValue, maxSliderValue: self.maxSliderValue, isLogarithmic: self.isLogarithmic)
|
||||
}
|
||||
|
||||
func withMaxRealValue(_ maxRealValue: Int) -> Amount {
|
||||
return Amount(realValue: self.realValue, minRealValue: self.minRealValue, minAllowedRealValue: self.minAllowedRealValue, maxRealValue: maxRealValue, maxSliderValue: self.maxSliderValue, isLogarithmic: self.isLogarithmic)
|
||||
}
|
||||
}
|
||||
|
||||
final class View: UIView, UIScrollViewDelegate {
|
||||
@ -1369,13 +1373,12 @@ private final class GiftAuctionBidScreenComponent: Component {
|
||||
}
|
||||
|
||||
private var isLoading = false
|
||||
private func placeBid() {
|
||||
private func commitBid(value: Int64) {
|
||||
guard let component = self.component, case let .generic(gift) = component.gift, let controller = self.environment?.controller() else {
|
||||
return
|
||||
}
|
||||
|
||||
var isUpdate = false
|
||||
let value = Int64(self.amount.realValue)
|
||||
if let myBidAmount = self.giftAuctionState?.myState.bidAmount {
|
||||
isUpdate = true
|
||||
if value == myBidAmount {
|
||||
@ -1447,10 +1450,19 @@ private final class GiftAuctionBidScreenComponent: Component {
|
||||
return
|
||||
}
|
||||
self.isLoading = false
|
||||
|
||||
let newMaxValue = Int(Double(value) * 1.5)
|
||||
var updatedAmount = self.amount.withMinAllowedRealValue(Int(value))
|
||||
if newMaxValue > self.amount.maxRealValue {
|
||||
updatedAmount = updatedAmount.withMaxRealValue(newMaxValue)
|
||||
}
|
||||
self.amount = updatedAmount
|
||||
self.state?.updated()
|
||||
|
||||
self.amount = self.amount.withMinAllowedRealValue(Int(value))
|
||||
|
||||
if !isUpdate {
|
||||
component.auctionContext.load()
|
||||
}
|
||||
|
||||
let title = isUpdate ? presentationData.strings.Gift_AuctionBid_Increased_Title : presentationData.strings.Gift_AuctionBid_Placed_Title
|
||||
let text = isUpdate ? presentationData.strings.Gift_AuctionBid_Increased_Text("\(giftsPerRounds)").string : presentationData.strings.Gift_AuctionBid_Placed_Text("\(giftsPerRounds)").string
|
||||
|
||||
@ -1737,8 +1749,12 @@ private final class GiftAuctionBidScreenComponent: Component {
|
||||
peerIds.append(context.account.peerId)
|
||||
|
||||
var minBidAmount: Int64 = 100
|
||||
if case let .ongoing(_, _, _, auctionMinBidAmount, _, _, _, _, _, _) = state?.auctionState {
|
||||
var maxBidAmount: Int64 = 50000
|
||||
if case let .ongoing(_, _, _, auctionMinBidAmount, bidLevels, _, _, _, _, _) = state?.auctionState {
|
||||
minBidAmount = auctionMinBidAmount
|
||||
if let firstLevel = bidLevels.first(where: { $0.position == 1 }) {
|
||||
maxBidAmount = max(maxBidAmount, Int64(Double(firstLevel.amount) * 1.5))
|
||||
}
|
||||
}
|
||||
var currentValue = max(Int(minBidAmount), 100)
|
||||
if let myBidAmount = state?.myState.bidAmount {
|
||||
@ -1750,7 +1766,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
||||
minAllowedRealValue = myBidAmount
|
||||
}
|
||||
|
||||
self.amount = Amount(realValue: currentValue, minRealValue: Int(minBidAmount), minAllowedRealValue: Int(minAllowedRealValue), maxRealValue: 30000, maxSliderValue: 999, isLogarithmic: true)
|
||||
self.amount = Amount(realValue: currentValue, minRealValue: Int(minBidAmount), minAllowedRealValue: Int(minAllowedRealValue), maxRealValue: Int(maxBidAmount), maxSliderValue: 999, isLogarithmic: true)
|
||||
transition = .immediate
|
||||
}
|
||||
|
||||
@ -2521,8 +2537,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
self.placeBid()
|
||||
self.commitBid(value: Int64(self.amount.realValue))
|
||||
}
|
||||
)),
|
||||
environment: {},
|
||||
@ -2666,10 +2681,26 @@ public class GiftAuctionBidScreen: ViewControllerComponentContainer {
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func dismissAllTooltips() {
|
||||
self.window?.forEachController({ controller in
|
||||
if let controller = controller as? UndoOverlayController {
|
||||
controller.dismiss()
|
||||
}
|
||||
})
|
||||
self.forEachController({ controller in
|
||||
if let controller = controller as? UndoOverlayController {
|
||||
controller.dismiss()
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
override public func dismiss(completion: (() -> Void)? = nil) {
|
||||
if !self.isDismissed {
|
||||
self.isDismissed = true
|
||||
|
||||
self.dismissAllTooltips()
|
||||
|
||||
if let componentView = self.node.hostView.componentView as? GiftAuctionBidScreenComponent.View {
|
||||
componentView.animateOut(completion: { [weak self] in
|
||||
completion?()
|
||||
|
||||
@ -292,9 +292,7 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
}
|
||||
}))
|
||||
|
||||
if arguments.upgradeStars == nil {
|
||||
self.fetchUpgradeForm()
|
||||
}
|
||||
self.fetchUpgradeForm()
|
||||
}
|
||||
}
|
||||
|
||||
@ -2139,6 +2137,31 @@ private final class GiftViewSheetContent: CombinedComponent {
|
||||
}
|
||||
} else {
|
||||
self.scheduledUpgradeCommit = true
|
||||
|
||||
self.inProgress = true
|
||||
self.updated()
|
||||
|
||||
Queue.mainQueue().after(5.0, {
|
||||
if self.scheduledUpgradeCommit {
|
||||
self.scheduledUpgradeCommit = false
|
||||
self.inProgress = false
|
||||
self.updated()
|
||||
|
||||
let presentationData = self.context.sharedContext.currentPresentationData.with { $0 }
|
||||
let alertController = textAlertController(
|
||||
context: self.context,
|
||||
title: nil,
|
||||
text: presentationData.strings.Login_UnknownError,
|
||||
actions: [
|
||||
TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})
|
||||
],
|
||||
parseMarkdown: true
|
||||
)
|
||||
if let controller = self.getController() {
|
||||
controller.present(alertController, in: .window(.root))
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user