Skip to content

Commit e5a004f

Browse files
committed
Various fixes
1 parent 14c5612 commit e5a004f

File tree

6 files changed

+91
-30
lines changed

6 files changed

+91
-30
lines changed

submodules/TelegramNotices/Sources/Notices.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ private enum ApplicationSpecificGlobalNotice: Int32 {
208208
case videoMessagesPauseSuggestion = 81
209209
case voiceMessagesResumeTrimWarning = 82
210210
case globalPostsSearch = 83
211+
case giftAuctionTips = 84
211212

212213
var key: ValueBoxKey {
213214
let v = ValueBoxKey(length: 4)
@@ -589,6 +590,10 @@ private struct ApplicationSpecificNoticeKeys {
589590
static func globalPostsSearch() -> NoticeEntryKey {
590591
return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.globalPostsSearch.key)
591592
}
593+
594+
static func giftAuctionTips() -> NoticeEntryKey {
595+
return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.giftAuctionTips.key)
596+
}
592597
}
593598

594599
public struct ApplicationSpecificNotice {
@@ -2586,4 +2591,31 @@ public struct ApplicationSpecificNotice {
25862591
return Int(previousValue)
25872592
}
25882593
}
2594+
2595+
public static func getGiftAuctionTips(accountManager: AccountManager<TelegramAccountManagerTypes>) -> Signal<Int32, NoError> {
2596+
return accountManager.transaction { transaction -> Int32 in
2597+
if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.giftAuctionTips())?.get(ApplicationSpecificCounterNotice.self) {
2598+
return value.value
2599+
} else {
2600+
return 0
2601+
}
2602+
}
2603+
}
2604+
2605+
public static func incrementGiftAuctionTips(accountManager: AccountManager<TelegramAccountManagerTypes>, count: Int = 1) -> Signal<Int, NoError> {
2606+
return accountManager.transaction { transaction -> Int in
2607+
var currentValue: Int32 = 0
2608+
if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.giftAuctionTips())?.get(ApplicationSpecificCounterNotice.self) {
2609+
currentValue = value.value
2610+
}
2611+
let previousValue = currentValue
2612+
currentValue += Int32(count)
2613+
2614+
if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) {
2615+
transaction.setNotice(ApplicationSpecificNoticeKeys.giftAuctionTips(), entry)
2616+
}
2617+
2618+
return Int(previousValue)
2619+
}
2620+
}
25892621
}

submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ swift_library(
2121
"//submodules/Components/MultilineTextComponent",
2222
"//submodules/Components/BalancedTextComponent",
2323
"//submodules/TelegramPresentationData",
24+
"//submodules/TelegramNotices",
2425
"//submodules/AccountContext",
2526
"//submodules/AppBundle",
2627
"//submodules/ItemListUI",

submodules/TelegramUI/Components/Gifts/GiftOptionsScreen/Sources/GiftOptionsScreen.swift

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Postbox
77
import TelegramCore
88
import TelegramPresentationData
99
import TelegramUIPreferences
10+
import TelegramNotices
1011
import PresentationDataUtils
1112
import AccountContext
1213
import ComponentFlow
@@ -369,22 +370,11 @@ final class GiftOptionsScreenComponent: Component {
369370
guard let giftAuctionsManager = component.context.giftAuctionsManager else {
370371
return
371372
}
372-
373-
self.loadingGiftId = gift.id
374-
Queue.mainQueue().after(0.25) {
375-
if self.loadingGiftId != nil {
376-
self.state?.updated()
377-
}
378-
}
379-
380373
self.auctionDisposable.set((giftAuctionsManager.auctionContext(for: .giftId(gift.id))
381374
|> deliverOnMainQueue).start(next: { [weak self, weak mainController] auctionContext in
382375
guard let self, let auctionContext, let component = self.component, let mainController else {
383376
return
384377
}
385-
self.loadingGiftId = nil
386-
self.state?.updated()
387-
388378
if let currentBidPeerId = auctionContext.currentBidPeerId {
389379
if currentBidPeerId == component.peerId {
390380
let giftController = component.context.sharedContext.makeGiftAuctionBidScreen(
@@ -419,20 +409,39 @@ final class GiftOptionsScreenComponent: Component {
419409
})
420410
}
421411
} else {
422-
let giftController = component.context.sharedContext.makeGiftAuctionViewScreen(
423-
context: component.context,
424-
auctionContext: auctionContext,
425-
completion: { [weak mainController] in
426-
let controller = GiftSetupScreen(
427-
context: context,
428-
peerId: component.peerId,
429-
subject: .starGift(gift, nil),
430-
completion: nil
412+
let _ = (ApplicationSpecificNotice.getGiftAuctionTips(accountManager: context.sharedContext.accountManager)
413+
|> deliverOnMainQueue).start(next: { [weak mainController] count in
414+
let presentAuction = {
415+
let giftController = component.context.sharedContext.makeGiftAuctionViewScreen(
416+
context: component.context,
417+
auctionContext: auctionContext,
418+
completion: { [weak mainController] in
419+
let controller = GiftSetupScreen(
420+
context: context,
421+
peerId: component.peerId,
422+
subject: .starGift(gift, nil),
423+
completion: nil
424+
)
425+
mainController?.push(controller)
426+
}
431427
)
432-
mainController?.push(controller)
428+
mainController?.push(giftController)
433429
}
434-
)
435-
mainController.push(giftController)
430+
431+
if count > 0 {
432+
presentAuction()
433+
} else {
434+
let infoController = component.context.sharedContext.makeGiftAuctionInfoScreen(
435+
context: component.context,
436+
auctionContext: auctionContext,
437+
completion: {
438+
presentAuction()
439+
let _ = ApplicationSpecificNotice.incrementGiftAuctionTips(accountManager: component.context.sharedContext.accountManager).startStandalone()
440+
}
441+
)
442+
mainController?.push(infoController)
443+
}
444+
})
436445
}
437446
}))
438447
} else {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ final class BadgeLabelView: UIView {
109109
}
110110

111111
if self.staticLabel.superview == nil {
112+
self.staticLabel.alpha = 0.0
112113
self.staticLabel.textColor = self.color
113114
self.staticLabel.font = font
114115
self.addSubview(self.staticLabel)

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ private final class GiftAuctionBidScreenComponent: Component {
10031003

10041004
private static func makeSliderSteps(minRealValue: Int, maxRealValue: Int, isLogarithmic: Bool) -> [Int] {
10051005
if isLogarithmic {
1006-
var sliderSteps: [Int] = [1, 10, 50, 100, 500, 1_000, 2_000, 5_000, 10_000, 20_000, 30_000, 40_000, 50_000]
1006+
var sliderSteps: [Int] = [100, 500, 1_000, 2_000, 5_000, 10_000, 25_000, 50_000, 100_000, 500_000]
10071007
sliderSteps.removeAll(where: { $0 <= minRealValue })
10081008
sliderSteps.insert(minRealValue, at: 0)
10091009
sliderSteps.removeAll(where: { $0 >= maxRealValue })
@@ -1083,6 +1083,17 @@ private final class GiftAuctionBidScreenComponent: Component {
10831083
func withMaxRealValue(_ maxRealValue: Int) -> Amount {
10841084
return Amount(realValue: self.realValue, minRealValue: self.minRealValue, minAllowedRealValue: self.minAllowedRealValue, maxRealValue: maxRealValue, maxSliderValue: self.maxSliderValue, isLogarithmic: self.isLogarithmic)
10851085
}
1086+
1087+
func cutoffSliderValue(for cutoffRealValue: Int) -> Int {
1088+
let clampedReal = max(self.minRealValue, min(cutoffRealValue, self.maxRealValue))
1089+
1090+
return Amount.remapValueToSlider(
1091+
realValue: clampedReal,
1092+
minAllowedRealValue: self.minAllowedRealValue,
1093+
maxSliderValue: self.maxSliderValue,
1094+
steps: self.sliderSteps
1095+
)
1096+
}
10861097
}
10871098

10881099
final class View: UIView, UIScrollViewDelegate {
@@ -2016,16 +2027,22 @@ private final class GiftAuctionBidScreenComponent: Component {
20162027
giftsPerRound = giftsPerRoundValue
20172028
}
20182029

2019-
var topCutoff: CGFloat?
2030+
var topCutoffRealValue: Int?
20202031
if let giftAuctionState = self.giftAuctionState, case let .ongoing(_, _, _, _, bidLevels, _, _, _, _, _) = giftAuctionState.auctionState {
20212032
for bidLevel in bidLevels {
20222033
if bidLevel.position == giftsPerRound - 1 {
2023-
topCutoff = CGFloat(bidLevel.amount) / CGFloat(self.amount.maxRealValue)
2034+
topCutoffRealValue = Int(bidLevel.amount)
20242035
break
20252036
}
20262037
}
20272038
}
20282039

2040+
var topCutoff: CGFloat?
2041+
if let topCutoffRealValue {
2042+
let cutoffSliderValue = self.amount.cutoffSliderValue(for: topCutoffRealValue)
2043+
topCutoff = CGFloat(cutoffSliderValue) / CGFloat(self.amount.maxSliderValue)
2044+
}
2045+
20292046
let _ = self.sliderBackground.update(
20302047
transition: transition,
20312048
component: AnyComponent(SliderBackgroundComponent(

submodules/TelegramUI/Components/GlassBarButtonComponent/Sources/GlassBarButtonComponent.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public final class GlassBarButtonComponent: Component {
6464
private let containerView: UIView
6565
private let genericContainerView: UIView
6666
private let genericBackgroundView: SimpleGlassView
67-
private let glassContainerView: UIView
67+
private let glassContainerView: GlassBackgroundContainerView
6868
private let glassBackgroundView: GlassBackgroundView
6969
private var componentView: ComponentView<Empty>?
7070

@@ -74,7 +74,7 @@ public final class GlassBarButtonComponent: Component {
7474
self.containerView = UIView()
7575
self.genericContainerView = UIView()
7676
self.genericBackgroundView = SimpleGlassView()
77-
self.glassContainerView = UIView()
77+
self.glassContainerView = GlassBackgroundContainerView()
7878
self.glassBackgroundView = GlassBackgroundView()
7979

8080
super.init(frame: frame)
@@ -87,7 +87,7 @@ public final class GlassBarButtonComponent: Component {
8787
self.containerView.addSubview(self.glassContainerView)
8888

8989
self.genericContainerView.addSubview(self.genericBackgroundView)
90-
self.glassContainerView.addSubview(self.glassBackgroundView)
90+
self.glassContainerView.contentView.addSubview(self.glassBackgroundView)
9191

9292
self.addTarget(self, action: #selector(self.pressed), for: .touchUpInside)
9393

@@ -176,7 +176,7 @@ public final class GlassBarButtonComponent: Component {
176176
switch effectiveState {
177177
case .generic:
178178
genericAlpha = 1.0
179-
glassAlpha = 0.001
179+
glassAlpha = 0.0
180180
case .glass, .tintedGlass:
181181
glassAlpha = 1.0
182182
genericAlpha = 0.0
@@ -194,6 +194,7 @@ public final class GlassBarButtonComponent: Component {
194194

195195
transition.setAlpha(view: self.glassContainerView, alpha: glassAlpha)
196196
transition.setFrame(view: self.glassContainerView, frame: bounds)
197+
self.glassContainerView.update(size: bounds.size, isDark: component.isDark, transition: transition)
197198

198199
transition.setFrame(view: self.genericBackgroundView, frame: bounds)
199200
transition.setFrame(view: self.glassBackgroundView, frame: bounds)

0 commit comments

Comments
 (0)