Implement Lists Menu (IOS-21)

This commit is contained in:
Marcus Kida 2024-07-12 11:06:43 +02:00
parent 7f96aa579f
commit 4c832d0547
No known key found for this signature in database
GPG Key ID: 19FF64E08013CA40
4 changed files with 51 additions and 3 deletions

View File

@ -477,7 +477,11 @@
"title": "Home",
"timeline_menu": {
"following": "Following",
"local_community": "Local"
"local_community": "Local",
"lists": {
"title": "Lists",
"manage_lists": "Manage Lists"
}
},
"timeline_pill": {
"offline": "Offline",

View File

@ -142,8 +142,44 @@ final class HomeTimelineViewController: UIViewController, NeedsDependency, Media
showFollowingAction.state = .on
}
}
let listsSubmenu = UIDeferredMenuElement.uncached { [weak self] callback in
guard let self else { return callback([]) }
Task { @MainActor in
let lists = (try? await Mastodon.API.Lists.getLists(
session: .shared,
domain: self.authContext.mastodonAuthenticationBox.domain,
authorization: self.authContext.mastodonAuthenticationBox.userAuthorization
).singleOutput().value) ?? []
var listEntries = lists.map {
return LabeledAction(title: $0.title, image: nil, handler: {
assertionFailure("Not yet implemented!")
}).menuElement
}
listEntries += [LabeledAction(
title: L10n.Scene.HomeTimeline.TimelineMenu.Lists.manageLists,
image: UIImage(systemName: "pencil"),
handler: {
assertionFailure("Not yet implemented!")
}).menuElement
]
callback(listEntries)
}
}
let listsMenu = UIMenu(
title: L10n.Scene.HomeTimeline.TimelineMenu.Lists.title,
image: UIImage(systemName: "list.bullet.rectangle.portrait"),
children: [listsSubmenu]
)
let listsDivider = UIMenu(title: "", options: .displayInline, children: [listsMenu])
return UIMenu(children: [showFollowingAction, showLocalTimelineAction])
return UIMenu(children: [showFollowingAction, showLocalTimelineAction, listsDivider])
}
}

View File

@ -862,6 +862,12 @@ public enum L10n {
public static let following = L10n.tr("Localizable", "Scene.HomeTimeline.TimelineMenu.Following", fallback: "Following")
/// Local
public static let localCommunity = L10n.tr("Localizable", "Scene.HomeTimeline.TimelineMenu.LocalCommunity", fallback: "Local")
public enum Lists {
/// Manage Lists
public static let manageLists = L10n.tr("Localizable", "Scene.HomeTimeline.TimelineMenu.Lists.ManageLists", fallback: "Manage Lists")
/// Lists
public static let title = L10n.tr("Localizable", "Scene.HomeTimeline.TimelineMenu.Lists.Title", fallback: "Lists")
}
}
public enum TimelinePill {
/// New Posts

View File

@ -305,6 +305,8 @@ uploaded to Mastodon.";
"Scene.Following.Title" = "following";
"Scene.HomeTimeline.TimelineMenu.Following" = "Following";
"Scene.HomeTimeline.TimelineMenu.LocalCommunity" = "Local";
"Scene.HomeTimeline.TimelineMenu.Lists.Title" = "Lists";
"Scene.HomeTimeline.TimelineMenu.Lists.ManageLists" = "Manage Lists";
"Scene.HomeTimeline.TimelinePill.NewPosts" = "New Posts";
"Scene.HomeTimeline.TimelinePill.Offline" = "Offline";
"Scene.HomeTimeline.TimelinePill.PostSent" = "Post Sent";
@ -617,4 +619,4 @@ If you disagree with the policy for **%@**, you can go back and pick a different
"Widget.MultipleFollowers.ConfigurationDescription" = "Show number of followers for multiple accounts.";
"Widget.MultipleFollowers.ConfigurationDisplayName" = "Multiple followers";
"Widget.MultipleFollowers.MockUser.AccountName" = "another@follower.social";
"Widget.MultipleFollowers.MockUser.DisplayName" = "Another follower";
"Widget.MultipleFollowers.MockUser.DisplayName" = "Another follower";