mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-23 06:35:51 +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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user