Video message reply for stories

This commit is contained in:
Ilya Laktyushin
2023-07-03 23:17:48 +02:00
parent bd418c8689
commit 08fd6f80a3
23 changed files with 289 additions and 90 deletions

View File

@@ -120,9 +120,7 @@ public final class MediaPreviewPanelComponent: Component {
public let vibrancyContainer: UIView
private let trackingLayer: HierarchyTrackingLayer
private let indicator = ComponentView<Empty>()
private let timerFont: UIFont
private let timerText = ComponentView<Empty>()

View File

@@ -173,7 +173,7 @@ public final class MessageInputActionButtonComponent: Component {
if self.micButton == nil {
let micButton = ChatTextInputMediaRecordingButton(
context: component.context,
theme: component.theme,
theme: defaultDarkPresentationTheme,
useDarkTheme: true,
strings: component.strings,
presentController: component.presentController
@@ -182,6 +182,8 @@ public final class MessageInputActionButtonComponent: Component {
micButton.statusBarHost = component.context.sharedContext.mainWindow?.statusBarHost
self.addSubview(micButton)
micButton.disablesInteractiveKeyboardGestureRecognizer = true
micButton.beginRecording = { [weak self] in
guard let self, let component = self.component else {
return
@@ -356,7 +358,7 @@ public final class MessageInputActionButtonComponent: Component {
if let micButton = self.micButton {
if themeUpdated {
micButton.updateTheme(theme: component.theme)
micButton.updateTheme(theme: defaultDarkPresentationTheme)
}
let micButtonFrame = CGRect(origin: CGPoint(), size: availableSize)

View File

@@ -86,6 +86,7 @@ public final class MessageInputPanelComponent: Component {
public let videoRecordingStatus: InstantVideoControllerRecordingStatus?
public let isRecordingLocked: Bool
public let recordedAudioPreview: ChatRecordedMediaPreview?
public let hasRecordedVideoPreview: Bool
public let wasRecordingDismissed: Bool
public let timeoutValue: String?
public let timeoutSelected: Bool
@@ -124,6 +125,7 @@ public final class MessageInputPanelComponent: Component {
videoRecordingStatus: InstantVideoControllerRecordingStatus?,
isRecordingLocked: Bool,
recordedAudioPreview: ChatRecordedMediaPreview?,
hasRecordedVideoPreview: Bool,
wasRecordingDismissed: Bool,
timeoutValue: String?,
timeoutSelected: Bool,
@@ -162,6 +164,7 @@ public final class MessageInputPanelComponent: Component {
self.isRecordingLocked = isRecordingLocked
self.wasRecordingDismissed = wasRecordingDismissed
self.recordedAudioPreview = recordedAudioPreview
self.hasRecordedVideoPreview = hasRecordedVideoPreview
self.timeoutValue = timeoutValue
self.timeoutSelected = timeoutSelected
self.displayGradient = displayGradient
@@ -214,6 +217,9 @@ public final class MessageInputPanelComponent: Component {
if lhs.recordedAudioPreview !== rhs.recordedAudioPreview {
return false
}
if lhs.hasRecordedVideoPreview != rhs.hasRecordedVideoPreview {
return false
}
if lhs.timeoutValue != rhs.timeoutValue {
return false
}
@@ -468,8 +474,8 @@ public final class MessageInputPanelComponent: Component {
self.textFieldExternalState.initialText = initialText
}
let hasMediaRecording = component.audioRecorder != nil || component.videoRecordingStatus != nil
let hasMediaEditing = component.recordedAudioPreview != nil
let hasMediaRecording = component.audioRecorder != nil || (component.videoRecordingStatus != nil && !component.hasRecordedVideoPreview)
let hasMediaEditing = component.recordedAudioPreview != nil || component.hasRecordedVideoPreview
let topGradientHeight: CGFloat = 32.0
if self.gradientView.image == nil {
@@ -814,6 +820,8 @@ public final class MessageInputPanelComponent: Component {
if case .up = action {
if component.recordedAudioPreview != nil {
component.sendMessageAction()
} else if component.hasRecordedVideoPreview {
component.sendMessageAction()
} else if case let .text(string) = self.getSendMessageInput(), string.string.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
} else {
component.sendMessageAction()