mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Cleanup
This commit is contained in:
parent
cd4dc4b1c0
commit
e84b49e081
@ -180,14 +180,6 @@ public final class _UpdatedChildComponent {
|
||||
var _opacity: CGFloat?
|
||||
var _cornerRadius: CGFloat?
|
||||
var _clipsToBounds: Bool?
|
||||
/// Quick animation addition
|
||||
var _animations: [AnimationKey: AnimationType] = [:]
|
||||
|
||||
public typealias AnimationKey = String
|
||||
public enum AnimationType {
|
||||
case transition
|
||||
case custom(duration: TimeInterval, curveAndOtherParams: Any)
|
||||
}
|
||||
|
||||
fileprivate var transitionAppear: Transition.Appear?
|
||||
fileprivate var transitionAppearWithGuide: (Transition.AppearWithGuide, _AnyChildComponent.Id)?
|
||||
@ -249,11 +241,6 @@ public final class _UpdatedChildComponent {
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult public func animation(key: AnimationKey) -> _UpdatedChildComponent {
|
||||
self._animations[key] = .transition
|
||||
return self
|
||||
}
|
||||
|
||||
@discardableResult public func scale(_ scale: CGFloat) -> _UpdatedChildComponent {
|
||||
self._scale = scale
|
||||
return self
|
||||
@ -708,8 +695,6 @@ public extension CombinedComponent {
|
||||
|
||||
view.insertSubview(updatedChild.view, at: index)
|
||||
|
||||
let currentPosition = updatedChild.view.center
|
||||
|
||||
if let scale = updatedChild._scale {
|
||||
updatedChild.view.bounds = CGRect(origin: CGPoint(), size: updatedChild.size)
|
||||
updatedChild.view.center = updatedChild._position ?? CGPoint()
|
||||
@ -717,14 +702,6 @@ public extension CombinedComponent {
|
||||
} else {
|
||||
updatedChild.view.frame = updatedChild.size.centered(around: updatedChild._position ?? CGPoint())
|
||||
}
|
||||
// for animation in updatedChild._animations { }
|
||||
|
||||
if updatedChild._animations["position"] != nil, let position = updatedChild._position {
|
||||
transition.animatePosition(view: updatedChild.view, from: currentPosition, to: position)
|
||||
}
|
||||
if updatedChild._animations["opacity"] != nil, let opacity = updatedChild._opacity {
|
||||
transition.animateAlpha(view: updatedChild.view, from: updatedChild.view.alpha, to: opacity)
|
||||
}
|
||||
|
||||
updatedChild.view.alpha = updatedChild._opacity ?? 1.0
|
||||
updatedChild.view.clipsToBounds = updatedChild._clipsToBounds ?? false
|
||||
|
@ -548,25 +548,6 @@ public struct Transition {
|
||||
}
|
||||
}
|
||||
|
||||
public func animateCornerRadius(layer: CALayer, from fromValue: CGFloat, to toValue: CGFloat) {
|
||||
switch self.animation {
|
||||
case .none:
|
||||
break
|
||||
case let .curve(duration, curve):
|
||||
layer.animate(
|
||||
from: fromValue as NSNumber,
|
||||
to: toValue as NSNumber,
|
||||
keyPath: "cornerRadius",
|
||||
duration: duration,
|
||||
delay: 0.0,
|
||||
curve: curve,
|
||||
removeOnCompletion: true,
|
||||
additive: false,
|
||||
completion: nil
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public func animateBoundsOrigin(layer: CALayer, from fromValue: CGPoint, to toValue: CGPoint, additive: Bool = false, completion: ((Bool) -> Void)? = nil) {
|
||||
switch self.animation {
|
||||
case .none:
|
||||
|
@ -102,11 +102,11 @@ private final class CreateExternalMediaStreamScreenComponent: CombinedComponent
|
||||
}
|
||||
|
||||
strongSelf.isDelayingLoadingIndication = true
|
||||
Timer(timeout: 0.3, repeat: false, completion: { [weak strongSelf] in
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.7) { [weak strongSelf] in
|
||||
guard let strongSelf else { return }
|
||||
strongSelf.isDelayingLoadingIndication = false
|
||||
strongSelf.updated(transition: .easeInOut(duration: 0.3))
|
||||
}, queue: .mainQueue()).start()
|
||||
}
|
||||
|
||||
var cancelImpl: (() -> Void)?
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
@ -541,20 +541,7 @@ public final class StandaloneShimmerEffect {
|
||||
animation.repeatCount = .infinity
|
||||
animation.duration = 0.8 * delay
|
||||
animation.timingFunction = .init(name: .easeInEaseOut)
|
||||
// animation.beginTime = layer.convertTime(1.0, from: nil)
|
||||
layer.add(animation, forKey: "shimmer")
|
||||
/*let opacityAnimation = CAKeyframeAnimation(keyPath: "opacity")
|
||||
opacityAnimation.values = [0.0, 1.0, 0.0]
|
||||
opacityAnimation.keyTimes = [0, 0.5, 0]
|
||||
opacityAnimation.calculationMode = .linear
|
||||
// opacityAnimation.fromValue = 2.0 as NSNumber
|
||||
// opacityAnimation.toValue = -2.0 as NSNumber
|
||||
// opacityAnimation.isAdditive = true
|
||||
opacityAnimation.repeatCount = .infinity
|
||||
opacityAnimation.duration = 1.6
|
||||
opacityAnimation.timingFunctions = [.init(name: .easeInEaseOut)]
|
||||
// opacityAnimation.beginTime = layer.convertTime(1.0, from: nil)
|
||||
layer.add(opacityAnimation, forKey: "opacity")*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,8 @@ import UIKit
|
||||
import Display
|
||||
import ComponentFlow
|
||||
|
||||
private let purple = UIColor(rgb: 0xdf44b8) // 0x3252ef)
|
||||
private let pink = UIColor(rgb: 0x3851eb) // 0xe4436c)
|
||||
|
||||
private let latePurple = UIColor(rgb: 0x974aa9)
|
||||
private let latePink = UIColor(rgb: 0xf0436c)
|
||||
private let purple = UIColor(rgb: 0xdf44b8)
|
||||
private let pink = UIColor(rgb: 0x3851eb)
|
||||
|
||||
public final class AnimatedCountView: UIView {
|
||||
let countLabel = AnimatedCountLabel()
|
||||
@ -59,15 +56,9 @@ public final class AnimatedCountView: UIView {
|
||||
self.foregroundView.frame = CGRect(origin: CGPoint.zero, size: bounds.size)// .insetBy(dx: -40, dy: -40)
|
||||
self.foregroundGradientLayer.frame = CGRect(origin: .zero, size: bounds.size).insetBy(dx: -60, dy: -60)
|
||||
self.maskingView.frame = CGRect(origin: .zero, size: bounds.size)
|
||||
// 18
|
||||
// let counterInset: CGFloat = 8
|
||||
// let counterBottomOffset: CGFloat = subtitleHeight + counterInset
|
||||
|
||||
countLabel.frame = CGRect(origin: .zero, size: CGSize(width: bounds.width, height: bounds.height))
|
||||
subtitleLabel.frame = subtitleFrame
|
||||
// backgroundColor = .white.withAlphaComponent(0.3)
|
||||
// countLabel.backgroundColor = .red.withAlphaComponent(0.2)
|
||||
// subtitleLabel.backgroundColor = .blue.withAlphaComponent(0.2)
|
||||
}
|
||||
|
||||
}
|
||||
@ -348,7 +339,7 @@ class AnimatedCountLabel: UILabel {
|
||||
self.clipsToBounds = false
|
||||
}
|
||||
func animateOut(for layer: CALayer, duration: CFTimeInterval, beginTime: CFTimeInterval) {
|
||||
let beginTimeOffset: CFTimeInterval = 0/*beginTime == .zero ? 0 :*/ // CFTimeInterval(DispatchTime.now().uptimeNanoseconds / 1000000000) /*layer.convertTime(*/// CACurrentMediaTime()//, to: nil)
|
||||
let beginTimeOffset: CFTimeInterval = 0
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + beginTime) {
|
||||
let beginTime: CFTimeInterval = 0
|
||||
|
||||
|
@ -1083,13 +1083,13 @@ public final class MediaStreamComponentController: ViewControllerComponentContai
|
||||
})
|
||||
|
||||
self.view.layer.allowsGroupOpacity = true
|
||||
self.view.layer.animateAlpha(from: 1.0, to: 1.0, duration: 0.2, completion: { [weak self] _ in
|
||||
|
||||
self.backgroundDimView.layer.animateAlpha(from: 0, to: 1, duration: 0.3, completion: { [weak self] _ in
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
}
|
||||
strongSelf.view.layer.allowsGroupOpacity = false
|
||||
})
|
||||
self.backgroundDimView.layer.animateAlpha(from: 0, to: 1, duration: 0.3)
|
||||
if backgroundDimView.superview == nil {
|
||||
guard let superview = view.superview else { return }
|
||||
superview.insertSubview(backgroundDimView, belowSubview: view)
|
||||
@ -1130,9 +1130,7 @@ public final class MediaStreamComponentController: ViewControllerComponentContai
|
||||
|
||||
override public func dismiss(completion: (() -> Void)? = nil) {
|
||||
self.view.layer.allowsGroupOpacity = true
|
||||
// self.view.layer.animateAlpha(from: 1.0, to: 1.0, duration: 0.4, removeOnCompletion: false, completion: { [weak self] _ in
|
||||
//
|
||||
// })
|
||||
|
||||
self.backgroundDimView.layer.animateAlpha(from: 1.0, to: 0, duration: 0.3, removeOnCompletion: false)
|
||||
self.view.layer.animatePosition(from: self.view.center, to: CGPoint(x: self.view.center.x, y: self.view.bounds.maxY + self.view.bounds.height / 2), duration: 0.4, removeOnCompletion: false, completion: { [weak self] _ in
|
||||
guard let strongSelf = self else {
|
||||
@ -1371,7 +1369,6 @@ private final class NavigationBarComponent: CombinedComponent {
|
||||
context.add(background
|
||||
.position(CGPoint(x: size.width / 2.0, y: size.height / 2.0))
|
||||
.opacity(context.component.backgroundVisible ? 1 : 0)
|
||||
.animation(key: "opacity")
|
||||
)
|
||||
|
||||
var centerLeftInset = sideInset
|
||||
@ -1688,8 +1685,6 @@ private final class StreamTitleComponent: Component {
|
||||
private final class OriginInfoComponent: CombinedComponent {
|
||||
let participantsCount: Int
|
||||
|
||||
private static var usingAnimatedCounter: Bool { true }
|
||||
|
||||
init(
|
||||
memberCount: Int
|
||||
) {
|
||||
@ -1705,64 +1700,29 @@ private final class OriginInfoComponent: CombinedComponent {
|
||||
}
|
||||
|
||||
static var body: Body {
|
||||
if usingAnimatedCounter {
|
||||
let viewerCounter = Child(ParticipantsComponent.self)
|
||||
let viewerCounter = Child(ParticipantsComponent.self)
|
||||
|
||||
return { context in
|
||||
let viewerCounter = viewerCounter.update(
|
||||
component: ParticipantsComponent(
|
||||
count: context.component.participantsCount,
|
||||
showsSubtitle: true,
|
||||
fontSize: 18.0,
|
||||
gradientColors: [UIColor.white.cgColor]
|
||||
),
|
||||
availableSize: CGSize(width: context.availableSize.width, height: context.availableSize.height),
|
||||
transition: context.transition
|
||||
)
|
||||
let heightReduction: CGFloat = 16.0
|
||||
var size = CGSize(width: viewerCounter.size.width, height: viewerCounter.size.height - heightReduction)
|
||||
size.width = min(size.width, context.availableSize.width)
|
||||
size.height = min(size.height, context.availableSize.height)
|
||||
|
||||
return { context in
|
||||
// let spacing: CGFloat = 0.0
|
||||
|
||||
let viewerCounter = viewerCounter.update(
|
||||
component: ParticipantsComponent(
|
||||
count: context.component.participantsCount,
|
||||
showsSubtitle: true,
|
||||
fontSize: 18.0,
|
||||
gradientColors: [UIColor.white.cgColor]
|
||||
),
|
||||
availableSize: CGSize(width: context.availableSize.width, height: context.availableSize.height),
|
||||
transition: context.transition
|
||||
)
|
||||
let heightReduction: CGFloat = 16.0
|
||||
var size = CGSize(width: viewerCounter.size.width, height: viewerCounter.size.height - heightReduction)
|
||||
size.width = min(size.width, context.availableSize.width)
|
||||
size.height = min(size.height, context.availableSize.height)
|
||||
|
||||
context.add(viewerCounter
|
||||
.position(CGPoint(x: size.width / 2.0, y: /*(context.availableSize.height - viewerCounter.size.height)*/context.availableSize.height / 2.0 + 16.0 - heightReduction / 2))
|
||||
)
|
||||
|
||||
return size
|
||||
}
|
||||
} else {
|
||||
let subtitle = Child(Text.self)
|
||||
context.add(viewerCounter
|
||||
.position(CGPoint(x: size.width / 2.0, y: context.availableSize.height / 2.0 + 16.0 - heightReduction / 2))
|
||||
)
|
||||
|
||||
return { context in
|
||||
// let spacing: CGFloat = 0.0
|
||||
|
||||
let memberCount = context.component.participantsCount
|
||||
let memberCountString: String
|
||||
if memberCount == 0 {
|
||||
memberCountString = "no viewers"
|
||||
} else {
|
||||
memberCountString = memberCount > 0 ? presentationStringsFormattedNumber(Int32(memberCount), ",") : ""
|
||||
}
|
||||
|
||||
let subtitle = subtitle.update(
|
||||
component: Text(
|
||||
text: memberCountString, font: Font.regular(14.0), color: .white),
|
||||
availableSize: context.availableSize,
|
||||
transition: context.transition
|
||||
)
|
||||
|
||||
var size = CGSize(width: subtitle.size.width, height: subtitle.size.height)
|
||||
size.width = min(size.width, context.availableSize.width)
|
||||
size.height = min(size.height, context.availableSize.height)
|
||||
|
||||
context.add(subtitle
|
||||
.position(CGPoint(x: size.width / 2.0, y: subtitle.size.height / 2.0))
|
||||
)
|
||||
|
||||
return size
|
||||
}
|
||||
return size
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1939,13 +1899,13 @@ private final class ButtonsRowComponent: CombinedComponent {
|
||||
var availableWidth = context.availableSize.width
|
||||
let sideInset: CGFloat = 48.0 + context.component.sideInset
|
||||
|
||||
let contentHeight: CGFloat = 80 // 44
|
||||
let contentHeight: CGFloat = 80.0
|
||||
let size = CGSize(width: context.availableSize.width, height: contentHeight + context.component.bottomInset)
|
||||
|
||||
let leftItem = context.component.leftItem.flatMap { leftItemComponent in
|
||||
return leftItem.update(
|
||||
component: leftItemComponent,
|
||||
availableSize: CGSize(width: 50, height: contentHeight),
|
||||
availableSize: CGSize(width: 50.0, height: contentHeight),
|
||||
transition: context.transition
|
||||
)
|
||||
}
|
||||
@ -1956,7 +1916,7 @@ private final class ButtonsRowComponent: CombinedComponent {
|
||||
let rightItem = context.component.rightItem.flatMap { rightItemComponent in
|
||||
return rightItem.update(
|
||||
component: rightItemComponent,
|
||||
availableSize: CGSize(width: 50, height: contentHeight),
|
||||
availableSize: CGSize(width: 50.0, height: contentHeight),
|
||||
transition: context.transition
|
||||
)
|
||||
}
|
||||
@ -1967,7 +1927,7 @@ private final class ButtonsRowComponent: CombinedComponent {
|
||||
let centerItem = context.component.centerItem.flatMap { centerItemComponent in
|
||||
return centerItem.update(
|
||||
component: centerItemComponent,
|
||||
availableSize: CGSize(width: 50, height: contentHeight),
|
||||
availableSize: CGSize(width: 50.0, height: contentHeight),
|
||||
transition: context.transition
|
||||
)
|
||||
}
|
||||
|
@ -149,8 +149,14 @@ final class MediaStreamVideoComponent: Component {
|
||||
private var isFullscreen: Bool = false
|
||||
private let videoLoadingThrottler = Throttler<Bool>(duration: 1, queue: .main)
|
||||
private var wasFullscreen: Bool = false
|
||||
private var isAnimating = false
|
||||
private var didRequestBringBack = false
|
||||
|
||||
private weak var state: State?
|
||||
|
||||
private var lastPresentation: UIView?
|
||||
private var pipTrackDisplayLink: CADisplayLink?
|
||||
|
||||
override init(frame: CGRect) {
|
||||
self.blurTintView = UIView()
|
||||
self.blurTintView.backgroundColor = UIColor(white: 0.0, alpha: 0.55)
|
||||
@ -169,8 +175,8 @@ final class MediaStreamVideoComponent: Component {
|
||||
deinit {
|
||||
avatarDisposable?.dispose()
|
||||
frameInputDisposable?.dispose()
|
||||
self.x?.invalidate()
|
||||
self.x = nil
|
||||
self.pipTrackDisplayLink?.invalidate()
|
||||
self.pipTrackDisplayLink = nil
|
||||
}
|
||||
|
||||
public func matches(tag: Any) -> Bool {
|
||||
@ -180,16 +186,13 @@ final class MediaStreamVideoComponent: Component {
|
||||
return false
|
||||
}
|
||||
|
||||
var didPassExpandFromPiP = false
|
||||
|
||||
func expandFromPictureInPicture() {
|
||||
didPassExpandFromPiP = true
|
||||
if let pictureInPictureController = self.pictureInPictureController, pictureInPictureController.isPictureInPictureActive {
|
||||
self.requestedExpansion = true
|
||||
self.pictureInPictureController?.stopPictureInPicture()
|
||||
}
|
||||
}
|
||||
private var isAnimating = false
|
||||
|
||||
private func updateVideoStalled(isStalled: Bool, transition: Transition?) {
|
||||
if isStalled {
|
||||
guard let component = self.component else { return }
|
||||
@ -359,7 +362,7 @@ final class MediaStreamVideoComponent: Component {
|
||||
if #available(iOS 13.0, *) {
|
||||
sampleBufferVideoView.sampleBufferLayer.preventsDisplaySleepDuringVideoPlayback = true
|
||||
}
|
||||
// if #available(iOSApplicationExtension 15.0, iOS 15.0, *), AVPictureInPictureController.isPictureInPictureSupported() {
|
||||
|
||||
final class PlaybackDelegateImpl: NSObject, AVPictureInPictureSampleBufferPlaybackDelegate {
|
||||
var onTransitionFinished: (() -> Void)?
|
||||
func pictureInPictureController(_ pictureInPictureController: AVPictureInPictureController, setPlaying playing: Bool) {
|
||||
@ -408,7 +411,6 @@ final class MediaStreamVideoComponent: Component {
|
||||
pictureInPictureController?.requiresLinearPlayback = true
|
||||
}
|
||||
self.pictureInPictureController = pictureInPictureController
|
||||
// }
|
||||
}
|
||||
|
||||
videoView.setOnOrientationUpdated { [weak state] _, _ in
|
||||
@ -445,7 +447,7 @@ final class MediaStreamVideoComponent: Component {
|
||||
})
|
||||
}
|
||||
fullScreenBackgroundPlaceholder.frame = .init(origin: .zero, size: availableSize)
|
||||
// fullScreenBackgroundPlaceholder.isHidden = true
|
||||
|
||||
let videoInset: CGFloat
|
||||
if !component.isFullscreen {
|
||||
videoInset = 16
|
||||
@ -526,29 +528,17 @@ final class MediaStreamVideoComponent: Component {
|
||||
size: blurredVideoSize
|
||||
), completion: nil)
|
||||
} else {
|
||||
videoFrameUpdateTransition.setFrame(view: videoBlurView, frame: videoView.frame.insetBy(dx: -69 * aspect, dy: -69))
|
||||
// videoBlurView.frame = videoView.frame.insetBy(dx: -69 * aspect, dy: -69)
|
||||
videoFrameUpdateTransition.setFrame(view: videoBlurView, frame: videoView.frame.insetBy(dx: -70.0 * aspect, dy: -70.0))
|
||||
}
|
||||
|
||||
videoBlurView.layer.mask = videoBlurGradientMask
|
||||
|
||||
if !component.isFullscreen {
|
||||
transition.setAlpha(layer: videoBlurSolidMask, alpha: 0)
|
||||
// if videoBlurView.layer.mask !== videoBlurGradientMask {
|
||||
// UIView.transition(with: videoBlurView, duration: transition.animation.isImmediate ? 0.0 : 0.3) { [self] in
|
||||
// videoBlurView.layer.mask = videoBlurGradientMask
|
||||
// }
|
||||
// }
|
||||
// videoBlurView.layer.mask = maskGradientLayer
|
||||
} else {
|
||||
transition.setAlpha(layer: videoBlurSolidMask, alpha: 1)
|
||||
// if videoBlurView.layer.mask != nil {
|
||||
// UIView.transition(with: videoBlurView, duration: transition.animation.isImmediate ? 0.0 : 0.3) {
|
||||
// videoBlurView.layer.mask = nil
|
||||
// }
|
||||
// }
|
||||
}
|
||||
//
|
||||
|
||||
videoFrameUpdateTransition.setFrame(layer: self.videoBlurGradientMask, frame: videoBlurView.bounds)
|
||||
videoFrameUpdateTransition.setFrame(layer: self.videoBlurSolidMask, frame: self.videoBlurGradientMask.bounds)
|
||||
}
|
||||
@ -557,13 +547,11 @@ final class MediaStreamVideoComponent: Component {
|
||||
}
|
||||
|
||||
let loadingBlurViewFrame = CGRect(origin: CGPoint(x: floor((availableSize.width - videoSize.width) / 2.0), y: floor((availableSize.height - videoSize.height) / 2.0)), size: videoSize)
|
||||
// UIView.animate(withDuration: 0.5) {
|
||||
// self.loadingBlurView.frame = loadingBlurViewFrame
|
||||
// }
|
||||
|
||||
if loadingBlurView.frame == .zero {
|
||||
loadingBlurView.frame = loadingBlurViewFrame
|
||||
} else {
|
||||
// Using Transition.setFrame UIVisualEffectView causes instant update of subviews
|
||||
// Using Transition.setFrame on UIVisualEffectView causes instant update of sublayers
|
||||
switch videoFrameUpdateTransition.animation {
|
||||
case let .curve(duration, curve):
|
||||
UIView.animate(withDuration: duration, delay: 0, options: curve.containedViewLayoutTransitionCurve.viewAnimationOptions, animations: { [self] in
|
||||
@ -574,29 +562,21 @@ final class MediaStreamVideoComponent: Component {
|
||||
loadingBlurView.frame = loadingBlurViewFrame
|
||||
}
|
||||
}
|
||||
// loadingBlurView.frame = CGRect(origin: CGPoint(x: floor((availableSize.width - videoSize.width) / 2.0), y: floor((availableSize.height - videoSize.height) / 2.0)), size: videoSize)
|
||||
|
||||
videoFrameUpdateTransition.setCornerRadius(layer: loadingBlurView.layer, cornerRadius: videoCornerRadius)
|
||||
// loadingBlurView.layer.cornerRadius = videoCornerRadius
|
||||
|
||||
videoFrameUpdateTransition.setFrame(view: placeholderView, frame: loadingBlurViewFrame)
|
||||
// placeholderView.frame = loadingBlurView.frame
|
||||
videoFrameUpdateTransition.setCornerRadius(layer: placeholderView.layer, cornerRadius: videoCornerRadius)
|
||||
// placeholderView.layer.cornerRadius = videoCornerRadius
|
||||
placeholderView.clipsToBounds = true
|
||||
placeholderView.subviews.forEach {
|
||||
videoFrameUpdateTransition.setFrame(view: $0, frame: placeholderView.bounds)
|
||||
// $0.frame = placeholderView.bounds
|
||||
}
|
||||
|
||||
let initialShimmerBounds = shimmerBorderLayer.bounds
|
||||
videoFrameUpdateTransition.setFrame(layer: shimmerBorderLayer, frame: loadingBlurView.bounds)
|
||||
// shimmerBorderLayer.frame = loadingBlurView.bounds
|
||||
|
||||
let borderMask = CAShapeLayer()
|
||||
let initialPath = CGPath(roundedRect: .init(x: 0, y: 0, width: initialShimmerBounds.width, height: initialShimmerBounds.height), cornerWidth: videoCornerRadius, cornerHeight: videoCornerRadius, transform: nil)
|
||||
borderMask.path = initialPath
|
||||
// borderMask.path = CGPath(roundedRect: .init(x: 0, y: 0, width: shimmerBorderLayer.bounds.width, height: shimmerBorderLayer.bounds.height), cornerWidth: videoCornerRadius, cornerHeight: videoCornerRadius, transform: nil)
|
||||
|
||||
videoFrameUpdateTransition.setShapeLayerPath(layer: borderMask, path: CGPath(roundedRect: .init(x: 0, y: 0, width: shimmerBorderLayer.bounds.width, height: shimmerBorderLayer.bounds.height), cornerWidth: videoCornerRadius, cornerHeight: videoCornerRadius, transform: nil))
|
||||
|
||||
borderMask.fillColor = UIColor.white.withAlphaComponent(0.4).cgColor
|
||||
@ -605,12 +585,6 @@ final class MediaStreamVideoComponent: Component {
|
||||
shimmerBorderLayer.mask = borderMask
|
||||
shimmerBorderLayer.cornerRadius = videoCornerRadius
|
||||
|
||||
// if component.isAdmin {
|
||||
// shimmerBorderLayer.isHidden = true
|
||||
// } else {
|
||||
// shimmerBorderLayer.isHidden = false
|
||||
// }
|
||||
//
|
||||
if !self.hadVideo {
|
||||
|
||||
if self.noSignalTimer == nil {
|
||||
@ -636,7 +610,7 @@ final class MediaStreamVideoComponent: Component {
|
||||
noSignalTransition = transition.withAnimation(.none)
|
||||
noSignalView = ComponentHostView<Empty>()
|
||||
self.noSignalView = noSignalView
|
||||
// TODO: above blurred animation
|
||||
|
||||
self.addSubview(noSignalView)
|
||||
noSignalView.layer.zPosition = loadingBlurView.layer.zPosition + 1
|
||||
|
||||
@ -664,7 +638,7 @@ final class MediaStreamVideoComponent: Component {
|
||||
guard let strongSelf = self, let pictureInPictureController = strongSelf.pictureInPictureController else {
|
||||
return
|
||||
}
|
||||
print("[pip] started")
|
||||
|
||||
pictureInPictureController.startPictureInPicture()
|
||||
|
||||
completion(Void())
|
||||
@ -694,46 +668,33 @@ final class MediaStreamVideoComponent: Component {
|
||||
videoView.alpha = 0
|
||||
lastPresentation?.removeFromSuperview()
|
||||
lastPresentation = presentation
|
||||
// UIView.animate(withDuration: 0.04, delay: 0.04, animations: {
|
||||
// presentation.alpha = 0
|
||||
// }, completion: { _ in
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) {
|
||||
self.lastPresentation?.removeFromSuperview()
|
||||
self.lastPresentation = nil
|
||||
self.x?.invalidate()
|
||||
self.x = nil
|
||||
self.pipTrackDisplayLink?.invalidate()
|
||||
self.pipTrackDisplayLink = nil
|
||||
}
|
||||
// })
|
||||
}
|
||||
UIView.animate(withDuration: 0.1) { [self] in
|
||||
videoBlurView?.alpha = 0
|
||||
}
|
||||
// UIApplication.shared.windows.first?.windowLevel == .normal
|
||||
// TODO: make safe
|
||||
UIApplication.shared.windows.first?/*(where: { $0.layer !== (UIApplication.shared.connectedScenes.first as? UIWindowScene)?.keyWindow?.layer })?*/.layer.cornerRadius = 10// (where: { !($0 is NativeWindow)*/ })
|
||||
// TODO: assure player window
|
||||
UIApplication.shared.windows.first?.layer.cornerRadius = 10.0
|
||||
UIApplication.shared.windows.first?.layer.masksToBounds = true
|
||||
|
||||
// UIApplication.shared.windows.first?.subviews[0].subviews[0].subviews[1].subviews[0].subviews[0].backgroundColor = .red
|
||||
// UIApplication.shared.windows.first?.subviews[0].subviews[0].subviews[1].subviews[0].subviews[0].setNeedsDisplay()
|
||||
// UIApplication.shared.windows.first?.subviews[0].subviews[0].subviews[1].backgroundColor = .red
|
||||
// UIApplication.shared.windows.first?.subviews[0].subviews[0].subviews[1].setNeedsDisplay()
|
||||
|
||||
self.x?.invalidate()
|
||||
let x = CADisplayLink(target: self, selector: #selector(observePiPWindow))
|
||||
x.add(to: .main, forMode: .default)
|
||||
self.x = x
|
||||
self.pipTrackDisplayLink?.invalidate()
|
||||
self.pipTrackDisplayLink = CADisplayLink(target: self, selector: #selector(observePiPWindow))
|
||||
self.pipTrackDisplayLink?.add(to: .main, forMode: .default)
|
||||
}
|
||||
|
||||
var lastPresentation: UIView?
|
||||
var x: CADisplayLink?
|
||||
|
||||
@objc func observePiPWindow() {
|
||||
let pipViewDidBecomeVisible = (UIApplication.shared.windows.first?.layer.animationKeys()?.count ?? 0) > 0
|
||||
if pipViewDidBecomeVisible {
|
||||
lastPresentation?.removeFromSuperview()
|
||||
lastPresentation = nil
|
||||
self.x?.invalidate()
|
||||
self.x = nil
|
||||
self.pipTrackDisplayLink?.invalidate()
|
||||
self.pipTrackDisplayLink = nil
|
||||
}
|
||||
}
|
||||
|
||||
@ -747,7 +708,7 @@ final class MediaStreamVideoComponent: Component {
|
||||
completionHandler(true)
|
||||
}
|
||||
}
|
||||
var didRequestBringBack = false
|
||||
|
||||
func pictureInPictureControllerDidStartPictureInPicture(_ pictureInPictureController: AVPictureInPictureController) {
|
||||
self.didRequestBringBack = false
|
||||
self.state?.updated(transition: .immediate)
|
||||
@ -788,7 +749,7 @@ final class MediaStreamVideoComponent: Component {
|
||||
// TODO: move to appropriate place
|
||||
fileprivate var lastFrame: [String: UIView] = [:]
|
||||
|
||||
class CustomIntensityVisualEffectView: UIVisualEffectView {
|
||||
private final class CustomIntensityVisualEffectView: UIVisualEffectView {
|
||||
private var animator: UIViewPropertyAnimator!
|
||||
|
||||
init(effect: UIVisualEffect, intensity: CGFloat) {
|
||||
|
@ -175,7 +175,7 @@ final class StreamSheetComponent: CombinedComponent {
|
||||
|
||||
let videoHeight = context.component.videoHeight
|
||||
let sheetHeight = context.component.sheetHeight
|
||||
let animatedParticipantsVisible = !isFullscreen// context.component.participantsCount != -1
|
||||
let animatedParticipantsVisible = !isFullscreen
|
||||
|
||||
context.add(viewerCounter
|
||||
.position(CGPoint(x: context.availableSize.width / 2, y: topOffset + 50.0 + videoHeight + (sheetHeight - 69.0 - videoHeight - 50.0 - context.component.bottomPadding) / 2 - 10.0))
|
||||
@ -187,10 +187,6 @@ final class StreamSheetComponent: CombinedComponent {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private let latePurple = UIColor(rgb: 0x974aa9)
|
||||
private let latePink = UIColor(rgb: 0xf0436c)
|
||||
|
||||
final class SheetBackgroundComponent: Component {
|
||||
private let color: UIColor
|
||||
private let radius: CGFloat
|
||||
|
@ -105,7 +105,7 @@ public final class SharedAccountContextImpl: SharedAccountContext {
|
||||
private var callController: CallController?
|
||||
public let hasOngoingCall = ValuePromise<Bool>(false)
|
||||
private let callState = Promise<PresentationCallState?>(nil)
|
||||
// Rename to LiveStreamingController
|
||||
|
||||
private var groupCallController: VoiceChatController?
|
||||
public var currentGroupCallController: ViewController? {
|
||||
return self.groupCallController
|
||||
|
Loading…
x
Reference in New Issue
Block a user