Fixing transition animations and delaying activityIndicator when starting live stream

This commit is contained in:
Ilya Yelagov 2023-01-06 15:26:11 +04:00
parent f1108af238
commit 2863524530
4 changed files with 27 additions and 13 deletions

View file

@ -50,6 +50,7 @@ private final class CreateExternalMediaStreamScreenComponent: CombinedComponent
let peerId: EnginePeer.Id
private(set) var credentials: GroupCallStreamCredentials?
var isDelayingLoadingIndication: Bool = true
private var credentialsDisposable: Disposable?
private let activeActionDisposable = MetaDisposable()
@ -100,6 +101,13 @@ private final class CreateExternalMediaStreamScreenComponent: CombinedComponent
return
}
strongSelf.isDelayingLoadingIndication = true
Timer(timeout: 0.3, repeat: false, completion: { [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 }
let progressSignal = Signal<Never, NoError> { [weak baseController] subscriber in
@ -397,7 +405,7 @@ private final class CreateExternalMediaStreamScreenComponent: CombinedComponent
context.add(credentialsCopyKeyButton
.position(CGPoint(x: credentialsFrame.maxX - 12.0 - credentialsCopyKeyButton.size.width / 2.0, y: credentialsFrame.minY + credentialsItemHeight + credentialsItemHeight / 2.0))
)
} else {
} else if !context.state.isDelayingLoadingIndication {
let activityIndicator = activityIndicator.update(
component: ActivityIndicatorComponent(color: environment.theme.list.controlSecondaryColor),
availableSize: CGSize(width: 100.0, height: 100.0),

View file

@ -2,8 +2,8 @@ import Foundation
import UIKit
import Display
private let purple = UIColor(rgb: 0x3252ef)
private let pink = UIColor(rgb: 0xe4436c)
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)

View file

@ -760,7 +760,7 @@ public final class MediaStreamComponent: CombinedComponent {
} else {
if isFullyDragged || state.initialOffset != 0 {
state.updateDismissOffset(value: 0.0, interactive: false)
state.updateDismissOffset(value: 0.0, interactive: false)
// state.updateDismissOffset(value: 0.0, interactive: false)
} else {
if state.isPictureInPictureSupported {
activatePictureInPicture.invoke(Action {

View file

@ -104,7 +104,6 @@ final class MediaStreamVideoComponent: Component {
private let blurTintView: UIView
private var videoBlurView: VideoRenderingView?
private var videoView: VideoRenderingView?
private var loadingView: ComponentHostView<Empty>?
private var videoPlaceholderView: UIView?
private var noSignalView: ComponentHostView<Empty>?
@ -233,8 +232,6 @@ final class MediaStreamVideoComponent: Component {
shimmerBorderLayer.masksToBounds = true
shimmerBorderLayer.compositingFilter = "softLightBlendMode"
let borderMask = CAShapeLayer()
shimmerBorderLayer.mask = borderMask
@ -437,11 +434,11 @@ final class MediaStreamVideoComponent: Component {
} else if component.isFullscreen {
if fullScreenBackgroundPlaceholder.superview == nil {
insertSubview(fullScreenBackgroundPlaceholder, at: 0)
transition.animateAlpha(view: fullScreenBackgroundPlaceholder, from: 0, to: 1)
transition.setAlpha(view: self.fullScreenBackgroundPlaceholder, alpha: 1)
}
fullScreenBackgroundPlaceholder.backgroundColor = UIColor.black.withAlphaComponent(0.5)
} else {
transition.animateAlpha(view: fullScreenBackgroundPlaceholder, from: 1, to: 0, completion: { didComplete in
transition.setAlpha(view: self.fullScreenBackgroundPlaceholder, alpha: 0, completion: { didComplete in
if didComplete {
self.fullScreenBackgroundPlaceholder.removeFromSuperview()
}
@ -480,9 +477,7 @@ final class MediaStreamVideoComponent: Component {
if aspect <= 0.01 {
aspect = 16.0 / 9
}
} else if self.hadVideo {
// aspect = aspect
} else {
} else if !self.hadVideo && !component.isFullscreen {
aspect = 16.0 / 9
}
@ -568,7 +563,18 @@ final class MediaStreamVideoComponent: Component {
if loadingBlurView.frame == .zero {
loadingBlurView.frame = loadingBlurViewFrame
} else {
transition.setFrame(view: loadingBlurView, frame: loadingBlurViewFrame)
// Using Transition.setFrame UIVisualEffectView causes instant update of subviews
switch videoFrameUpdateTransition.animation {
case let .curve(duration, curve):
UIView.animate(withDuration: duration, delay: 0, options: curve.containedViewLayoutTransitionCurve.viewAnimationOptions, animations: { [self] in
loadingBlurView.frame = loadingBlurViewFrame
})
default:
loadingBlurView.frame = loadingBlurViewFrame
}
// transition.setFrame(view: 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)