mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Various Fixes
This commit is contained in:
parent
e9eac3eac0
commit
acc0c683a1
@ -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;
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user