damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 3e5029a4ad114e7caea1edc4ccf8da33c13da40f
parent 05b2cb6376805ca8177e4647f9f79aa9508efb8f
Author: ericholguin <eric.holguinsanchez@gmail.com>
Date:   Sat,  2 Dec 2023 11:56:25 -0700

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>

Diffstat:
Mdamus/Views/SearchHomeView.swift | 4++++
Mdamus/Views/SuggestedHashtagsView.swift | 26+++++++++++++++++++++-----
2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/damus/Views/SearchHomeView.swift b/damus/Views/SearchHomeView.swift @@ -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")) diff --git a/damus/Views/SuggestedHashtagsView.swift b/damus/Views/SuggestedHashtagsView.swift @@ -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