mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 01:10:09 +00:00
Improve message stats overview block layout
This commit is contained in:
parent
75a707c439
commit
1ccb78dc77
@ -127,14 +127,13 @@ class MessageStatsOverviewItemNode: ListViewItemNode {
|
|||||||
let itemBackgroundColor: UIColor
|
let itemBackgroundColor: UIColor
|
||||||
let itemSeparatorColor: UIColor
|
let itemSeparatorColor: UIColor
|
||||||
|
|
||||||
let horizontalSpacing: CGFloat = 62.0
|
|
||||||
let topInset: CGFloat = 14.0
|
let topInset: CGFloat = 14.0
|
||||||
let sideInset: CGFloat = 16.0
|
let sideInset: CGFloat = 16.0
|
||||||
|
|
||||||
var height: CGFloat = topInset * 2.0
|
var height: CGFloat = topInset * 2.0
|
||||||
|
|
||||||
let leftInset = params.leftInset
|
let leftInset = params.leftInset
|
||||||
let rightInset: CGFloat = params.rightInset
|
let rightInset = params.rightInset
|
||||||
var updatedTheme: PresentationTheme?
|
var updatedTheme: PresentationTheme?
|
||||||
|
|
||||||
if currentItem?.presentationData.theme !== item.presentationData.theme {
|
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()))
|
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()))
|
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))
|
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 {
|
if let leftValueLabelLayout = leftValueLabelLayoutAndApply?.0, let leftTitleLabelLayout = leftTitleLabelLayoutAndApply?.0 {
|
||||||
strongSelf.leftValueLabel.frame = CGRect(origin: CGPoint(x: x, y: topInset), size: leftValueLabelLayout.size)
|
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)
|
strongSelf.leftTitleLabel.frame = CGRect(origin: CGPoint(x: x, y: strongSelf.leftValueLabel.frame.maxY), size: leftTitleLabelLayout.size)
|
||||||
|
|||||||
@ -5,18 +5,14 @@ import TelegramApi
|
|||||||
import MtProtoKit
|
import MtProtoKit
|
||||||
import SyncCore
|
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 struct MessageStats: Equatable {
|
||||||
public let views: Int
|
public let views: Int
|
||||||
public let publicForwards: Int
|
public let forwards: Int
|
||||||
public let privateForwards: Int
|
|
||||||
public let interactionsGraph: StatsGraph
|
public let interactionsGraph: StatsGraph
|
||||||
|
|
||||||
init(views: Int, publicForwards: Int, privateForwards: Int, interactionsGraph: StatsGraph) {
|
init(views: Int, forwards: Int, interactionsGraph: StatsGraph) {
|
||||||
self.views = views
|
self.views = views
|
||||||
self.publicForwards = publicForwards
|
self.forwards = forwards
|
||||||
self.privateForwards = privateForwards
|
|
||||||
self.interactionsGraph = interactionsGraph
|
self.interactionsGraph = interactionsGraph
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,10 +20,7 @@ public struct MessageStats: Equatable {
|
|||||||
if lhs.views != rhs.views {
|
if lhs.views != rhs.views {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lhs.publicForwards != rhs.publicForwards {
|
if lhs.forwards != rhs.forwards {
|
||||||
return false
|
|
||||||
}
|
|
||||||
if lhs.privateForwards != rhs.privateForwards {
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if lhs.interactionsGraph != rhs.interactionsGraph {
|
if lhs.interactionsGraph != rhs.interactionsGraph {
|
||||||
@ -37,7 +30,7 @@ public struct MessageStats: Equatable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func withUpdatedInteractionsGraph(_ interactionsGraph: StatsGraph) -> MessageStats {
|
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
|
return signal
|
||||||
|> map { result -> MessageStats? in
|
|> map { result -> MessageStats? in
|
||||||
if case let .messageStats(apiViewsGraph) = result {
|
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 {
|
} else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user