mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Fix voice chat expanded avatar position
This commit is contained in:
parent
c863952605
commit
5f3bab6261
@ -1271,33 +1271,29 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
|
||||
var overflowOffset: CGFloat
|
||||
var contentContainerFrame: CGRect
|
||||
// if keepInPlace {
|
||||
overflowOffset = min(0.0, originalActionsFrame.minY - contentTopInset)
|
||||
|
||||
overflowOffset = min(0.0, originalActionsFrame.minY - contentTopInset)
|
||||
let contentParentNode = referenceNode
|
||||
contentContainerFrame = originalContentFrame
|
||||
if !overflowOffset.isZero {
|
||||
let offsetDelta = contentParentNode.frame.height + 4.0
|
||||
overflowOffset += offsetDelta
|
||||
overflowOffset = min(0.0, overflowOffset)
|
||||
|
||||
originalActionsFrame.origin.x -= contentParentNode.frame.width + 14.0
|
||||
originalActionsFrame.origin.x = max(actionsSideInset, originalActionsFrame.origin.x)
|
||||
//originalActionsFrame.origin.y += contentParentNode.contentRect.height
|
||||
if originalActionsFrame.minX < contentContainerFrame.minX {
|
||||
contentContainerFrame.origin.x = min(originalActionsFrame.maxX + 14.0, layout.size.width - actionsSideInset)
|
||||
}
|
||||
originalActionsFrame.origin.y += offsetDelta
|
||||
if originalActionsFrame.maxY < originalContentFrame.maxY {
|
||||
originalActionsFrame.origin.y += contentParentNode.frame.height
|
||||
originalActionsFrame.origin.y = min(originalActionsFrame.origin.y, layout.size.height - originalActionsFrame.height - actionsBottomInset)
|
||||
}
|
||||
contentHeight -= offsetDelta
|
||||
contentContainerFrame = originalContentFrame
|
||||
if !overflowOffset.isZero {
|
||||
let offsetDelta = contentParentNode.frame.height + 4.0
|
||||
overflowOffset += offsetDelta
|
||||
overflowOffset = min(0.0, overflowOffset)
|
||||
|
||||
originalActionsFrame.origin.x -= contentParentNode.frame.width + 14.0
|
||||
originalActionsFrame.origin.x = max(actionsSideInset, originalActionsFrame.origin.x)
|
||||
|
||||
if originalActionsFrame.minX < contentContainerFrame.minX {
|
||||
contentContainerFrame.origin.x = min(originalActionsFrame.maxX + 14.0, layout.size.width - actionsSideInset)
|
||||
}
|
||||
// } else {
|
||||
// overflowOffset = min(0.0, originalContentFrame.minY - contentTopInset)
|
||||
// contentContainerFrame = originalContentFrame.offsetBy(dx: -contentParentNode.contentRect.minX, dy: -overflowOffset - contentParentNode.contentRect.minY)
|
||||
// }
|
||||
|
||||
originalActionsFrame.origin.y += offsetDelta
|
||||
if originalActionsFrame.maxY < originalContentFrame.maxY {
|
||||
originalActionsFrame.origin.y += contentParentNode.frame.height
|
||||
originalActionsFrame.origin.y = min(originalActionsFrame.origin.y, layout.size.height - originalActionsFrame.height - actionsBottomInset)
|
||||
}
|
||||
contentHeight -= offsetDelta
|
||||
}
|
||||
|
||||
let scrollContentSize = CGSize(width: layout.size.width, height: contentHeight)
|
||||
if self.scrollNode.view.contentSize != scrollContentSize {
|
||||
self.scrollNode.view.contentSize = scrollContentSize
|
||||
@ -1388,6 +1384,14 @@ private final class ContextControllerNode: ViewControllerTracingNode, UIScrollVi
|
||||
contentContainerFrame = originalContentFrame.offsetBy(dx: -contentParentNode.contentRect.minX, dy: -overflowOffset - contentParentNode.contentRect.minY)
|
||||
}
|
||||
|
||||
if case let .extracted(source) = self.source, source.centerVertically {
|
||||
let totalHeight = contentContainerFrame.height + originalActionsFrame.height
|
||||
let updatedOrigin = floor((layout.size.height - totalHeight) / 2.0)
|
||||
let delta = updatedOrigin - contentContainerFrame.origin.y
|
||||
contentContainerFrame.origin.y = updatedOrigin
|
||||
originalActionsFrame.origin.y += delta
|
||||
}
|
||||
|
||||
let scrollContentSize = CGSize(width: layout.size.width, height: contentHeight)
|
||||
if self.scrollNode.view.contentSize != scrollContentSize {
|
||||
self.scrollNode.view.contentSize = scrollContentSize
|
||||
@ -1697,6 +1701,7 @@ public final class ContextControllerPutBackViewInfo {
|
||||
}
|
||||
|
||||
public protocol ContextExtractedContentSource: class {
|
||||
var centerVertically: Bool { get }
|
||||
var keepInPlace: Bool { get }
|
||||
var ignoreContentTouches: Bool { get }
|
||||
var blurBackground: Bool { get }
|
||||
@ -1707,6 +1712,10 @@ public protocol ContextExtractedContentSource: class {
|
||||
}
|
||||
|
||||
public extension ContextExtractedContentSource {
|
||||
var centerVertically: Bool {
|
||||
return false
|
||||
}
|
||||
|
||||
var shouldBeDismissed: Signal<Bool, NoError> {
|
||||
return .single(false)
|
||||
}
|
||||
|
@ -1432,7 +1432,7 @@ public final class VoiceChatController: ViewController {
|
||||
|
||||
|
||||
let dismissPromise = ValuePromise<Bool>(false)
|
||||
let source = VoiceChatContextExtractedContentSource(controller: controller, sourceNode: sourceNode, keepInPlace: false, blurBackground: true, shouldBeDismissed: dismissPromise.get())
|
||||
let source = VoiceChatContextExtractedContentSource(controller: controller, sourceNode: sourceNode, keepInPlace: false, blurBackground: true, centerVertically: entry.peer.smallProfileImage != nil, shouldBeDismissed: dismissPromise.get())
|
||||
sourceNode.requestDismiss = {
|
||||
dismissPromise.set(true)
|
||||
}
|
||||
@ -3905,13 +3905,15 @@ private final class VoiceChatContextExtractedContentSource: ContextExtractedCont
|
||||
private let controller: ViewController
|
||||
private let sourceNode: ContextExtractedContentContainingNode
|
||||
|
||||
var centerVertically: Bool
|
||||
var shouldBeDismissed: Signal<Bool, NoError>
|
||||
|
||||
init(controller: ViewController, sourceNode: ContextExtractedContentContainingNode, keepInPlace: Bool, blurBackground: Bool, shouldBeDismissed: Signal<Bool, NoError>) {
|
||||
init(controller: ViewController, sourceNode: ContextExtractedContentContainingNode, keepInPlace: Bool, blurBackground: Bool, centerVertically: Bool, shouldBeDismissed: Signal<Bool, NoError>) {
|
||||
self.controller = controller
|
||||
self.sourceNode = sourceNode
|
||||
self.keepInPlace = keepInPlace
|
||||
self.blurBackground = blurBackground
|
||||
self.centerVertically = centerVertically
|
||||
self.shouldBeDismissed = shouldBeDismissed
|
||||
}
|
||||
|
||||
|
@ -756,6 +756,10 @@ class VoiceChatParticipantItemNode: ItemListRevealOptionsItemNode {
|
||||
strongSelf.nonExtractedRect = nonExtractedRect
|
||||
|
||||
if strongSelf.isExtracted {
|
||||
var extractedRect = extractedRect
|
||||
if !extractedVerticalOffset.isZero {
|
||||
extractedRect = CGRect(x: extractedRect.minX, y: extractedRect.minY + extractedVerticalOffset, width: extractedRect.width, height: extractedRect.height - extractedVerticalOffset)
|
||||
}
|
||||
strongSelf.backgroundImageNode.frame = extractedRect
|
||||
} else {
|
||||
strongSelf.backgroundImageNode.frame = nonExtractedRect
|
||||
|
Loading…
x
Reference in New Issue
Block a user