mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-02 00:17:02 +00:00
Added recent stickers clearing Added sending logs via email Added forward recipient change on forward acccessory panel tap Tweaked undo panel design Various UI fixes
131 lines
6.7 KiB
Swift
131 lines
6.7 KiB
Swift
import Foundation
|
|
import AsyncDisplayKit
|
|
import Postbox
|
|
import TelegramCore
|
|
import Display
|
|
import SwiftSignalKit
|
|
|
|
private let textFont = Font.regular(15.0)
|
|
|
|
final class ChatListInputActivitiesNode: ASDisplayNode {
|
|
private let activityNode: ChatTitleActivityNode
|
|
|
|
override init() {
|
|
self.activityNode = ChatTitleActivityNode()
|
|
|
|
super.init()
|
|
|
|
self.addSubnode(self.activityNode)
|
|
}
|
|
|
|
func asyncLayout() -> (CGSize, PresentationStrings, UIColor, PeerId, [(Peer, PeerInputActivity)]) -> (CGSize, () -> Void) {
|
|
return { [weak self] boundingSize, strings, color, peerId, activities in
|
|
var state = ChatTitleActivityNodeState.none
|
|
|
|
if !activities.isEmpty {
|
|
var commonKey: Int32? = activities[0].1.key
|
|
for i in 1 ..< activities.count {
|
|
if activities[i].1.key != commonKey {
|
|
commonKey = nil
|
|
break
|
|
}
|
|
}
|
|
|
|
if activities.count == 1 {
|
|
if activities[0].0.id == peerId {
|
|
let text: String
|
|
switch activities[0].1 {
|
|
case .uploadingVideo:
|
|
text = strings.Activity_UploadingVideo
|
|
case .uploadingInstantVideo:
|
|
text = strings.Activity_UploadingVideoMessage
|
|
case .uploadingPhoto:
|
|
text = strings.Activity_UploadingPhoto
|
|
case .uploadingFile:
|
|
text = strings.Activity_UploadingDocument
|
|
case .recordingVoice:
|
|
text = strings.Activity_RecordingAudio
|
|
case .recordingInstantVideo:
|
|
text = strings.Activity_RecordingVideoMessage
|
|
case .playingGame:
|
|
text = strings.Activity_PlayingGame
|
|
case .typingText:
|
|
text = strings.DialogList_Typing
|
|
}
|
|
let string = NSAttributedString(string: text, font: textFont, textColor: color)
|
|
|
|
switch activities[0].1 {
|
|
case .typingText:
|
|
state = .typingText(string, color)
|
|
case .recordingVoice:
|
|
state = .recordingVoice(string, color)
|
|
case .recordingInstantVideo:
|
|
state = .recordingVideo(string, color)
|
|
case .uploadingFile, .uploadingInstantVideo, .uploadingPhoto, .uploadingVideo:
|
|
state = .uploading(string, color)
|
|
case .playingGame:
|
|
state = .playingGame(string, color)
|
|
}
|
|
} else {
|
|
let text: String
|
|
if let _ = commonKey {
|
|
let peerTitle = activities[0].0.compactDisplayTitle
|
|
switch activities[0].1 {
|
|
case .uploadingVideo:
|
|
text = strings.DialogList_SingleUploadingVideoSuffix(peerTitle).0
|
|
case .uploadingInstantVideo:
|
|
text = strings.DialogList_SingleUploadingVideoSuffix(peerTitle).0
|
|
case .uploadingPhoto:
|
|
text = strings.DialogList_SingleUploadingPhotoSuffix(peerTitle).0
|
|
case .uploadingFile:
|
|
text = strings.DialogList_SingleUploadingFileSuffix(peerTitle).0
|
|
case .recordingVoice:
|
|
text = strings.DialogList_SingleRecordingAudioSuffix(peerTitle).0
|
|
case .recordingInstantVideo:
|
|
text = strings.DialogList_SingleRecordingVideoMessageSuffix(peerTitle).0
|
|
case .playingGame:
|
|
text = strings.DialogList_SinglePlayingGameSuffix(peerTitle).0
|
|
case .typingText:
|
|
text = strings.DialogList_SingleTypingSuffix(peerTitle).0
|
|
}
|
|
} else {
|
|
text = activities[0].0.compactDisplayTitle
|
|
}
|
|
let string = NSAttributedString(string: text, font: textFont, textColor: color)
|
|
|
|
switch activities[0].1 {
|
|
case .typingText:
|
|
state = .typingText(string, color)
|
|
case .recordingVoice:
|
|
state = .recordingVoice(string, color)
|
|
case .recordingInstantVideo:
|
|
state = .recordingVideo(string, color)
|
|
case .uploadingFile, .uploadingInstantVideo, .uploadingPhoto, .uploadingVideo:
|
|
state = .uploading(string, color)
|
|
case .playingGame:
|
|
state = .playingGame(string, color)
|
|
}
|
|
}
|
|
} else {
|
|
let string: NSAttributedString
|
|
if activities.count > 1 {
|
|
let peerTitle = activities[0].0.compactDisplayTitle
|
|
string = NSAttributedString(string: strings.DialogList_MultipleTyping(peerTitle, strings.DialogList_MultipleTypingSuffix(activities.count - 1).0).0, font: textFont, textColor: color)
|
|
} else {
|
|
string = NSAttributedString(string: strings.DialogList_MultipleTypingSuffix(activities.count).0, font: textFont, textColor: color)
|
|
}
|
|
state = .typingText(string, color)
|
|
}
|
|
}
|
|
|
|
return (boundingSize, {
|
|
if let strongSelf = self {
|
|
let _ = strongSelf.activityNode.transitionToState(state, animation: .none)
|
|
let size = strongSelf.activityNode.updateLayout(CGSize(width: boundingSize.width - 12.0, height: boundingSize.height), alignment: .left)
|
|
strongSelf.activityNode.frame = CGRect(origin: CGPoint(x: -3.0, y: 1.0), size: size)
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}
|