Monoforums

This commit is contained in:
Isaac 2025-05-27 21:17:05 +08:00
parent 545140337b
commit df088af209
10 changed files with 23 additions and 15 deletions

View file

@ -145,6 +145,9 @@ private enum ChatListRecentEntry: Comparable, Identifiable {
if case .secretChat = maybeChatPeer, let associatedPeerId = maybeChatPeer._asPeer().associatedPeerId, let associatedPeer = peer.peer.peers[associatedPeerId] {
primaryPeer = EnginePeer(associatedPeer)
chatPeer = maybeChatPeer
} else if case .channel = maybeChatPeer, let mainChannel = peer.peer.chatOrMonoforumMainPeer {
primaryPeer = EnginePeer(mainChannel)
chatPeer = maybeChatPeer
} else {
primaryPeer = maybeChatPeer
chatPeer = maybeChatPeer

View file

@ -85,6 +85,7 @@ public struct PresentationResourcesSettings {
public static let balance = renderIcon(name: "Settings/Menu/Balance", scaleFactor: 0.97, backgroundColors: [UIColor(rgb: 0x34c759)])
public static let affiliateProgram = renderIcon(name: "Settings/Menu/AffiliateProgram")
public static let earnStars = renderIcon(name: "Settings/Menu/EarnStars")
public static let channelMessages = renderIcon(name: "Chat/Info/ChannelMessages", backgroundColors: [UIColor(rgb: 0xFF9500)])
public static let premium = generateImage(CGSize(width: 29.0, height: 29.0), contextGenerator: { size, context in
let bounds = CGRect(origin: CGPoint(), size: size)

View file

@ -325,11 +325,16 @@ public final class AsyncListComponent: Component {
}
private final class ListItemNodeImpl: ListViewItemNode {
private let contentContainer: UIView
private let contentsView = ComponentView<Empty>()
private(set) var item: ListItemImpl?
init() {
self.contentContainer = UIView()
super.init(layerBacked: false, dynamicBounce: false, rotated: false, seeThrough: false)
self.view.addSubview(self.contentContainer)
}
deinit {
@ -377,16 +382,17 @@ public final class AsyncListComponent: Component {
switch item.direction {
case .vertical:
self.layer.sublayerTransform = CATransform3DIdentity
self.contentContainer.layer.sublayerTransform = CATransform3DIdentity
case .horizontal:
self.layer.sublayerTransform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
self.contentContainer.layer.sublayerTransform = CATransform3DMakeRotation(CGFloat.pi / 2.0, 0.0, 0.0, 1.0)
}
self.contentContainer.frame = CGRect(origin: CGPoint(), size: mappedContentsSize)
let contentsFrame = CGRect(origin: CGPoint(), size: contentsSize)
if let contentsComponentView = self.contentsView.view {
if contentsComponentView.superview == nil {
self.view.addSubview(contentsComponentView)
self.contentContainer.addSubview(contentsComponentView)
}
contentsComponentView.center = CGPoint(x: mappedContentsSize.width * 0.5, y: mappedContentsSize.height * 0.5)
contentsComponentView.bounds = CGRect(origin: CGPoint(), size: contentsFrame.size)

View file

@ -1033,7 +1033,7 @@ private func settingsItems(data: PeerInfoScreenData?, context: AccountContext, p
}
}
if !isPremiumDisabled || context.isPremium {
items[.payment]!.append(PeerInfoScreenDisclosureItem(id: 103, label: .text(""), additionalBadgeLabel: presentationData.strings.Settings_New, text: presentationData.strings.Settings_Business, icon: PresentationResourcesSettings.business, action: {
items[.payment]!.append(PeerInfoScreenDisclosureItem(id: 103, label: .text(""), additionalBadgeLabel: nil, text: presentationData.strings.Settings_Business, icon: PresentationResourcesSettings.business, action: {
interaction.openSettings(.businessSetup)
}))
}
@ -2219,7 +2219,7 @@ private func editingItems(data: PeerInfoScreenData?, boostStatus: ChannelBoostSt
interaction.editingOpenDiscussionGroupSetup()
}))
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemPostSuggestionsSettings, label: .text(channel.linkedMonoforumId == nil ? presentationData.strings.PeerInfo_AllowChannelMessages_Off : presentationData.strings.PeerInfo_AllowChannelMessages_On), additionalBadgeLabel: presentationData.strings.Settings_New, text: presentationData.strings.PeerInfo_AllowChannelMessages, icon: UIImage(bundleImageName: "Chat/Info/PostSuggestionsIcon"), action: {
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemPostSuggestionsSettings, label: .text(channel.linkedMonoforumId == nil ? presentationData.strings.PeerInfo_AllowChannelMessages_Off : presentationData.strings.PeerInfo_AllowChannelMessages_On), additionalBadgeLabel: presentationData.strings.Settings_New, text: presentationData.strings.PeerInfo_AllowChannelMessages, icon: PresentationResourcesSettings.channelMessages, action: {
interaction.editingOpenPostSuggestionsSetup()
}))
}
@ -2246,10 +2246,7 @@ private func editingItems(data: PeerInfoScreenData?, boostStatus: ChannelBoostSt
} else {
label = ""
}
var additionalBadgeLabel: String? = nil
if case .broadcast = channel.info {
additionalBadgeLabel = presentationData.strings.Settings_New
}
let additionalBadgeLabel: String? = nil
items[.peerSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemReactions, label: .text(label), additionalBadgeLabel: additionalBadgeLabel, text: presentationData.strings.PeerInfo_Reactions, icon: UIImage(bundleImageName: "Settings/Menu/Reactions"), action: {
interaction.editingOpenReactionsSetup()
}))
@ -2356,7 +2353,7 @@ private func editingItems(data: PeerInfoScreenData?, boostStatus: ChannelBoostSt
}))
if channel.linkedMonoforumId != nil {
items[.peerAdditionalSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemChannelMessages, label: .none, text: presentationData.strings.PeerInfo_ChannelMessages, icon: UIImage(bundleImageName: "Chat/Info/RecentActionsIcon"), action: {
items[.peerAdditionalSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemChannelMessages, label: .none, text: presentationData.strings.PeerInfo_ChannelMessages, icon: PresentationResourcesSettings.channelMessages, action: {
interaction.openChannelMessages()
}))
}
@ -2373,7 +2370,7 @@ private func editingItems(data: PeerInfoScreenData?, boostStatus: ChannelBoostSt
}
if canJoinRefProgram {
items[.peerAdditionalSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemAffiliatePrograms, label: .text(""), additionalBadgeLabel: presentationData.strings.Settings_New, text: presentationData.strings.PeerInfo_ItemAffiliatePrograms_Title, icon: PresentationResourcesSettings.affiliateProgram, action: {
items[.peerAdditionalSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemAffiliatePrograms, label: .text(""), additionalBadgeLabel: nil, text: presentationData.strings.PeerInfo_ItemAffiliatePrograms_Title, icon: PresentationResourcesSettings.affiliateProgram, action: {
interaction.editingOpenAffiliateProgram()
}))
}
@ -2529,7 +2526,8 @@ private func editingItems(data: PeerInfoScreenData?, boostStatus: ChannelBoostSt
if let approximateBoostLevel = channel.approximateBoostLevel, approximateBoostLevel < 1 {
boostIcon = generateDisclosureActionBoostLevelBadgeImage(text: presentationData.strings.Channel_Info_BoostLevelPlusBadge("1").string)
} else {
let labelText = NSAttributedString(string: presentationData.strings.Settings_New, font: Font.medium(11.0), textColor: presentationData.theme.list.itemCheckColors.foregroundColor)
boostIcon = nil
/*let labelText = NSAttributedString(string: presentationData.strings.Settings_New, font: Font.medium(11.0), textColor: presentationData.theme.list.itemCheckColors.foregroundColor)
let labelBounds = labelText.boundingRect(with: CGSize(width: 100.0, height: 100.0), options: [.usesLineFragmentOrigin], context: nil)
let labelSize = CGSize(width: ceil(labelBounds.width), height: ceil(labelBounds.height))
let badgeSize = CGSize(width: labelSize.width + 8.0, height: labelSize.height + 2.0 + 1.0)
@ -2545,7 +2543,7 @@ private func editingItems(data: PeerInfoScreenData?, boostStatus: ChannelBoostSt
UIGraphicsPushContext(context)
labelText.draw(at: CGPoint(x: 4.0, y: 1.0 + UIScreenPixel))
UIGraphicsPopContext()
})
})*/
}
items[.peerDataSettings]!.append(PeerInfoScreenDisclosureItem(id: ItemAppearance, label: .image(colorImage, colorImage.size), additionalBadgeIcon: boostIcon, text: presentationData.strings.Channel_Info_AppearanceItem, icon: UIImage(bundleImageName: "Chat/Info/NameColorIcon"), action: {
interaction.editingOpenNameColorSetup()

View file

@ -230,7 +230,7 @@ final class PostSuggestionsSettingsScreenComponent: Component {
let iconSize = self.icon.update(
transition: .immediate,
component: AnyComponent(LottieComponent(
content: LottieComponent.AppBundleContent(name: "LampEmoji"),
content: LottieComponent.AppBundleContent(name: "ChannelMessages"),
loop: false
)),
environment: {},

View file

@ -1,7 +1,7 @@
{
"images" : [
{
"filename" : "ic_discussion.pdf",
"filename" : "bubbles_30 (1).pdf",
"idiom" : "universal"
}
],