diff --git a/submodules/StatisticsUI/Sources/MessageStatsOverviewItem.swift b/submodules/StatisticsUI/Sources/MessageStatsOverviewItem.swift index f48597187a..1775d8868b 100644 --- a/submodules/StatisticsUI/Sources/MessageStatsOverviewItem.swift +++ b/submodules/StatisticsUI/Sources/MessageStatsOverviewItem.swift @@ -127,14 +127,13 @@ class MessageStatsOverviewItemNode: ListViewItemNode { let itemBackgroundColor: UIColor let itemSeparatorColor: UIColor - let horizontalSpacing: CGFloat = 62.0 let topInset: CGFloat = 14.0 let sideInset: CGFloat = 16.0 var height: CGFloat = topInset * 2.0 let leftInset = params.leftInset - let rightInset: CGFloat = params.rightInset + let rightInset = params.rightInset var updatedTheme: PresentationTheme? if currentItem?.presentationData.theme !== item.presentationData.theme { @@ -167,7 +166,7 @@ class MessageStatsOverviewItemNode: ListViewItemNode { centerValueLabelLayoutAndApply = makeCenterValueLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.publicShares.flatMap { compactNumericCountString(Int($0)) } ?? "–", font: valueFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) - rightValueLabelLayoutAndApply = makeRightValueLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.publicShares.flatMap { "≈\( compactNumericCountString(item.stats.privateForwards - Int($0)))" } ?? "–", font: valueFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) + rightValueLabelLayoutAndApply = makeRightValueLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.publicShares.flatMap { "≈\( compactNumericCountString(item.stats.forwards - Int($0)))" } ?? "–", font: valueFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) leftTitleLabelLayoutAndApply = makeLeftTitleLabelLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: "Views", font: titleFont, textColor: item.presentationData.theme.list.sectionHeaderTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) @@ -252,7 +251,13 @@ class MessageStatsOverviewItemNode: ListViewItemNode { strongSelf.bottomStripeNode.frame = CGRect(origin: CGPoint(x: bottomStripeInset, y: contentSize.height - separatorHeight), size: CGSize(width: params.width - bottomStripeInset, height: separatorHeight)) } - var x: CGFloat = sideInset + leftInset + let maxLeftWidth = max(leftValueLabelLayoutAndApply?.0.size.width ?? 0.0, leftTitleLabelLayoutAndApply?.0.size.width ?? 0.0) + let maxCenterWidth = max(centerValueLabelLayoutAndApply?.0.size.width ?? 0.0, centerTitleLabelLayoutAndApply?.0.size.width ?? 0.0) + let maxRightWidth = max(rightValueLabelLayoutAndApply?.0.size.width ?? 0.0, rightTitleLabelLayoutAndApply?.0.size.width ?? 0.0) + + let horizontalSpacing = min(60, (params.width - leftInset - rightInset - sideInset * 2.0 - maxLeftWidth - maxCenterWidth - maxRightWidth) / 2.0) + + var x: CGFloat = leftInset + (params.width - maxLeftWidth - maxCenterWidth - maxRightWidth - horizontalSpacing * 2.0) / 2.0 if let leftValueLabelLayout = leftValueLabelLayoutAndApply?.0, let leftTitleLabelLayout = leftTitleLabelLayoutAndApply?.0 { strongSelf.leftValueLabel.frame = CGRect(origin: CGPoint(x: x, y: topInset), size: leftValueLabelLayout.size) strongSelf.leftTitleLabel.frame = CGRect(origin: CGPoint(x: x, y: strongSelf.leftValueLabel.frame.maxY), size: leftTitleLabelLayout.size) diff --git a/submodules/TelegramCore/Sources/MessageStatistics.swift b/submodules/TelegramCore/Sources/MessageStatistics.swift index 0a78c22484..d1a261a9ad 100644 --- a/submodules/TelegramCore/Sources/MessageStatistics.swift +++ b/submodules/TelegramCore/Sources/MessageStatistics.swift @@ -5,18 +5,14 @@ import TelegramApi import MtProtoKit import SyncCore -//stats.getMessagePublicForwards channel:InputChannel msg_id:int offset_rate:int offset_peer:InputPeer offset_id:int limit:int = messages.Messages; - public struct MessageStats: Equatable { public let views: Int - public let publicForwards: Int - public let privateForwards: Int + public let forwards: Int public let interactionsGraph: StatsGraph - init(views: Int, publicForwards: Int, privateForwards: Int, interactionsGraph: StatsGraph) { + init(views: Int, forwards: Int, interactionsGraph: StatsGraph) { self.views = views - self.publicForwards = publicForwards - self.privateForwards = privateForwards + self.forwards = forwards self.interactionsGraph = interactionsGraph } @@ -24,10 +20,7 @@ public struct MessageStats: Equatable { if lhs.views != rhs.views { return false } - if lhs.publicForwards != rhs.publicForwards { - return false - } - if lhs.privateForwards != rhs.privateForwards { + if lhs.forwards != rhs.forwards { return false } if lhs.interactionsGraph != rhs.interactionsGraph { @@ -37,7 +30,7 @@ public struct MessageStats: Equatable { } public func withUpdatedInteractionsGraph(_ interactionsGraph: StatsGraph) -> MessageStats { - return MessageStats(views: self.views, publicForwards: self.publicForwards, privateForwards: self.privateForwards, interactionsGraph: self.interactionsGraph) + return MessageStats(views: self.views, forwards: self.forwards, interactionsGraph: self.interactionsGraph) } } @@ -87,7 +80,7 @@ private func requestMessageStats(postbox: Postbox, network: Network, datacenterI return signal |> map { result -> MessageStats? in if case let .messageStats(apiViewsGraph) = result { - return MessageStats(views: views, publicForwards: forwards, privateForwards: forwards, interactionsGraph: StatsGraph(apiStatsGraph: apiViewsGraph)) + return MessageStats(views: views, forwards: forwards, interactionsGraph: StatsGraph(apiStatsGraph: apiViewsGraph)) } else { return nil }