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 diameter = minSide - 24.0f;
CGFloat diameter = MIN(404.0, minSide - 24.0f);
CGFloat shadowSize = 21.0f;
CGFloat circleWrapperViewLength = diameter + shadowSize * 2.0;
@ -335,14 +335,14 @@ typedef enum
_placeholderView.accessibilityIgnoresInvertColors = true;
}
CGFloat ringViewLength = minSide > 320.0f ? 260.0f : 234.0f;
CGFloat ringViewLength = diameter - 8.0f;
_ringView = [[TGVideoMessageRingView alloc] initWithFrame:(CGRect){
.origin.x = (_circleWrapperView.bounds.size.width - ringViewLength) / 2.0f,
.origin.y = (_circleWrapperView.bounds.size.height - ringViewLength) / 2.0f,
.size.width = 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];
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) {
if self.hasScheduledUnblur {
self.hasScheduledUnblur = false
}
if self.isBlurred == isBlurred {
return
}
@ -326,18 +329,22 @@ private final class CallVideoNode: ASDisplayNode, PreviewVideoNode {
}
}
private var hasScheduledUnblur = false
func flip(withBackground: Bool) {
if withBackground {
self.backgroundColor = .black
}
UIView.transition(with: withBackground ? self.videoTransformContainer.view : self.view, duration: 0.4, options: [.transitionFlipFromLeft, .curveEaseOut], animations: {
UIView.performWithoutAnimation {
self.updateIsBlurred(isBlurred: true, light: true, animated: false)
self.updateIsBlurred(isBlurred: true, light: false, animated: false)
}
}) { finished in
self.backgroundColor = nil
self.hasScheduledUnblur = true
Queue.mainQueue().after(0.5) {
self.updateIsBlurred(isBlurred: false)
if self.hasScheduledUnblur {
self.updateIsBlurred(isBlurred: false)
}
}
}
}

View File

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

View File

@ -418,7 +418,7 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
isTablet = false
}
var insets = layout.insets(options: [.statusBar, .input])
var insets = layout.insets(options: [.statusBar])
insets.top = max(10.0, insets.top)
let contentSize: CGSize
@ -458,11 +458,7 @@ private class VoiceChatCameraPreviewControllerNode: ViewControllerTracingNode, U
let titleSize = self.titleNode.measure(CGSize(width: contentFrame.width, height: .greatestFiniteMagnitude))
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)
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 previewFrame: CGRect
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.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.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))
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)
transition.updateFrame(node: self.wheelNode, frame: wheelFrame)

View File

@ -77,6 +77,10 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
super.init(layerBacked: false)
self.interactiveVideoNode.shouldOpen = { [weak self] in
return !(self?.animatingHeight ?? false)
}
self.containerNode.shouldBegin = { [weak self] location in
guard let strongSelf = self else {
return false
@ -125,7 +129,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
self.addSubnode(self.messageAccessibilityArea)
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
}
@ -334,7 +338,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
var isPlaying = false
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
if item.associatedData.currentlyPlayingMessageId == item.message.index {
isPlaying = true
@ -1077,7 +1081,7 @@ class ChatMessageInstantVideoItemNode: ChatMessageItemView, UIGestureRecognizerD
var isPlaying = false
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 {
isPlaying = true
}

View File

@ -82,7 +82,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
}
}
private var animating = false
var shouldOpen: () -> Bool = { return true }
override init() {
self.secretVideoPlaceholderBackground = ASImageNode()
@ -680,7 +680,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
if let current = self.playbackStatusNode {
playbackStatusNode = current
} 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
guard let strongSelf = self else {
return
@ -748,7 +748,7 @@ class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
}
private func activateVideoPlayback() {
guard let item = self.item else {
guard let item = self.item, self.shouldOpen() else {
return
}
if self.infoBackgroundNode.alpha.isZero {

View File

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

View File

@ -37,7 +37,7 @@ final class OverlayInstantVideoDecoration: UniversalVideoDecoration {
self.contentContainerNode.clipsToBounds = true
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.foregroundNode = self.foregroundContainerNode
}