Charts improvements

This commit is contained in:
Ilya Laktyushin
2020-03-14 00:46:32 +04:00
parent 598f270635
commit bcae054398
33 changed files with 461 additions and 339 deletions

View File

@@ -22,7 +22,7 @@ private class LeftAlignedIconButton: UIButton {
}
}
class ChartStackSection: UIView, GColorModeContainer {
class ChartStackSection: UIView, ChartThemeContainer {
var chartView: ChartView
var rangeView: RangeChartView
var visibilityView: ChartVisibilityView
@@ -81,37 +81,37 @@ class ChartStackSection: UIView, GColorModeContainer {
backButton.setVisible(false, animated: false)
}
func apply(colorMode: GColorMode, animated: Bool) {
func apply(theme: ChartTheme, animated: Bool) {
UIView.perform(animated: animated && self.isVisibleInWindow) {
self.backgroundColor = colorMode.tableBackgroundColor
self.backgroundColor = theme.tableBackgroundColor
self.sectionContainerView.backgroundColor = colorMode.chartBackgroundColor
self.rangeView.backgroundColor = colorMode.chartBackgroundColor
self.visibilityView.backgroundColor = colorMode.chartBackgroundColor
self.sectionContainerView.backgroundColor = theme.chartBackgroundColor
self.rangeView.backgroundColor = theme.chartBackgroundColor
self.visibilityView.backgroundColor = theme.chartBackgroundColor
self.backButton.tintColor = colorMode.actionButtonColor
self.backButton.setTitleColor(colorMode.actionButtonColor, for: .normal)
self.backButton.tintColor = theme.actionButtonColor
self.backButton.setTitleColor(theme.actionButtonColor, for: .normal)
for separator in self.separators {
separator.backgroundColor = colorMode.tableSeparatorColor
separator.backgroundColor = theme.tableSeparatorColor
}
}
if rangeView.isVisibleInWindow || chartView.isVisibleInWindow {
chartView.loadDetailsViewIfNeeded()
chartView.apply(colorMode: colorMode, animated: animated && chartView.isVisibleInWindow)
controller.apply(colorMode: colorMode, animated: animated)
rangeView.apply(colorMode: colorMode, animated: animated && rangeView.isVisibleInWindow)
chartView.apply(theme: theme, animated: animated && chartView.isVisibleInWindow)
controller.apply(theme: theme, animated: animated)
rangeView.apply(theme: theme, animated: animated && rangeView.isVisibleInWindow)
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + TimeInterval.random(in: 0...0.1)) {
self.chartView.loadDetailsViewIfNeeded()
self.controller.apply(colorMode: colorMode, animated: false)
self.chartView.apply(colorMode: colorMode, animated: false)
self.rangeView.apply(colorMode: colorMode, animated: false)
self.controller.apply(theme: theme, animated: false)
self.chartView.apply(theme: theme, animated: false)
self.rangeView.apply(theme: theme, animated: false)
}
}
self.titleLabel.setTextColor(colorMode.chartTitleColor, animated: animated && titleLabel.isVisibleInWindow)
self.titleLabel.setTextColor(theme.chartTitleColor, animated: animated && titleLabel.isVisibleInWindow)
}
@objc private func didTapBackButton() {
@@ -147,10 +147,10 @@ class ChartStackSection: UIView, GColorModeContainer {
let bounds = self.bounds
self.titleLabel.frame = CGRect(origin: CGPoint(x: backButton.alpha > 0.0 ? 36.0 : 0.0, y: 5.0), size: CGSize(width: bounds.width, height: 28.0))
self.sectionContainerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: bounds.width, height: 400.0))
self.sectionContainerView.frame = CGRect(origin: CGPoint(), size: CGSize(width: bounds.width, height: 750.0))
self.chartView.frame = CGRect(origin: CGPoint(), size: CGSize(width: bounds.width, height: 250.0))
self.rangeView.frame = CGRect(origin: CGPoint(x: 0.0, y: 250.0), size: CGSize(width: bounds.width, height: 42.0))
self.visibilityView.frame = CGRect(origin: CGPoint(x: 0.0, y: 308.0), size: CGSize(width: bounds.width, height: 222.0))
self.visibilityView.frame = CGRect(origin: CGPoint(x: 0.0, y: 308.0), size: CGSize(width: bounds.width, height: 350.0))
self.backButton.frame = CGRect(x: 0.0, y: 0.0, width: 96.0, height: 38.0)
}
@@ -214,9 +214,9 @@ class ChartStackSection: UIView, GColorModeContainer {
controller.initializeChart()
updateToolViews(animated: false)
// rangeView.setRange(0.8...1.0, animated: false)
rangeView.setRange(0.8...1.0, animated: false)
// TimeInterval.animationDurationMultipler = 0.00001
// controller.updateChartRange(0.8...1.0)
controller.updateChartRange(0.8...1.0, animated: false)
// TimeInterval.animationDurationMultipler = 1.0
}
}