mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Refactoring
This commit is contained in:
parent
6a7233ed05
commit
07c0ae9792
@ -5,4 +5,5 @@ public typealias EngineTempBox = TempBox
|
|||||||
|
|
||||||
public extension EngineTempBox {
|
public extension EngineTempBox {
|
||||||
typealias File = TempBoxFile
|
typealias File = TempBoxFile
|
||||||
|
typealias Directory = TempBoxDirectory
|
||||||
}
|
}
|
||||||
|
@ -348,6 +348,8 @@ swift_library(
|
|||||||
"//submodules/TelegramUI/Components/Chat/EditableTokenListNode",
|
"//submodules/TelegramUI/Components/Chat/EditableTokenListNode",
|
||||||
"//submodules/TelegramUI/Components/Chat/ChatInputTextNode",
|
"//submodules/TelegramUI/Components/Chat/ChatInputTextNode",
|
||||||
"//submodules/TelegramUI/Components/Chat/ChatMessageReplyInfoNode",
|
"//submodules/TelegramUI/Components/Chat/ChatMessageReplyInfoNode",
|
||||||
|
"//submodules/TelegramUI/Components/Chat/ChatOverscrollControl",
|
||||||
|
"//submodules/TelegramUI/Components/AudioWaveformNode",
|
||||||
] + select({
|
] + select({
|
||||||
"@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets,
|
"@build_bazel_rules_apple//apple:ios_arm64": appcenter_targets,
|
||||||
"//build-system:ios_sim_arm64": [],
|
"//build-system:ios_sim_arm64": [],
|
||||||
|
20
submodules/TelegramUI/Components/AudioWaveformNode/BUILD
Normal file
20
submodules/TelegramUI/Components/AudioWaveformNode/BUILD
Normal 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",
|
||||||
|
],
|
||||||
|
)
|
@ -20,8 +20,8 @@ private final class AudioWaveformNodeParameters: NSObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class AudioWaveformNode: ASDisplayNode {
|
public final class AudioWaveformNode: ASDisplayNode {
|
||||||
enum Gravity {
|
public enum Gravity {
|
||||||
case bottom
|
case bottom
|
||||||
case center
|
case center
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ final class AudioWaveformNode: ASDisplayNode {
|
|||||||
private var color: UIColor?
|
private var color: UIColor?
|
||||||
private var gravity: Gravity?
|
private var gravity: Gravity?
|
||||||
|
|
||||||
var progress: CGFloat? {
|
public var progress: CGFloat? {
|
||||||
didSet {
|
didSet {
|
||||||
if self.progress != oldValue {
|
if self.progress != oldValue {
|
||||||
self.setNeedsDisplay()
|
self.setNeedsDisplay()
|
||||||
@ -38,13 +38,13 @@ final class AudioWaveformNode: ASDisplayNode {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override init() {
|
override public init() {
|
||||||
super.init()
|
super.init()
|
||||||
|
|
||||||
self.isOpaque = false
|
self.isOpaque = false
|
||||||
}
|
}
|
||||||
|
|
||||||
override var frame: CGRect {
|
override public var frame: CGRect {
|
||||||
get {
|
get {
|
||||||
return super.frame
|
return super.frame
|
||||||
} set(value) {
|
} 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 {
|
if self.color == nil || !self.color!.isEqual(color) || self.waveform != waveform || self.gravity != gravity {
|
||||||
self.color = color
|
self.color = color
|
||||||
self.gravity = gravity
|
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)
|
return AudioWaveformNodeParameters(waveform: self.waveform, color: self.color, gravity: self.gravity, progress: self.progress)
|
||||||
}
|
}
|
||||||
|
|
@ -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",
|
||||||
|
],
|
||||||
|
)
|
@ -984,7 +984,7 @@ final class OverscrollContentsComponent: Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ChatOverscrollControl: CombinedComponent {
|
public final class ChatOverscrollControl: CombinedComponent {
|
||||||
let backgroundColor: UIColor
|
let backgroundColor: UIColor
|
||||||
let foregroundColor: UIColor
|
let foregroundColor: UIColor
|
||||||
let peer: EnginePeer?
|
let peer: EnginePeer?
|
||||||
@ -997,7 +997,7 @@ final class ChatOverscrollControl: CombinedComponent {
|
|||||||
let absoluteSize: CGSize
|
let absoluteSize: CGSize
|
||||||
let wallpaperNode: WallpaperBackgroundNode?
|
let wallpaperNode: WallpaperBackgroundNode?
|
||||||
|
|
||||||
init(
|
public init(
|
||||||
backgroundColor: UIColor,
|
backgroundColor: UIColor,
|
||||||
foregroundColor: UIColor,
|
foregroundColor: UIColor,
|
||||||
peer: EnginePeer?,
|
peer: EnginePeer?,
|
||||||
@ -1023,7 +1023,7 @@ final class ChatOverscrollControl: CombinedComponent {
|
|||||||
self.wallpaperNode = wallpaperNode
|
self.wallpaperNode = wallpaperNode
|
||||||
}
|
}
|
||||||
|
|
||||||
static func ==(lhs: ChatOverscrollControl, rhs: ChatOverscrollControl) -> Bool {
|
public static func ==(lhs: ChatOverscrollControl, rhs: ChatOverscrollControl) -> Bool {
|
||||||
if !lhs.backgroundColor.isEqual(rhs.backgroundColor) {
|
if !lhs.backgroundColor.isEqual(rhs.backgroundColor) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@ -1060,7 +1060,7 @@ final class ChatOverscrollControl: CombinedComponent {
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
static var body: Body {
|
public static var body: Body {
|
||||||
let contents = Child(OverscrollContentsComponent.self)
|
let contents = Child(OverscrollContentsComponent.self)
|
||||||
|
|
||||||
return { context in
|
return { context in
|
||||||
@ -1093,12 +1093,12 @@ final class ChatOverscrollControl: CombinedComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ChatInputPanelOverscrollNode: ASDisplayNode {
|
public final class ChatInputPanelOverscrollNode: ASDisplayNode {
|
||||||
let text: (String, [(Int, NSRange)])
|
public let text: (String, [(Int, NSRange)])
|
||||||
let priority: Int
|
public let priority: Int
|
||||||
private let titleNode: ImmediateTextNode
|
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.text = text
|
||||||
self.priority = priority
|
self.priority = priority
|
||||||
self.titleNode = ImmediateTextNode()
|
self.titleNode = ImmediateTextNode()
|
||||||
@ -1113,7 +1113,7 @@ final class ChatInputPanelOverscrollNode: ASDisplayNode {
|
|||||||
self.addSubnode(self.titleNode)
|
self.addSubnode(self.titleNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
func update(size: CGSize) {
|
public func update(size: CGSize) {
|
||||||
let titleSize = self.titleNode.updateLayout(size)
|
let titleSize = self.titleNode.updateLayout(size)
|
||||||
self.titleNode.frame = titleSize.centered(in: CGRect(origin: CGPoint(), size: size))
|
self.titleNode.frame = titleSize.centered(in: CGRect(origin: CGPoint(), size: size))
|
||||||
}
|
}
|
@ -27,6 +27,7 @@ import ChatControllerInteraction
|
|||||||
import ChatAvatarNavigationNode
|
import ChatAvatarNavigationNode
|
||||||
import AccessoryPanelNode
|
import AccessoryPanelNode
|
||||||
import ForwardAccessoryPanelNode
|
import ForwardAccessoryPanelNode
|
||||||
|
import ChatOverscrollControl
|
||||||
|
|
||||||
final class VideoNavigationControllerDropContentItem: NavigationControllerDropContentItem {
|
final class VideoNavigationControllerDropContentItem: NavigationControllerDropContentItem {
|
||||||
let itemNode: OverlayMediaItemNode
|
let itemNode: OverlayMediaItemNode
|
||||||
|
@ -24,6 +24,7 @@ import TelegramNotices
|
|||||||
import ChatControllerInteraction
|
import ChatControllerInteraction
|
||||||
import TranslateUI
|
import TranslateUI
|
||||||
import ChatHistoryEntry
|
import ChatHistoryEntry
|
||||||
|
import ChatOverscrollControl
|
||||||
|
|
||||||
extension ChatReplyThreadMessage {
|
extension ChatReplyThreadMessage {
|
||||||
var effectiveTopId: MessageId {
|
var effectiveTopId: MessageId {
|
||||||
|
@ -13,9 +13,9 @@ import AnimationUI
|
|||||||
import ManagedAnimationNode
|
import ManagedAnimationNode
|
||||||
import ChatPresentationInterfaceState
|
import ChatPresentationInterfaceState
|
||||||
import ChatSendButtonRadialStatusNode
|
import ChatSendButtonRadialStatusNode
|
||||||
|
import AudioWaveformNode
|
||||||
|
|
||||||
extension AudioWaveformNode: CustomMediaPlayerScrubbingForegroundNode {
|
extension AudioWaveformNode: CustomMediaPlayerScrubbingForegroundNode {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final class ChatRecordingPreviewInputPanelNode: ChatInputPanelNode {
|
final class ChatRecordingPreviewInputPanelNode: ChatInputPanelNode {
|
||||||
|
@ -46,7 +46,7 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
|
|||||||
private var dataSource: AudioBroadcastDataSource?
|
private var dataSource: AudioBroadcastDataSource?
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
private let debugDumpDirectory = EngineTempBox.shared.tempDirectory()
|
private let debugDumpDirectory: EngineTempBox.Directory?
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
init(queue: Queue, engine: TelegramEngine, callId: Int64, accessHash: Int64, isExternalStream: Bool) {
|
init(queue: Queue, engine: TelegramEngine, callId: Int64, accessHash: Int64, isExternalStream: Bool) {
|
||||||
@ -55,6 +55,10 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
|
|||||||
self.callId = callId
|
self.callId = callId
|
||||||
self.accessHash = accessHash
|
self.accessHash = accessHash
|
||||||
self.isExternalStream = isExternalStream
|
self.isExternalStream = isExternalStream
|
||||||
|
|
||||||
|
#if DEBUG && true
|
||||||
|
self.debugDumpDirectory = EngineTempBox.shared.tempDirectory()
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
func requestTime(completion: @escaping (Int64) -> Void) -> Disposable {
|
func requestTime(completion: @escaping (Int64) -> Void) -> Disposable {
|
||||||
@ -143,9 +147,10 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
|
|||||||
}
|
}
|
||||||
|> deliverOn(self.queue)
|
|> deliverOn(self.queue)
|
||||||
|
|
||||||
/*#if DEBUG
|
#if DEBUG
|
||||||
let debugDumpDirectory = self.debugDumpDirectory
|
let debugDumpDirectory = self.debugDumpDirectory
|
||||||
#endif*/
|
#endif
|
||||||
|
|
||||||
return signal.start(next: { result in
|
return signal.start(next: { result in
|
||||||
guard let result = result else {
|
guard let result = result else {
|
||||||
completion(OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: Double(timestampIdMilliseconds), status: .notReady, oggData: Data()))
|
completion(OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: Double(timestampIdMilliseconds), status: .notReady, oggData: Data()))
|
||||||
@ -154,11 +159,13 @@ final class NetworkBroadcastPartSource: BroadcastPartSource {
|
|||||||
let part: OngoingGroupCallBroadcastPart
|
let part: OngoingGroupCallBroadcastPart
|
||||||
switch result.status {
|
switch result.status {
|
||||||
case let .data(dataValue):
|
case let .data(dataValue):
|
||||||
/*#if DEBUG
|
#if DEBUG
|
||||||
|
if let debugDumpDirectory {
|
||||||
let tempFilePath = debugDumpDirectory.path + "/\(timestampMilliseconds).mp4"
|
let tempFilePath = debugDumpDirectory.path + "/\(timestampMilliseconds).mp4"
|
||||||
let _ = try? dataValue.subdata(in: 32 ..< dataValue.count).write(to: URL(fileURLWithPath: tempFilePath))
|
let _ = try? dataValue.subdata(in: 32 ..< dataValue.count).write(to: URL(fileURLWithPath: tempFilePath))
|
||||||
print("Dump stream part: \(tempFilePath)")
|
print("Dump stream part: \(tempFilePath)")
|
||||||
#endif*/
|
}
|
||||||
|
#endif
|
||||||
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .success, oggData: dataValue)
|
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .success, oggData: dataValue)
|
||||||
case .notReady:
|
case .notReady:
|
||||||
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .notReady, oggData: Data())
|
part = OngoingGroupCallBroadcastPart(timestampMilliseconds: timestampIdMilliseconds, responseTimestamp: result.responseTimestamp, status: .notReady, oggData: Data())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user