Skip to content

Commit 5f44db6

Browse files
committed
Various fixes
1 parent 9c95be3 commit 5f44db6

File tree

5 files changed

+35
-24
lines changed

5 files changed

+35
-24
lines changed

submodules/AccountContext/Sources/AccountContext.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,7 @@ public final class NavigateToChatControllerParams {
502502
public let peerNearbyData: ChatPeerNearbyData?
503503
public let reportReason: NavigateToChatControllerParams.ReportReason?
504504
public let animated: Bool
505+
public let forceAnimatedScroll: Bool
505506
public let options: NavigationAnimationOptions
506507
public let parentGroupId: PeerGroupId?
507508
public let chatListFilter: Int32?
@@ -514,7 +515,7 @@ public final class NavigateToChatControllerParams {
514515
public let forceOpenChat: Bool
515516
public let customChatNavigationStack: [EnginePeer.Id]?
516517

517-
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) {
518+
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) {
518519
self.navigationController = navigationController
519520
self.chatController = chatController
520521
self.chatLocationContextHolder = chatLocationContextHolder
@@ -536,6 +537,7 @@ public final class NavigateToChatControllerParams {
536537
self.peerNearbyData = peerNearbyData
537538
self.reportReason = reportReason
538539
self.animated = animated
540+
self.forceAnimatedScroll = forceAnimatedScroll
539541
self.options = options
540542
self.parentGroupId = parentGroupId
541543
self.chatListFilter = chatListFilter

submodules/TelegramUI/Components/ButtonComponent/Sources/ButtonComponent.swift

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ public final class ButtonComponent: Component {
559559
shimmeringView = ButtonShimmeringView(frame: .zero)
560560
self.insertSubview(shimmeringView, at: 0)
561561
}
562-
shimmeringView.update(size: availableSize, color: component.background.color, cornerRadius: component.background.cornerRadius, transition: shimmeringTransition)
562+
shimmeringView.update(size: availableSize, background: component.background, cornerRadius: component.background.cornerRadius, transition: shimmeringTransition)
563563
shimmeringTransition.setFrame(view: shimmeringView, frame: CGRect(origin: .zero, size: availableSize))
564564
} else if let shimmeringView = self.shimmeringView {
565565
self.shimmeringView = nil
@@ -598,6 +598,8 @@ private class ButtonShimmeringView: UIView {
598598

599599
super.init(frame: frame)
600600

601+
self.isUserInteractionEnabled = false
602+
601603
self.addSubview(self.shimmerView)
602604
self.addSubview(self.borderView)
603605
}
@@ -606,7 +608,9 @@ private class ButtonShimmeringView: UIView {
606608
preconditionFailure()
607609
}
608610

609-
func update(size: CGSize, color: UIColor, cornerRadius: CGFloat, transition: ComponentTransition) {
611+
func update(size: CGSize, background: ButtonComponent.Background, cornerRadius: CGFloat, transition: ComponentTransition) {
612+
let color = background.foreground
613+
610614
let alpha: CGFloat
611615
let borderAlpha: CGFloat
612616
let compositingFilter: String?
@@ -620,14 +624,16 @@ private class ButtonShimmeringView: UIView {
620624
compositingFilter = nil
621625
}
622626

627+
self.backgroundColor = background.color
628+
self.layer.cornerRadius = cornerRadius
629+
self.borderMaskView.layer.cornerRadius = cornerRadius
630+
623631
self.shimmerView.update(backgroundColor: .clear, foregroundColor: color.withAlphaComponent(alpha), gradientSize: 70.0, globalTimeOffset: false, duration: 4.0, horizontal: true)
624632
self.shimmerView.layer.compositingFilter = compositingFilter
625633

626634
self.borderShimmerView.update(backgroundColor: .clear, foregroundColor: color.withAlphaComponent(borderAlpha), gradientSize: 70.0, globalTimeOffset: false, duration: 4.0, horizontal: true)
627635
self.borderShimmerView.layer.compositingFilter = compositingFilter
628636

629-
self.borderMaskView.layer.cornerRadius = cornerRadius
630-
631637
let bounds = CGRect(origin: .zero, size: size)
632638
transition.setFrame(view: self.shimmerView, frame: bounds)
633639
transition.setFrame(view: self.borderView, frame: bounds)

submodules/TelegramUI/Components/Gifts/GiftAnimationComponent/Sources/GiftCompositionComponent.swift

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,26 @@ public final class GiftCompositionComponent: Component {
191191
}
192192
}
193193

194-
if case let .model(_, file, _) = self.previewModels[Int(self.previewModelIndex)] {
195-
animationFile = file
196-
}
197-
198-
if case let .pattern(_, file, _) = self.previewPatterns[Int(self.previewPatternIndex)] {
199-
patternFile = file
200-
files[file.fileId.id] = file
201-
}
202-
203-
if case let .backdrop(_, innerColorValue, outerColorValue, patternColorValue, _, _) = self.previewBackdrops[Int(self.previewBackdropIndex)] {
204-
backgroundColor = UIColor(rgb: UInt32(bitPattern: outerColorValue))
205-
secondBackgroundColor = UIColor(rgb: UInt32(bitPattern: innerColorValue))
206-
patternColor = UIColor(rgb: UInt32(bitPattern: patternColorValue))
194+
if !self.previewModels.isEmpty {
195+
if case let .model(_, file, _) = self.previewModels[Int(self.previewModelIndex)] {
196+
animationFile = file
197+
}
198+
199+
if case let .pattern(_, file, _) = self.previewPatterns[Int(self.previewPatternIndex)] {
200+
patternFile = file
201+
files[file.fileId.id] = file
202+
}
203+
204+
if case let .backdrop(_, innerColorValue, outerColorValue, patternColorValue, _, _) = self.previewBackdrops[Int(self.previewBackdropIndex)] {
205+
backgroundColor = UIColor(rgb: UInt32(bitPattern: outerColorValue))
206+
secondBackgroundColor = UIColor(rgb: UInt32(bitPattern: innerColorValue))
207+
patternColor = UIColor(rgb: UInt32(bitPattern: patternColorValue))
208+
}
207209
}
208210

209211
if self.previewTimer == nil {
210212
self.previewTimer = SwiftSignalKit.Timer(timeout: 2.0, repeat: true, completion: { [weak self] in
211-
guard let self else {
213+
guard let self, !self.previewModels.isEmpty else {
212214
return
213215
}
214216
self.previewModelIndex = (self.previewModelIndex + 1) % Int32(self.previewModels.count)

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,7 @@ private final class GiftViewSheetContent: CombinedComponent {
14501450
isEnabled: true,
14511451
displaysProgress: false,
14521452
action: {
1453+
component.cancel(true)
14531454
component.viewUpgraded(upgradeMessageId)
14541455
}),
14551456
availableSize: CGSize(width: context.availableSize.width - sideInset * 2.0, height: 50.0),
@@ -2064,17 +2065,17 @@ public class GiftViewScreen: ViewControllerComponentContainer {
20642065
}
20652066

20662067
viewUpgradedImpl = { [weak self] messageId in
2067-
guard let self else {
2068+
guard let self, let navigationController = self.navigationController as? NavigationController else {
20682069
return
20692070
}
20702071
let _ = (context.engine.data.get(
20712072
TelegramEngine.EngineData.Item.Peer.Peer(id: messageId.peerId)
20722073
)
2073-
|> deliverOnMainQueue).start(next: { peer in
2074-
guard let peer, let navigationController = self.navigationController as? NavigationController else {
2074+
|> deliverOnMainQueue).start(next: { [weak navigationController] peer in
2075+
guard let peer, let navigationController else {
20752076
return
20762077
}
2077-
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))
2078+
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))
20782079
})
20792080
}
20802081

submodules/TelegramUI/Sources/NavigateToChatController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public func navigateToChatControllerImpl(_ params: NavigateToChatControllerParam
124124
if case let .id(messageId) = messageSubject {
125125
let navigationController = params.navigationController
126126
let animated = params.animated
127-
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
127+
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
128128
if let navigationController = navigationController, let controller = controller {
129129
let _ = navigationController.popToViewController(controller, animated: animated)
130130
}

0 commit comments

Comments
 (0)