1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-11 08:06:23 +01:00
mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonUI/View/Content/TrendView+Configuration.swift

36 lines
959 B
Swift
Raw Normal View History

//
// TrendView+Configuration.swift
//
//
// Created by MainasuK on 2022-4-13.
//
import UIKit
import MastodonSDK
import MastodonLocalization
extension TrendView {
public func configure(tag: Mastodon.Entity.Tag) {
let primaryLabelText = "#" + tag.name
2022-04-15 11:22:30 +02:00
let secondaryLabelText = L10n.Plural.peopleTalking(tag.talkingPeopleCount ?? 0)
primaryLabel.text = primaryLabelText
secondaryLabel.text = secondaryLabelText
lineChartView.data = (tag.history ?? [])
.sorted(by: { $0.day < $1.day }) // latest last
.map { entry in
guard let point = Int(entry.accounts) else {
return .zero
}
return CGFloat(point)
}
isAccessibilityElement = true
accessibilityLabel = [
primaryLabelText,
secondaryLabelText
].joined(separator: ", ")
}
}