mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-12-23 13:28:50 +01:00
Add followed tags to tag suggestion
This commit is contained in:
parent
1297331407
commit
6435b40a51
@ -4,12 +4,15 @@ import Foundation
|
||||
import SwiftUI
|
||||
import Models
|
||||
import SwiftData
|
||||
|
||||
import Env
|
||||
|
||||
extension StatusEditorAutoCompleteView {
|
||||
|
||||
@MainActor
|
||||
struct ExpandedView: View {
|
||||
@Environment(\.modelContext) private var context
|
||||
@Environment(Theme.self) private var theme
|
||||
@Environment(CurrentAccount.self) private var currentAccount
|
||||
|
||||
var viewModel: StatusEditorViewModel
|
||||
@Binding var isTagSuggestionExpanded: Bool
|
||||
@ -17,6 +20,15 @@ extension StatusEditorAutoCompleteView {
|
||||
@Query(sort: \RecentTag.lastUse, order: .reverse) var recentTags: [RecentTag]
|
||||
|
||||
var body: some View {
|
||||
TabView {
|
||||
recentTagsPage
|
||||
followedTagsPage
|
||||
}
|
||||
.tabViewStyle(.page(indexDisplayMode: .always))
|
||||
.frame(height: 200)
|
||||
}
|
||||
|
||||
private var recentTagsPage: some View {
|
||||
ScrollView(.vertical) {
|
||||
LazyVStack(alignment: .leading, spacing: 12) {
|
||||
Text("status.editor.language-select.recently-used")
|
||||
@ -48,15 +60,41 @@ extension StatusEditorAutoCompleteView {
|
||||
}
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
}
|
||||
.frame(height: 200)
|
||||
.gesture(DragGesture(minimumDistance: 0, coordinateSpace: .local)
|
||||
.onEnded({ value in
|
||||
}
|
||||
|
||||
private var followedTagsPage: some View {
|
||||
ScrollView(.vertical) {
|
||||
LazyVStack(alignment: .leading, spacing: 12) {
|
||||
Text("timeline.filter.tags")
|
||||
.font(.scaledSubheadline)
|
||||
.foregroundStyle(theme.labelColor)
|
||||
.fontWeight(.bold)
|
||||
ForEach(currentAccount.tags) { tag in
|
||||
HStack {
|
||||
Button {
|
||||
if let index = recentTags.firstIndex(where: { $0.title.lowercased() == tag.name.lowercased() }) {
|
||||
recentTags[index].lastUse = Date()
|
||||
} else {
|
||||
context.insert(RecentTag(title: tag.name))
|
||||
}
|
||||
withAnimation {
|
||||
if value.translation.height > 0 {
|
||||
isTagSuggestionExpanded = false
|
||||
viewModel.selectHashtagSuggestion(tag: tag.name)
|
||||
}
|
||||
} label: {
|
||||
VStack(alignment: .leading) {
|
||||
Text("#\(tag.name)")
|
||||
.font(.scaledFootnote)
|
||||
.fontWeight(.bold)
|
||||
.foregroundColor(theme.labelColor)
|
||||
}
|
||||
}
|
||||
}))
|
||||
Spacer()
|
||||
}
|
||||
}
|
||||
}
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ struct StatusEditorAutoCompleteView: View {
|
||||
.padding(.horizontal, .layoutPadding)
|
||||
}
|
||||
.scrollContentBackground(.hidden)
|
||||
if !viewModel.tagsSuggestions.isEmpty {
|
||||
if viewModel.mentionsSuggestions.isEmpty {
|
||||
Spacer()
|
||||
Button {
|
||||
withAnimation {
|
||||
@ -46,10 +46,10 @@ struct StatusEditorAutoCompleteView: View {
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: isTagSuggestionExpanded ? "chevron.down.circle" : "chevron.up.circle")
|
||||
}
|
||||
.padding(.trailing, 8)
|
||||
}
|
||||
}
|
||||
}
|
||||
.frame(height: 40)
|
||||
if isTagSuggestionExpanded {
|
||||
Self.ExpandedView(viewModel: viewModel, isTagSuggestionExpanded: $isTagSuggestionExpanded)
|
||||
|
Loading…
Reference in New Issue
Block a user