Various fixes

This commit is contained in:
Ilya Laktyushin 2024-12-28 18:46:12 +04:00
parent 9c95be3766
commit 5f44db6b7b
5 changed files with 35 additions and 24 deletions

View File

@ -502,6 +502,7 @@ public final class NavigateToChatControllerParams {
public let peerNearbyData: ChatPeerNearbyData? public let peerNearbyData: ChatPeerNearbyData?
public let reportReason: NavigateToChatControllerParams.ReportReason? public let reportReason: NavigateToChatControllerParams.ReportReason?
public let animated: Bool public let animated: Bool
public let forceAnimatedScroll: Bool
public let options: NavigationAnimationOptions public let options: NavigationAnimationOptions
public let parentGroupId: PeerGroupId? public let parentGroupId: PeerGroupId?
public let chatListFilter: Int32? public let chatListFilter: Int32?
@ -514,7 +515,7 @@ public final class NavigateToChatControllerParams {
public let forceOpenChat: Bool public let forceOpenChat: Bool
public let customChatNavigationStack: [EnginePeer.Id]? public let customChatNavigationStack: [EnginePeer.Id]?
public init(navigationController: NavigationController, chatController: ChatController? = nil, context: AccountContext, chatLocation: Location, chatLocationContextHolder: Atomic<ChatLocationContextHolder?> = Atomic<ChatLocationContextHolder?>(value: nil), subject: ChatControllerSubject? = nil, botStart: ChatControllerInitialBotStart? = nil, attachBotStart: ChatControllerInitialAttachBotStart? = nil, botAppStart: ChatControllerInitialBotAppStart? = nil, updateTextInputState: ChatTextInputState? = nil, activateInput: ChatControllerActivateInput? = nil, keepStack: NavigateToChatKeepStack = .default, useExisting: Bool = true, useBackAnimation: Bool = false, purposefulAction: (() -> Void)? = nil, scrollToEndIfExists: Bool = false, activateMessageSearch: (ChatSearchDomain, String)? = nil, peekData: ChatPeekTimeout? = nil, peerNearbyData: ChatPeerNearbyData? = nil, reportReason: NavigateToChatControllerParams.ReportReason? = nil, animated: Bool = true, options: NavigationAnimationOptions = [], parentGroupId: PeerGroupId? = nil, chatListFilter: Int32? = nil, chatNavigationStack: [ChatNavigationStackItem] = [], changeColors: Bool = false, setupController: @escaping (ChatController) -> Void = { _ in }, pushController: ((ChatController, Bool, @escaping () -> Void) -> Void)? = nil, completion: @escaping (ChatController) -> Void = { _ in }, chatListCompletion: @escaping (ChatListController) -> Void = { _ in }, forceOpenChat: Bool = false, customChatNavigationStack: [EnginePeer.Id]? = nil) { public init(navigationController: NavigationController, chatController: ChatController? = nil, context: AccountContext, chatLocation: Location, chatLocationContextHolder: Atomic<ChatLocationContextHolder?> = Atomic<ChatLocationContextHolder?>(value: nil), subject: ChatControllerSubject? = nil, botStart: ChatControllerInitialBotStart? = nil, attachBotStart: ChatControllerInitialAttachBotStart? = nil, botAppStart: ChatControllerInitialBotAppStart? = nil, updateTextInputState: ChatTextInputState? = nil, activateInput: ChatControllerActivateInput? = nil, keepStack: NavigateToChatKeepStack = .default, useExisting: Bool = true, useBackAnimation: Bool = false, purposefulAction: (() -> Void)? = nil, scrollToEndIfExists: Bool = false, activateMessageSearch: (ChatSearchDomain, String)? = nil, peekData: ChatPeekTimeout? = nil, peerNearbyData: ChatPeerNearbyData? = nil, reportReason: NavigateToChatControllerParams.ReportReason? = nil, animated: Bool = true, forceAnimatedScroll: Bool = false, options: NavigationAnimationOptions = [], parentGroupId: PeerGroupId? = nil, chatListFilter: Int32? = nil, chatNavigationStack: [ChatNavigationStackItem] = [], changeColors: Bool = false, setupController: @escaping (ChatController) -> Void = { _ in }, pushController: ((ChatController, Bool, @escaping () -> Void) -> Void)? = nil, completion: @escaping (ChatController) -> Void = { _ in }, chatListCompletion: @escaping (ChatListController) -> Void = { _ in }, forceOpenChat: Bool = false, customChatNavigationStack: [EnginePeer.Id]? = nil) {
self.navigationController = navigationController self.navigationController = navigationController
self.chatController = chatController self.chatController = chatController
self.chatLocationContextHolder = chatLocationContextHolder self.chatLocationContextHolder = chatLocationContextHolder
@ -536,6 +537,7 @@ public final class NavigateToChatControllerParams {
self.peerNearbyData = peerNearbyData self.peerNearbyData = peerNearbyData
self.reportReason = reportReason self.reportReason = reportReason
self.animated = animated self.animated = animated
self.forceAnimatedScroll = forceAnimatedScroll
self.options = options self.options = options
self.parentGroupId = parentGroupId self.parentGroupId = parentGroupId
self.chatListFilter = chatListFilter self.chatListFilter = chatListFilter

View File

@ -559,7 +559,7 @@ public final class ButtonComponent: Component {
shimmeringView = ButtonShimmeringView(frame: .zero) shimmeringView = ButtonShimmeringView(frame: .zero)
self.insertSubview(shimmeringView, at: 0) self.insertSubview(shimmeringView, at: 0)
} }
shimmeringView.update(size: availableSize, color: component.background.color, cornerRadius: component.background.cornerRadius, transition: shimmeringTransition) shimmeringView.update(size: availableSize, background: component.background, cornerRadius: component.background.cornerRadius, transition: shimmeringTransition)
shimmeringTransition.setFrame(view: shimmeringView, frame: CGRect(origin: .zero, size: availableSize)) shimmeringTransition.setFrame(view: shimmeringView, frame: CGRect(origin: .zero, size: availableSize))
} else if let shimmeringView = self.shimmeringView { } else if let shimmeringView = self.shimmeringView {
self.shimmeringView = nil self.shimmeringView = nil
@ -598,6 +598,8 @@ private class ButtonShimmeringView: UIView {
super.init(frame: frame) super.init(frame: frame)
self.isUserInteractionEnabled = false
self.addSubview(self.shimmerView) self.addSubview(self.shimmerView)
self.addSubview(self.borderView) self.addSubview(self.borderView)
} }
@ -606,7 +608,9 @@ private class ButtonShimmeringView: UIView {
preconditionFailure() preconditionFailure()
} }
func update(size: CGSize, color: UIColor, cornerRadius: CGFloat, transition: ComponentTransition) { func update(size: CGSize, background: ButtonComponent.Background, cornerRadius: CGFloat, transition: ComponentTransition) {
let color = background.foreground
let alpha: CGFloat let alpha: CGFloat
let borderAlpha: CGFloat let borderAlpha: CGFloat
let compositingFilter: String? let compositingFilter: String?
@ -620,14 +624,16 @@ private class ButtonShimmeringView: UIView {
compositingFilter = nil compositingFilter = nil
} }
self.backgroundColor = background.color
self.layer.cornerRadius = cornerRadius
self.borderMaskView.layer.cornerRadius = cornerRadius
self.shimmerView.update(backgroundColor: .clear, foregroundColor: color.withAlphaComponent(alpha), gradientSize: 70.0, globalTimeOffset: false, duration: 4.0, horizontal: true) self.shimmerView.update(backgroundColor: .clear, foregroundColor: color.withAlphaComponent(alpha), gradientSize: 70.0, globalTimeOffset: false, duration: 4.0, horizontal: true)
self.shimmerView.layer.compositingFilter = compositingFilter self.shimmerView.layer.compositingFilter = compositingFilter
self.borderShimmerView.update(backgroundColor: .clear, foregroundColor: color.withAlphaComponent(borderAlpha), gradientSize: 70.0, globalTimeOffset: false, duration: 4.0, horizontal: true) self.borderShimmerView.update(backgroundColor: .clear, foregroundColor: color.withAlphaComponent(borderAlpha), gradientSize: 70.0, globalTimeOffset: false, duration: 4.0, horizontal: true)
self.borderShimmerView.layer.compositingFilter = compositingFilter self.borderShimmerView.layer.compositingFilter = compositingFilter
self.borderMaskView.layer.cornerRadius = cornerRadius
let bounds = CGRect(origin: .zero, size: size) let bounds = CGRect(origin: .zero, size: size)
transition.setFrame(view: self.shimmerView, frame: bounds) transition.setFrame(view: self.shimmerView, frame: bounds)
transition.setFrame(view: self.borderView, frame: bounds) transition.setFrame(view: self.borderView, frame: bounds)

View File

@ -191,6 +191,7 @@ public final class GiftCompositionComponent: Component {
} }
} }
if !self.previewModels.isEmpty {
if case let .model(_, file, _) = self.previewModels[Int(self.previewModelIndex)] { if case let .model(_, file, _) = self.previewModels[Int(self.previewModelIndex)] {
animationFile = file animationFile = file
} }
@ -205,10 +206,11 @@ public final class GiftCompositionComponent: Component {
secondBackgroundColor = UIColor(rgb: UInt32(bitPattern: innerColorValue)) secondBackgroundColor = UIColor(rgb: UInt32(bitPattern: innerColorValue))
patternColor = UIColor(rgb: UInt32(bitPattern: patternColorValue)) patternColor = UIColor(rgb: UInt32(bitPattern: patternColorValue))
} }
}
if self.previewTimer == nil { if self.previewTimer == nil {
self.previewTimer = SwiftSignalKit.Timer(timeout: 2.0, repeat: true, completion: { [weak self] in self.previewTimer = SwiftSignalKit.Timer(timeout: 2.0, repeat: true, completion: { [weak self] in
guard let self else { guard let self, !self.previewModels.isEmpty else {
return return
} }
self.previewModelIndex = (self.previewModelIndex + 1) % Int32(self.previewModels.count) self.previewModelIndex = (self.previewModelIndex + 1) % Int32(self.previewModels.count)

View File

@ -1450,6 +1450,7 @@ private final class GiftViewSheetContent: CombinedComponent {
isEnabled: true, isEnabled: true,
displaysProgress: false, displaysProgress: false,
action: { action: {
component.cancel(true)
component.viewUpgraded(upgradeMessageId) component.viewUpgraded(upgradeMessageId)
}), }),
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0, height: 50.0), availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0, height: 50.0),
@ -2064,17 +2065,17 @@ public class GiftViewScreen: ViewControllerComponentContainer {
} }
viewUpgradedImpl = { [weak self] messageId in viewUpgradedImpl = { [weak self] messageId in
guard let self else { guard let self, let navigationController = self.navigationController as? NavigationController else {
return return
} }
let _ = (context.engine.data.get( let _ = (context.engine.data.get(
TelegramEngine.EngineData.Item.Peer.Peer(id: messageId.peerId) TelegramEngine.EngineData.Item.Peer.Peer(id: messageId.peerId)
) )
|> deliverOnMainQueue).start(next: { peer in |> deliverOnMainQueue).start(next: { [weak navigationController] peer in
guard let peer, let navigationController = self.navigationController as? NavigationController else { guard let peer, let navigationController else {
return return
} }
context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peer), subject: .message(id: .id(messageId), highlight: ChatControllerSubject.MessageHighlight(quote: nil), timecode: nil, setupReply: false), keepStack: .always, useExisting: false, purposefulAction: {}, peekData: nil)) context.sharedContext.navigateToChatController(NavigateToChatControllerParams(navigationController: navigationController, context: context, chatLocation: .peer(peer), subject: .message(id: .id(messageId), highlight: ChatControllerSubject.MessageHighlight(quote: nil), timecode: nil, setupReply: false), keepStack: .always, useExisting: true, purposefulAction: {}, peekData: nil, forceAnimatedScroll: true))
}) })
} }

View File

@ -124,7 +124,7 @@ public func navigateToChatControllerImpl(_ params: NavigateToChatControllerParam
if case let .id(messageId) = messageSubject { if case let .id(messageId) = messageSubject {
let navigationController = params.navigationController let navigationController = params.navigationController
let animated = params.animated let animated = params.animated
controller.navigateToMessage(messageLocation: .id(messageId, NavigateToMessageParams(timestamp: timecode, quote: (highlight?.quote).flatMap { quote in NavigateToMessageParams.Quote(string: quote.string, offset: quote.offset) }, setupReply: setupReply)), animated: isFirst, completion: { [weak navigationController, weak controller] in controller.navigateToMessage(messageLocation: .id(messageId, NavigateToMessageParams(timestamp: timecode, quote: (highlight?.quote).flatMap { quote in NavigateToMessageParams.Quote(string: quote.string, offset: quote.offset) }, setupReply: setupReply)), animated: isFirst || params.forceAnimatedScroll, completion: { [weak navigationController, weak controller] in
if let navigationController = navigationController, let controller = controller { if let navigationController = navigationController, let controller = controller {
let _ = navigationController.popToViewController(controller, animated: animated) let _ = navigationController.popToViewController(controller, animated: animated)
} }