Video message recording improvements

This commit is contained in:
Ilya Laktyushin 2024-01-14 17:31:02 +04:00
parent f34d0913df
commit 42421342b8
4 changed files with 51 additions and 3 deletions

View File

@ -1022,6 +1022,16 @@ public class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewI
return rects
}
public func animateInstantVideoFromSnapshot(snapshotView: UIView, transition: CombinedTransition) {
for contentNode in self.contentNodes {
if let contentNode = contentNode as? ChatMessageInstantVideoBubbleContentNode {
snapshotView.frame = contentNode.interactiveVideoNode.view.convert(snapshotView.frame, from: self.view)
contentNode.interactiveVideoNode.animateFromSnapshot(snapshotView: snapshotView, transition: transition)
return
}
}
}
override public func didLoad() {
super.didLoad()

View File

@ -1778,9 +1778,16 @@ public class ChatMessageInteractiveInstantVideoNode: ASDisplayNode {
if !self.animatedFadeIn {
self.animatedFadeIn = true
self.dateAndStatusNode.layer.animateAlpha(from: 0.0, to: self.dateAndStatusNode.alpha, duration: 0.15, delay: 0.18)
if let durationNode = self.durationNode {
durationNode.layer.animateAlpha(from: 0.0, to: durationNode.alpha, duration: 0.15, delay: 0.18)
}
if let durationBackgroundNode = self.durationBackgroundNode {
durationBackgroundNode.layer.animateAlpha(from: 0.0, to: durationBackgroundNode.alpha, duration: 0.15, delay: 0.18)
}
if let audioTranscriptionButton = self.audioTranscriptionButton {
audioTranscriptionButton.layer.animateAlpha(from: 0.0, to: audioTranscriptionButton.alpha, duration: 0.15, delay: 0.18)
}
}
}

View File

@ -311,6 +311,8 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
let viewOnceButton = Child(PlainButtonComponent.self)
let recordMoreButton = Child(PlainButtonComponent.self)
let muteIcon = Child(ZStack<Empty>.self)
return { context in
let environment = context.environment[ViewControllerComponentContainer.Environment.self].value
let component = context.component
@ -455,6 +457,35 @@ private final class VideoMessageCameraScreenComponent: CombinedComponent {
)
}
if component.isPreviewing && component.isMuted {
let muteIcon = muteIcon.update(
component: ZStack([
AnyComponentWithIdentity(
id: "background",
component: AnyComponent(
RoundedRectangle(color: UIColor(rgb: 0x000000, alpha: 0.3), cornerRadius: 24.0)
)
),
AnyComponentWithIdentity(
id: "icon",
component: AnyComponent(
BundleIconComponent(
name: "Chat/Message/InstantVideoMute",
tintColor: .white
)
)
)
]),
availableSize: CGSize(width: 24.0, height: 24.0),
transition: context.transition
)
context.add(muteIcon
.position(CGPoint(x: component.previewFrame.midX, y: component.previewFrame.maxY - 24.0))
.appear(.default(scale: true, alpha: true))
.disappear(.default(scale: true, alpha: true))
)
}
return availableSize
}
}
@ -1466,7 +1497,7 @@ public class VideoMessageCameraScreen: ViewController {
}
public func hideVideoSnapshot() {
self.node.previewContainerView.alpha = 0.02
self.node.previewContainerView.isHidden = true
}
public func updateTrimRange(start: Double, end: Double, updatedEnd: Bool, apply: Bool) {

View File

@ -635,7 +635,7 @@ public final class ChatMessageTransitionNodeImpl: ASDisplayNode, ChatMessageTran
case let .videoMessage(videoMessage):
let combinedTransition = CombinedTransition(horizontal: .animated(duration: horizontalDuration, curve: ChatMessageTransitionNodeImpl.horizontalAnimationCurve), vertical: .animated(duration: verticalDuration, curve: ChatMessageTransitionNodeImpl.verticalAnimationCurve))
if let itemNode = self.itemNode as? ChatMessageInstantVideoItemNode {
if let itemNode = self.itemNode as? ChatMessageBubbleItemNode {
itemNode.cancelInsertionAnimations()
self.contextSourceNode.isExtractedToContextPreview = true
@ -659,7 +659,7 @@ public final class ChatMessageTransitionNodeImpl: ASDisplayNode, ChatMessageTran
strongSelf.endAnimation()
})
itemNode.animateFromSnapshot(snapshotView: videoMessage.view, transition: combinedTransition)
itemNode.animateInstantVideoFromSnapshot(snapshotView: videoMessage.view, transition: combinedTransition)
}
case let .mediaInput(mediaInput):
if let snapshotView = mediaInput.extractSnapshot() {