mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 22:55:00 +00:00
Improve charts theming
This commit is contained in:
@@ -19,10 +19,7 @@ public enum ChartType {
|
||||
|
||||
public extension ChartTheme {
|
||||
convenience init(presentationTheme: PresentationTheme) {
|
||||
let tableBackgroundColor = UIColor(rgb: 0xefeff4)
|
||||
let rangeViewTintColor = UIColor(rgb: 0xefeff4)
|
||||
|
||||
self.init(chartTitleColor: presentationTheme.list.itemPrimaryTextColor, actionButtonColor: presentationTheme.list.itemAccentColor, tableBackgroundColor: tableBackgroundColor, chartBackgroundColor: presentationTheme.list.itemBlocksBackgroundColor, tableSeparatorColor: presentationTheme.list.itemSecondaryTextColor, chartLabelsColor: presentationTheme.list.itemSecondaryTextColor, chartHelperLinesColor: presentationTheme.list.itemSecondaryTextColor, chartStrongLinesColor: presentationTheme.list.itemSecondaryTextColor, barChartStrongLinesColor: presentationTheme.list.itemSecondaryTextColor, chartDetailsTextColor: presentationTheme.list.itemSecondaryTextColor, chartDetailsArrowColor: presentationTheme.list.itemSecondaryTextColor, chartDetailsViewColor: presentationTheme.list.itemSecondaryTextColor, descriptionActionColor: presentationTheme.list.itemSecondaryTextColor, rangeViewFrameColor: presentationTheme.list.itemSecondaryTextColor, rangeViewTintColor: rangeViewTintColor, rangeViewMarkerColor: UIColor.white)
|
||||
self.init(chartTitleColor: presentationTheme.list.itemPrimaryTextColor, actionButtonColor: presentationTheme.list.itemAccentColor, chartBackgroundColor: presentationTheme.list.itemBlocksBackgroundColor, chartLabelsColor: presentationTheme.chart.labelsColor, chartHelperLinesColor: presentationTheme.chart.helperLinesColor, chartStrongLinesColor: presentationTheme.chart.strongLinesColor, barChartStrongLinesColor: presentationTheme.chart.barStrongLinesColor, chartDetailsTextColor: presentationTheme.chart.detailsTextColor, chartDetailsArrowColor: presentationTheme.chart.detailsArrowColor, chartDetailsViewColor: presentationTheme.chart.detailsViewColor, rangeViewFrameColor: presentationTheme.chart.rangeViewFrameColor, rangeViewTintColor: presentationTheme.list.blocksBackgroundColor.withAlphaComponent(0.5), rangeViewMarkerColor: presentationTheme.chart.rangeViewMarkerColor)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +85,7 @@ public final class ChartNode: ASDisplayNode {
|
||||
}
|
||||
|
||||
public func setupTheme(_ theme: ChartTheme) {
|
||||
self.chartView.apply(theme: ChartTheme.defaultDayTheme, animated: false)
|
||||
self.chartView.apply(theme: theme, animated: false)
|
||||
}
|
||||
|
||||
public func setup(controller: BaseChartController) {
|
||||
|
||||
@@ -27,7 +27,6 @@ class ChartStackSection: UIView, ChartThemeContainer {
|
||||
var rangeView: RangeChartView
|
||||
var visibilityView: ChartVisibilityView
|
||||
var sectionContainerView: UIView
|
||||
var separators: [UIView] = []
|
||||
|
||||
var titleLabel: UILabel!
|
||||
var backButton: UIButton!
|
||||
@@ -87,19 +86,13 @@ class ChartStackSection: UIView, ChartThemeContainer {
|
||||
func apply(theme: ChartTheme, animated: Bool) {
|
||||
self.theme = theme
|
||||
|
||||
UIView.perform(animated: animated && self.isVisibleInWindow) {
|
||||
self.backgroundColor = theme.tableBackgroundColor
|
||||
|
||||
UIView.perform(animated: animated && self.isVisibleInWindow) {
|
||||
self.sectionContainerView.backgroundColor = theme.chartBackgroundColor
|
||||
self.rangeView.backgroundColor = theme.chartBackgroundColor
|
||||
self.visibilityView.backgroundColor = theme.chartBackgroundColor
|
||||
|
||||
self.backButton.tintColor = theme.actionButtonColor
|
||||
self.backButton.setTitleColor(theme.actionButtonColor, for: .normal)
|
||||
|
||||
for separator in self.separators {
|
||||
separator.backgroundColor = theme.tableSeparatorColor
|
||||
}
|
||||
}
|
||||
|
||||
if rangeView.isVisibleInWindow || chartView.isVisibleInWindow {
|
||||
|
||||
@@ -152,7 +152,6 @@ extension ChartVisibilityView: ChartThemeContainer {
|
||||
func apply(theme: ChartTheme, animated: Bool) {
|
||||
UIView.perform(animated: animated) {
|
||||
self.backgroundColor = theme.chartBackgroundColor
|
||||
self.tintColor = theme.descriptionActionColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ private extension RangeChartView {
|
||||
|
||||
extension RangeChartView: ChartThemeContainer {
|
||||
func apply(theme: ChartTheme, animated: Bool) {
|
||||
let colusre = {
|
||||
let closure = {
|
||||
self.lowerBoundTintView.backgroundColor = theme.rangeViewTintColor
|
||||
self.upperBoundTintView.backgroundColor = theme.rangeViewTintColor
|
||||
}
|
||||
@@ -321,9 +321,9 @@ extension RangeChartView: ChartThemeContainer {
|
||||
self.cropFrameView.setImage(image, animated: animated)
|
||||
|
||||
if animated {
|
||||
UIView.animate(withDuration: .defaultDuration, animations: colusre)
|
||||
UIView.animate(withDuration: .defaultDuration, animations: closure)
|
||||
} else {
|
||||
colusre()
|
||||
closure()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user