commit 09f12845c0b9ad39f67820327a1884ef71d50717
parent b882a962066c72f7e825f19395a9e6020c1d9ed6
Author: William Casarin <jb55@jb55.com>
Date: Tue, 7 Feb 2023 10:21:21 -0800
FollowButton: show "Follows You" if they follow you
Changelog-Changed: Show "Follow Back" button on profile page
Diffstat:
3 files changed, 16 insertions(+), 8 deletions(-)
diff --git a/damus/Views/FollowButtonView.swift b/damus/Views/FollowButtonView.swift
@@ -12,13 +12,14 @@ struct FollowButtonView: View {
@Environment(\.colorScheme) var colorScheme
let target: FollowTarget
+ let follows_you: Bool
@State var follow_state: FollowState
var body: some View {
Button {
follow_state = perform_follow_btn_action(follow_state, target: target)
} label: {
- Text(follow_btn_txt(follow_state))
+ Text(follow_btn_txt(follow_state, follows_you: follows_you))
.frame(width: 105, height: 30)
//.padding(.vertical, 10)
.font(.caption.weight(.bold))
@@ -70,16 +71,19 @@ struct FollowButtonPreviews: View {
var body: some View {
VStack {
Text("Unfollows", comment: "Text to indicate that the button next to it is in a state that will unfollow a profile when tapped.")
- FollowButtonView(target: target, follow_state: .unfollows)
+ FollowButtonView(target: target, follows_you: false, follow_state: .unfollows)
Text("Following", comment: "Text to indicate that the button next to it is in a state that indicates that it is in the process of following a profile.")
- FollowButtonView(target: target, follow_state: .following)
+ FollowButtonView(target: target, follows_you: false, follow_state: .following)
+
+ Text("Follows", comment: "Text to indicate that button next to it is in a state that will follow a profile when tapped.")
+ FollowButtonView(target: target, follows_you: false, follow_state: .follows)
Text("Follows", comment: "Text to indicate that button next to it is in a state that will follow a profile when tapped.")
- FollowButtonView(target: target, follow_state: .follows)
+ FollowButtonView(target: target, follows_you: true, follow_state: .follows)
Text("Unfollowing", comment: "Text to indicate that the button next to it is in a state that indicates that it is in the process of unfollowing a profile.")
- FollowButtonView(target: target, follow_state: .unfollowing)
+ FollowButtonView(target: target, follows_you: false, follow_state: .unfollowing)
}
}
}
diff --git a/damus/Views/FollowingView.swift b/damus/Views/FollowingView.swift
@@ -17,7 +17,7 @@ struct FollowUserView: View {
HStack {
UserView(damus_state: damus_state, pubkey: target.pubkey)
- FollowButtonView(target: target, follow_state: damus_state.contacts.follow_state(target.pubkey))
+ FollowButtonView(target: target, follows_you: false, follow_state: damus_state.contacts.follow_state(target.pubkey))
}
}
}
diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift
@@ -19,7 +19,7 @@ enum FollowState {
case unfollows
}
-func follow_btn_txt(_ fs: FollowState) -> String {
+func follow_btn_txt(_ fs: FollowState, follows_you: Bool) -> String {
switch fs {
case .follows:
return NSLocalizedString("Unfollow", comment: "Button to unfollow a user.")
@@ -28,7 +28,11 @@ func follow_btn_txt(_ fs: FollowState) -> String {
case .unfollowing:
return NSLocalizedString("Unfollowing...", comment: "Label to indicate that the user is in the process of unfollowing another user.")
case .unfollows:
- return NSLocalizedString("Follow", comment: "Button to follow a user.")
+ if follows_you {
+ return NSLocalizedString("Follow Back", comment: "Button to follow a user back.")
+ } else {
+ return NSLocalizedString("Follow", comment: "Button to follow a user.")
+ }
}
}