IceCubesApp/Packages/StatusKit/Sources/StatusKit/Editor/Components/AutoComplete/RecentTagsView.swift

40 lines
1 KiB
Swift
Raw Normal View History

2024-01-06 09:52:04 +00:00
import DesignSystem
import EmojiText
import Foundation
import Models
import SwiftData
2024-02-14 11:48:14 +00:00
import SwiftUI
2024-01-06 09:52:04 +00:00
2024-02-14 11:48:14 +00:00
extension StatusEditor.AutoCompleteView {
2024-01-06 09:52:04 +00:00
struct RecentTagsView: View {
@Environment(Theme.self) private var theme
2024-02-14 11:48:14 +00:00
2024-01-06 17:43:26 +00:00
var viewModel: StatusEditor.ViewModel
2024-01-06 09:52:04 +00:00
@Binding var isTagSuggestionExpanded: Bool
2024-02-14 11:48:14 +00:00
2024-01-06 09:52:04 +00:00
@Query(sort: \RecentTag.lastUse, order: .reverse) var recentTags: [RecentTag]
2024-02-14 11:48:14 +00:00
2024-01-06 09:52:04 +00:00
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)
2024-01-06 09:52:04 +00:00
}
}
}
}
}
}