Video avatar fixes

This commit is contained in:
Ilya Laktyushin 2020-07-11 01:16:07 +03:00
parent b25e1e502b
commit 99f166b698
4 changed files with 12 additions and 28 deletions

View File

@ -368,7 +368,7 @@ public func createChannelController(context: AccountContext) -> ViewController {
}
if let timestamp = videoStartTimestamp {
videoStartTimestamp = max(0.0, min(timestamp, result.duration))
videoStartTimestamp = max(0.0, min(timestamp, result.duration - 0.05))
}
var value = stat()

View File

@ -626,7 +626,7 @@ public func createGroupControllerImpl(context: AccountContext, peerIds: [PeerId]
}
if let timestamp = videoStartTimestamp {
videoStartTimestamp = max(0.0, min(timestamp, result.duration))
videoStartTimestamp = max(0.0, min(timestamp, result.duration - 0.05))
}
var value = stat()

View File

@ -1070,21 +1070,6 @@ final class PeerInfoAvatarTransformContainerNode: ASDisplayNode {
}
}
func reattachVideoNode() {
if let videoNode = self.videoNode {
let maskPath = UIBezierPath(ovalIn: CGRect(origin: CGPoint(), size: self.avatarNode.frame.size))
let shape = CAShapeLayer()
shape.path = maskPath.cgPath
videoNode.layer.mask = shape
videoNode.transform = CATransform3DIdentity
videoNode.updateLayout(size: self.avatarNode.frame.size, transition: .immediate)
videoNode.frame = self.avatarNode.frame
self.addSubnode(videoNode)
}
}
func updateTransitionFraction(_ fraction: CGFloat, transition: ContainedViewLayoutTransition) {
if let videoNode = self.videoNode {
if case .immediate = transition, fraction == 1.0 {
@ -2287,6 +2272,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
private(set) var isAvatarExpanded: Bool
private(set) var twoLineInfo = false
var skipCollapseCompletion = false
var ignoreCollapse = false
let avatarListNode: PeerInfoAvatarListNode
@ -2837,7 +2823,7 @@ final class PeerInfoHeaderNode: ASDisplayNode {
}
self.avatarListNode.listContainerNode.update(size: expandedAvatarListSize, peer: peer, isExpanded: self.isAvatarExpanded, transition: transition)
if self.avatarListNode.listContainerNode.isCollapsing {
if self.avatarListNode.listContainerNode.isCollapsing && !self.ignoreCollapse {
self.avatarListNode.avatarContainerNode.canAttachVideo = false
}

View File

@ -3990,13 +3990,11 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
}
if self.headerNode.isAvatarExpanded {
self.headerNode.ignoreCollapse = true
self.headerNode.updateIsAvatarExpanded(false, transition: .immediate)
self.updateNavigationExpansionPresentation(isExpanded: false, animated: true)
}
if let (layout, navigationHeight) = self.validLayout {
self.scrollNode.view.setContentOffset(CGPoint(), animated: false)
self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate, additive: false)
}
self.scrollNode.view.setContentOffset(CGPoint(), animated: false)
let resource = LocalFileMediaResource(fileId: arc4random64())
self.context.account.postbox.mediaBox.storeResourceData(resource.id, data: data)
@ -4006,6 +4004,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
if let (layout, navigationHeight) = self.validLayout {
self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate, additive: false)
}
self.headerNode.ignoreCollapse = false
let postbox = self.context.account.postbox
let signal = self.isSettings ? updateAccountPhoto(account: self.context.account, resource: resource, videoResource: nil, videoStartTimestamp: nil, mapResourceToAvatarSizes: { resource, representations in
@ -4036,13 +4035,11 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
}
if self.headerNode.isAvatarExpanded {
self.headerNode.ignoreCollapse = true
self.headerNode.updateIsAvatarExpanded(false, transition: .immediate)
self.updateNavigationExpansionPresentation(isExpanded: false, animated: true)
}
if let (layout, navigationHeight) = self.validLayout {
self.scrollNode.view.setContentOffset(CGPoint(), animated: false)
self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate, additive: false)
}
self.scrollNode.view.setContentOffset(CGPoint(), animated: false)
let photoResource = LocalFileMediaResource(fileId: arc4random64())
self.context.account.postbox.mediaBox.storeResourceData(photoResource.id, data: data)
@ -4052,6 +4049,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
if let (layout, navigationHeight) = self.validLayout {
self.containerLayoutUpdated(layout: layout, navigationHeight: navigationHeight, transition: .immediate, additive: false)
}
self.headerNode.ignoreCollapse = false
var videoStartTimestamp: Double? = nil
if let adjustments = adjustments, adjustments.videoStartValue > 0.0 {
@ -4083,7 +4081,7 @@ private final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewD
}
if let timestamp = videoStartTimestamp {
videoStartTimestamp = max(0.0, min(timestamp, result.duration))
videoStartTimestamp = max(0.0, min(timestamp, result.duration - 0.05))
}
var value = stat()