mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +00:00
Further attach menu refinements
This commit is contained in:
@@ -0,0 +1,133 @@
|
||||
import Foundation
|
||||
import AccountContext
|
||||
import SwiftSignalKit
|
||||
|
||||
public enum ChatTextInputAccessoryItem: Equatable {
|
||||
case keyboard
|
||||
case stickers(Bool)
|
||||
case inputButtons
|
||||
case commands
|
||||
case silentPost(Bool)
|
||||
case messageAutoremoveTimeout(Int32?)
|
||||
case scheduledMessages
|
||||
}
|
||||
|
||||
public final class InstantVideoControllerRecordingStatus {
|
||||
public let micLevel: Signal<Float, NoError>
|
||||
public let duration: Signal<TimeInterval, NoError>
|
||||
|
||||
public init(micLevel: Signal<Float, NoError>, duration: Signal<TimeInterval, NoError>) {
|
||||
self.micLevel = micLevel
|
||||
self.duration = duration
|
||||
}
|
||||
}
|
||||
|
||||
public struct ChatTextInputPanelState: Equatable {
|
||||
public let accessoryItems: [ChatTextInputAccessoryItem]
|
||||
public let contextPlaceholder: NSAttributedString?
|
||||
public let mediaRecordingState: ChatTextInputPanelMediaRecordingState?
|
||||
|
||||
public init(accessoryItems: [ChatTextInputAccessoryItem], contextPlaceholder: NSAttributedString?, mediaRecordingState: ChatTextInputPanelMediaRecordingState?) {
|
||||
self.accessoryItems = accessoryItems
|
||||
self.contextPlaceholder = contextPlaceholder
|
||||
self.mediaRecordingState = mediaRecordingState
|
||||
}
|
||||
|
||||
public init() {
|
||||
self.accessoryItems = []
|
||||
self.contextPlaceholder = nil
|
||||
self.mediaRecordingState = nil
|
||||
}
|
||||
|
||||
public func withUpdatedMediaRecordingState(_ mediaRecordingState: ChatTextInputPanelMediaRecordingState?) -> ChatTextInputPanelState {
|
||||
return ChatTextInputPanelState(accessoryItems: self.accessoryItems, contextPlaceholder: self.contextPlaceholder, mediaRecordingState: mediaRecordingState)
|
||||
}
|
||||
|
||||
public static func ==(lhs: ChatTextInputPanelState, rhs: ChatTextInputPanelState) -> Bool {
|
||||
if lhs.accessoryItems != rhs.accessoryItems {
|
||||
return false
|
||||
}
|
||||
if let lhsContextPlaceholder = lhs.contextPlaceholder, let rhsContextPlaceholder = rhs.contextPlaceholder {
|
||||
return lhsContextPlaceholder.isEqual(to: rhsContextPlaceholder)
|
||||
} else if (lhs.contextPlaceholder != nil) != (rhs.contextPlaceholder != nil) {
|
||||
return false
|
||||
}
|
||||
if lhs.mediaRecordingState != rhs.mediaRecordingState {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
public enum ChatVideoRecordingStatus: Equatable {
|
||||
case recording(InstantVideoControllerRecordingStatus)
|
||||
case editing
|
||||
|
||||
public static func ==(lhs: ChatVideoRecordingStatus, rhs: ChatVideoRecordingStatus) -> Bool {
|
||||
switch lhs {
|
||||
case let .recording(lhsStatus):
|
||||
if case let .recording(rhsStatus) = rhs, lhsStatus === rhsStatus {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .editing:
|
||||
if case .editing = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum ChatTextInputPanelMediaRecordingState: Equatable {
|
||||
case audio(recorder: ManagedAudioRecorder, isLocked: Bool)
|
||||
case video(status: ChatVideoRecordingStatus, isLocked: Bool)
|
||||
case waitingForPreview
|
||||
|
||||
public var isLocked: Bool {
|
||||
switch self {
|
||||
case let .audio(_, isLocked):
|
||||
return isLocked
|
||||
case let .video(_, isLocked):
|
||||
return isLocked
|
||||
case .waitingForPreview:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
public func withLocked(_ isLocked: Bool) -> ChatTextInputPanelMediaRecordingState {
|
||||
switch self {
|
||||
case let .audio(recorder, _):
|
||||
return .audio(recorder: recorder, isLocked: isLocked)
|
||||
case let .video(status, _):
|
||||
return .video(status: status, isLocked: isLocked)
|
||||
case .waitingForPreview:
|
||||
return .waitingForPreview
|
||||
}
|
||||
}
|
||||
|
||||
public static func ==(lhs: ChatTextInputPanelMediaRecordingState, rhs: ChatTextInputPanelMediaRecordingState) -> Bool {
|
||||
switch lhs {
|
||||
case let .audio(lhsRecorder, lhsIsLocked):
|
||||
if case let .audio(rhsRecorder, rhsIsLocked) = rhs, lhsRecorder === rhsRecorder, lhsIsLocked == rhsIsLocked {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .video(status, isLocked):
|
||||
if case .video(status, isLocked) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .waitingForPreview:
|
||||
if case .waitingForPreview = rhs {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user