mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-02 04:38:33 +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_1" = "%@ Star";
|
||||||
"Gift.AuctionBid.AddMoreStars.Stars_any" = "%@ Stars";
|
"Gift.AuctionBid.AddMoreStars.Stars_any" = "%@ Stars";
|
||||||
"Gift.AuctionBid.Top" = "TOP %@";
|
"Gift.AuctionBid.Top" = "TOP %@";
|
||||||
|
"Gift.AuctionBid.Custom" = "Custom";
|
||||||
|
|
||||||
"Gift.Auction.Context.About" = "About";
|
"Gift.Auction.Context.About" = "About";
|
||||||
"Gift.Auction.Context.CopyLink" = "Copy Link";
|
"Gift.Auction.Context.CopyLink" = "Copy Link";
|
||||||
|
|||||||
@ -350,7 +350,7 @@ public class GiftAuctionsManager {
|
|||||||
for (giftId, update) in updates {
|
for (giftId, update) in updates {
|
||||||
if let auctionContext = self.auctionContexts[giftId] {
|
if let auctionContext = self.auctionContexts[giftId] {
|
||||||
auctionContext.updateAuctionState(update)
|
auctionContext.updateAuctionState(update)
|
||||||
} else {
|
} else if case .ongoing = update {
|
||||||
reload = true
|
reload = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@ -98,6 +98,7 @@ final class BadgeLabelView: UIView {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func update(value: String, transition: ComponentTransition) -> CGSize {
|
func update(value: String, transition: ComponentTransition) -> CGSize {
|
||||||
if value.contains(" ") {
|
if value.contains(" ") {
|
||||||
for (_, view) in self.itemViews {
|
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] {
|
private static func makeSliderSteps(minRealValue: Int, maxRealValue: Int, isLogarithmic: Bool) -> [Int] {
|
||||||
if isLogarithmic {
|
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.removeAll(where: { $0 <= minRealValue })
|
||||||
sliderSteps.insert(minRealValue, at: 0)
|
sliderSteps.insert(minRealValue, at: 0)
|
||||||
sliderSteps.removeAll(where: { $0 >= maxRealValue })
|
sliderSteps.removeAll(where: { $0 >= maxRealValue })
|
||||||
@ -1028,6 +1028,10 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
func withMinAllowedRealValue(_ minAllowedRealValue: Int) -> Amount {
|
func withMinAllowedRealValue(_ minAllowedRealValue: Int) -> Amount {
|
||||||
return Amount(realValue: self.realValue, minRealValue: self.minRealValue, minAllowedRealValue: minAllowedRealValue, maxRealValue: self.maxRealValue, maxSliderValue: self.maxSliderValue, isLogarithmic: self.isLogarithmic)
|
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 {
|
final class View: UIView, UIScrollViewDelegate {
|
||||||
@ -1369,13 +1373,12 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var isLoading = false
|
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 {
|
guard let component = self.component, case let .generic(gift) = component.gift, let controller = self.environment?.controller() else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var isUpdate = false
|
var isUpdate = false
|
||||||
let value = Int64(self.amount.realValue)
|
|
||||||
if let myBidAmount = self.giftAuctionState?.myState.bidAmount {
|
if let myBidAmount = self.giftAuctionState?.myState.bidAmount {
|
||||||
isUpdate = true
|
isUpdate = true
|
||||||
if value == myBidAmount {
|
if value == myBidAmount {
|
||||||
@ -1447,9 +1450,18 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.isLoading = false
|
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.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 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
|
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)
|
peerIds.append(context.account.peerId)
|
||||||
|
|
||||||
var minBidAmount: Int64 = 100
|
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
|
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)
|
var currentValue = max(Int(minBidAmount), 100)
|
||||||
if let myBidAmount = state?.myState.bidAmount {
|
if let myBidAmount = state?.myState.bidAmount {
|
||||||
@ -1750,7 +1766,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
minAllowedRealValue = myBidAmount
|
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
|
transition = .immediate
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2521,8 +2537,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
self.commitBid(value: Int64(self.amount.realValue))
|
||||||
self.placeBid()
|
|
||||||
}
|
}
|
||||||
)),
|
)),
|
||||||
environment: {},
|
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) {
|
override public func dismiss(completion: (() -> Void)? = nil) {
|
||||||
if !self.isDismissed {
|
if !self.isDismissed {
|
||||||
self.isDismissed = true
|
self.isDismissed = true
|
||||||
|
|
||||||
|
self.dismissAllTooltips()
|
||||||
|
|
||||||
if let componentView = self.node.hostView.componentView as? GiftAuctionBidScreenComponent.View {
|
if let componentView = self.node.hostView.componentView as? GiftAuctionBidScreenComponent.View {
|
||||||
componentView.animateOut(completion: { [weak self] in
|
componentView.animateOut(completion: { [weak self] in
|
||||||
completion?()
|
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 {
|
} else {
|
||||||
self.scheduledUpgradeCommit = true
|
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