mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
[WIP] Topics
This commit is contained in:
@@ -7,9 +7,11 @@ import Postbox
|
||||
import SwiftSignalKit
|
||||
import TelegramStringFormatting
|
||||
import ChatPresentationInterfaceState
|
||||
import TelegramPresentationData
|
||||
|
||||
final class ChatRestrictedInputPanelNode: ChatInputPanelNode {
|
||||
private let textNode: ImmediateTextNode
|
||||
private var iconView: UIImageView?
|
||||
|
||||
private var presentationInterfaceState: ChatPresentationInterfaceState?
|
||||
|
||||
@@ -41,9 +43,12 @@ final class ChatRestrictedInputPanelNode: ChatInputPanelNode {
|
||||
bannedPermission = nil
|
||||
}
|
||||
|
||||
var iconImage: UIImage?
|
||||
|
||||
if let threadData = interfaceState.threadData, threadData.isClosed {
|
||||
//TODO:localize
|
||||
self.textNode.attributedText = NSAttributedString(string: "The topic is closed by admin", font: Font.regular(13.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
|
||||
iconImage = PresentationResourcesChat.chatPanelLockIcon(interfaceState.theme)
|
||||
self.textNode.attributedText = NSAttributedString(string: "The topic is closed by admin", font: Font.regular(15.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
|
||||
} else if let (untilDate, personal) = bannedPermission {
|
||||
if personal && untilDate != 0 && untilDate != Int32.max {
|
||||
self.textNode.attributedText = NSAttributedString(string: interfaceState.strings.Conversation_RestrictedTextTimed(stringForFullDate(timestamp: untilDate, strings: interfaceState.strings, dateTimeFormat: interfaceState.dateTimeFormat)).string, font: Font.regular(13.0), textColor: interfaceState.theme.chat.inputPanel.secondaryTextColor)
|
||||
@@ -57,7 +62,24 @@ final class ChatRestrictedInputPanelNode: ChatInputPanelNode {
|
||||
let panelHeight = defaultHeight(metrics: metrics)
|
||||
let textSize = self.textNode.updateLayout(CGSize(width: width - leftInset - rightInset - 8.0 * 2.0, height: panelHeight))
|
||||
|
||||
self.textNode.frame = CGRect(origin: CGPoint(x: leftInset + floor((width - leftInset - rightInset - textSize.width) / 2.0), y: floor((panelHeight - textSize.height) / 2.0)), size: textSize)
|
||||
let textFrame = CGRect(origin: CGPoint(x: leftInset + floor((width - leftInset - rightInset - textSize.width) / 2.0), y: floor((panelHeight - textSize.height) / 2.0)), size: textSize)
|
||||
self.textNode.frame = textFrame
|
||||
|
||||
if let iconImage = iconImage {
|
||||
let iconView: UIImageView
|
||||
if let current = self.iconView {
|
||||
iconView = current
|
||||
} else {
|
||||
iconView = UIImageView()
|
||||
self.iconView = iconView
|
||||
self.view.addSubview(iconView)
|
||||
}
|
||||
iconView.image = iconImage
|
||||
iconView.frame = CGRect(origin: CGPoint(x: textFrame.minX - 4.0 - iconImage.size.width, y: textFrame.minY + UIScreenPixel + floorToScreenPixels((textFrame.height - iconImage.size.height) / 2.0)), size: iconImage.size)
|
||||
} else if let iconView = self.iconView {
|
||||
self.iconView = nil
|
||||
iconView.removeFromSuperview()
|
||||
}
|
||||
|
||||
return panelHeight
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user