1
0
mirror of git://jb55.com/damus synced 2024-09-16 02:03:45 +00:00

ui: allow users to collapse suggested hashtag view

Closes: https://github.com/damus-io/damus/pull/1789
Changelog-Added: Add ability to hide suggested hashtags
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
ericholguin 2023-12-02 11:56:25 -07:00 committed by William Casarin
parent 05b2cb6376
commit 3e5029a4ad
2 changed files with 25 additions and 5 deletions

View File

@ -78,6 +78,10 @@ struct SearchHomeView: View {
content: {
AnyView(VStack {
SuggestedHashtagsView(damus_state: damus_state, max_items: 5, events: model.events)
Divider()
.frame(height: 1)
HStack {
Image("notes.fill")
Text(NSLocalizedString("All recent notes", comment: "A label indicating that the notes being displayed below it are all recent notes"))

View File

@ -24,6 +24,7 @@ struct SuggestedHashtagsView: View {
let damus_state: DamusState
@StateObject var events: EventHolder
@SceneStorage("SuggestedHashtagsView.show_suggested_hashtags") var show_suggested_hashtags : Bool = true
var item_limit: Int?
let suggested_hashtags: [String]
var hashtags_with_count_to_display: [HashtagWithUserCount] {
@ -58,16 +59,31 @@ struct SuggestedHashtagsView: View {
Image(systemName: "sparkles")
Text(NSLocalizedString("Suggested hashtags", comment: "A label indicating that the items below it are suggested hashtags"))
Spacer()
Button(action: {
withAnimation(.easeOut(duration: 0.2)) {
show_suggested_hashtags.toggle()
}
}) {
if show_suggested_hashtags {
Image(systemName: "rectangle.compress.vertical")
.foregroundStyle(PinkGradient)
} else {
Image(systemName: "rectangle.expand.vertical")
.foregroundStyle(PinkGradient)
}
}
}
.foregroundColor(.secondary)
.padding(.bottom, 10)
.padding(.vertical, 10)
ForEach(hashtags_with_count_to_display,
id: \.self) { hashtag_with_count in
SuggestedHashtagView(damus_state: damus_state, hashtag: hashtag_with_count.hashtag, count: hashtag_with_count.count)
if show_suggested_hashtags {
ForEach(hashtags_with_count_to_display,
id: \.self) { hashtag_with_count in
SuggestedHashtagView(damus_state: damus_state, hashtag: hashtag_with_count.hashtag, count: hashtag_with_count.count)
}
}
}
.padding()
.padding(.horizontal)
}
private struct SuggestedHashtagView: View { // Purposefully private to SuggestedHashtagsView because it assumes the same 24h window