Merge commit 'efa1212fa696ac6bf0053b5ffe71cf7c25158834'

This commit is contained in:
Isaac 2024-01-19 10:49:30 +04:00
commit 5256fabea1
3 changed files with 36 additions and 32 deletions

View File

@ -7,6 +7,7 @@ public final class CameraButton: Component {
let minSize: CGSize? let minSize: CGSize?
let tag: AnyObject? let tag: AnyObject?
let isEnabled: Bool let isEnabled: Bool
let isExclusive: Bool
let action: () -> Void let action: () -> Void
let longTapAction: (() -> Void)? let longTapAction: (() -> Void)?
@ -15,6 +16,7 @@ public final class CameraButton: Component {
minSize: CGSize? = nil, minSize: CGSize? = nil,
tag: AnyObject? = nil, tag: AnyObject? = nil,
isEnabled: Bool = true, isEnabled: Bool = true,
isExclusive: Bool = true,
action: @escaping () -> Void, action: @escaping () -> Void,
longTapAction: (() -> Void)? = nil longTapAction: (() -> Void)? = nil
) { ) {
@ -22,6 +24,7 @@ public final class CameraButton: Component {
self.minSize = minSize self.minSize = minSize
self.tag = tag self.tag = tag
self.isEnabled = isEnabled self.isEnabled = isEnabled
self.isExclusive = isExclusive
self.action = action self.action = action
self.longTapAction = longTapAction self.longTapAction = longTapAction
} }
@ -32,6 +35,7 @@ public final class CameraButton: Component {
minSize: self.minSize, minSize: self.minSize,
tag: tag, tag: tag,
isEnabled: self.isEnabled, isEnabled: self.isEnabled,
isExclusive: self.isExclusive,
action: self.action, action: self.action,
longTapAction: self.longTapAction longTapAction: self.longTapAction
) )
@ -50,6 +54,9 @@ public final class CameraButton: Component {
if lhs.isEnabled != rhs.isEnabled { if lhs.isEnabled != rhs.isEnabled {
return false return false
} }
if lhs.isExclusive != rhs.isExclusive {
return false
}
return true return true
} }
@ -90,8 +97,6 @@ public final class CameraButton: Component {
super.init(frame: frame) super.init(frame: frame)
self.isExclusiveTouch = true
self.addSubview(self.containerView) self.addSubview(self.containerView)
self.containerView.addSubview(self.contentView) self.containerView.addSubview(self.contentView)
@ -175,6 +180,8 @@ public final class CameraButton: Component {
self.component = component self.component = component
self.isExclusiveTouch = component.isExclusive
self.updateScale(transition: transition) self.updateScale(transition: transition)
self.isEnabled = component.isEnabled self.isEnabled = component.isEnabled
self.longTapGestureRecognizer?.isEnabled = component.longTapAction != nil self.longTapGestureRecognizer?.isEnabled = component.longTapAction != nil

View File

@ -181,7 +181,7 @@ final class StoryInteractionGuideComponent: Component {
transition: transition, transition: transition,
component: AnyComponent(List(items)), component: AnyComponent(List(items)),
environment: {}, environment: {},
containerSize: CGSize(width: availableSize.width - sideInset * 2.0, height: availableSize.height) containerSize: CGSize(width: min(500.0, availableSize.width - sideInset * 2.0), height: availableSize.height)
) )
let textSpacing: CGFloat = 7.0 let textSpacing: CGFloat = 7.0

View File

@ -170,6 +170,8 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
private var resultDisposable = MetaDisposable() private var resultDisposable = MetaDisposable()
var cameraState: CameraState? var cameraState: CameraState?
var didDisplayViewOnce = false
private let hapticFeedback = HapticFeedback() private let hapticFeedback = HapticFeedback()
@ -355,7 +357,7 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
} }
if let controller = component.getController() { if let controller = component.getController() {
if controller.isSendingImmediately || controller.scheduledLock { if controller.scheduledLock {
showViewOnce = true showViewOnce = true
} }
if !controller.viewOnceAvailable { if !controller.viewOnceAvailable {
@ -363,6 +365,12 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
} }
} }
if state.didDisplayViewOnce {
showViewOnce = true
} else if showViewOnce {
state.didDisplayViewOnce = true
}
if !component.isPreviewing { if !component.isPreviewing {
let flipButton = flipButton.update( let flipButton = flipButton.update(
component: CameraButton( component: CameraButton(
@ -377,6 +385,7 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
) )
), ),
minSize: CGSize(width: 44.0, height: 44.0), minSize: CGSize(width: 44.0, height: 44.0),
isExclusive: false,
action: { [weak state] in action: { [weak state] in
if let state { if let state {
state.togglePosition() state.togglePosition()
@ -672,15 +681,9 @@ public class VideoMessageCameraScreen: ViewController {
} }
self.loadingView.alpha = 0.0 self.loadingView.alpha = 0.0
self.additionalPreviewView.removePlaceholder(delay: 0.0) self.additionalPreviewView.removePlaceholder(delay: 0.0)
Queue.mainQueue().after(0.15) {
self.startRecording.invoke(Void())
}
}) })
self.idleTimerExtensionDisposable.set(self.context.sharedContext.applicationBindings.pushIdleTimerExtension()) self.idleTimerExtensionDisposable.set(self.context.sharedContext.applicationBindings.pushIdleTimerExtension())
self.setupCamera()
} }
deinit { deinit {
@ -689,28 +692,19 @@ public class VideoMessageCameraScreen: ViewController {
} }
func withReadyCamera(isFirstTime: Bool = false, _ f: @escaping () -> Void) { func withReadyCamera(isFirstTime: Bool = false, _ f: @escaping () -> Void) {
guard let controller = self.controller else { let previewReady: Signal<Bool, NoError>
return
}
if #available(iOS 13.0, *) { if #available(iOS 13.0, *) {
let _ = (combineLatest(queue: Queue.mainQueue(), previewReady = self.cameraState.isDualCameraEnabled ? self.additionalPreviewView.isPreviewing : self.mainPreviewView.isPreviewing
self.cameraState.isDualCameraEnabled ? self.additionalPreviewView.isPreviewing : self.mainPreviewView.isPreviewing,
controller.audioSessionReady.get()
)
|> filter { $0 && $1 }
|> take(1)).startStandalone(next: { _, _ in
f()
})
} else { } else {
let _ = (combineLatest(queue: Queue.mainQueue(), previewReady = .single(true) |> delay(0.35, queue: Queue.mainQueue())
.single(true) |> delay(0.35, queue: Queue.mainQueue()),
controller.audioSessionReady.get()
)
|> filter { $0 && $1 }
|> take(1)).startStandalone(next: { _, _ in
f()
})
} }
let _ = (previewReady
|> filter { $0 }
|> take(1)
|> deliverOnMainQueue).startStandalone(next: { _ in
f()
})
} }
func setupLiveUpload(filePath: String) { func setupLiveUpload(filePath: String) {
@ -734,7 +728,7 @@ public class VideoMessageCameraScreen: ViewController {
self.view.addGestureRecognizer(pinchGestureRecognizer) self.view.addGestureRecognizer(pinchGestureRecognizer)
} }
private func setupCamera() { fileprivate func setupCamera() {
guard self.camera == nil else { guard self.camera == nil else {
return return
} }
@ -771,6 +765,10 @@ public class VideoMessageCameraScreen: ViewController {
camera.startCapture() camera.startCapture()
self.camera = camera self.camera = camera
Queue.mainQueue().justDispatch {
self.startRecording.invoke(Void())
}
} }
@objc private func handlePinch(_ gestureRecognizer: UIPinchGestureRecognizer) { @objc private func handlePinch(_ gestureRecognizer: UIPinchGestureRecognizer) {
@ -1252,7 +1250,6 @@ public class VideoMessageCameraScreen: ViewController {
fileprivate let completion: (EnqueueMessage?, Bool?, Int32?) -> Void fileprivate let completion: (EnqueueMessage?, Bool?, Int32?) -> Void
private var audioSessionDisposable: Disposable? private var audioSessionDisposable: Disposable?
fileprivate let audioSessionReady = ValuePromise<Bool>(false)
private let hapticFeedback = HapticFeedback() private let hapticFeedback = HapticFeedback()
@ -1633,7 +1630,7 @@ public class VideoMessageCameraScreen: ViewController {
try? AVAudioSession.sharedInstance().setAllowHapticsAndSystemSoundsDuringRecording(true) try? AVAudioSession.sharedInstance().setAllowHapticsAndSystemSoundsDuringRecording(true)
} }
if let self { if let self {
self.audioSessionReady.set(true) self.node.setupCamera()
} }
}, deactivate: { _ in }, deactivate: { _ in
return .single(Void()) return .single(Void())