mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Merge branch 'master' of gitlab.com:peter-iakovlev/telegram-ios
This commit is contained in:
@@ -13,14 +13,21 @@ import Cocoa
|
||||
import UIKit
|
||||
#endif
|
||||
|
||||
struct ChartVisibilityItem {
|
||||
var title: String
|
||||
var color: GColor
|
||||
|
||||
static func generateItemsFrames(for chartWidth: CGFloat, items: [ChartVisibilityItem]) -> [CGRect] {
|
||||
public struct ChartVisibilityItem {
|
||||
public var title: String
|
||||
public var color: GColor
|
||||
public init(title: String, color: GColor) {
|
||||
self.title = title
|
||||
self.color = color
|
||||
}
|
||||
public static func generateItemsFrames(for chartWidth: CGFloat, items: [ChartVisibilityItem]) -> [CGRect] {
|
||||
|
||||
if items.count == 1 {
|
||||
return []
|
||||
}
|
||||
|
||||
var previousPoint = CGPoint(x: ChatVisibilityItemConstants.insets.left, y: ChatVisibilityItemConstants.insets.top)
|
||||
var frames: [CGRect] = []
|
||||
|
||||
for item in items {
|
||||
let labelSize = textSize(with: item.title, font: ChatVisibilityItemConstants.textFont)
|
||||
let width = (labelSize.width + ChatVisibilityItemConstants.labelTextApproxInsets).rounded(.up)
|
||||
@@ -35,7 +42,7 @@ struct ChartVisibilityItem {
|
||||
}
|
||||
previousPoint.x += width + ChatVisibilityItemConstants.itemSpacing
|
||||
}
|
||||
|
||||
|
||||
return frames
|
||||
}
|
||||
|
||||
|
||||
@@ -128,6 +128,7 @@ public class BaseChartController: ChartThemeContainer {
|
||||
return ChartVisibilityItem(title: value.name, color: value.color)
|
||||
}
|
||||
let frames = ChartVisibilityItem.generateItemsFrames(for: width, items: items)
|
||||
|
||||
guard let lastFrame = frames.last else { return height }
|
||||
|
||||
height += lastFrame.maxY
|
||||
|
||||
@@ -15,11 +15,11 @@ import UIKit
|
||||
|
||||
class ChartDetailsRenderer: BaseChartRenderer, ChartThemeContainer {
|
||||
private lazy var colorAnimator = AnimationController<CGFloat>(current: 1, refreshClosure: refreshClosure)
|
||||
private var fromColorMode: ChartTheme = ChartTheme.defaultDayTheme
|
||||
private var currentColorMode: ChartTheme = ChartTheme.defaultDayTheme
|
||||
private var fromTheme: ChartTheme = ChartTheme.defaultDayTheme
|
||||
private var currentTheme: ChartTheme = ChartTheme.defaultDayTheme
|
||||
func apply(theme: ChartTheme, animated: Bool) {
|
||||
fromColorMode = currentColorMode
|
||||
currentColorMode = theme
|
||||
fromTheme = currentTheme
|
||||
currentTheme = theme
|
||||
colorAnimator.set(current: 1)
|
||||
}
|
||||
|
||||
@@ -91,11 +91,11 @@ class ChartDetailsRenderer: BaseChartRenderer, ChartThemeContainer {
|
||||
|
||||
let totalWidth: CGFloat = max(prefixesWidth + labelsWidth + valuesWidth, titleWidth + iconWidth) + margins * 2
|
||||
let totalHeight: CGFloat = CGFloat(detailsViewModel.values.count + 1) * rowHeight + margins * 2
|
||||
let backgroundColor = GColor.valueBetween(start: fromColorMode.chartDetailsViewColor,
|
||||
end: currentColorMode.chartDetailsViewColor,
|
||||
let backgroundColor = GColor.valueBetween(start: fromTheme.chartDetailsViewColor,
|
||||
end: currentTheme.chartDetailsViewColor,
|
||||
offset: Double(colorAnimator.current))
|
||||
let titleAndTextColor = GColor.valueBetween(start: fromColorMode.chartDetailsTextColor,
|
||||
end: currentColorMode.chartDetailsTextColor,
|
||||
let titleAndTextColor = GColor.valueBetween(start: fromTheme.chartDetailsTextColor,
|
||||
end: currentTheme.chartDetailsTextColor,
|
||||
offset: Double(colorAnimator.current))
|
||||
let detailsViewFrame: CGRect
|
||||
if totalWidth + detailViewTopOffset > detailsViewPosition {
|
||||
|
||||
@@ -26,11 +26,13 @@ extension NSAttributedString {
|
||||
}
|
||||
|
||||
func textSize(with string: String, font: NSFont) -> CGSize {
|
||||
|
||||
let attributedString:NSAttributedString = NSAttributedString(string: string, attributes: [.font : font])
|
||||
let layout = LabelNode.layoutText(attributedString, CGSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude))
|
||||
var size:CGSize = layout.0.size
|
||||
size.width = ceil(size.width)
|
||||
size.height = ceil(size.height)
|
||||
|
||||
return size
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// colorMode.swift
|
||||
// theme.swift
|
||||
// GraphTest
|
||||
//
|
||||
// Created by Andrew Solovey on 15/03/2019.
|
||||
@@ -66,6 +66,9 @@ public class ChartTheme {
|
||||
|
||||
public static var defaultDayTheme = ChartTheme(chartTitleColor: GColor.black, actionButtonColor: GColor(red: 53/255.0, green: 120/255.0, blue: 246/255.0, alpha: 1.0), tableBackgroundColor: GColor(red: 239/255.0, green: 239/255.0, blue: 244/255.0, alpha: 1.0), chartBackgroundColor: GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0), tableSeparatorColor: GColor(red: 200/255.0, green: 199/255.0, blue: 204/255.0, alpha: 1.0), chartLabelsColor: GColor(red: 37/255.0, green: 37/255.0, blue: 41/255.0, alpha: 0.5), chartHelperLinesColor: GColor(red: 24/255.0, green: 45/255.0, blue: 59/255.0, alpha: 0.1), chartStrongLinesColor: GColor(red: 24/255.0, green: 45/255.0, blue: 59/255.0, alpha: 0.35), barChartStrongLinesColor: GColor(red: 37/255.0, green: 37/255.0, blue: 41/255.0, alpha: 0.2), chartDetailsTextColor: GColor(red: 109/255.0, green: 109/255.0, blue: 114/255.0, alpha: 1.0), chartDetailsArrowColor: GColor(red: 197/255.0, green: 199/255.0, blue: 205/255.0, alpha: 1.0), chartDetailsViewColor: GColor(red: 245/255.0, green: 245/255.0, blue: 251/255.0, alpha: 1.0), descriptionActionColor: GColor(red: 1/255.0, green: 125/255.0, blue: 229/255.0, alpha: 1.0), rangeViewFrameColor: GColor(red: 202/255.0, green: 212/255.0, blue: 222/255.0, alpha: 1.0), rangeViewTintColor: GColor(red: 239/255.0, green: 239/255.0, blue: 244/255.0, alpha: 0.5), rangeViewMarkerColor: GColor.white)
|
||||
|
||||
|
||||
public static var defaultNightTheme = ChartTheme(chartTitleColor: GColor.white, actionButtonColor: GColor(red: 84/255.0, green: 164/255.0, blue: 247/255.0, alpha: 1.0), tableBackgroundColor: GColor(red: 24/255.0, green: 34/255.0, blue: 45/255.0, alpha: 1.0), chartBackgroundColor: GColor(red: 34/255.0, green: 47/255.0, blue: 63/255.0, alpha: 1.0), tableSeparatorColor: GColor(red: 18/255.0, green: 26/255.0, blue: 35/255.0, alpha: 1.0), chartLabelsColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.6), chartHelperLinesColor: GColor(red: 133/255.0, green: 150/255.0, blue: 171/255.0, alpha: 0.20), chartStrongLinesColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.45), barChartStrongLinesColor: GColor(red: 186/255.0, green: 204/255.0, blue: 225/255.0, alpha: 0.45), chartDetailsTextColor: GColor(red: 254/255.0, green: 254/255.0, blue: 254/255.0, alpha: 1.0), chartDetailsArrowColor: GColor(red: 76/255.0, green: 84/255.0, blue: 96/255.0, alpha: 1.0), chartDetailsViewColor: GColor(red: 25/255.0, green: 35/255.0, blue: 47/255.0, alpha: 1.0), descriptionActionColor: GColor(red: 24/255.0, green: 145/255.0, blue: 255/255.0, alpha: 1.0), rangeViewFrameColor: GColor(red: 53/255.0, green: 70/255.0, blue: 89/255.0, alpha: 1.0), rangeViewTintColor: GColor(red: 24/255.0, green: 34/255.0, blue: 45/255.0, alpha: 0.5), rangeViewMarkerColor: GColor.white)
|
||||
|
||||
|
||||
// public var actionButtonColor: GColor { // Кнопка Zoom Out/ Смена режима день/ночь
|
||||
// switch self {
|
||||
|
||||
Reference in New Issue
Block a user