mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-05 14:02:48 +00:00
Various fixes
This commit is contained in:
parent
62157e92ae
commit
d574fb7a11
@ -205,7 +205,6 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
|
|||||||
private let titleView: MediaPickerTitleView
|
private let titleView: MediaPickerTitleView
|
||||||
private let cancelButtonNode: WebAppCancelButtonNode
|
private let cancelButtonNode: WebAppCancelButtonNode
|
||||||
|
|
||||||
private var glassContainerView = GlassBackgroundContainerView()
|
|
||||||
private var cancelButton: ComponentView<Empty>?
|
private var cancelButton: ComponentView<Empty>?
|
||||||
private var rightButton: ComponentView<Empty>?
|
private var rightButton: ComponentView<Empty>?
|
||||||
private let moreButtonPlayOnce = ActionSlot<Void>()
|
private let moreButtonPlayOnce = ActionSlot<Void>()
|
||||||
@ -2573,14 +2572,6 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
|
|||||||
transition.updateAlpha(layer: self.controllerNode.topEdgeEffectView.layer, alpha: self.controllerNode.scrolledExactlyToTop && self.controllerNode.currentDisplayMode == .all ? 0.0 : 1.0)
|
transition.updateAlpha(layer: self.controllerNode.topEdgeEffectView.layer, alpha: self.controllerNode.scrolledExactlyToTop && self.controllerNode.currentDisplayMode == .all ? 0.0 : 1.0)
|
||||||
self.controllerNode.topEdgeEffectView.update(content: topEdgeColor, blur: true, alpha: 0.8, rect: topEdgeEffectFrame, edge: .top, edgeSize: topEdgeEffectFrame.height, transition: ComponentTransition(transition))
|
self.controllerNode.topEdgeEffectView.update(content: topEdgeColor, blur: true, alpha: 0.8, rect: topEdgeEffectFrame, edge: .top, edgeSize: topEdgeEffectFrame.height, transition: ComponentTransition(transition))
|
||||||
|
|
||||||
if self.cancelButton != nil {
|
|
||||||
if self.glassContainerView.superview == nil {
|
|
||||||
self.view.addSubview(self.glassContainerView)
|
|
||||||
}
|
|
||||||
self.glassContainerView.frame = CGRect(origin: .zero, size: CGSize(width: layout.size.width, height: 72.0))
|
|
||||||
self.glassContainerView.update(size: self.glassContainerView.frame.size, isDark: self.presentationData.theme.overallDarkAppearance, transition: .immediate)
|
|
||||||
}
|
|
||||||
|
|
||||||
if let cancelButton = self.cancelButton {
|
if let cancelButton = self.cancelButton {
|
||||||
if cancelButton.view == nil {
|
if cancelButton.view == nil {
|
||||||
buttonTransition = .immediate
|
buttonTransition = .immediate
|
||||||
@ -2608,7 +2599,7 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
|
|||||||
let cancelButtonFrame = CGRect(origin: CGPoint(x: barButtonSideInset + layout.safeInsets.left, y: barButtonSideInset), size: cancelButtonSize)
|
let cancelButtonFrame = CGRect(origin: CGPoint(x: barButtonSideInset + layout.safeInsets.left, y: barButtonSideInset), size: cancelButtonSize)
|
||||||
if let view = cancelButton.view {
|
if let view = cancelButton.view {
|
||||||
if view.superview == nil {
|
if view.superview == nil {
|
||||||
self.glassContainerView.contentView.addSubview(view)
|
self.view.addSubview(view)
|
||||||
}
|
}
|
||||||
view.bounds = CGRect(origin: .zero, size: cancelButtonFrame.size)
|
view.bounds = CGRect(origin: .zero, size: cancelButtonFrame.size)
|
||||||
view.center = cancelButtonFrame.center
|
view.center = cancelButtonFrame.center
|
||||||
@ -2643,7 +2634,7 @@ public final class MediaPickerScreenImpl: ViewController, MediaPickerScreen, Att
|
|||||||
let moreButtonFrame = CGRect(origin: CGPoint(x: layout.size.width - moreButtonSize.width - barButtonSideInset - layout.safeInsets.right, y: barButtonSideInset), size: moreButtonSize)
|
let moreButtonFrame = CGRect(origin: CGPoint(x: layout.size.width - moreButtonSize.width - barButtonSideInset - layout.safeInsets.right, y: barButtonSideInset), size: moreButtonSize)
|
||||||
if let view = moreButton.view {
|
if let view = moreButton.view {
|
||||||
if view.superview == nil {
|
if view.superview == nil {
|
||||||
self.glassContainerView.contentView.addSubview(view)
|
self.view.addSubview(view)
|
||||||
}
|
}
|
||||||
view.bounds = CGRect(origin: .zero, size: moreButtonFrame.size)
|
view.bounds = CGRect(origin: .zero, size: moreButtonFrame.size)
|
||||||
view.center = moreButtonFrame.center
|
view.center = moreButtonFrame.center
|
||||||
|
|||||||
@ -1901,7 +1901,7 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
|
|||||||
case let .updateMonoForumNoPaidException(flags, channelId, savedPeerId):
|
case let .updateMonoForumNoPaidException(flags, channelId, savedPeerId):
|
||||||
updatedState.updateMonoForumNoPaidException(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: savedPeerId.peerId.toInt64(), isFree: (flags & (1 << 0)) != 0)
|
updatedState.updateMonoForumNoPaidException(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: savedPeerId.peerId.toInt64(), isFree: (flags & (1 << 0)) != 0)
|
||||||
case let .updateStarGiftAuctionState(giftId, state):
|
case let .updateStarGiftAuctionState(giftId, state):
|
||||||
if let state = GiftAuctionContext.State.AuctionState(apiAuctionState: state) {
|
if let state = GiftAuctionContext.State.AuctionState(apiAuctionState: state, peers: updatedState.peers) {
|
||||||
updatedState.updateStarGiftAuctionState(giftId: giftId, state: state)
|
updatedState.updateStarGiftAuctionState(giftId: giftId, state: state)
|
||||||
}
|
}
|
||||||
case let .updateStarGiftAuctionUserState(giftId, userState):
|
case let .updateStarGiftAuctionUserState(giftId, userState):
|
||||||
|
|||||||
@ -37,7 +37,7 @@ private func _internal_getStarGiftAuctionState(postbox: Postbox, network: Networ
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
gift: gift,
|
gift: gift,
|
||||||
state: GiftAuctionContext.State.AuctionState(apiAuctionState: state),
|
state: GiftAuctionContext.State.AuctionState(apiAuctionState: state, transaction: transaction),
|
||||||
myState: GiftAuctionContext.State.MyState(apiAuctionUserState: userState),
|
myState: GiftAuctionContext.State.MyState(apiAuctionUserState: userState),
|
||||||
timeout: timeout
|
timeout: timeout
|
||||||
)
|
)
|
||||||
@ -55,7 +55,7 @@ public final class GiftAuctionContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum AuctionState: Equatable {
|
public enum AuctionState: Equatable {
|
||||||
case ongoing(version: Int32, startDate: Int32, endDate: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer.Id], nextRoundDate: Int32, giftsLeft: Int32, currentRound: Int32, totalRounds: Int32)
|
case ongoing(version: Int32, startDate: Int32, endDate: Int32, minBidAmount: Int64, bidLevels: [BidLevel], topBidders: [EnginePeer], nextRoundDate: Int32, giftsLeft: Int32, currentRound: Int32, totalRounds: Int32)
|
||||||
case finished(startDate: Int32, endDate: Int32, averagePrice: Int64)
|
case finished(startDate: Int32, endDate: Int32, averagePrice: Int64)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,10 +208,33 @@ extension GiftAuctionContext.State.BidLevel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension GiftAuctionContext.State.AuctionState {
|
extension GiftAuctionContext.State.AuctionState {
|
||||||
init?(apiAuctionState: Api.StarGiftAuctionState) {
|
init?(apiAuctionState: Api.StarGiftAuctionState, peers: [PeerId: Peer]) {
|
||||||
switch apiAuctionState {
|
switch apiAuctionState {
|
||||||
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBidders, nextRoundAt, giftsLeft, currentRound, totalRounds):
|
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBiddersPeerIds, nextRoundAt, giftsLeft, currentRound, totalRounds):
|
||||||
self = .ongoing(version: version, startDate: startDate, endDate: endDate, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders.map { EnginePeer.Id(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value($0)) }, nextRoundDate: nextRoundAt, giftsLeft: giftsLeft, currentRound: currentRound, totalRounds: totalRounds)
|
var topBidders: [EnginePeer] = []
|
||||||
|
for peerId in topBiddersPeerIds {
|
||||||
|
if let peer = peers[PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(peerId))] {
|
||||||
|
topBidders.append(EnginePeer(peer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self = .ongoing(version: version, startDate: startDate, endDate: endDate, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders, nextRoundDate: nextRoundAt, giftsLeft: giftsLeft, currentRound: currentRound, totalRounds: totalRounds)
|
||||||
|
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
|
||||||
|
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
|
||||||
|
case .starGiftAuctionStateNotModified:
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init?(apiAuctionState: Api.StarGiftAuctionState, transaction: Transaction) {
|
||||||
|
switch apiAuctionState {
|
||||||
|
case let .starGiftAuctionState(version, startDate, endDate, minBidAmount, bidLevels, topBiddersPeerIds, nextRoundAt, giftsLeft, currentRound, totalRounds):
|
||||||
|
var topBidders: [EnginePeer] = []
|
||||||
|
for peerId in topBiddersPeerIds {
|
||||||
|
if let peer = transaction.getPeer(PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(peerId))) {
|
||||||
|
topBidders.append(EnginePeer(peer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self = .ongoing(version: version, startDate: startDate, endDate: endDate, minBidAmount: minBidAmount, bidLevels: bidLevels.map(GiftAuctionContext.State.BidLevel.init(apiBidLevel:)), topBidders: topBidders, nextRoundDate: nextRoundAt, giftsLeft: giftsLeft, currentRound: currentRound, totalRounds: totalRounds)
|
||||||
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
|
case let .starGiftAuctionStateFinished(startDate, endDate, averagePrice):
|
||||||
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
|
self = .finished(startDate: startDate, endDate: endDate, averagePrice: averagePrice)
|
||||||
case .starGiftAuctionStateNotModified:
|
case .starGiftAuctionStateNotModified:
|
||||||
@ -314,7 +337,7 @@ func _internal_getActiveGiftAuctions(account: Account, hash: Int64) -> Signal<[G
|
|||||||
auctionContexts.append(GiftAuctionContext(
|
auctionContexts.append(GiftAuctionContext(
|
||||||
account: account,
|
account: account,
|
||||||
gift: gift,
|
gift: gift,
|
||||||
initialAuctionState: GiftAuctionContext.State.AuctionState(apiAuctionState: auctionState),
|
initialAuctionState: GiftAuctionContext.State.AuctionState(apiAuctionState: auctionState, transaction: transaction),
|
||||||
initialMyState: GiftAuctionContext.State.MyState(apiAuctionUserState: userState),
|
initialMyState: GiftAuctionContext.State.MyState(apiAuctionUserState: userState),
|
||||||
initialTimeout: nil
|
initialTimeout: nil
|
||||||
))
|
))
|
||||||
|
|||||||
@ -1793,14 +1793,6 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
self.giftAuctionState = state
|
self.giftAuctionState = state
|
||||||
|
|
||||||
var peerIds: [EnginePeer.Id] = []
|
var peerIds: [EnginePeer.Id] = []
|
||||||
if case let .ongoing(_, _, _, _, _, topBidders, _, _, _, _) = state?.auctionState {
|
|
||||||
for bidder in topBidders {
|
|
||||||
if self.peersMap[bidder] == nil {
|
|
||||||
peerIds.append(bidder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var transition = ComponentTransition.spring(duration: 0.4)
|
var transition = ComponentTransition.spring(duration: 0.4)
|
||||||
|
|
||||||
if isFirstTime {
|
if isFirstTime {
|
||||||
@ -2357,8 +2349,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var i: Int32 = 1
|
var i: Int32 = 1
|
||||||
for bidder in topBidders {
|
for peer in topBidders {
|
||||||
if let peer = self.peersMap[bidder] {
|
|
||||||
var bid: Int64 = 0
|
var bid: Int64 = 0
|
||||||
for level in bidLevels {
|
for level in bidLevels {
|
||||||
if level.position == i {
|
if level.position == i {
|
||||||
@ -2366,8 +2357,7 @@ private final class GiftAuctionBidScreenComponent: Component {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
topBidsComponents.append((bidder, AnyComponent(PeerComponent(context: component.context, theme: environment.theme, groupingSeparator: environment.dateTimeFormat.groupingSeparator, peer: peer, place: i, amount: bid, isLast: i == topBidders.count, action: peer.id != component.context.account.peerId ? { [weak self] in self?.openPeer(peer, dismiss: false) } : nil))))
|
topBidsComponents.append((peer.id, AnyComponent(PeerComponent(context: component.context, theme: environment.theme, groupingSeparator: environment.dateTimeFormat.groupingSeparator, peer: peer, place: i, amount: bid, isLast: i == topBidders.count, action: peer.id != component.context.account.peerId ? { [weak self] in self?.openPeer(peer, dismiss: false) } : nil))))
|
||||||
}
|
|
||||||
i += 1
|
i += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -193,7 +193,7 @@ public final class GlassBarButtonComponent: Component {
|
|||||||
transition.setAlpha(view: self.genericContainerView, alpha: genericAlpha)
|
transition.setAlpha(view: self.genericContainerView, alpha: genericAlpha)
|
||||||
transition.setFrame(view: self.genericContainerView, frame: bounds)
|
transition.setFrame(view: self.genericContainerView, frame: bounds)
|
||||||
|
|
||||||
transition.setAlpha(view: self.glassContainerView, alpha: glassAlpha)
|
transition.setAlpha(view: self.glassBackgroundView, alpha: glassAlpha)
|
||||||
transition.setFrame(view: self.glassContainerView, frame: bounds)
|
transition.setFrame(view: self.glassContainerView, frame: bounds)
|
||||||
|
|
||||||
transition.setFrame(view: self.genericBackgroundView, frame: bounds)
|
transition.setFrame(view: self.genericBackgroundView, frame: bounds)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user