mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 13:13:55 +00:00
Fix discussion setup header
This commit is contained in:
parent
49671a27c4
commit
121f33b968
@ -30,7 +30,7 @@ private enum ChannelDiscussionGroupSetupControllerEntryStableId: Hashable {
|
||||
}
|
||||
|
||||
private enum ChannelDiscussionGroupSetupControllerEntry: ItemListNodeEntry {
|
||||
case header(PresentationTheme, String, String)
|
||||
case header(PresentationTheme, PresentationStrings, String?, Bool, String)
|
||||
case create(PresentationTheme, String)
|
||||
case group(Int, PresentationTheme, PresentationStrings, Peer, PresentationPersonNameOrder)
|
||||
case groupsInfo(PresentationTheme, String)
|
||||
@ -64,8 +64,8 @@ private enum ChannelDiscussionGroupSetupControllerEntry: ItemListNodeEntry {
|
||||
|
||||
static func ==(lhs: ChannelDiscussionGroupSetupControllerEntry, rhs: ChannelDiscussionGroupSetupControllerEntry) -> Bool {
|
||||
switch lhs {
|
||||
case let .header(lhsTheme, lhsTitle, lhsLabel):
|
||||
if case let .header(rhsTheme, rhsTitle, rhsLabel) = rhs, lhsTheme === rhsTheme, lhsTitle == rhsTitle, lhsLabel == rhsLabel {
|
||||
case let .header(lhsTheme, lhsStrings, lhsTitle, lhsIsGroup, lhsLabel):
|
||||
if case let .header(rhsTheme, rhsStrings, rhsTitle, rhsIsGroup, rhsLabel) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsTitle == rhsTitle, lhsIsGroup == rhsIsGroup, lhsLabel == rhsLabel {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
@ -118,8 +118,8 @@ private enum ChannelDiscussionGroupSetupControllerEntry: ItemListNodeEntry {
|
||||
|
||||
func item(_ arguments: ChannelDiscussionGroupSetupControllerArguments) -> ListViewItem {
|
||||
switch self {
|
||||
case let .header(theme, title, label):
|
||||
return ChannelDiscussionGroupSetupHeaderItem(theme: theme, text: title, label: label, sectionId: self.section)
|
||||
case let .header(theme, strings, title, isGroup, label):
|
||||
return ChannelDiscussionGroupSetupHeaderItem(theme: theme, strings: strings, title: title, isGroup: isGroup, label: label, sectionId: self.section)
|
||||
case let .create(theme, text):
|
||||
return ItemListPeerActionItem(theme: theme, icon: PresentationResourcesItemList.plusIconImage(theme), title: text, sectionId: self.section, editing: false, action: {
|
||||
arguments.createGroup()
|
||||
@ -156,9 +156,9 @@ private func channelDiscussionGroupSetupControllerEntries(presentationData: Pres
|
||||
if let linkedDiscussionPeerId = cachedData.linkedDiscussionPeerId {
|
||||
if let group = view.peers[linkedDiscussionPeerId] {
|
||||
if case .group = peer.info {
|
||||
entries.append(.header(presentationData.theme, presentationData.strings.Channel_DiscussionGroup_HeaderSet(group.displayTitle).0, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
entries.append(.header(presentationData.theme, presentationData.strings, group.displayTitle, true, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
} else {
|
||||
entries.append(.header(presentationData.theme, presentationData.strings.Channel_DiscussionGroup_HeaderSet(group.displayTitle).0, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
entries.append(.header(presentationData.theme, presentationData.strings, group.displayTitle, false, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
}
|
||||
|
||||
entries.append(.group(0, presentationData.theme, presentationData.strings, group, presentationData.nameDisplayOrder))
|
||||
@ -175,7 +175,7 @@ private func channelDiscussionGroupSetupControllerEntries(presentationData: Pres
|
||||
}
|
||||
} else if case .broadcast = peer.info, canEditChannel {
|
||||
if let groups = groups {
|
||||
entries.append(.header(presentationData.theme, presentationData.strings.Channel_DiscussionGroup_Header, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
entries.append(.header(presentationData.theme, presentationData.strings, nil, true, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
|
||||
entries.append(.create(presentationData.theme, presentationData.strings.Channel_DiscussionGroup_Create))
|
||||
var index = 0
|
||||
|
||||
@ -5,15 +5,19 @@ import SwiftSignalKit
|
||||
|
||||
class ChannelDiscussionGroupSetupHeaderItem: ListViewItem, ItemListItem {
|
||||
let theme: PresentationTheme
|
||||
let text: String
|
||||
let strings: PresentationStrings
|
||||
let title: String?
|
||||
let isGroup: Bool
|
||||
let label: String
|
||||
let sectionId: ItemListSectionId
|
||||
|
||||
let isAlwaysPlain: Bool = true
|
||||
|
||||
init(theme: PresentationTheme, text: String, label: String, sectionId: ItemListSectionId) {
|
||||
init(theme: PresentationTheme, strings: PresentationStrings, title: String?, isGroup: Bool, label: String, sectionId: ItemListSectionId) {
|
||||
self.theme = theme
|
||||
self.text = text
|
||||
self.strings = strings
|
||||
self.title = title
|
||||
self.isGroup = isGroup
|
||||
self.label = label
|
||||
self.sectionId = sectionId
|
||||
}
|
||||
@ -57,6 +61,7 @@ class ChannelDiscussionGroupSetupHeaderItem: ListViewItem, ItemListItem {
|
||||
|
||||
private let iconFont = Font.medium(12.0)
|
||||
private let titleFont = Font.regular(14.0)
|
||||
private let titleBoldFont = Font.semibold(14.0)
|
||||
|
||||
class ChannelDiscussionGroupSetupHeaderItemNode: ListViewItemNode {
|
||||
private let imageNode: ASImageNode
|
||||
@ -116,7 +121,16 @@ class ChannelDiscussionGroupSetupHeaderItemNode: ListViewItemNode {
|
||||
iconImage = currentIconImage
|
||||
}
|
||||
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.text, font: titleFont, textColor: item.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
|
||||
let body = MarkdownAttributeSet(font: titleFont, textColor: item.theme.list.sectionHeaderTextColor)
|
||||
let bold = MarkdownAttributeSet(font: titleBoldFont, textColor: item.theme.list.sectionHeaderTextColor)
|
||||
let string: NSAttributedString
|
||||
if let title = item.title {
|
||||
string = addAttributesToStringWithRanges(item.isGroup ? item.strings.Channel_DiscussionGroup_HeaderGroupSet(title) : item.strings.Channel_DiscussionGroup_HeaderSet(title), body: body, argumentAttributes: [0: bold])
|
||||
} else {
|
||||
string = NSAttributedString(string: item.strings.Channel_DiscussionGroup_Header, font: titleFont, textColor: item.theme.list.sectionHeaderTextColor)
|
||||
}
|
||||
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: string, backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
let (labelLayout, labelApply) = makeLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.label, font: iconFont, textColor: item.theme.list.itemAccentColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .center, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user