Merge pull request #753 from j-f1/following-customization

Differentiate between “My followers” and other accounts followers for i18n
This commit is contained in:
Nathan Mattes 2022-12-20 14:05:07 +01:00 committed by GitHub
commit 08b63bda00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 62 additions and 18 deletions

View File

@ -463,9 +463,12 @@
"follows_you": "Follows You"
},
"dashboard": {
"posts": "posts",
"following": "following",
"followers": "followers"
"my_posts": "posts",
"my_following": "following",
"my_followers": "followers",
"other_posts": "posts",
"other_following": "following",
"other_followers": "followers"
},
"fields": {
"joined": "Joined",

View File

@ -463,9 +463,12 @@
"follows_you": "Follows You"
},
"dashboard": {
"posts": "posts",
"following": "following",
"followers": "followers"
"my_posts": "posts",
"my_following": "following",
"my_followers": "followers",
"other_posts": "posts",
"other_following": "following",
"other_followers": "followers"
},
"fields": {
"joined": "Joined",

View File

@ -153,6 +153,9 @@ extension ProfileHeaderViewController {
viewModel.$relationshipActionOptionSet
.assign(to: \.relationshipActionOptionSet, on: profileHeaderView.viewModel)
.store(in: &disposeBag)
viewModel.$isMyself
.assign(to: \.isMyself, on: profileHeaderView.viewModel)
.store(in: &disposeBag)
viewModel.$isEditing
.assign(to: \.isEditing, on: profileHeaderView.viewModel)
.store(in: &disposeBag)

View File

@ -30,6 +30,7 @@ final class ProfileHeaderViewModel {
@Published var user: MastodonUser?
@Published var relationshipActionOptionSet: RelationshipActionOptionSet = .none
@Published var isMyself = false
@Published var isEditing = false
@Published var isUpdating = false

View File

@ -48,6 +48,7 @@ extension ProfileHeaderView {
@Published var relationshipActionOptionSet: RelationshipActionOptionSet = .none
@Published var isRelationshipActionButtonHidden = false
@Published var isMyself = false
init() {
$relationshipActionOptionSet
@ -189,6 +190,19 @@ extension ProfileHeaderView.ViewModel {
}
.store(in: &disposeBag)
// dashboard
$isMyself
.sink { isMyself in
if isMyself {
view.statusDashboardView.postDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.myPosts
view.statusDashboardView.followingDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.myFollowing
view.statusDashboardView.followersDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.myFollowers
} else {
view.statusDashboardView.postDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.otherPosts
view.statusDashboardView.followingDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.otherFollowing
view.statusDashboardView.followersDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.otherFollowers
}
}
.store(in: &disposeBag)
$statusesCount
.sink { count in
let text = count.flatMap { MastodonMetricFormatter().string(from: $0) } ?? "-"

View File

@ -311,6 +311,9 @@ extension ProfileViewController {
viewModel.$isUpdating
.assign(to: \.isUpdating, on: headerViewModel)
.store(in: &disposeBag)
viewModel.relationshipViewModel.$isMyself
.assign(to: \.isMyself, on: headerViewModel)
.store(in: &disposeBag)
viewModel.relationshipViewModel.$optionSet
.map { $0 ?? .none }
.assign(to: \.relationshipActionOptionSet, on: headerViewModel)

View File

@ -792,11 +792,17 @@ public enum L10n {
}
public enum Dashboard {
/// followers
public static let followers = L10n.tr("Localizable", "Scene.Profile.Dashboard.Followers", fallback: "followers")
public static let myFollowers = L10n.tr("Localizable", "Scene.Profile.Dashboard.MyFollowers", fallback: "followers")
/// following
public static let following = L10n.tr("Localizable", "Scene.Profile.Dashboard.Following", fallback: "following")
public static let myFollowing = L10n.tr("Localizable", "Scene.Profile.Dashboard.MyFollowing", fallback: "following")
/// posts
public static let posts = L10n.tr("Localizable", "Scene.Profile.Dashboard.Posts", fallback: "posts")
public static let myPosts = L10n.tr("Localizable", "Scene.Profile.Dashboard.MyPosts", fallback: "posts")
/// followers
public static let otherFollowers = L10n.tr("Localizable", "Scene.Profile.Dashboard.OtherFollowers", fallback: "followers")
/// following
public static let otherFollowing = L10n.tr("Localizable", "Scene.Profile.Dashboard.OtherFollowing", fallback: "following")
/// posts
public static let otherPosts = L10n.tr("Localizable", "Scene.Profile.Dashboard.OtherPosts", fallback: "posts")
}
public enum Fields {
/// Add Row

View File

@ -283,9 +283,12 @@ uploaded to Mastodon.";
"Scene.Profile.Accessibility.EditAvatarImage" = "Edit avatar image";
"Scene.Profile.Accessibility.ShowAvatarImage" = "Show avatar image";
"Scene.Profile.Accessibility.ShowBannerImage" = "Show banner image";
"Scene.Profile.Dashboard.Followers" = "followers";
"Scene.Profile.Dashboard.Following" = "following";
"Scene.Profile.Dashboard.Posts" = "posts";
"Scene.Profile.Dashboard.MyFollowers" = "followers";
"Scene.Profile.Dashboard.MyFollowing" = "following";
"Scene.Profile.Dashboard.MyPosts" = "posts";
"Scene.Profile.Dashboard.OtherFollowers" = "followers";
"Scene.Profile.Dashboard.OtherFollowing" = "following";
"Scene.Profile.Dashboard.OtherPosts" = "posts";
"Scene.Profile.Fields.AddRow" = "Add Row";
"Scene.Profile.Fields.Joined" = "Joined";
"Scene.Profile.Fields.Placeholder.Content" = "Content";

View File

@ -43,7 +43,7 @@ extension ProfileCardView {
@Published public var isMuting = false
@Published public var isBlocking = false
@Published public var isBlockedBy = false
@Published public var groupedAccessibilityLabel = ""
@Published public var familiarFollowers: Mastodon.Entity.FamiliarFollowers?
@ -173,6 +173,19 @@ extension ProfileCardView.ViewModel {
}
private func bindDashboard(view: ProfileCardView) {
relationshipViewModel.$isMyself
.sink { isMyself in
if isMyself {
view.statusDashboardView.postDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.myPosts
view.statusDashboardView.followingDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.myFollowing
view.statusDashboardView.followersDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.myFollowers
} else {
view.statusDashboardView.postDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.otherPosts
view.statusDashboardView.followingDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.otherFollowing
view.statusDashboardView.followersDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.otherFollowers
}
}
.store(in: &disposeBag)
$statusesCount
.receive(on: DispatchQueue.main)
.sink { count in

View File

@ -29,7 +29,6 @@ public final class ProfileStatusDashboardMeterView: UIView {
let label = UILabel()
label.font = .systemFont(ofSize: 13, weight: .regular)
label.textColor = Asset.Colors.Label.primary.color
label.text = L10n.Scene.Profile.Dashboard.posts
label.textAlignment = .center
if UIView.isZoomedMode {
label.adjustsFontSizeToFitWidth = true

View File

@ -66,10 +66,6 @@ extension ProfileStatusDashboardView {
containerStackView.setCustomSpacing(spacing + 2, after: followingDashboardMeterView)
containerStackView.addArrangedSubview(followersDashboardMeterView)
postDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.posts
followingDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.following
followersDashboardMeterView.textLabel.text = L10n.Scene.Profile.Dashboard.followers
[postDashboardMeterView, followingDashboardMeterView, followersDashboardMeterView].forEach { meterView in
let tapGestureRecognizer = UITapGestureRecognizer.singleTapGestureRecognizer
tapGestureRecognizer.addTarget(self, action: #selector(ProfileStatusDashboardView.tapGestureRecognizerHandler(_:)))