FollowButton: show "Follows You" if they follow you
Changelog-Changed: Show "Follow Back" button on profile page
This commit is contained in:
@@ -12,13 +12,14 @@ struct FollowButtonView: View {
|
|||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
|
|
||||||
let target: FollowTarget
|
let target: FollowTarget
|
||||||
|
let follows_you: Bool
|
||||||
@State var follow_state: FollowState
|
@State var follow_state: FollowState
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Button {
|
Button {
|
||||||
follow_state = perform_follow_btn_action(follow_state, target: target)
|
follow_state = perform_follow_btn_action(follow_state, target: target)
|
||||||
} label: {
|
} label: {
|
||||||
Text(follow_btn_txt(follow_state))
|
Text(follow_btn_txt(follow_state, follows_you: follows_you))
|
||||||
.frame(width: 105, height: 30)
|
.frame(width: 105, height: 30)
|
||||||
//.padding(.vertical, 10)
|
//.padding(.vertical, 10)
|
||||||
.font(.caption.weight(.bold))
|
.font(.caption.weight(.bold))
|
||||||
@@ -70,16 +71,19 @@ struct FollowButtonPreviews: View {
|
|||||||
var body: some View {
|
var body: some View {
|
||||||
VStack {
|
VStack {
|
||||||
Text("Unfollows", comment: "Text to indicate that the button next to it is in a state that will unfollow a profile when tapped.")
|
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.")
|
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.")
|
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.")
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ struct FollowUserView: View {
|
|||||||
HStack {
|
HStack {
|
||||||
UserView(damus_state: damus_state, pubkey: target.pubkey)
|
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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ enum FollowState {
|
|||||||
case unfollows
|
case unfollows
|
||||||
}
|
}
|
||||||
|
|
||||||
func follow_btn_txt(_ fs: FollowState) -> String {
|
func follow_btn_txt(_ fs: FollowState, follows_you: Bool) -> String {
|
||||||
switch fs {
|
switch fs {
|
||||||
case .follows:
|
case .follows:
|
||||||
return NSLocalizedString("Unfollow", comment: "Button to unfollow a user.")
|
return NSLocalizedString("Unfollow", comment: "Button to unfollow a user.")
|
||||||
@@ -28,7 +28,11 @@ func follow_btn_txt(_ fs: FollowState) -> String {
|
|||||||
case .unfollowing:
|
case .unfollowing:
|
||||||
return NSLocalizedString("Unfollowing...", comment: "Label to indicate that the user is in the process of unfollowing another user.")
|
return NSLocalizedString("Unfollowing...", comment: "Label to indicate that the user is in the process of unfollowing another user.")
|
||||||
case .unfollows:
|
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.")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user