Various Fixes

This commit is contained in:
Ilya Laktyushin 2021-07-24 17:59:36 +03:00
parent e9eac3eac0
commit acc0c683a1
8 changed files with 53 additions and 31 deletions

View File

@ -300,7 +300,7 @@ typedef enum
} }
CGFloat minSide = MIN(_wrapperView.frame.size.width, _wrapperView.frame.size.height); CGFloat minSide = MIN(_wrapperView.frame.size.width, _wrapperView.frame.size.height);
CGFloat diameter = minSide - 24.0f; CGFloat diameter = MIN(404.0, minSide - 24.0f);
CGFloat shadowSize = 21.0f; CGFloat shadowSize = 21.0f;
CGFloat circleWrapperViewLength = diameter + shadowSize * 2.0; CGFloat circleWrapperViewLength = diameter + shadowSize * 2.0;
@ -335,14 +335,14 @@ typedef enum
_placeholderView.accessibilityIgnoresInvertColors = true; _placeholderView.accessibilityIgnoresInvertColors = true;
} }
CGFloat ringViewLength = minSide > 320.0f ? 260.0f : 234.0f; CGFloat ringViewLength = diameter - 8.0f;
_ringView = [[TGVideoMessageRingView alloc] initWithFrame:(CGRect){ _ringView = [[TGVideoMessageRingView alloc] initWithFrame:(CGRect){
.origin.x = (_circleWrapperView.bounds.size.width - ringViewLength) / 2.0f, .origin.x = (_circleWrapperView.bounds.size.width - ringViewLength) / 2.0f,
.origin.y = (_circleWrapperView.bounds.size.height - ringViewLength) / 2.0f, .origin.y = (_circleWrapperView.bounds.size.height - ringViewLength) / 2.0f,
.size.width = ringViewLength, .size.width = ringViewLength,
.size.height = ringViewLength .size.height = ringViewLength
}]; }];
_ringView.accentColor = self.pallete != nil ? self.pallete.buttonColor : TGAccentColor(); _ringView.accentColor = [UIColor colorWithWhite:1.0 alpha:0.6];
[_circleWrapperView addSubview:_ringView]; [_circleWrapperView addSubview:_ringView];
CGRect controlsFrame = _controlsFrame; CGRect controlsFrame = _controlsFrame;

View File

@ -295,6 +295,9 @@ private final class CallVideoNode: ASDisplayNode, PreviewVideoNode {
} }
func updateIsBlurred(isBlurred: Bool, light: Bool = false, animated: Bool = true) { func updateIsBlurred(isBlurred: Bool, light: Bool = false, animated: Bool = true) {
if self.hasScheduledUnblur {
self.hasScheduledUnblur = false
}
if self.isBlurred == isBlurred { if self.isBlurred == isBlurred {
return return
} }
@ -326,22 +329,26 @@ private final class CallVideoNode: ASDisplayNode, PreviewVideoNode {
} }
} }
private var hasScheduledUnblur = false
func flip(withBackground: Bool) { func flip(withBackground: Bool) {
if withBackground { if withBackground {
self.backgroundColor = .black self.backgroundColor = .black
} }
UIView.transition(with: withBackground ? self.videoTransformContainer.view : self.view, duration: 0.4, options: [.transitionFlipFromLeft, .curveEaseOut], animations: { UIView.transition(with: withBackground ? self.videoTransformContainer.view : self.view, duration: 0.4, options: [.transitionFlipFromLeft, .curveEaseOut], animations: {
UIView.performWithoutAnimation { UIView.performWithoutAnimation {
self.updateIsBlurred(isBlurred: true, light: true, animated: false) self.updateIsBlurred(isBlurred: true, light: false, animated: false)
} }
}) { finished in }) { finished in
self.backgroundColor = nil self.backgroundColor = nil
self.hasScheduledUnblur = true
Queue.mainQueue().after(0.5) { Queue.mainQueue().after(0.5) {
if self.hasScheduledUnblur {
self.updateIsBlurred(isBlurred: false) self.updateIsBlurred(isBlurred: false)
} }
} }
} }
} }
}
final class CallControllerNode: ViewControllerTracingNode, CallControllerNodeProtocol { final class CallControllerNode: ViewControllerTracingNode, CallControllerNodeProtocol {
private enum VideoNodeCorner { private enum VideoNodeCorner {

View File

@ -99,6 +99,9 @@ final class GroupVideoNode: ASDisplayNode, PreviewVideoNode {
} }
func updateIsBlurred(isBlurred: Bool, light: Bool = false, animated: Bool = true) { func updateIsBlurred(isBlurred: Bool, light: Bool = false, animated: Bool = true) {
if self.hasScheduledUnblur {
self.hasScheduledUnblur = false
}
if self.isBlurred == isBlurred { if self.isBlurred == isBlurred {
return return
} }
@ -128,6 +131,7 @@ final class GroupVideoNode: ASDisplayNode, PreviewVideoNode {
} }
} }
private var hasScheduledUnblur = false
func flip(withBackground: Bool) { func flip(withBackground: Bool) {
if withBackground { if withBackground {
self.backgroundColor = .black self.backgroundColor = .black
@ -145,20 +149,25 @@ final class GroupVideoNode: ASDisplayNode, PreviewVideoNode {
} }
}) { finished in }) { finished in
self.backgroundColor = nil self.backgroundColor = nil
self.hasScheduledUnblur = true
if let snapshotView = snapshotView { if let snapshotView = snapshotView {
Queue.mainQueue().after(0.3) { Queue.mainQueue().after(0.3) {
snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak snapshotView] _ in snapshotView.layer.animateAlpha(from: 1.0, to: 0.0, duration: 0.2, removeOnCompletion: false, completion: { [weak snapshotView] _ in
snapshotView?.removeFromSuperview() snapshotView?.removeFromSuperview()
}) })
if self.hasScheduledUnblur {
self.updateIsBlurred(isBlurred: false) self.updateIsBlurred(isBlurred: false)
} }
}
} else { } else {
Queue.mainQueue().after(0.4) { Queue.mainQueue().after(0.4) {
if self.hasScheduledUnblur {
self.updateIsBlurred(isBlurred: false) self.updateIsBlurred(isBlurred: false)
} }
} }
} }
} }
}
@objc private func tapGesture(_ recognizer: UITapGestureRecognizer) { @objc private func tapGesture(_ recognizer: UITapGestureRecognizer) {
if case .ended = recognizer.state { if case .ended = recognizer.state {

View File

@ -418,7 +418,7 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
isTablet = false isTablet = false
} }
var insets = layout.insets(options: [.statusBar, .input]) var insets = layout.insets(options: [.statusBar])
insets.top = max(10.0, insets.top) insets.top = max(10.0, insets.top)
let contentSize: CGSize let contentSize: CGSize
@ -459,10 +459,6 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
let titleFrame = CGRect(origin: CGPoint(x: floor((contentFrame.width - titleSize.width) / 2.0), y: 20.0), size: titleSize) let titleFrame = CGRect(origin: CGPoint(x: floor((contentFrame.width - titleSize.width) / 2.0), y: 20.0), size: titleSize)
transition.updateFrame(node: self.titleNode, frame: titleFrame) transition.updateFrame(node: self.titleNode, frame: titleFrame)
let cancelButtonSize = self.cancelButton.measure(CGSize(width: (contentFrame.width - titleSize.width) / 2.0, height: .greatestFiniteMagnitude))
let cancelButtonFrame = CGRect(origin: CGPoint(x: layout.safeInsets.left + 17.0, y: 20.0), size: cancelButtonSize)
transition.updateFrame(node: self.cancelButton, frame: cancelButtonFrame)
var previewSize: CGSize var previewSize: CGSize
var previewFrame: CGRect var previewFrame: CGRect
let previewAspectRatio: CGFloat = 1.85 let previewAspectRatio: CGFloat = 1.85
@ -479,6 +475,10 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
self.shimmerNode.update(foregroundColor: UIColor(rgb: 0xffffff, alpha: 0.07)) self.shimmerNode.update(foregroundColor: UIColor(rgb: 0xffffff, alpha: 0.07))
self.shimmerNode.updateAbsoluteRect(previewFrame, within: layout.size) self.shimmerNode.updateAbsoluteRect(previewFrame, within: layout.size)
let cancelButtonSize = self.cancelButton.measure(CGSize(width: (previewFrame.width - titleSize.width) / 2.0, height: .greatestFiniteMagnitude))
let cancelButtonFrame = CGRect(origin: CGPoint(x: previewFrame.minX + 17.0, y: 20.0), size: cancelButtonSize)
transition.updateFrame(node: self.cancelButton, frame: cancelButtonFrame)
self.cameraNode.frame = CGRect(origin: CGPoint(), size: previewSize) self.cameraNode.frame = CGRect(origin: CGPoint(), size: previewSize)
self.cameraNode.updateLayout(size: previewSize, layoutMode: isLandscape ? .fillHorizontal : .fillVertical, transition: .immediate) self.cameraNode.updateLayout(size: previewSize, layoutMode: isLandscape ? .fillHorizontal : .fillVertical, transition: .immediate)
@ -499,7 +499,7 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
transition.updateFrame(node: self.doneButton, frame: CGRect(x: floorToScreenPixels((contentFrame.width - buttonWidth) / 2.0), y: previewFrame.maxY - doneButtonHeight - buttonInset, width: buttonWidth, height: doneButtonHeight)) transition.updateFrame(node: self.doneButton, frame: CGRect(x: floorToScreenPixels((contentFrame.width - buttonWidth) / 2.0), y: previewFrame.maxY - doneButtonHeight - buttonInset, width: buttonWidth, height: doneButtonHeight))
self.broadcastPickerView?.frame = self.doneButton.frame self.broadcastPickerView?.frame = self.doneButton.frame
let wheelFrame = CGRect(origin: CGPoint(x: 16.0, y: previewFrame.maxY - doneButtonHeight - buttonInset - 36.0 - 20.0), size: CGSize(width: contentFrame.width - 32.0, height: 36.0)) let wheelFrame = CGRect(origin: CGPoint(x: 16.0 + previewFrame.minX, y: previewFrame.maxY - doneButtonHeight - buttonInset - 36.0 - 20.0), size: CGSize(width: previewFrame.width - 32.0, height: 36.0))
self.wheelNode.updateLayout(size: wheelFrame.size, transition: transition) self.wheelNode.updateLayout(size: wheelFrame.size, transition: transition)
transition.updateFrame(node: self.wheelNode, frame: wheelFrame) transition.updateFrame(node: self.wheelNode, frame: wheelFrame)

View File

@ -77,6 +77,10 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
super.init(layerBacked: false) super.init(layerBacked: false)
self.interactiveVideoNode.shouldOpen = { [weak self] in
return !(self?.animatingHeight ?? false)
}
self.containerNode.shouldBegin = { [weak self] location in self.containerNode.shouldBegin = { [weak self] location in
guard let strongSelf = self else { guard let strongSelf = self else {
return false return false
@ -125,7 +129,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
self.addSubnode(self.messageAccessibilityArea) self.addSubnode(self.messageAccessibilityArea)
self.messageAccessibilityArea.activate = { [weak self] in self.messageAccessibilityArea.activate = { [weak self] in
guard let strongSelf = self, let accessibilityData = strongSelf.accessibilityData else { guard let strongSelf = self, let _ = strongSelf.accessibilityData else {
return false return false
} }
@ -334,7 +338,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
var isPlaying = false var isPlaying = false
var displaySize = layoutConstants.instantVideo.dimensions var displaySize = layoutConstants.instantVideo.dimensions
let maximumDisplaySize = CGSize(width: params.width - 20.0, height: params.width - 20.0) let maximumDisplaySize = CGSize(width: min(404, params.width - 20.0), height: min(404, params.width - 20.0))
var effectiveAvatarInset = avatarInset var effectiveAvatarInset = avatarInset
if item.associatedData.currentlyPlayingMessageId == item.message.index { if item.associatedData.currentlyPlayingMessageId == item.message.index {
isPlaying = true isPlaying = true
@ -1077,7 +1081,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
var isPlaying = false var isPlaying = false
var displaySize = layoutConstants.instantVideo.dimensions var displaySize = layoutConstants.instantVideo.dimensions
let maximumDisplaySize = CGSize(width: params.width - 20.0, height: params.width - 20.0) let maximumDisplaySize = CGSize(width: min(404, params.width - 20.0), height: min(404, params.width - 20.0))
if item.associatedData.currentlyPlayingMessageId == item.message.index { if item.associatedData.currentlyPlayingMessageId == item.message.index {
isPlaying = true isPlaying = true
} }

View File

@ -82,7 +82,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
} }
} }
private var animating = false var shouldOpen: () -> Bool = { return true }
override init() { override init() {
self.secretVideoPlaceholderBackground = ASImageNode() self.secretVideoPlaceholderBackground = ASImageNode()
@ -680,7 +680,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
if let current = self.playbackStatusNode { if let current = self.playbackStatusNode {
playbackStatusNode = current playbackStatusNode = current
} else { } else {
playbackStatusNode = InstantVideoRadialStatusNode(color: UIColor(white: 1.0, alpha: 0.6)) playbackStatusNode = InstantVideoRadialStatusNode(color: UIColor(white: 1.0, alpha: 0.6), hasSeek: true)
playbackStatusNode.seekTo = { [weak self] position, play in playbackStatusNode.seekTo = { [weak self] position, play in
guard let strongSelf = self else { guard let strongSelf = self else {
return return
@ -748,7 +748,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
} }
private func activateVideoPlayback() { private func activateVideoPlayback() {
guard let item = self.item else { guard let item = self.item, self.shouldOpen() else {
return return
} }
if self.infoBackgroundNode.alpha.isZero { if self.infoBackgroundNode.alpha.isZero {

View File

@ -37,6 +37,7 @@ private extension CGPoint {
final class InstantVideoRadialStatusNode: ASDisplayNode, UIGestureRecognizerDelegate { final class InstantVideoRadialStatusNode: ASDisplayNode, UIGestureRecognizerDelegate {
private let color: UIColor private let color: UIColor
private let hasSeek: Bool
private let hapticFeedback = HapticFeedback() private let hapticFeedback = HapticFeedback()
private var effectiveProgress: CGFloat = 0.0 { private var effectiveProgress: CGFloat = 0.0 {
@ -99,8 +100,9 @@ final class InstantVideoRadialStatusNode: ASDisplayNode, UIGestureRecognizerDele
var seekTo: ((Double, Bool) -> Void)? var seekTo: ((Double, Bool) -> Void)?
init(color: UIColor) { init(color: UIColor, hasSeek: Bool) {
self.color = color self.color = color
self.hasSeek = hasSeek
super.init() super.init()
@ -121,6 +123,10 @@ final class InstantVideoRadialStatusNode: ASDisplayNode, UIGestureRecognizerDele
override func didLoad() { override func didLoad() {
super.didLoad() super.didLoad()
guard self.hasSeek else {
return
}
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:))) let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(self.tapGesture(_:)))
tapGestureRecognizer.delegate = self tapGestureRecognizer.delegate = self
self.view.addGestureRecognizer(tapGestureRecognizer) self.view.addGestureRecognizer(tapGestureRecognizer)
@ -144,15 +150,6 @@ final class InstantVideoRadialStatusNode: ASDisplayNode, UIGestureRecognizerDele
} }
} }
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
if gestureRecognizer === self.panGestureRecognizer, let otherGestureRecognizer = otherGestureRecognizer as? UIPanGestureRecognizer {
otherGestureRecognizer.isEnabled = false
otherGestureRecognizer.isEnabled = true
return true
}
return true
}
@objc private func tapGesture(_ gestureRecognizer: UITapGestureRecognizer) { @objc private func tapGesture(_ gestureRecognizer: UITapGestureRecognizer) {
let center = CGPoint(x: self.bounds.width / 2.0, y: self.bounds.height / 2.0) let center = CGPoint(x: self.bounds.width / 2.0, y: self.bounds.height / 2.0)
let location = gestureRecognizer.location(in: self.view) let location = gestureRecognizer.location(in: self.view)
@ -299,6 +296,11 @@ final class InstantVideoRadialStatusNode: ASDisplayNode, UIGestureRecognizerDele
if self.seeking { if self.seeking {
dimmed = true dimmed = true
} }
if !self.hasSeek {
dimmed = false
}
if dimmed != self.dimmed { if dimmed != self.dimmed {
self.dimmed = dimmed self.dimmed = dimmed

View File

@ -37,7 +37,7 @@ final class OverlayInstantVideoDecoration: UniversalVideoDecoration {
self.contentContainerNode.clipsToBounds = true self.contentContainerNode.clipsToBounds = true
self.foregroundContainerNode = ASDisplayNode() self.foregroundContainerNode = ASDisplayNode()
self.progressNode = InstantVideoRadialStatusNode(color: UIColor(white: 1.0, alpha: 0.6)) self.progressNode = InstantVideoRadialStatusNode(color: UIColor(white: 1.0, alpha: 0.6), hasSeek: false)
self.foregroundContainerNode.addSubnode(self.progressNode) self.foregroundContainerNode.addSubnode(self.progressNode)
self.foregroundNode = self.foregroundContainerNode self.foregroundNode = self.foregroundContainerNode
} }