1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2024-12-08 22:56:41 +01:00
mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonUI/View/Content/TrendView+Configuration.swift
2022-04-15 17:33:48 +08:00

36 lines
959 B
Swift

//
// 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
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: ", ")
}
}