IceCubesApp/Packages/Status/Sources/Status/Editor/Components/AutoComplete/RecentTagsView.swift
2024-01-06 18:43:26 +01:00

41 lines
1 KiB
Swift

import DesignSystem
import EmojiText
import Foundation
import SwiftUI
import Models
import SwiftData
extension StatusEditor.AutoCompleteView {
struct RecentTagsView: View {
@Environment(Theme.self) private var theme
var viewModel: StatusEditor.ViewModel
@Binding var isTagSuggestionExpanded: Bool
@Query(sort: \RecentTag.lastUse, order: .reverse) var recentTags: [RecentTag]
var body: some View {
ForEach(recentTags) { tag in
Button {
withAnimation {
isTagSuggestionExpanded = false
viewModel.selectHashtagSuggestion(tag: tag.title)
}
tag.lastUse = Date()
} label: {
VStack(alignment: .leading) {
Text("#\(tag.title)")
.font(.scaledFootnote)
.fontWeight(.bold)
.foregroundColor(theme.labelColor)
Text(tag.formattedDate)
.font(.scaledFootnote)
.foregroundStyle(theme.tintColor)
}
}
}
}
}
}