Skip to content

Commit 7d962cc

Browse files
committed
Fixed chat message preview layout on scrolling
1 parent dabf729 commit 7d962cc

3 files changed

Lines changed: 24 additions & 18 deletions

File tree

‎submodules/TelegramUI/TelegramUI/ChatHistoryNavigationButtonNode.swift‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,11 @@ class ChatHistoryNavigationButtonNode: ASControlNode {
3737
}
3838

3939
private var theme: PresentationTheme
40+
private let type: ChatHistoryNavigationButtonType
4041

4142
init(theme: PresentationTheme, type: ChatHistoryNavigationButtonType) {
4243
self.theme = theme
44+
self.type = type
4345

4446
self.imageNode = ASImageNode()
4547
self.imageNode.displayWithoutProcessing = true
@@ -77,7 +79,7 @@ class ChatHistoryNavigationButtonNode: ASControlNode {
7779
if self.theme !== theme {
7880
self.theme = theme
7981

80-
switch type {
82+
switch self.type {
8183
case .down:
8284
self.imageNode.image = PresentationResourcesChat.chatHistoryNavigationButtonImage(theme)
8385
case .mentions:

‎submodules/TelegramUI/TelegramUI/ChatSendMessageActionSheetControllerNode.swift‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -390,14 +390,6 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
390390
intermediateCompletion()
391391
})
392392

393-
Queue.mainQueue().after(0.7) {
394-
completedAlpha = true
395-
completedButton = true
396-
completedBubble = true
397-
completedEffect = true
398-
intermediateCompletion()
399-
}
400-
401393
self.dimNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.3, removeOnCompletion: false)
402394
self.contentContainerNode.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { _ in })
403395

@@ -453,13 +445,21 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
453445
let textOffset = self.textInputNode.textView.contentSize.height - self.textInputNode.textView.contentOffset.y - self.textInputNode.textView.frame.height
454446
self.fromMessageTextNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: delta * 2.0 + textOffset), duration: duration, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, additive: true)
455447
self.toMessageTextNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 0.0, y: delta * 2.0 + textOffset), duration: duration, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, additive: true)
448+
} else {
449+
completedBubble = true
456450
}
457451

458452
self.contentContainerNode.layer.animatePosition(from: CGPoint(), to: CGPoint(x: 160.0, y: 0.0), duration: duration, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false, additive: true)
459453
self.contentContainerNode.layer.animateScale(from: 1.0, to: 0.4, duration: duration, timingFunction: kCAMediaTimingFunctionSpring, removeOnCompletion: false)
460454
}
461455
}
462456

457+
func scrollViewDidScroll(_ scrollView: UIScrollView) {
458+
if let layout = self.validLayout {
459+
self.containerLayoutUpdated(layout, transition: .immediate)
460+
}
461+
}
462+
463463
func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) {
464464
self.validLayout = layout
465465

@@ -484,10 +484,13 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
484484
let insets = layout.insets(options: [.statusBar, .input])
485485
let inputHeight = layout.inputHeight ?? 0.0
486486

487+
let contentOffset = self.scrollNode.view.contentOffset.y
488+
487489
var contentOrigin = CGPoint(x: layout.size.width - sideInset - contentSize.width - layout.safeInsets.right, y: layout.size.height - 6.0 - insets.bottom - contentSize.height)
488490
if inputHeight > 0.0 {
489491
contentOrigin.y += 60.0
490492
}
493+
contentOrigin.y = min(contentOrigin.y + contentOffset, layout.size.height - 6.0 - layout.intrinsicInsets.bottom - contentSize.height)
491494

492495
transition.updateFrame(node: self.contentContainerNode, frame: CGRect(origin: contentOrigin, size: contentSize))
493496
var nextY: CGFloat = 0.0
@@ -502,6 +505,7 @@ final class ChatSendMessageActionSheetControllerNode: ViewControllerTracingNode,
502505
if inputHeight.isZero {
503506
sendButtonFrame.origin.y -= 60.0
504507
}
508+
sendButtonFrame.origin.y = min(sendButtonFrame.origin.y + contentOffset, layout.size.height - layout.intrinsicInsets.bottom - initialSendButtonFrame.height)
505509
transition.updateFrame(node: self.sendButtonNode, frame: sendButtonFrame)
506510

507511
var messageFrame = self.textFieldFrame

‎submodules/TelegramUIPreferences/Sources/PresentationThemeSettings.swift‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,15 @@ public struct PresentationThemeAccentColor: PostboxCoding, Equatable {
257257
}
258258

259259
public var color: UIColor {
260-
let color: UIColor
261-
if self.value < 0.5 {
262-
color = self.baseColor.color.interpolateTo(self.baseColor.edgeColors.0, fraction: 0.5 - self.value)!
263-
} else if self.value > 0.5 {
264-
color = self.baseColor.color.interpolateTo(self.baseColor.edgeColors.1, fraction: self.value - 0.5)!
265-
} else {
266-
color = self.baseColor.color
267-
}
268-
return color
260+
// let color: UIColor
261+
// if self.value < 0.5 {
262+
// color = self.baseColor.color.interpolateTo(self.baseColor.edgeColors.0, fraction: 0.5 - self.value)!
263+
// } else if self.value > 0.5 {
264+
// color = self.baseColor.color.interpolateTo(self.baseColor.edgeColors.1, fraction: self.value - 0.5)!
265+
// } else {
266+
// color = self.baseColor.color
267+
// }
268+
return self.baseColor.color
269269
}
270270
}
271271

0 commit comments

Comments
 (0)