ui: add followed hashtags to FollowingView
When users view who a certain person follows, now they will see an extra tab to see the hashtags that they follow. This new tab contains a list of followed hashtags, each of which includes an option to follow/unfollow the hashtag, as well as the ability to visit the hashtag timeline Testing **iOS:** 17.0 (iPhone 14 Pro Simulator) **Damus:** (This commit) **Test steps:** 1. Go to search view, search for a couple of hashtags: #apple, #orange, #kiwi 2. Go to the test accounts own profile via the drawer menu 3. Click on "Following". Make sure there are two tabs now. 4. Scroll down, switch tabs between "People" and "Hashtags". Make sure that scrolling and switching tabs work 5. Unfollow and follow a user. Make sure that this still works 6. Make sure that #apple, #orange, #kiwi hashtags are visible under the "Hashtags" tab 7. Unfollow "#kiwi". Check that the button label now switches from "Unfollow" to "Follow" 8. Click on "#kiwi". Make sure that it takes you to the page where posts with that hashtag appears 9. Go to @jb55's profile 10. Click on "Following" 11. Ensure that there is a "Hashtags" tab 12. Check that @jb55's followed hashtags are shown (not your own) 13. Follow one of the same hashtags as @jb55's 14. Go back to your own profile and go to your own following view again. 15. Make sure that this newly added tag is present on the list, and that #kiwi is not. Closes: https://github.com/damus-io/damus/issues/606 Changelog-Added: Add followed hashtags to your following list Signed-off-by: Daniel D’Aquino <daniel@daquino.me> Reviewed-by: William Casarin <jb55@jb55.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
committed by
William Casarin
parent
440e37c1d3
commit
8586eed635
@@ -25,22 +25,11 @@ struct SearchHeaderView: View {
|
||||
|
||||
var Icon: some View {
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(Color(red: 0xF8/255.0, green: 0xE7/255.0, blue: 0xF8/255.0))
|
||||
.frame(width: 54, height: 54)
|
||||
|
||||
switch described {
|
||||
case .hashtag:
|
||||
Text(verbatim: "#")
|
||||
.font(.largeTitle.bold())
|
||||
.foregroundStyle(PinkGradient)
|
||||
.mask(Text(verbatim: "#")
|
||||
.font(.largeTitle.bold()))
|
||||
|
||||
case .unknown:
|
||||
Image(systemName: "magnifyingglass")
|
||||
.font(.title.bold())
|
||||
.foregroundStyle(PinkGradient)
|
||||
case .hashtag:
|
||||
SingleCharacterAvatar(character: "#")
|
||||
case .unknown:
|
||||
SystemIconAvatar(system_name: "magnifyingglass")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -49,32 +38,6 @@ struct SearchHeaderView: View {
|
||||
Text(described.description)
|
||||
}
|
||||
|
||||
func unfollow(_ hashtag: String) {
|
||||
is_following = false
|
||||
handle_unfollow(state: state, unfollow: FollowRef.hashtag(hashtag))
|
||||
}
|
||||
|
||||
func follow(_ hashtag: String) {
|
||||
is_following = true
|
||||
handle_follow(state: state, follow: .hashtag(hashtag))
|
||||
}
|
||||
|
||||
func FollowButton(_ ht: String) -> some View {
|
||||
return Button(action: { follow(ht) }) {
|
||||
Text("Follow hashtag", comment: "Button to follow a given hashtag.")
|
||||
.font(.footnote.bold())
|
||||
}
|
||||
.buttonStyle(GradientButtonStyle(padding: 10))
|
||||
}
|
||||
|
||||
func UnfollowButton(_ ht: String) -> some View {
|
||||
return Button(action: { unfollow(ht) }) {
|
||||
Text("Unfollow hashtag", comment: "Button to unfollow a given hashtag.")
|
||||
.font(.footnote.bold())
|
||||
}
|
||||
.buttonStyle(GradientButtonStyle(padding: 10))
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
HStack(alignment: .center, spacing: 30) {
|
||||
Icon
|
||||
@@ -86,9 +49,9 @@ struct SearchHeaderView: View {
|
||||
|
||||
if state.is_privkey_user, case .hashtag(let ht) = described {
|
||||
if is_following {
|
||||
UnfollowButton(ht)
|
||||
HashtagUnfollowButton(damus_state: state, hashtag: ht, is_following: $is_following)
|
||||
} else {
|
||||
FollowButton(ht)
|
||||
HashtagFollowButton(damus_state: state, hashtag: ht, is_following: $is_following)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -104,6 +67,87 @@ struct SearchHeaderView: View {
|
||||
}
|
||||
}
|
||||
|
||||
struct SystemIconAvatar: View {
|
||||
let system_name: String
|
||||
|
||||
var body: some View {
|
||||
NonImageAvatar {
|
||||
Image(systemName: system_name)
|
||||
.font(.title.bold())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SingleCharacterAvatar: View {
|
||||
let character: String
|
||||
|
||||
var body: some View {
|
||||
NonImageAvatar {
|
||||
Text(verbatim: character)
|
||||
.font(.largeTitle.bold())
|
||||
.mask(Text(verbatim: character)
|
||||
.font(.largeTitle.bold()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct NonImageAvatar<Content: View>: View {
|
||||
let content: Content
|
||||
|
||||
init(@ViewBuilder content: () -> Content) {
|
||||
self.content = content()
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ZStack {
|
||||
Circle()
|
||||
.fill(Color(red: 0xF8/255.0, green: 0xE7/255.0, blue: 0xF8/255.0))
|
||||
.frame(width: 54, height: 54)
|
||||
|
||||
content
|
||||
.foregroundStyle(PinkGradient)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct HashtagUnfollowButton: View {
|
||||
let damus_state: DamusState
|
||||
let hashtag: String
|
||||
@Binding var is_following: Bool
|
||||
|
||||
var body: some View {
|
||||
return Button(action: { unfollow(hashtag) }) {
|
||||
Text("Unfollow hashtag", comment: "Button to unfollow a given hashtag.")
|
||||
.font(.footnote.bold())
|
||||
}
|
||||
.buttonStyle(GradientButtonStyle(padding: 10))
|
||||
}
|
||||
|
||||
func unfollow(_ hashtag: String) {
|
||||
is_following = false
|
||||
handle_unfollow(state: damus_state, unfollow: FollowRef.hashtag(hashtag))
|
||||
}
|
||||
}
|
||||
|
||||
struct HashtagFollowButton: View {
|
||||
let damus_state: DamusState
|
||||
let hashtag: String
|
||||
@Binding var is_following: Bool
|
||||
|
||||
var body: some View {
|
||||
return Button(action: { follow(hashtag) }) {
|
||||
Text("Follow hashtag", comment: "Button to follow a given hashtag.")
|
||||
.font(.footnote.bold())
|
||||
}
|
||||
.buttonStyle(GradientButtonStyle(padding: 10))
|
||||
}
|
||||
|
||||
func follow(_ hashtag: String) {
|
||||
is_following = true
|
||||
handle_follow(state: damus_state, follow: .hashtag(hashtag))
|
||||
}
|
||||
}
|
||||
|
||||
func hashtag_matches_search(desc: DescribedSearch, ref: FollowRef) -> Bool {
|
||||
guard case .hashtag(let follow_ht) = ref,
|
||||
case .hashtag(let search_ht) = desc,
|
||||
|
||||
Reference in New Issue
Block a user