Channel Statistics

This commit is contained in:
Ilya Laktyushin
2020-02-24 18:14:51 +04:00
parent c02450ce88
commit df97d36211
27 changed files with 3890 additions and 3941 deletions

View File

@@ -12,14 +12,12 @@ import Charts
class StatsGraphItem: ListViewItem, ItemListItem {
let presentationData: ItemListPresentationData
let title: String
let graph: ChannelStatsGraph
let sectionId: ItemListSectionId
let style: ItemListStyle
init(presentationData: ItemListPresentationData, title: String, graph: ChannelStatsGraph, sectionId: ItemListSectionId, style: ItemListStyle) {
init(presentationData: ItemListPresentationData, graph: ChannelStatsGraph, sectionId: ItemListSectionId, style: ItemListStyle) {
self.presentationData = presentationData
self.title = title
self.graph = graph
self.sectionId = sectionId
self.style = style
@@ -117,12 +115,12 @@ class StatsGraphItemNode: ListViewItemNode {
case .plain:
itemBackgroundColor = item.presentationData.theme.list.plainBackgroundColor
itemSeparatorColor = item.presentationData.theme.list.itemPlainSeparatorColor
contentSize = CGSize(width: params.width, height: 320.0)
contentSize = CGSize(width: params.width, height: 340.0)
insets = itemListNeighborsPlainInsets(neighbors)
case .blocks:
itemBackgroundColor = item.presentationData.theme.list.itemBlocksBackgroundColor
itemSeparatorColor = item.presentationData.theme.list.itemBlocksSeparatorColor
contentSize = CGSize(width: params.width, height: 320.0)
contentSize = CGSize(width: params.width, height: 340.0)
insets = itemListNeighborsGroupedInsets(neighbors)
}
@@ -137,11 +135,7 @@ class StatsGraphItemNode: ListViewItemNode {
strongSelf.bottomStripeNode.backgroundColor = itemSeparatorColor
strongSelf.backgroundNode.backgroundColor = itemBackgroundColor
}
if let updatedGraph = updatedGraph, case let .Loaded(data) = updatedGraph {
strongSelf.chartNode.setup(data)
}
switch item.style {
case .plain:
if strongSelf.backgroundNode.supernode != nil {
@@ -179,12 +173,17 @@ class StatsGraphItemNode: ListViewItemNode {
bottomStripeInset = 0.0
}
strongSelf.chartNode.frame = CGRect(origin: CGPoint(x: leftInset, y: -30.0), size: CGSize(width: layout.size.width - leftInset - rightInset, height: 350.0))
strongSelf.chartNode.frame = CGRect(origin: CGPoint(x: leftInset, y: -10.0), size: CGSize(width: layout.size.width - leftInset - rightInset, height: 350.0))
strongSelf.backgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: params.width, height: contentSize.height + min(insets.top, separatorHeight) + min(insets.bottom, separatorHeight)))
strongSelf.topStripeNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -min(insets.top, separatorHeight)), size: CGSize(width: params.width, height: separatorHeight))
strongSelf.bottomStripeNode.frame = CGRect(origin: CGPoint(x: bottomStripeInset, y: contentSize.height - separatorHeight), size: CGSize(width: params.width - bottomStripeInset, height: separatorHeight))
}
if let updatedGraph = updatedGraph, case let .Loaded(data) = updatedGraph {
var data = data.replacingOccurrences(of: "step", with: "bar")
strongSelf.chartNode.setup(data)
}
}
})
}