IceCubesApp/Packages/Timeline/Sources/Timeline/View/TimelineTagHeaderView.swift
Thomas Ricouard 1f858414d8 format .
2024-02-14 12:48:14 +01:00

49 lines
1.3 KiB
Swift

import DesignSystem
import Env
import Models
import SwiftUI
struct TimelineTagHeaderView: View {
@Environment(CurrentAccount.self) private var account
@Binding var tag: Tag?
@State var isLoading: Bool = false
var body: some View {
if let tag {
TimelineHeaderView {
HStack {
TagChartView(tag: tag)
.padding(.top, 12)
VStack(alignment: .leading, spacing: 4) {
Text("#\(tag.name)")
.font(.scaledHeadline)
Text("timeline.n-recent-from-n-participants \(tag.totalUses) \(tag.totalAccounts)")
.font(.scaledFootnote)
.foregroundStyle(.secondary)
}
.accessibilityElement(children: .combine)
Spacer()
Button {
Task {
isLoading = true
if tag.following {
self.tag = await account.unfollowTag(id: tag.name)
} else {
self.tag = await account.followTag(id: tag.name)
}
isLoading = false
}
} label: {
Text(tag.following ? "account.follow.following" : "account.follow.follow")
}
.disabled(isLoading)
.buttonStyle(.bordered)
}
}
}
}
}