Skip to content

Commit d33fd57

Browse files
author
Isaac
committed
Merge commit '1c3b749eded5c20f496772948948ec391dde8402'
2 parents c57aa07 + 1c3b749 commit d33fd57

File tree

1 file changed

+31
-9
lines changed

1 file changed

+31
-9
lines changed

submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionBidScreen.swift

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import UndoUI
3030
import GiftItemComponent
3131
import LottieComponent
3232
import EdgeEffect
33+
import ConfettiEffect
3334

3435
private final class BadgeComponent: Component {
3536
let theme: PresentationTheme
@@ -1142,7 +1143,7 @@ private final class GiftAuctionBidScreenComponent: Component {
11421143
private var giftAuctionTimer: SwiftSignalKit.Timer?
11431144
private var peersMap: [EnginePeer.Id: EnginePeer] = [:]
11441145

1145-
private var giftAuctionAcquiredGifts: [GiftAuctionAcquiredGift] = []
1146+
private var giftAuctionAcquiredGifts: [GiftAuctionAcquiredGift]?
11461147
private let giftAuctionAcquiredGiftsDisposable = MetaDisposable()
11471148

11481149
private let actionButton = ComponentView<Empty>()
@@ -1324,7 +1325,13 @@ private final class GiftAuctionBidScreenComponent: Component {
13241325
guard let self else {
13251326
return
13261327
}
1328+
let previous = self.giftAuctionAcquiredGifts
13271329
self.giftAuctionAcquiredGifts = acquiredGifts
1330+
1331+
if let previous, previous.count < acquiredGifts.count {
1332+
self.resetSliderValue()
1333+
self.addSubview(ConfettiView(frame: self.bounds))
1334+
}
13281335
self.state?.updated(transition: .easeInOut(duration: 0.25))
13291336
}))
13301337
}
@@ -1568,7 +1575,10 @@ private final class GiftAuctionBidScreenComponent: Component {
15681575
guard let self, let component = self.component else {
15691576
return
15701577
}
1571-
self.isLoading = false
1578+
Queue.mainQueue().after(0.1) {
1579+
self.isLoading = false
1580+
self.state?.updated()
1581+
}
15721582

15731583
let newMaxValue = Int(Double(value) * 1.5)
15741584
var updatedAmount = self.amount.withMinAllowedRealValue(Int(value)).withRealValue(Int(value))
@@ -2260,6 +2270,7 @@ private final class GiftAuctionBidScreenComponent: Component {
22602270

22612271
var perks: [([AnimatedTextComponent.Item], String)] = []
22622272

2273+
var minBidIsSmall = false
22632274
var minBidAnimatedItems: [AnimatedTextComponent.Item] = []
22642275
var untilNextDropAnimatedItems: [AnimatedTextComponent.Item] = []
22652276
var dropsLeftAnimatedItems: [AnimatedTextComponent.Item] = []
@@ -2270,7 +2281,11 @@ private final class GiftAuctionBidScreenComponent: Component {
22702281
if let myMinBidAmmount = self.giftAuctionState?.myState.minBidAmount {
22712282
minBidAmount = myMinBidAmmount
22722283
}
2273-
let minBidString = "# \(presentationStringsFormattedNumber(Int32(clamping: minBidAmount), environment.dateTimeFormat.groupingSeparator))"
2284+
var minBidString = "# \(presentationStringsFormattedNumber(Int32(clamping: minBidAmount), environment.dateTimeFormat.groupingSeparator))"
2285+
if minBidAmount > 999999 {
2286+
minBidString = "# \(minBidAmount)"
2287+
minBidIsSmall = true
2288+
}
22742289
if let hashIndex = minBidString.firstIndex(of: "#") {
22752290
var prefix = String(minBidString[..<hashIndex])
22762291
if !prefix.isEmpty {
@@ -2337,7 +2352,7 @@ private final class GiftAuctionBidScreenComponent: Component {
23372352
let seconds = Int(dropTimeout % 60)
23382353

23392354
if dropTimeout == 0, place <= giftsPerRound {
2340-
Queue.mainQueue().after(1.0, {
2355+
Queue.mainQueue().after(1.5, {
23412356
self.reloadAcquiredGifts()
23422357
})
23432358
}
@@ -2391,6 +2406,7 @@ private final class GiftAuctionBidScreenComponent: Component {
23912406
gift: i == perks.count - 1 ? component.auctionContext.gift : nil,
23922407
title: perk.0,
23932408
subtitle: perk.1,
2409+
small: i == 0 && minBidIsSmall,
23942410
theme: environment.theme
23952411
)),
23962412
environment: {},
@@ -2407,15 +2423,15 @@ private final class GiftAuctionBidScreenComponent: Component {
24072423
contentHeight += perkHeight
24082424
contentHeight += 24.0
24092425

2410-
if self.giftAuctionAcquiredGifts.count > 0, case let .generic(gift) = component.gift {
2426+
if let giftAuctionAcquiredGifts = self.giftAuctionAcquiredGifts, giftAuctionAcquiredGifts.count > 0, case let .generic(gift) = component.gift {
24112427
var myGiftsTransition = transition
24122428
let myGiftsSize = self.myGifts.update(
24132429
transition: .immediate,
24142430
component: AnyComponent(
24152431
PlainButtonComponent(content: AnyComponent(
24162432
HStack([
24172433
AnyComponentWithIdentity(id: "count", component: AnyComponent(
2418-
MultilineTextComponent(text: .plain(NSAttributedString(string: presentationStringsFormattedNumber(Int32(self.giftAuctionAcquiredGifts.count), environment.dateTimeFormat.groupingSeparator), font: Font.regular(17.0), textColor: environment.theme.actionSheet.controlAccentColor)))
2434+
MultilineTextComponent(text: .plain(NSAttributedString(string: presentationStringsFormattedNumber(Int32(giftAuctionAcquiredGifts.count), environment.dateTimeFormat.groupingSeparator), font: Font.regular(17.0), textColor: environment.theme.actionSheet.controlAccentColor)))
24192435
)),
24202436
AnyComponentWithIdentity(id: "spacing", component: AnyComponent(
24212437
Rectangle(color: .clear, width: 8.0, height: 1.0)
@@ -2431,7 +2447,7 @@ private final class GiftAuctionBidScreenComponent: Component {
24312447
)
24322448
)),
24332449
AnyComponentWithIdentity(id: "text", component: AnyComponent(
2434-
MultilineTextComponent(text: .plain(NSAttributedString(string: " \(environment.strings.Gift_Auction_ItemsBought(Int32(self.giftAuctionAcquiredGifts.count)))", font: Font.regular(17.0), textColor: environment.theme.actionSheet.controlAccentColor)))
2450+
MultilineTextComponent(text: .plain(NSAttributedString(string: " \(environment.strings.Gift_Auction_ItemsBought(Int32(giftAuctionAcquiredGifts.count)))", font: Font.regular(17.0), textColor: environment.theme.actionSheet.controlAccentColor)))
24352451
)),
24362452
AnyComponentWithIdentity(id: "arrow", component: AnyComponent(
24372453
BundleIconComponent(name: "Chat/Context Menu/Arrow", tintColor: environment.theme.actionSheet.controlAccentColor)
@@ -2441,7 +2457,7 @@ private final class GiftAuctionBidScreenComponent: Component {
24412457
guard let self, let component = self.component else {
24422458
return
24432459
}
2444-
let giftController = GiftAuctionAcquiredScreen(context: component.context, gift: component.auctionContext.gift, acquiredGifts: self.giftAuctionAcquiredGifts)
2460+
let giftController = GiftAuctionAcquiredScreen(context: component.context, gift: component.auctionContext.gift, acquiredGifts: self.giftAuctionAcquiredGifts ?? [])
24452461
self.environment?.controller()?.push(giftController)
24462462
}, animateScale: false)
24472463
),
@@ -3194,19 +3210,22 @@ private final class AuctionStatComponent: Component {
31943210
let gift: StarGift?
31953211
let title: [AnimatedTextComponent.Item]
31963212
let subtitle: String
3213+
let small: Bool
31973214
let theme: PresentationTheme
31983215

31993216
init(
32003217
context: AccountContext,
32013218
gift: StarGift?,
32023219
title: [AnimatedTextComponent.Item],
32033220
subtitle: String,
3221+
small: Bool,
32043222
theme: PresentationTheme
32053223
) {
32063224
self.context = context
32073225
self.gift = gift
32083226
self.title = title
32093227
self.subtitle = subtitle
3228+
self.small = small
32103229
self.theme = theme
32113230
}
32123231

@@ -3220,6 +3239,9 @@ private final class AuctionStatComponent: Component {
32203239
if lhs.subtitle != rhs.subtitle {
32213240
return false
32223241
}
3242+
if lhs.small != rhs.small {
3243+
return false
3244+
}
32233245
if lhs.theme != rhs.theme {
32243246
return false
32253247
}
@@ -3263,7 +3285,7 @@ private final class AuctionStatComponent: Component {
32633285
let titleSize = self.title.update(
32643286
transition: .spring(duration: 0.2),
32653287
component: AnyComponent(AnimatedTextComponent(
3266-
font: Font.with(size: 20.0, weight: .semibold, traits: .monospacedNumbers),
3288+
font: Font.with(size: component.small ? 17.0 : 20.0, weight: .semibold, traits: .monospacedNumbers),
32673289
color: component.theme.list.itemPrimaryTextColor,
32683290
items: component.title,
32693291
noDelay: true,

0 commit comments

Comments
 (0)