mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-30 03:44:18 +00:00
Various improvements
This commit is contained in:
parent
297fdbcf63
commit
acd18b62e5
@ -592,6 +592,7 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
backgroundColor: .clear,
|
backgroundColor: .clear,
|
||||||
separatorColor: strongSelf.presentationData.theme.list.itemPlainSeparatorColor.withMultipliedAlpha(0.5),
|
separatorColor: strongSelf.presentationData.theme.list.itemPlainSeparatorColor.withMultipliedAlpha(0.5),
|
||||||
hideTopPanel: hideTopPanel,
|
hideTopPanel: hideTopPanel,
|
||||||
|
disableTopPanel: strongSelf.alwaysAllowPremiumReactions,
|
||||||
hideTopPanelUpdated: { hideTopPanel, transition in
|
hideTopPanelUpdated: { hideTopPanel, transition in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
@ -1217,6 +1218,7 @@ public final class ReactionContextNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
backgroundColor: .clear,
|
backgroundColor: .clear,
|
||||||
separatorColor: self.presentationData.theme.list.itemPlainSeparatorColor.withMultipliedAlpha(0.5),
|
separatorColor: self.presentationData.theme.list.itemPlainSeparatorColor.withMultipliedAlpha(0.5),
|
||||||
hideTopPanel: hideTopPanel,
|
hideTopPanel: hideTopPanel,
|
||||||
|
disableTopPanel: self.alwaysAllowPremiumReactions,
|
||||||
hideTopPanelUpdated: { [weak self] hideTopPanel, transition in
|
hideTopPanelUpdated: { [weak self] hideTopPanel, transition in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
|
|||||||
@ -1496,32 +1496,61 @@ struct ChatRecentActionsEntry: Comparable, Identifiable {
|
|||||||
var text: String = ""
|
var text: String = ""
|
||||||
var entities: [MessageTextEntity] = []
|
var entities: [MessageTextEntity] = []
|
||||||
|
|
||||||
let rawText: PresentationStrings.FormattedString
|
|
||||||
switch updatedValue {
|
switch updatedValue {
|
||||||
case .all:
|
case .all:
|
||||||
rawText = self.presentationData.strings.Channel_AdminLog_ReactionsEnabled(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "")
|
let rawText = self.presentationData.strings.Channel_AdminLog_ReactionsEnabled(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "")
|
||||||
case let .limited(reactions):
|
appendAttributedText(text: rawText, generateEntities: { index in
|
||||||
let emojiString = reactions.compactMap({ reaction -> String? in
|
if index == 0, let author = author {
|
||||||
switch reaction {
|
return [.TextMention(peerId: author.id)]
|
||||||
case let .builtin(value):
|
} else if index == 1 {
|
||||||
return value
|
return [.Bold]
|
||||||
case .custom:
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
}).joined(separator: ", ")
|
return []
|
||||||
rawText = self.presentationData.strings.Channel_AdminLog_AllowedReactionsUpdated(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "", emojiString)
|
}, to: &text, entities: &entities)
|
||||||
case .empty:
|
case let .limited(reactions):
|
||||||
rawText = self.presentationData.strings.Channel_AdminLog_ReactionsDisabled(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "")
|
let authorTitle = author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""
|
||||||
}
|
let rawText = self.presentationData.strings.Channel_AdminLog_AllowedReactionsUpdated(authorTitle, "")
|
||||||
|
var previousIndex = 0
|
||||||
appendAttributedText(text: rawText, generateEntities: { index in
|
let nsText = rawText.string as NSString
|
||||||
if index == 0, let author = author {
|
for range in rawText.ranges.sorted(by: { $0.range.lowerBound < $1.range.lowerBound }) {
|
||||||
return [.TextMention(peerId: author.id)]
|
if range.range.lowerBound > previousIndex {
|
||||||
} else if index == 1 {
|
text.append(nsText.substring(with: NSRange(location: previousIndex, length: range.range.lowerBound - previousIndex)))
|
||||||
return [.Bold]
|
}
|
||||||
|
if range.index == 0 {
|
||||||
|
if let author {
|
||||||
|
entities.append(MessageTextEntity(range: (text as NSString).length ..< (text as NSString).length + (authorTitle as NSString).length, type: .TextMention(peerId: author.id)))
|
||||||
|
}
|
||||||
|
text.append(authorTitle)
|
||||||
|
} else if range.index == 1 {
|
||||||
|
for reaction in reactions {
|
||||||
|
let reactionText: String
|
||||||
|
switch reaction {
|
||||||
|
case let .builtin(value):
|
||||||
|
reactionText = value
|
||||||
|
text.append(reactionText)
|
||||||
|
case let .custom(fileId):
|
||||||
|
reactionText = "."
|
||||||
|
entities.append(MessageTextEntity(range: (text as NSString).length ..< (text as NSString).length + (reactionText as NSString).length, type: .CustomEmoji(stickerPack: nil, fileId: fileId)))
|
||||||
|
text.append(reactionText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
previousIndex = range.range.upperBound
|
||||||
}
|
}
|
||||||
return []
|
if nsText.length > previousIndex {
|
||||||
}, to: &text, entities: &entities)
|
text.append(nsText.substring(with: NSRange(location: previousIndex, length: nsText.length - previousIndex)))
|
||||||
|
}
|
||||||
|
case .empty:
|
||||||
|
let rawText = self.presentationData.strings.Channel_AdminLog_ReactionsDisabled(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? "")
|
||||||
|
appendAttributedText(text: rawText, generateEntities: { index in
|
||||||
|
if index == 0, let author = author {
|
||||||
|
return [.TextMention(peerId: author.id)]
|
||||||
|
} else if index == 1 {
|
||||||
|
return [.Bold]
|
||||||
|
}
|
||||||
|
return []
|
||||||
|
}, to: &text, entities: &entities)
|
||||||
|
}
|
||||||
|
|
||||||
let action = TelegramMediaActionType.customText(text: text, entities: entities)
|
let action = TelegramMediaActionType.customText(text: text, entities: entities)
|
||||||
|
|
||||||
|
|||||||
@ -65,6 +65,7 @@ public final class EmojiStatusSelectionComponent: Component {
|
|||||||
public let backgroundColor: UIColor
|
public let backgroundColor: UIColor
|
||||||
public let separatorColor: UIColor
|
public let separatorColor: UIColor
|
||||||
public let hideTopPanel: Bool
|
public let hideTopPanel: Bool
|
||||||
|
public let disableTopPanel: Bool
|
||||||
public let hideTopPanelUpdated: (Bool, Transition) -> Void
|
public let hideTopPanelUpdated: (Bool, Transition) -> Void
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
@ -75,6 +76,7 @@ public final class EmojiStatusSelectionComponent: Component {
|
|||||||
backgroundColor: UIColor,
|
backgroundColor: UIColor,
|
||||||
separatorColor: UIColor,
|
separatorColor: UIColor,
|
||||||
hideTopPanel: Bool,
|
hideTopPanel: Bool,
|
||||||
|
disableTopPanel: Bool,
|
||||||
hideTopPanelUpdated: @escaping (Bool, Transition) -> Void
|
hideTopPanelUpdated: @escaping (Bool, Transition) -> Void
|
||||||
) {
|
) {
|
||||||
self.theme = theme
|
self.theme = theme
|
||||||
@ -84,6 +86,7 @@ public final class EmojiStatusSelectionComponent: Component {
|
|||||||
self.backgroundColor = backgroundColor
|
self.backgroundColor = backgroundColor
|
||||||
self.separatorColor = separatorColor
|
self.separatorColor = separatorColor
|
||||||
self.hideTopPanel = hideTopPanel
|
self.hideTopPanel = hideTopPanel
|
||||||
|
self.disableTopPanel = disableTopPanel
|
||||||
self.hideTopPanelUpdated = hideTopPanelUpdated
|
self.hideTopPanelUpdated = hideTopPanelUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,6 +112,9 @@ public final class EmojiStatusSelectionComponent: Component {
|
|||||||
if lhs.hideTopPanel != rhs.hideTopPanel {
|
if lhs.hideTopPanel != rhs.hideTopPanel {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.disableTopPanel != rhs.disableTopPanel {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +199,8 @@ public final class EmojiStatusSelectionComponent: Component {
|
|||||||
displayBottomPanel: false,
|
displayBottomPanel: false,
|
||||||
isExpanded: false,
|
isExpanded: false,
|
||||||
clipContentToTopPanel: false,
|
clipContentToTopPanel: false,
|
||||||
useExternalSearchContainer: false
|
useExternalSearchContainer: false,
|
||||||
|
hidePanels: component.disableTopPanel
|
||||||
)),
|
)),
|
||||||
environment: {},
|
environment: {},
|
||||||
containerSize: availableSize
|
containerSize: availableSize
|
||||||
@ -984,6 +991,7 @@ public final class EmojiStatusSelectionController: ViewController {
|
|||||||
backgroundColor: listBackgroundColor,
|
backgroundColor: listBackgroundColor,
|
||||||
separatorColor: separatorColor,
|
separatorColor: separatorColor,
|
||||||
hideTopPanel: self.isReactionSearchActive,
|
hideTopPanel: self.isReactionSearchActive,
|
||||||
|
disableTopPanel: false,
|
||||||
hideTopPanelUpdated: { [weak self] hideTopPanel, transition in
|
hideTopPanelUpdated: { [weak self] hideTopPanel, transition in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user