Skip to content

Commit 4fdbe44

Browse files
author
Isaac
committed
Various improvements
1 parent 0a1be88 commit 4fdbe44

File tree

12 files changed

+116
-50
lines changed

12 files changed

+116
-50
lines changed

Telegram/Telegram-iOS/en.lproj/Localizable.strings

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14383,7 +14383,7 @@ Sorry for the inconvenience.";
1438314383
"ChannelMessages.PriceSectionTitle" = "PRICE FOR EACH MESSAGE";
1438414384
"ChannelMessages.PriceSectionFooter" = "You will receive 85% of the selected fee for each incoming message.";
1438514385

14386-
"ChatList.MonoforumLabel" = "MESSAGES";
14386+
"ChatList.MonoforumLabel" = "DIRECT";
1438714387
"ChatList.MonoforumEmptyText" = "No messages here yet...";
1438814388

1438914389
"Chat.InlineTopicMenu.Reorder" = "Reorder";
@@ -14400,6 +14400,7 @@ Sorry for the inconvenience.";
1440014400

1440114401
"Chat.EmptyStateMonoforum.Text" = "Send a direct message to the administrator of **%@**.";
1440214402
"Chat.EmptyStateMonoforumPaid.Text" = "**%1$@** charges **%2$@**\nper message to its admin.";
14403+
"Chat.Monoforum.Subtitle" = "Direct messages";
1440314404

1440414405
"Monoforum.NameFormat" = "%@ Messages";
1440514406

submodules/Display/Source/TransformImageNode.swift

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,14 @@ open class TransformImageNode: ASDisplayNode {
9797
self.disposable.set((result |> deliverOnMainQueue).start(next: { [weak self] next in
9898
let apply: () -> Void = {
9999
if let strongSelf = self {
100+
var animateFromContents: Any?
101+
100102
if strongSelf.contents == nil {
101103
if strongSelf.contentAnimations.contains(.firstUpdate) && !attemptSynchronously {
102104
strongSelf.layer.animateAlpha(from: 0.0, to: 1.0, duration: 0.15)
103105
}
104106
} else if strongSelf.contentAnimations.contains(.subsequentUpdates) {
105-
let tempLayer = CALayer()
106-
if strongSelf.captureProtected {
107-
setLayerDisableScreenshots(tempLayer, strongSelf.captureProtected)
108-
}
109-
tempLayer.frame = strongSelf.bounds
110-
tempLayer.contentsGravity = strongSelf.layer.contentsGravity
111-
tempLayer.contents = strongSelf.contents
112-
strongSelf.layer.addSublayer(tempLayer)
113-
tempLayer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, removeOnCompletion: false, completion: { [weak tempLayer] _ in
114-
tempLayer?.removeFromSuperlayer()
115-
})
107+
animateFromContents = strongSelf.contents
116108
}
117109

118110
var imageUpdate: UIImage?
@@ -129,6 +121,23 @@ open class TransformImageNode: ASDisplayNode {
129121
if let imageUpdated = strongSelf.imageUpdated {
130122
imageUpdated(imageUpdate)
131123
}
124+
125+
if let animateFromContents {
126+
let transition: ContainedViewLayoutTransition = .animated(duration: 0.2, curve: .linear)
127+
transition.animateContents(layer: strongSelf.layer, from: animateFromContents)
128+
129+
/*let tempLayer = CALayer()
130+
if strongSelf.captureProtected {
131+
setLayerDisableScreenshots(tempLayer, strongSelf.captureProtected)
132+
}
133+
tempLayer.frame = strongSelf.bounds
134+
tempLayer.contentsGravity = strongSelf.layer.contentsGravity
135+
tempLayer.contents = animateFromContents
136+
strongSelf.layer.addSublayer(tempLayer)
137+
tempLayer.animateAlpha(from: 1.0, to: 0.0, duration: 0.15, removeOnCompletion: false, completion: { [weak tempLayer] _ in
138+
tempLayer?.removeFromSuperlayer()
139+
})*/
140+
}
132141
}
133142
}
134143
if dispatchOnDisplayLink && !attemptSynchronously {
@@ -168,6 +177,34 @@ open class TransformImageNode: ASDisplayNode {
168177
}
169178
}
170179

180+
public func asyncLayoutWithAnimation() -> (TransformImageArguments) -> ((ListViewItemUpdateAnimation) -> Void) {
181+
let currentTransform = self.currentTransform
182+
let currentArguments = self.currentArguments
183+
return { [weak self] arguments in
184+
let updatedImage: UIImage?
185+
186+
if currentArguments != arguments {
187+
updatedImage = currentTransform?(arguments)?.generateImage()
188+
} else {
189+
updatedImage = nil
190+
}
191+
return { animation in
192+
guard let self else {
193+
return
194+
}
195+
if let image = updatedImage {
196+
self.contents = image.cgImage
197+
self.image = image
198+
self.currentArguments = arguments
199+
if let _ = self.overlayColor {
200+
self.applyOverlayColor(animated: false)
201+
}
202+
}
203+
self.argumentsPromise.set(arguments)
204+
}
205+
}
206+
}
207+
171208
public class func asyncLayout(_ maybeNode: TransformImageNode?) -> (TransformImageArguments) -> (() -> TransformImageNode) {
172209
return { arguments in
173210
let node: TransformImageNode

submodules/MediaPlayer/Sources/MediaPlayerNode.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public final class MediaPlayerNode: ASDisplayNode {
402402
}
403403
}
404404

405-
private func updateLayout() {
405+
public func updateLayout() {
406406
let bounds = self.bounds
407407
if bounds.isEmpty {
408408
return

submodules/TelegramUI/Components/Chat/ChatMessageInteractiveMediaNode/Sources/ChatMessageInteractiveMediaNode.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
858858
public func asyncLayout() -> (_ context: AccountContext, _ presentationData: ChatPresentationData, _ dateTimeFormat: PresentationDateTimeFormat, _ message: Message, _ associatedData: ChatMessageItemAssociatedData, _ attributes: ChatMessageEntryAttributes, _ media: Media, _ mediaIndex: Int?, _ dateAndStatus: ChatMessageDateAndStatus?, _ automaticDownload: InteractiveMediaNodeAutodownloadMode, _ peerType: MediaAutoDownloadPeerType, _ peerId: EnginePeer.Id?, _ sizeCalculation: InteractiveMediaNodeSizeCalculation, _ layoutConstants: ChatMessageItemLayoutConstants, _ contentMode: InteractiveMediaNodeContentMode, _ presentationContext: ChatPresentationContext) -> (CGSize, CGFloat, (CGSize, Bool, Bool, ImageCorners) -> (CGFloat, (CGFloat) -> (CGSize, (ListViewItemUpdateAnimation, Bool) -> Void))) {
859859
let currentMessage = self.message
860860
let currentMedia = self.media
861-
let imageLayout = self.imageNode.asyncLayout()
861+
let imageLayout = self.imageNode.asyncLayoutWithAnimation()
862862
let statusLayout = self.dateAndStatusNode.asyncLayout()
863863

864864
let currentVideoNode = self.videoNode
@@ -1894,7 +1894,7 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
18941894
timestampMaskView.image = strongSelf.generateTimestampMaskImage(corners: arguments.corners)
18951895
}
18961896
strongSelf.currentImageArguments = arguments
1897-
imageApply()
1897+
imageApply(transition)
18981898

18991899
if let statusApply = statusApply {
19001900
let dateAndStatusFrame = CGRect(origin: CGPoint(x: cleanImageFrame.width - layoutConstants.image.statusInsets.right - statusSize.width, y: cleanImageFrame.height - layoutConstants.image.statusInsets.bottom - statusSize.height), size: statusSize)
@@ -2084,8 +2084,13 @@ public final class ChatMessageInteractiveMediaNode: ASDisplayNode, GalleryItemTr
20842084
strongSelf.imageNode.cornerRadius = 0.0
20852085
}
20862086

2087-
videoNode.updateLayout(size: arguments.drawingSize, transition: .immediate)
2088-
videoNode.frame = CGRect(origin: CGPoint(), size: imageFrame.size)
2087+
if videoNode.bounds.isEmpty {
2088+
videoNode.updateLayout(size: arguments.drawingSize, transition: .immediate)
2089+
videoNode.frame = CGRect(origin: CGPoint(), size: imageFrame.size)
2090+
} else {
2091+
videoNode.updateLayout(size: arguments.drawingSize, transition: transition.transition)
2092+
transition.animator.updateFrame(layer: videoNode.layer, frame: CGRect(origin: CGPoint(), size: imageFrame.size), completion: nil)
2093+
}
20892094

20902095
if strongSelf.visibility && strongSelf.internallyVisible && !presentationData.isPreview {
20912096
if !videoNode.canAttachContent {

submodules/TelegramUI/Components/Chat/ChatSideTopicsPanel/Sources/ChatSideTopicsPanel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ public final class ChatSideTopicsPanel: Component {
13591359
maximumNumberOfLines: 2
13601360
)),
13611361
environment: {},
1362-
containerSize: CGSize(width: 200.0, height: 200.0)
1362+
containerSize: CGSize(width: 400.0, height: 200.0)
13631363
)
13641364

13651365
let contentSize: CGFloat = leftInset + rightInset + titleSize.height

submodules/TelegramUI/Components/ChatTitleView/Sources/ChatTitleView.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public enum ChatTitleContent: Equatable {
6868
return false
6969
}
7070
if lhs.peerPresences.count != rhs.peerPresences.count {
71+
return false
72+
} else {
7173
for (key, value) in lhs.peerPresences {
7274
if let rhsValue = rhs.peerPresences[key] {
7375
if !value.isEqual(to: rhsValue) {

submodules/TelegramUI/Sources/Chat/ChatControllerNavigationButtonAction.swift

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -397,21 +397,30 @@ extension ChatControllerImpl {
397397
self.navigationActionDisposable.set((peerView.get()
398398
|> take(1)
399399
|> deliverOnMainQueue).startStrict(next: { [weak self] peerView in
400-
if let strongSelf = self, let peer = peerView.peers[peerView.peerId], peer.restrictionText(platform: "ios", contentSettings: strongSelf.context.currentContentSettings.with { $0 }) == nil && !strongSelf.presentationInterfaceState.isNotAccessible {
401-
402-
if peer.id == strongSelf.context.account.peerId {
403-
if let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer, let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: true, requestsContext: nil) {
404-
strongSelf.effectiveNavigationController?.pushViewController(infoController)
400+
guard let self else {
401+
return
402+
}
403+
guard var peer = peerView.peers[peerView.peerId] else {
404+
return
405+
}
406+
if let channel = peer as? TelegramChannel, channel.isMonoForum, let linkedMonoforumId = channel.linkedMonoforumId, let mainPeer = peerView.peers[linkedMonoforumId] {
407+
peer = mainPeer
408+
}
409+
410+
if peer.restrictionText(platform: "ios", contentSettings: self.context.currentContentSettings.with { $0 }) == nil && !self.presentationInterfaceState.isNotAccessible {
411+
if peer.id == self.context.account.peerId {
412+
if let peer = self.presentationInterfaceState.renderedPeer?.chatMainPeer, let infoController = self.context.sharedContext.makePeerInfoController(context: self.context, updatedPresentationData: self.updatedPresentationData, peer: peer, mode: .generic, avatarInitiallyExpanded: false, fromChat: true, requestsContext: nil) {
413+
self.effectiveNavigationController?.pushViewController(infoController)
405414
}
406415
} else {
407416
var expandAvatar = expandAvatar
408417
if peer.smallProfileImage == nil {
409418
expandAvatar = false
410419
}
411-
if let validLayout = strongSelf.validLayout, validLayout.deviceMetrics.type == .tablet {
420+
if let validLayout = self.validLayout, validLayout.deviceMetrics.type == .tablet {
412421
expandAvatar = false
413422
}
414-
let mode: PeerInfoControllerMode
423+
let mode: PeerInfoControllerMode
415424
switch section {
416425
case .groupsInCommon:
417426
mode = .groupsInCommon
@@ -420,12 +429,12 @@ extension ChatControllerImpl {
420429
default:
421430
mode = .generic
422431
}
423-
if let infoController = strongSelf.context.sharedContext.makePeerInfoController(context: strongSelf.context, updatedPresentationData: strongSelf.updatedPresentationData, peer: peer, mode: mode, avatarInitiallyExpanded: expandAvatar, fromChat: true, requestsContext: strongSelf.contentData?.inviteRequestsContext) {
424-
strongSelf.effectiveNavigationController?.pushViewController(infoController)
432+
if let infoController = self.context.sharedContext.makePeerInfoController(context: self.context, updatedPresentationData: self.updatedPresentationData, peer: peer, mode: mode, avatarInitiallyExpanded: expandAvatar, fromChat: true, requestsContext: self.contentData?.inviteRequestsContext) {
433+
self.effectiveNavigationController?.pushViewController(infoController)
425434
}
426435
}
427436

428-
let _ = strongSelf.dismissPreviewing?(false)
437+
let _ = self.dismissPreviewing?(false)
429438
}
430439
}))
431440
case .replyThread:

submodules/TelegramUI/Sources/ChatControllerContentData.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,9 +548,9 @@ extension ChatControllerImpl {
548548
strongSelf.state.chatTitleContent = .custom(strings.Chat_TitlePinnedMessages(Int32(displayedCount ?? 1)), nil, false)
549549
} else if let channel = peer as? TelegramChannel, channel.isMonoForum {
550550
if let linkedMonoforumId = channel.linkedMonoforumId, let mainPeer = peerView.peers[linkedMonoforumId] {
551-
strongSelf.state.chatTitleContent = .custom(mainPeer.debugDisplayTitle, "Direct messages", false)
551+
strongSelf.state.chatTitleContent = .custom(mainPeer.debugDisplayTitle, strings.Chat_Monoforum_Subtitle, true)
552552
} else {
553-
strongSelf.state.chatTitleContent = .custom(channel.debugDisplayTitle, nil, false)
553+
strongSelf.state.chatTitleContent = .custom(channel.debugDisplayTitle, nil, true)
554554
}
555555
} else {
556556
strongSelf.state.chatTitleContent = .peer(peerView: ChatTitleContent.PeerData(peerView: peerView), customTitle: nil, onlineMemberCount: onlineMemberCount, isScheduledMessages: isScheduledMessages, isMuted: nil, customMessageCount: nil, isEnabled: hasPeerInfo)

submodules/TelegramUI/Sources/ChatControllerNode.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2552,17 +2552,9 @@ class ChatControllerNode: ASDisplayNode, ASScrollViewDelegate {
25522552
if self.leftPanel != nil || dismissedLeftPanel != nil {
25532553
titleTopicsAccessoryPanelNode.updateGlobalOffset(globalOffset: -titleTopicsAccessoryPanelFrame.height, transition: .immediate)
25542554
}
2555-
2556-
let topPanelTransition = ComponentTransition(transition)
2557-
/*switch topPanelTransition.animation {
2558-
case let .curve(duration, _):
2559-
topPanelTransition = topPanelTransition.withAnimation(.curve(duration: duration, curve: ComponentTransition.Animation.Curve(ChatMessageTransitionNodeImpl.verticalAnimationCurve)))
2560-
default:
2561-
break
2562-
}*/
25632555

2564-
topPanelTransition.setFrame(view: titleTopicsAccessoryPanelNode.view, frame: titleTopicsAccessoryPanelFrame)
2565-
titleTopicsAccessoryPanelNode.updateGlobalOffset(globalOffset: 0.0, transition: topPanelTransition)
2556+
ComponentTransition(transition).setFrame(view: titleTopicsAccessoryPanelNode.view, frame: titleTopicsAccessoryPanelFrame)
2557+
titleTopicsAccessoryPanelNode.updateGlobalOffset(globalOffset: 0.0, transition: ComponentTransition(transition))
25662558
} else {
25672559
let previousFrame = titleTopicsAccessoryPanelNode.frame
25682560
titleTopicsAccessoryPanelNode.frame = titleTopicsAccessoryPanelFrame

submodules/TelegramUI/Sources/ChatHistoryListNode.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
681681

682682
private var loadedMessagesFromCachedDataDisposable: Disposable?
683683

684+
private var isSettingTopReplyThreadMessageShown: Bool = false
684685
let isTopReplyThreadMessageShown = ValuePromise<Bool>(false, ignoreRepeated: true)
685686

686687
private var topVisibleMessageRangeValueInitialized: Bool = false
@@ -3178,8 +3179,15 @@ public final class ChatHistoryListNodeImpl: ListView, ChatHistoryNode, ChatHisto
31783179
}
31793180
}
31803181

3181-
3182-
self.isTopReplyThreadMessageShown.set(isTopReplyThreadMessageShownValue)
3182+
if !self.isSettingTopReplyThreadMessageShown {
3183+
self.isSettingTopReplyThreadMessageShown = true
3184+
self.isTopReplyThreadMessageShown.set(isTopReplyThreadMessageShownValue)
3185+
self.isSettingTopReplyThreadMessageShown = false
3186+
} else {
3187+
#if DEBUG
3188+
print("Ignore repeated isTopReplyThreadMessageShown update")
3189+
#endif
3190+
}
31833191
self.updateTopVisibleMessageRange(topVisibleMessageRange)
31843192
let _ = self.visibleMessageRange.swap(topVisibleMessageRange.flatMap { range in
31853193
return VisibleMessageRange(lowerBound: range.lowerBound, upperBound: range.upperBound)

0 commit comments

Comments
 (0)