Skip to content

Commit

Permalink
Update Profile-Menu (IOS-231) (mastodon#1297)
Browse files Browse the repository at this point in the history
Updates the Profile-menu on other profiles. This menu is not visible on
my own profile. For details see IOS-231

![Simulator Screenshot - iPhone 15 Pro - 2024-05-21 at 11 29
07](https://github.com/mastodon/mastodon-ios/assets/2580019/69e0e620-1e02-416b-ba8c-246e5247f1c3)
  • Loading branch information
kimar authored May 22, 2024
2 parents 7420563 + aeb3717 commit 5317e8c
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 99 deletions.
16 changes: 8 additions & 8 deletions Localization/StringsConvertor/input/en.lproj/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
},
"posted_via_application": "%s via %s",
"buttons": {
"reblogs_title": "Reblogs",
"reblogs_title": "Boosts",
"favorites_title": "Favorites",
"edit_history_title": "Edit History",
"edit_history_detail": "Last edit %s"
Expand Down Expand Up @@ -251,8 +251,8 @@
"unmute_user": "Unmute %s",
"muted": "Muted",
"edit_info": "Edit Info",
"show_reblogs": "Show Reblogs",
"hide_reblogs": "Hide Reblogs"
"show_reblogs": "Show Boosts",
"hide_reblogs": "Hide Boosts"
},
"timeline": {
"filtered": "Filtered",
Expand Down Expand Up @@ -616,12 +616,12 @@
"message": "Confirm to unblock %s"
},
"confirm_show_reblogs": {
"title": "Show Reblogs",
"message": "Confirm to show reblogs"
"title": "Show Boosts",
"message": "Confirm to show boosts"
},
"confirm_hide_reblogs": {
"title": "Hide Reblogs",
"message": "Confirm to hide reblogs"
"title": "Hide Boosts",
"message": "Confirm to hide boosts"
},
"confirm_block_domain": {
"title": "Block domain",
Expand Down Expand Up @@ -860,7 +860,7 @@
"unfollowed": "Unfollowed",
"unfollow_user": "Unfollow %s",
"mute_user": "Mute %s",
"you_wont_see_their_posts_or_reblogs_in_your_home_feed_they_wont_know_they_ve_been_muted": "You won’t see their posts or reblogs in your home feed. They won’t know they’ve been muted.",
"you_wont_see_their_posts_or_reblogs_in_your_home_feed_they_wont_know_they_ve_been_muted": "You won’t see their posts or boosts in your home feed. They won’t know they’ve been muted.",
"block_user": "Block %s",
"they_will_no_longer_be_able_to_follow_or_see_your_posts_but_they_can_see_if_theyve_been_blocked": "They will no longer be able to follow or see your posts, but they can see if they’ve been blocked.",
"while_we_review_this_you_can_take_action_against_user": "While we review this, you can take action against %s"
Expand Down
10 changes: 8 additions & 2 deletions Mastodon/Protocol/Provider/DataSourceFacade+Status.swift
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,14 @@ extension DataSourceFacade {
}

try await responseToStatusFavoriteAction(provider: dependency, status: status)
case .copyLink:
case .copyStatusLink:
guard let status: MastodonStatus = menuContext.statusViewModel?.originalStatus?.reblog ?? menuContext.statusViewModel?.originalStatus else {
assertionFailure()
return
}

UIPasteboard.general.string = status.entity.url
case .openInBrowser:
case .openStatusInBrowser:
guard
let status: MastodonStatus = menuContext.statusViewModel?.originalStatus?.reblog ?? menuContext.statusViewModel?.originalStatus,
let urlString = status.entity.url,
Expand All @@ -415,6 +415,12 @@ extension DataSourceFacade {
return
}

dependency.coordinator.present(scene: .safari(url: url), transition: .safariPresent(animated: true))
case .copyProfileLink(let url):
UIPasteboard.general.string = url?.absoluteString
case .openUserInBrowser(let url):
guard let url else { return }

dependency.coordinator.present(scene: .safari(url: url), transition: .safariPresent(animated: true))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ extension NotificationTableViewCellDelegate where Self: DataSourceProvider & Aut
barButtonItem: nil
)
)
case .translateStatus(_), .showOriginal, .shareUser(_), .blockDomain(_), .bookmarkStatus(_), .hideReblogs(_), .shareStatus, .deleteStatus, .editStatus, .followUser(_), .boostStatus(_), .favoriteStatus(_), .copyLink, .openInBrowser:
// Do Nothing
case .translateStatus(_), .showOriginal, .shareUser(_), .blockDomain(_), .bookmarkStatus(_), .hideReblogs(_), .shareStatus, .deleteStatus, .editStatus, .followUser(_), .boostStatus(_), .favoriteStatus(_), .copyStatusLink, .openStatusInBrowser, .openUserInBrowser(_), .copyProfileLink(_):
break

}
}
}
Expand Down
62 changes: 29 additions & 33 deletions Mastodon/Scene/Profile/ProfileViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ extension ProfileViewController {
.store(in: &disposeBag)
}

// This More-button is only visible for other users, but not myself
private func bindMoreBarButtonItem() {
Publishers.CombineLatest3(
viewModel.$account,
Expand All @@ -428,30 +429,41 @@ extension ProfileViewController {

let name = user.displayNameWithFallback

var menuActions: [MastodonMenu.Action] = [
.muteUser(.init(name: name, isMuting: relationship.muting)),
.blockUser(.init(name: name, isBlocking: relationship.blocking))
var items: [MastodonMenu.Submenu] = []

items.append(MastodonMenu.Submenu(actions: [
.shareUser(.init(name: name)),
.openUserInBrowser(URL(string: user.url)),
.copyProfileLink(URL(string: user.url))
]))


var relationshipActions: [MastodonMenu.Action] = [
.followUser(.init(name: name, isFollowing: relationship.following)),
.muteUser(.init(name: name, isMuting: relationship.muting))
]

if myDomain != domain {
menuActions.append(
.blockDomain(.init(domain: domain, isBlocking: relationship.domainBlocking))
)
if relationship.following {
relationshipActions.append(.hideReblogs(.init(showReblogs: relationship.showingReblogs)))
}

menuActions.append(contentsOf: [
items.append(MastodonMenu.Submenu(actions: relationshipActions))

var destructiveActions: [MastodonMenu.Action] = [
.blockUser(.init(name: name, isBlocking: relationship.blocking)),
.reportUser(.init(name: name)),
.shareUser(.init(name: name)),
])
]

if relationship.following {
let showReblogs = relationship.showingReblogs// me.showingReblogsBy.contains(user)
let context = MastodonMenu.HideReblogsActionContext(showReblogs: showReblogs)
menuActions.insert(.hideReblogs(context), at: 1)
if myDomain != domain {
destructiveActions.append(
.blockDomain(.init(domain: domain, isBlocking: relationship.domainBlocking))
)
}

items.append(MastodonMenu.Submenu(actions: destructiveActions))

let menu = MastodonMenu.setupMenu(
submenus: [MastodonMenu.Submenu(actions: menuActions)],
submenus: items,
delegate: self
)
return menu
Expand Down Expand Up @@ -929,22 +941,7 @@ extension ProfileViewController: ProfileAboutViewControllerDelegate {
extension ProfileViewController: MastodonMenuDelegate {
func menuAction(_ action: MastodonMenu.Action) {
switch action {
case .muteUser(_),
.blockUser(_),
.blockDomain(_),
.hideReblogs(_):
Task {
try await DataSourceFacade.responseToMenuAction(
dependency: self,
action: action,
menuContext: DataSourceFacade.MenuContext(
author: viewModel.account,
statusViewModel: nil,
button: nil,
barButtonItem: self.moreMenuBarButtonItem
))
}
case .reportUser(_), .shareUser(_):
case .muteUser(_), .blockUser(_), .blockDomain(_), .hideReblogs(_), .reportUser(_), .shareUser(_), .openUserInBrowser(_), .copyProfileLink(_), .followUser(_):
Task {
try await DataSourceFacade.responseToMenuAction(
dependency: self,
Expand All @@ -956,8 +953,7 @@ extension ProfileViewController: MastodonMenuDelegate {
barButtonItem: self.moreMenuBarButtonItem
))
}

case .translateStatus(_), .showOriginal, .bookmarkStatus(_), .shareStatus, .deleteStatus, .editStatus, .followUser(_), .boostStatus(_), .favoriteStatus(_), .copyLink, .openInBrowser:
case .translateStatus(_), .showOriginal, .bookmarkStatus(_), .shareStatus, .deleteStatus, .editStatus, .boostStatus(_), .favoriteStatus(_), .copyStatusLink, .openStatusInBrowser:
break
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ Please check your internet connection.";
"Common.Controls.Friendship.EditInfo" = "Edit Info";
"Common.Controls.Friendship.Follow" = "Follow";
"Common.Controls.Friendship.Following" = "Following";
"Common.Controls.Friendship.HideReblogs" = "Hide Reblogs";
"Common.Controls.Friendship.HideReblogs" = "Hide Boosts";
"Common.Controls.Friendship.Mute" = "Mute";
"Common.Controls.Friendship.MuteUser" = "Mute %@";
"Common.Controls.Friendship.Muted" = "Muted";
"Common.Controls.Friendship.Pending" = "Pending";
"Common.Controls.Friendship.Request" = "Request";
"Common.Controls.Friendship.ShowReblogs" = "Show Reblogs";
"Common.Controls.Friendship.ShowReblogs" = "Show Boosts";
"Common.Controls.Friendship.Unblock" = "Unblock";
"Common.Controls.Friendship.UnblockUser" = "Unblock %@";
"Common.Controls.Friendship.Unmute" = "Unmute";
Expand Down Expand Up @@ -134,7 +134,7 @@ Please check your internet connection.";
"Common.Controls.Status.Buttons.EditHistoryDetail" = "Last edit %@";
"Common.Controls.Status.Buttons.EditHistoryTitle" = "Edit History";
"Common.Controls.Status.Buttons.FavoritesTitle" = "Favorites";
"Common.Controls.Status.Buttons.ReblogsTitle" = "Reblogs";
"Common.Controls.Status.Buttons.ReblogsTitle" = "Boosts";
"Common.Controls.Status.ContentWarning" = "Content Warning";
"Common.Controls.Status.EditHistory.OriginalPost" = "Original Post · %@";
"Common.Controls.Status.EditHistory.Title" = "Edit History";
Expand Down Expand Up @@ -351,12 +351,12 @@ uploaded to Mastodon.";
"Scene.Profile.RelationshipActionAlert.ConfirmBlockDomain.Title" = "Block domain";
"Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Message" = "Confirm to block %@";
"Scene.Profile.RelationshipActionAlert.ConfirmBlockUser.Title" = "Block Account";
"Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Message" = "Confirm to hide reblogs";
"Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Title" = "Hide Reblogs";
"Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Message" = "Confirm to hide boosts";
"Scene.Profile.RelationshipActionAlert.ConfirmHideReblogs.Title" = "Hide Boosts";
"Scene.Profile.RelationshipActionAlert.ConfirmMuteUser.Message" = "Confirm to mute %@";
"Scene.Profile.RelationshipActionAlert.ConfirmMuteUser.Title" = "Mute Account";
"Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Message" = "Confirm to show reblogs";
"Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Title" = "Show Reblogs";
"Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Message" = "Confirm to show boosts";
"Scene.Profile.RelationshipActionAlert.ConfirmShowReblogs.Title" = "Show Boosts";
"Scene.Profile.RelationshipActionAlert.ConfirmUnblockDomain.Message" = "Confirm to unblock domain %@";
"Scene.Profile.RelationshipActionAlert.ConfirmUnblockDomain.Title" = "Unblock domain";
"Scene.Profile.RelationshipActionAlert.ConfirmUnblockUser.Message" = "Confirm to unblock %@";
Expand Down Expand Up @@ -421,7 +421,7 @@ uploaded to Mastodon.";
"Scene.Report.StepFinal.Unfollowed" = "Unfollowed";
"Scene.Report.StepFinal.WhenYouSeeSomethingYouDontLikeOnMastodonYouCanRemoveThePersonFromYourExperience." = "When you see something you don’t like on Mastodon, you can remove the person from your experience.";
"Scene.Report.StepFinal.WhileWeReviewThisYouCanTakeActionAgainstUser" = "While we review this, you can take action against %@";
"Scene.Report.StepFinal.YouWontSeeTheirPostsOrReblogsInYourHomeFeedTheyWontKnowTheyVeBeenMuted" = "You won’t see their posts or reblogs in your home feed. They won’t know they’ve been muted.";
"Scene.Report.StepFinal.YouWontSeeTheirPostsOrReblogsInYourHomeFeedTheyWontKnowTheyVeBeenMuted" = "You won’t see their posts or boosts in your home feed. They won’t know they’ve been muted.";
"Scene.Report.StepFour.IsThereAnythingElseWeShouldKnow" = "Is there anything else we should know?";
"Scene.Report.StepFour.Step4Of4" = "Step 4 of 4";
"Scene.Report.StepOne.IDontLikeIt" = "I don’t like it";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ extension StatusAuthorView {
items.append(MastodonMenu.Submenu(actions: [action]))
}

items.append(MastodonMenu.Submenu(actions: [.shareStatus, .openInBrowser, .copyLink]))
items.append(MastodonMenu.Submenu(actions: [.shareStatus, .openStatusInBrowser, .copyStatusLink]))

if menuContext.isMyself {
items.append(MastodonMenu.Submenu(actions: [.deleteStatus]))
Expand Down
Loading

0 comments on commit 5317e8c

Please sign in to comment.