Various fixes

This commit is contained in:
Ilya Laktyushin 2023-11-23 00:06:05 +04:00
parent 19d88aafcc
commit 2479b79da2
5 changed files with 29 additions and 18 deletions

View File

@ -147,12 +147,16 @@ public final class ChartNode: ASDisplayNode {
self.chartView.apply(theme: theme, strings: strings, animated: false) self.chartView.apply(theme: theme, strings: strings, animated: false)
} }
public func setup(controller: BaseChartController) { public func setup(controller: BaseChartController, noInitialZoom: Bool = false) {
var displayRange = true var displayRange = true
var zoomToEnding = true
if let controller = controller as? StepBarsChartController { if let controller = controller as? StepBarsChartController {
displayRange = !controller.hourly displayRange = !controller.hourly
} }
self.chartView.setup(controller: controller, displayRange: displayRange) if noInitialZoom {
zoomToEnding = false
}
self.chartView.setup(controller: controller, displayRange: displayRange, zoomToEnding: zoomToEnding)
} }
public func resetInteraction() { public func resetInteraction() {

View File

@ -181,7 +181,7 @@ class ChartStackSection: UIView, ChartThemeContainer {
self.chartView.setNeedsDisplay() self.chartView.setNeedsDisplay()
} }
func setup(controller: BaseChartController, displayRange: Bool = true) { func setup(controller: BaseChartController, displayRange: Bool = true, zoomToEnding: Bool = true) {
self.controller = controller self.controller = controller
self.displayRange = displayRange self.displayRange = displayRange
@ -246,7 +246,7 @@ class ChartStackSection: UIView, ChartThemeContainer {
controller.initializeChart() controller.initializeChart()
updateToolViews(animated: false) updateToolViews(animated: false)
let range: ClosedRange<CGFloat> = displayRange ? 0.8 ... 1.0 : 0.0 ... 1.0 let range: ClosedRange<CGFloat> = displayRange && zoomToEnding ? 0.8 ... 1.0 : 0.0 ... 1.0
rangeView.setRange(range, animated: false) rangeView.setRange(range, animated: false)
controller.updateChartRange(range, animated: false) controller.updateChartRange(range, animated: false)

View File

@ -39,10 +39,10 @@ private enum StatsEntry: ItemListNodeEntry {
case overview(PresentationTheme, PostStats, Int32?) case overview(PresentationTheme, PostStats, Int32?)
case interactionsTitle(PresentationTheme, String) case interactionsTitle(PresentationTheme, String)
case interactionsGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType) case interactionsGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType, Bool)
case reactionsTitle(PresentationTheme, String) case reactionsTitle(PresentationTheme, String)
case reactionsGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType) case reactionsGraph(PresentationTheme, PresentationStrings, PresentationDateTimeFormat, StatsGraph, ChartType, Bool)
case publicForwardsTitle(PresentationTheme, String) case publicForwardsTitle(PresentationTheme, String)
case publicForward(Int32, PresentationTheme, PresentationStrings, PresentationDateTimeFormat, EngineMessage) case publicForward(Int32, PresentationTheme, PresentationStrings, PresentationDateTimeFormat, EngineMessage)
@ -53,7 +53,7 @@ private enum StatsEntry: ItemListNodeEntry {
return StatsSection.overview.rawValue return StatsSection.overview.rawValue
case .interactionsTitle, .interactionsGraph: case .interactionsTitle, .interactionsGraph:
return StatsSection.interactions.rawValue return StatsSection.interactions.rawValue
case .reactionsTitle, .reactionsGraph: case .reactionsTitle, .reactionsGraph:
return StatsSection.reactions.rawValue return StatsSection.reactions.rawValue
case .publicForwardsTitle, .publicForward: case .publicForwardsTitle, .publicForward:
return StatsSection.publicForwards.rawValue return StatsSection.publicForwards.rawValue
@ -107,8 +107,8 @@ private enum StatsEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
case let .interactionsGraph(lhsTheme, lhsStrings, lhsDateTimeFormat, lhsGraph, lhsType): case let .interactionsGraph(lhsTheme, lhsStrings, lhsDateTimeFormat, lhsGraph, lhsType, lhsNoInitialZoom):
if case let .interactionsGraph(rhsTheme, rhsStrings, rhsDateTimeFormat, rhsGraph, rhsType) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsGraph == rhsGraph, lhsType == rhsType { if case let .interactionsGraph(rhsTheme, rhsStrings, rhsDateTimeFormat, rhsGraph, rhsType, rhsNoInitialZoom) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsGraph == rhsGraph, lhsType == rhsType, lhsNoInitialZoom == rhsNoInitialZoom {
return true return true
} else { } else {
return false return false
@ -119,8 +119,8 @@ private enum StatsEntry: ItemListNodeEntry {
} else { } else {
return false return false
} }
case let .reactionsGraph(lhsTheme, lhsStrings, lhsDateTimeFormat, lhsGraph, lhsType): case let .reactionsGraph(lhsTheme, lhsStrings, lhsDateTimeFormat, lhsGraph, lhsType, lhsNoInitialZoom):
if case let .reactionsGraph(rhsTheme, rhsStrings, rhsDateTimeFormat, rhsGraph, rhsType) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsGraph == rhsGraph, lhsType == rhsType { if case let .reactionsGraph(rhsTheme, rhsStrings, rhsDateTimeFormat, rhsGraph, rhsType, rhsNoInitialZoom) = rhs, lhsTheme === rhsTheme, lhsStrings === rhsStrings, lhsDateTimeFormat == rhsDateTimeFormat, lhsGraph == rhsGraph, lhsType == rhsType, lhsNoInitialZoom == rhsNoInitialZoom {
return true return true
} else { } else {
return false return false
@ -154,8 +154,8 @@ private enum StatsEntry: ItemListNodeEntry {
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section) return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
case let .overview(_, stats, publicShares): case let .overview(_, stats, publicShares):
return StatsOverviewItem(presentationData: presentationData, stats: stats as! Stats, publicShares: publicShares, sectionId: self.section, style: .blocks) return StatsOverviewItem(presentationData: presentationData, stats: stats as! Stats, publicShares: publicShares, sectionId: self.section, style: .blocks)
case let .interactionsGraph(_, _, _, graph, type), let .reactionsGraph(_, _, _, graph, type): case let .interactionsGraph(_, _, _, graph, type, noInitialZoom), let .reactionsGraph(_, _, _, graph, type, noInitialZoom):
return StatsGraphItem(presentationData: presentationData, graph: graph, type: type, getDetailsData: { date, completion in return StatsGraphItem(presentationData: presentationData, graph: graph, type: type, noInitialZoom: noInitialZoom, getDetailsData: { date, completion in
let _ = arguments.loadDetailedGraph(graph, Int64(date.timeIntervalSince1970) * 1000).start(next: { graph in let _ = arguments.loadDetailedGraph(graph, Int64(date.timeIntervalSince1970) * 1000).start(next: { graph in
if let graph = graph, case let .Loaded(_, data) = graph { if let graph = graph, case let .Loaded(_, data) = graph {
completion(data) completion(data)
@ -185,6 +185,11 @@ private func messageStatsControllerEntries(data: PostStats?, messages: SearchMes
if let data = data { if let data = data {
entries.append(.overviewTitle(presentationData.theme, presentationData.strings.Stats_MessageOverview.uppercased())) entries.append(.overviewTitle(presentationData.theme, presentationData.strings.Stats_MessageOverview.uppercased()))
entries.append(.overview(presentationData.theme, data, messages?.totalCount)) entries.append(.overview(presentationData.theme, data, messages?.totalCount))
var isStories = false
if let _ = data as? StoryStats {
isStories = true
}
if !data.interactionsGraph.isEmpty { if !data.interactionsGraph.isEmpty {
entries.append(.interactionsTitle(presentationData.theme, presentationData.strings.Stats_MessageInteractionsTitle.uppercased())) entries.append(.interactionsTitle(presentationData.theme, presentationData.strings.Stats_MessageInteractionsTitle.uppercased()))
@ -198,12 +203,12 @@ private func messageStatsControllerEntries(data: PostStats?, messages: SearchMes
chartType = .twoAxisStep chartType = .twoAxisStep
} }
entries.append(.interactionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.interactionsGraph, chartType)) entries.append(.interactionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.interactionsGraph, chartType, isStories))
} }
if !data.reactionsGraph.isEmpty { if !data.reactionsGraph.isEmpty {
entries.append(.reactionsTitle(presentationData.theme, presentationData.strings.Stats_MessageReactionsTitle.uppercased())) entries.append(.reactionsTitle(presentationData.theme, presentationData.strings.Stats_MessageReactionsTitle.uppercased()))
entries.append(.reactionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.reactionsGraph, .bars)) entries.append(.reactionsGraph(presentationData.theme, presentationData.strings, presentationData.dateTimeFormat, data.reactionsGraph, .bars, isStories))
} }
if let messages = messages, !messages.messages.isEmpty { if let messages = messages, !messages.messages.isEmpty {

View File

@ -15,14 +15,16 @@ class StatsGraphItem: ListViewItem, ItemListItem {
let presentationData: ItemListPresentationData let presentationData: ItemListPresentationData
let graph: StatsGraph let graph: StatsGraph
let type: ChartType let type: ChartType
let noInitialZoom: Bool
let getDetailsData: ((Date, @escaping (String?) -> Void) -> Void)? let getDetailsData: ((Date, @escaping (String?) -> Void) -> Void)?
let sectionId: ItemListSectionId let sectionId: ItemListSectionId
let style: ItemListStyle let style: ItemListStyle
init(presentationData: ItemListPresentationData, graph: StatsGraph, type: ChartType, getDetailsData: ((Date, @escaping (String?) -> Void) -> Void)? = nil, sectionId: ItemListSectionId, style: ItemListStyle) { init(presentationData: ItemListPresentationData, graph: StatsGraph, type: ChartType, noInitialZoom: Bool = false, getDetailsData: ((Date, @escaping (String?) -> Void) -> Void)? = nil, sectionId: ItemListSectionId, style: ItemListStyle) {
self.presentationData = presentationData self.presentationData = presentationData
self.graph = graph self.graph = graph
self.type = type self.type = type
self.noInitialZoom = noInitialZoom
self.getDetailsData = getDetailsData self.getDetailsData = getDetailsData
self.sectionId = sectionId self.sectionId = sectionId
self.style = style self.style = style
@ -266,7 +268,7 @@ class StatsGraphItemNode: ListViewItemNode {
if let updatedGraph = updatedGraph { if let updatedGraph = updatedGraph {
if case .Loaded = updatedGraph, let updatedController = updatedController { if case .Loaded = updatedGraph, let updatedController = updatedController {
strongSelf.chartNode.setup(controller: updatedController) strongSelf.chartNode.setup(controller: updatedController, noInitialZoom: item.noInitialZoom)
strongSelf.activityIndicator.isHidden = true strongSelf.activityIndicator.isHidden = true
strongSelf.chartNode.isHidden = false strongSelf.chartNode.isHidden = false
} else if case .OnDemand = updatedGraph { } else if case .OnDemand = updatedGraph {

View File

@ -612,7 +612,7 @@ private final class ChannelItemComponent: Component {
maximumNumberOfLines: 2 maximumNumberOfLines: 2
)), )),
environment: {}, environment: {},
containerSize: CGSize(width: itemSize.width - 16.0, height: 100.0) containerSize: CGSize(width: itemSize.width - 9.0, height: 100.0)
) )
let subtitleSize = self.subtitle.update( let subtitleSize = self.subtitle.update(