Refactoring

This commit is contained in:
Ali 2023-10-08 22:05:30 +04:00
parent 6a7233ed05
commit 07c0ae9792
10 changed files with 84 additions and 25 deletions

View File

@ -5,4 +5,5 @@ public typealias EngineTempBox = TempBox
public extension EngineTempBox {
typealias File = TempBoxFile
typealias Directory = TempBoxDirectory
}

View File

@ -348,6 +348,8 @@ swift_library(
"//submodules/TelegramUI/Components/Chat/EditableTokenListNode",
"//submodules/TelegramUI/Components/Chat/ChatInputTextNode",
"//submodules/TelegramUI/Components/Chat/ChatMessageReplyInfoNode",
"//submodules/TelegramUI/Components/Chat/ChatOverscrollControl",
"//submodules/TelegramUI/Components/AudioWaveformNode",
] + select({
"@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets,
"//build-system:ios_sim_arm64": [],

View File

@ -0,0 +1,20 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "AudioWaveformNode",
module_name = "AudioWaveformNode",
srcs = glob([
"Sources/**/*.swift",
]),
copts = [
"-warnings-as-errors",
],
deps = [
"//submodules/AsyncDisplayKit",
"//submodules/Display",
"//submodules/ChatPresentationInterfaceState",
],
visibility = [
"//visibility:public",
],
)

View File

@ -20,8 +20,8 @@ private final class AudioWaveformNodeParameters: NSObject {
}
}
final class AudioWaveformNode: ASDisplayNode {
enum Gravity {
public final class AudioWaveformNode: ASDisplayNode {
public enum Gravity {
case bottom
case center
}
@ -30,7 +30,7 @@ final class AudioWaveformNode: ASDisplayNode {
private var color: UIColor?
private var gravity: Gravity?
var progress: CGFloat? {
public var progress: CGFloat? {
didSet {
if self.progress != oldValue {
self.setNeedsDisplay()
@ -38,13 +38,13 @@ final class AudioWaveformNode: ASDisplayNode {
}
}
override init() {
override public init() {
super.init()
self.isOpaque = false
}
override var frame: CGRect {
override public var frame: CGRect {
get {
return super.frame
} set(value) {
@ -57,7 +57,7 @@ final class AudioWaveformNode: ASDisplayNode {
}
}
func setup(color: UIColor, gravity: Gravity, waveform: AudioWaveform?) {
public func setup(color: UIColor, gravity: Gravity, waveform: AudioWaveform?) {
if self.color == nil || !self.color!.isEqual(color) || self.waveform != waveform || self.gravity != gravity {
self.color = color
self.gravity = gravity
@ -66,7 +66,7 @@ final class AudioWaveformNode: ASDisplayNode {
}
}
override func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? {
override public func drawParameters(forAsyncLayer layer: _ASDisplayLayer) -> NSObjectProtocol? {
return AudioWaveformNodeParameters(waveform: self.waveform, color: self.color, gravity: self.gravity, progress: self.progress)
}

View File

@ -0,0 +1,27 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "ChatOverscrollControl",
module_name = "ChatOverscrollControl",
srcs = glob([
"Sources/**/*.swift",
]),
copts = [
"-warnings-as-errors",
],
deps = [
"//submodules/AsyncDisplayKit",
"//submodules/ComponentFlow",
"//submodules/Display",
"//submodules/TelegramCore",
"//submodules/Postbox",
"//submodules/AccountContext",
"//submodules/AvatarNode",
"//submodules/TextFormat",
"//submodules/Markdown",
"//submodules/WallpaperBackgroundNode",
],
visibility = [
"//visibility:public",
],
)

View File

@ -984,7 +984,7 @@ final class OverscrollContentsComponent: Component {
}
}
final class ChatOverscrollControl: CombinedComponent {
public final class ChatOverscrollControl: CombinedComponent {
let backgroundColor: UIColor
let foregroundColor: UIColor
let peer: EnginePeer?
@ -997,7 +997,7 @@ final class ChatOverscrollControl: CombinedComponent {
let absoluteSize: CGSize
let wallpaperNode: WallpaperBackgroundNode?
init(
public init(
backgroundColor: UIColor,
foregroundColor: UIColor,
peer: EnginePeer?,
@ -1023,7 +1023,7 @@ final class ChatOverscrollControl: CombinedComponent {
self.wallpaperNode = wallpaperNode
}
static func ==(lhs: ChatOverscrollControl, rhs: ChatOverscrollControl) -> Bool {
public static func ==(lhs: ChatOverscrollControl, rhs: ChatOverscrollControl) -> Bool {
if !lhs.backgroundColor.isEqual(rhs.backgroundColor) {
return false
}
@ -1060,7 +1060,7 @@ final class ChatOverscrollControl: CombinedComponent {
return true
}
static var body: Body {
public static var body: Body {
let contents = Child(OverscrollContentsComponent.self)
return { context in
@ -1093,12 +1093,12 @@ final class ChatOverscrollControl: CombinedComponent {
}
}
final class ChatInputPanelOverscrollNode: ASDisplayNode {
let text: (String, [(Int, NSRange)])
let priority: Int
public final class ChatInputPanelOverscrollNode: ASDisplayNode {
public let text: (String, [(Int, NSRange)])
public let priority: Int
private let titleNode: ImmediateTextNode
init(text: (String, [(Int, NSRange)]), color: UIColor, priority: Int) {
public init(text: (String, [(Int, NSRange)]), color: UIColor, priority: Int) {
self.text = text
self.priority = priority
self.titleNode = ImmediateTextNode()
@ -1113,7 +1113,7 @@ final class ChatInputPanelOverscrollNode: ASDisplayNode {
self.addSubnode(self.titleNode)
}
func update(size: CGSize) {
public func update(size: CGSize) {
let titleSize = self.titleNode.updateLayout(size)
self.titleNode.frame = titleSize.centered(in: CGRect(origin: CGPoint(), size: size))
}

View File

@ -27,6 +27,7 @@ import ChatControllerInteraction
import ChatAvatarNavigationNode
import AccessoryPanelNode
import ForwardAccessoryPanelNode
import ChatOverscrollControl
final class VideoNavigationControllerDropContentItem: NavigationControllerDropContentItem {
let itemNode: OverlayMediaItemNode

View File

@ -24,6 +24,7 @@ import TelegramNotices
import ChatControllerInteraction
import TranslateUI
import ChatHistoryEntry
import ChatOverscrollControl
extension ChatReplyThreadMessage {
var effectiveTopId: MessageId {

View File

@ -13,9 +13,9 @@ import AnimationUI
import ManagedAnimationNode
import ChatPresentationInterfaceState
import ChatSendButtonRadialStatusNode
import AudioWaveformNode
extension AudioWaveformNode: CustomMediaPlayerScrubbingForegroundNode {
}
final class ChatRecordingPreviewInputPanelNode: ChatInputPanelNode {

View File

@ -46,7 +46,7 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
private var dataSource: AudioBroadcastDataSource?
#if DEBUG
private let debugDumpDirectory = EngineTempBox.shared.tempDirectory()
private let debugDumpDirectory: EngineTempBox.Directory?
#endif
init(queue: Queue, engine: TelegramEngine, callId: Int64, accessHash: Int64, isExternalStream: Bool) {
@ -55,6 +55,10 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
self.callId = callId
self.accessHash = accessHash
self.isExternalStream = isExternalStream
#if DEBUG && true
self.debugDumpDirectory = EngineTempBox.shared.tempDirectory()
#endif
}
func requestTime(completion: @escaping (Int64) -> Void) -> Disposable {
@ -143,9 +147,10 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
}
|> deliverOn(self.queue)
/*#if DEBUG
#if DEBUG
let debugDumpDirectory = self.debugDumpDirectory
#endif*/
#endif
return signal.start(next: { result in
guard let result = result else {
completion(OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: Double(timestampIdMilliseconds), status: .notReady, oggData: Data()))
@ -154,11 +159,13 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
let part: OngoingGroupCallBroadcastPart
switch result.status {
case let .data(dataValue):
/*#if DEBUG
let tempFilePath = debugDumpDirectory.path + "/\(timestampMilliseconds).mp4"
let _ = try? dataValue.subdata(in: 32 ..< dataValue.count).write(to: URL(fileURLWithPath: tempFilePath))
print("Dump stream part: \(tempFilePath)")
#endif*/
#if DEBUG
if let debugDumpDirectory {
let tempFilePath = debugDumpDirectory.path + "/\(timestampMilliseconds).mp4"
let _ = try? dataValue.subdata(in: 32 ..< dataValue.count).write(to: URL(fileURLWithPath: tempFilePath))
print("Dump stream part: \(tempFilePath)")
}
#endif
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .success, oggData: dataValue)
case .notReady:
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .notReady, oggData: Data())