mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-06 22:33:10 +00:00
Various fixes
This commit is contained in:
parent
14c56127fa
commit
e5a004f67a
@ -208,6 +208,7 @@ private enum ApplicationSpecificGlobalNotice: Int32 {
|
|||||||
case videoMessagesPauseSuggestion = 81
|
case videoMessagesPauseSuggestion = 81
|
||||||
case voiceMessagesResumeTrimWarning = 82
|
case voiceMessagesResumeTrimWarning = 82
|
||||||
case globalPostsSearch = 83
|
case globalPostsSearch = 83
|
||||||
|
case giftAuctionTips = 84
|
||||||
|
|
||||||
var key: ValueBoxKey {
|
var key: ValueBoxKey {
|
||||||
let v = ValueBoxKey(length: 4)
|
let v = ValueBoxKey(length: 4)
|
||||||
@ -589,6 +590,10 @@ private struct ApplicationSpecificNoticeKeys {
|
|||||||
static func globalPostsSearch() -> NoticeEntryKey {
|
static func globalPostsSearch() -> NoticeEntryKey {
|
||||||
return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.globalPostsSearch.key)
|
return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.globalPostsSearch.key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static func giftAuctionTips() -> NoticeEntryKey {
|
||||||
|
return NoticeEntryKey(namespace: noticeNamespace(namespace: globalNamespace), key: ApplicationSpecificGlobalNotice.giftAuctionTips.key)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct ApplicationSpecificNotice {
|
public struct ApplicationSpecificNotice {
|
||||||
@ -2586,4 +2591,31 @@ public struct ApplicationSpecificNotice {
|
|||||||
return Int(previousValue)
|
return Int(previousValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static func getGiftAuctionTips(accountManager: AccountManager<TelegramAccountManagerTypes>) -> Signal<Int32, NoError> {
|
||||||
|
return accountManager.transaction { transaction -> Int32 in
|
||||||
|
if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.giftAuctionTips())?.get(ApplicationSpecificCounterNotice.self) {
|
||||||
|
return value.value
|
||||||
|
} else {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static func incrementGiftAuctionTips(accountManager: AccountManager<TelegramAccountManagerTypes>, count: Int = 1) -> Signal<Int, NoError> {
|
||||||
|
return accountManager.transaction { transaction -> Int in
|
||||||
|
var currentValue: Int32 = 0
|
||||||
|
if let value = transaction.getNotice(ApplicationSpecificNoticeKeys.giftAuctionTips())?.get(ApplicationSpecificCounterNotice.self) {
|
||||||
|
currentValue = value.value
|
||||||
|
}
|
||||||
|
let previousValue = currentValue
|
||||||
|
currentValue += Int32(count)
|
||||||
|
|
||||||
|
if let entry = CodableEntry(ApplicationSpecificCounterNotice(value: currentValue)) {
|
||||||
|
transaction.setNotice(ApplicationSpecificNoticeKeys.giftAuctionTips(), entry)
|
||||||
|
}
|
||||||
|
|
||||||
|
return Int(previousValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ swift_library(
|
|||||||
"//submodules/Components/MultilineTextComponent",
|
"//submodules/Components/MultilineTextComponent",
|
||||||
"//submodules/Components/BalancedTextComponent",
|
"//submodules/Components/BalancedTextComponent",
|
||||||
"//submodules/TelegramPresentationData",
|
"//submodules/TelegramPresentationData",
|
||||||
|
"//submodules/TelegramNotices",
|
||||||
"//submodules/AccountContext",
|
"//submodules/AccountContext",
|
||||||
"//submodules/AppBundle",
|
"//submodules/AppBundle",
|
||||||
"//submodules/ItemListUI",
|
"//submodules/ItemListUI",
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import Postbox
|
|||||||
import TelegramCore
|
import TelegramCore
|
||||||
import TelegramPresentationData
|
import TelegramPresentationData
|
||||||
import TelegramUIPreferences
|
import TelegramUIPreferences
|
||||||
|
import TelegramNotices
|
||||||
import PresentationDataUtils
|
import PresentationDataUtils
|
||||||
import AccountContext
|
import AccountContext
|
||||||
import ComponentFlow
|
import ComponentFlow
|
||||||
@ -369,22 +370,11 @@ final class GiftOptionsScreenComponent: Component {
|
|||||||
guard let giftAuctionsManager = component.context.giftAuctionsManager else {
|
guard let giftAuctionsManager = component.context.giftAuctionsManager else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.loadingGiftId = gift.id
|
|
||||||
Queue.mainQueue().after(0.25) {
|
|
||||||
if self.loadingGiftId != nil {
|
|
||||||
self.state?.updated()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.auctionDisposable.set((giftAuctionsManager.auctionContext(for: .giftId(gift.id))
|
self.auctionDisposable.set((giftAuctionsManager.auctionContext(for: .giftId(gift.id))
|
||||||
|> deliverOnMainQueue).start(next: { [weak self, weak mainController] auctionContext in
|
|> deliverOnMainQueue).start(next: { [weak self, weak mainController] auctionContext in
|
||||||
guard let self, let auctionContext, let component = self.component, let mainController else {
|
guard let self, let auctionContext, let component = self.component, let mainController else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
self.loadingGiftId = nil
|
|
||||||
self.state?.updated()
|
|
||||||
|
|
||||||
if let currentBidPeerId = auctionContext.currentBidPeerId {
|
if let currentBidPeerId = auctionContext.currentBidPeerId {
|
||||||
if currentBidPeerId == component.peerId {
|
if currentBidPeerId == component.peerId {
|
||||||
let giftController = component.context.sharedContext.makeGiftAuctionBidScreen(
|
let giftController = component.context.sharedContext.makeGiftAuctionBidScreen(
|
||||||
@ -419,20 +409,39 @@ final class GiftOptionsScreenComponent: Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let giftController = component.context.sharedContext.makeGiftAuctionViewScreen(
|
let _ = (ApplicationSpecificNotice.getGiftAuctionTips(accountManager: context.sharedContext.accountManager)
|
||||||
context: component.context,
|
|> deliverOnMainQueue).start(next: { [weak mainController] count in
|
||||||
auctionContext: auctionContext,
|
let presentAuction = {
|
||||||
completion: { [weak mainController] in
|
let giftController = component.context.sharedContext.makeGiftAuctionViewScreen(
|
||||||
let controller = GiftSetupScreen(
|
context: component.context,
|
||||||
context: context,
|
auctionContext: auctionContext,
|
||||||
peerId: component.peerId,
|
completion: { [weak mainController] in
|
||||||
subject: .starGift(gift, nil),
|
let controller = GiftSetupScreen(
|
||||||
completion: nil
|
context: context,
|
||||||
|
peerId: component.peerId,
|
||||||
|
subject: .starGift(gift, nil),
|
||||||
|
completion: nil
|
||||||
|
)
|
||||||
|
mainController?.push(controller)
|
||||||
|
}
|
||||||
)
|
)
|
||||||
mainController?.push(controller)
|
mainController?.push(giftController)
|
||||||
}
|
}
|
||||||
)
|
|
||||||
mainController.push(giftController)
|
if count > 0 {
|
||||||
|
presentAuction()
|
||||||
|
} else {
|
||||||
|
let infoController = component.context.sharedContext.makeGiftAuctionInfoScreen(
|
||||||
|
context: component.context,
|
||||||
|
auctionContext: auctionContext,
|
||||||
|
completion: {
|
||||||
|
presentAuction()
|
||||||
|
let _ = ApplicationSpecificNotice.incrementGiftAuctionTips(accountManager: component.context.sharedContext.accountManager).startStandalone()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
mainController?.push(infoController)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -109,6 +109,7 @@ final class BadgeLabelView: UIView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.staticLabel.superview == nil {
|
if self.staticLabel.superview == nil {
|
||||||
|
self.staticLabel.alpha = 0.0
|
||||||
self.staticLabel.textColor = self.color
|
self.staticLabel.textColor = self.color
|
||||||
self.staticLabel.font = font
|
self.staticLabel.font = font
|
||||||
self.addSubview(self.staticLabel)
|
self.addSubview(self.staticLabel)
|
||||||
|
|||||||
@ -1003,7 +1003,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, 10_000, 20_000, 30_000, 40_000, 50_000]
|
var sliderSteps: [Int] = [100, 500, 1_000, 2_000, 5_000, 10_000, 25_000, 50_000, 100_000, 500_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 })
|
||||||
@ -1083,6 +1083,17 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
func withMaxRealValue(_ maxRealValue: Int) -> Amount {
|
func withMaxRealValue(_ maxRealValue: Int) -> Amount {
|
||||||
return Amount(realValue: self.realValue, minRealValue: self.minRealValue, minAllowedRealValue: self.minAllowedRealValue, maxRealValue: maxRealValue, maxSliderValue: self.maxSliderValue, isLogarithmic: self.isLogarithmic)
|
return Amount(realValue: self.realValue, minRealValue: self.minRealValue, minAllowedRealValue: self.minAllowedRealValue, maxRealValue: maxRealValue, maxSliderValue: self.maxSliderValue, isLogarithmic: self.isLogarithmic)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cutoffSliderValue(for cutoffRealValue: Int) -> Int {
|
||||||
|
let clampedReal = max(self.minRealValue, min(cutoffRealValue, self.maxRealValue))
|
||||||
|
|
||||||
|
return Amount.remapValueToSlider(
|
||||||
|
realValue: clampedReal,
|
||||||
|
minAllowedRealValue: self.minAllowedRealValue,
|
||||||
|
maxSliderValue: self.maxSliderValue,
|
||||||
|
steps: self.sliderSteps
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class View: UIView, UIScrollViewDelegate {
|
final class View: UIView, UIScrollViewDelegate {
|
||||||
@ -2016,16 +2027,22 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
giftsPerRound = giftsPerRoundValue
|
giftsPerRound = giftsPerRoundValue
|
||||||
}
|
}
|
||||||
|
|
||||||
var topCutoff: CGFloat?
|
var topCutoffRealValue: Int?
|
||||||
if let giftAuctionState = self.giftAuctionState, case let .ongoing(_, _, _, _, bidLevels, _, _, _, _, _) = giftAuctionState.auctionState {
|
if let giftAuctionState = self.giftAuctionState, case let .ongoing(_, _, _, _, bidLevels, _, _, _, _, _) = giftAuctionState.auctionState {
|
||||||
for bidLevel in bidLevels {
|
for bidLevel in bidLevels {
|
||||||
if bidLevel.position == giftsPerRound - 1 {
|
if bidLevel.position == giftsPerRound - 1 {
|
||||||
topCutoff = CGFloat(bidLevel.amount) / CGFloat(self.amount.maxRealValue)
|
topCutoffRealValue = Int(bidLevel.amount)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var topCutoff: CGFloat?
|
||||||
|
if let topCutoffRealValue {
|
||||||
|
let cutoffSliderValue = self.amount.cutoffSliderValue(for: topCutoffRealValue)
|
||||||
|
topCutoff = CGFloat(cutoffSliderValue) / CGFloat(self.amount.maxSliderValue)
|
||||||
|
}
|
||||||
|
|
||||||
let _ = self.sliderBackground.update(
|
let _ = self.sliderBackground.update(
|
||||||
transition: transition,
|
transition: transition,
|
||||||
component: AnyComponent(SliderBackgroundComponent(
|
component: AnyComponent(SliderBackgroundComponent(
|
||||||
|
|||||||
@ -64,7 +64,7 @@ public final class GlassBarButtonComponent: Component {
|
|||||||
private let containerView: UIView
|
private let containerView: UIView
|
||||||
private let genericContainerView: UIView
|
private let genericContainerView: UIView
|
||||||
private let genericBackgroundView: SimpleGlassView
|
private let genericBackgroundView: SimpleGlassView
|
||||||
private let glassContainerView: UIView
|
private let glassContainerView: GlassBackgroundContainerView
|
||||||
private let glassBackgroundView: GlassBackgroundView
|
private let glassBackgroundView: GlassBackgroundView
|
||||||
private var componentView: ComponentView<Empty>?
|
private var componentView: ComponentView<Empty>?
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public final class GlassBarButtonComponent: Component {
|
|||||||
self.containerView = UIView()
|
self.containerView = UIView()
|
||||||
self.genericContainerView = UIView()
|
self.genericContainerView = UIView()
|
||||||
self.genericBackgroundView = SimpleGlassView()
|
self.genericBackgroundView = SimpleGlassView()
|
||||||
self.glassContainerView = UIView()
|
self.glassContainerView = GlassBackgroundContainerView()
|
||||||
self.glassBackgroundView = GlassBackgroundView()
|
self.glassBackgroundView = GlassBackgroundView()
|
||||||
|
|
||||||
super.init(frame: frame)
|
super.init(frame: frame)
|
||||||
@ -87,7 +87,7 @@ public final class GlassBarButtonComponent: Component {
|
|||||||
self.containerView.addSubview(self.glassContainerView)
|
self.containerView.addSubview(self.glassContainerView)
|
||||||
|
|
||||||
self.genericContainerView.addSubview(self.genericBackgroundView)
|
self.genericContainerView.addSubview(self.genericBackgroundView)
|
||||||
self.glassContainerView.addSubview(self.glassBackgroundView)
|
self.glassContainerView.contentView.addSubview(self.glassBackgroundView)
|
||||||
|
|
||||||
self.addTarget(self, action: #selector(self.pressed), for: .touchUpInside)
|
self.addTarget(self, action: #selector(self.pressed), for: .touchUpInside)
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ public final class GlassBarButtonComponent: Component {
|
|||||||
switch effectiveState {
|
switch effectiveState {
|
||||||
case .generic:
|
case .generic:
|
||||||
genericAlpha = 1.0
|
genericAlpha = 1.0
|
||||||
glassAlpha = 0.001
|
glassAlpha = 0.0
|
||||||
case .glass, .tintedGlass:
|
case .glass, .tintedGlass:
|
||||||
glassAlpha = 1.0
|
glassAlpha = 1.0
|
||||||
genericAlpha = 0.0
|
genericAlpha = 0.0
|
||||||
@ -194,6 +194,7 @@ public final class GlassBarButtonComponent: Component {
|
|||||||
|
|
||||||
transition.setAlpha(view: self.glassContainerView, alpha: glassAlpha)
|
transition.setAlpha(view: self.glassContainerView, alpha: glassAlpha)
|
||||||
transition.setFrame(view: self.glassContainerView, frame: bounds)
|
transition.setFrame(view: self.glassContainerView, frame: bounds)
|
||||||
|
self.glassContainerView.update(size: bounds.size, isDark: component.isDark, transition: transition)
|
||||||
|
|
||||||
transition.setFrame(view: self.genericBackgroundView, frame: bounds)
|
transition.setFrame(view: self.genericBackgroundView, frame: bounds)
|
||||||
transition.setFrame(view: self.glassBackgroundView, frame: bounds)
|
transition.setFrame(view: self.glassBackgroundView, frame: bounds)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user