2024-05-02 09:37:38 +00:00
|
|
|
import AppIntents
|
2024-05-04 11:19:19 +00:00
|
|
|
import Foundation
|
2024-05-02 09:37:38 +00:00
|
|
|
|
|
|
|
enum TabEnum: String, AppEnum, Sendable {
|
|
|
|
case timeline, notifications, mentions, explore, messages, settings
|
|
|
|
case trending, federated, local
|
|
|
|
case profile
|
|
|
|
case bookmarks
|
|
|
|
case favorites
|
|
|
|
case post
|
|
|
|
case followedTags
|
|
|
|
case lists
|
|
|
|
case links
|
|
|
|
|
2024-05-04 11:19:19 +00:00
|
|
|
static var typeDisplayName: LocalizedStringResource { "Tab" }
|
|
|
|
|
2024-05-02 09:37:38 +00:00
|
|
|
static let typeDisplayRepresentation: TypeDisplayRepresentation = "Tab"
|
2024-05-04 11:19:19 +00:00
|
|
|
|
|
|
|
nonisolated static var caseDisplayRepresentations: [TabEnum: DisplayRepresentation] {
|
2024-05-02 09:37:38 +00:00
|
|
|
[.timeline: .init(title: "Home Timeline"),
|
|
|
|
.trending: .init(title: "Trending Timeline"),
|
|
|
|
.federated: .init(title: "Federated Timeline"),
|
|
|
|
.local: .init(title: "Local Timeline"),
|
|
|
|
.notifications: .init(title: "Notifications"),
|
|
|
|
.mentions: .init(title: "Mentions"),
|
|
|
|
.explore: .init(title: "Explore & Trending"),
|
|
|
|
.messages: .init(title: "Private Messages"),
|
|
|
|
.settings: .init(title: "Settings"),
|
|
|
|
.profile: .init(title: "Profile"),
|
|
|
|
.bookmarks: .init(title: "Bookmarks"),
|
|
|
|
.favorites: .init(title: "Favorites"),
|
|
|
|
.followedTags: .init(title: "Followed Tags"),
|
|
|
|
.lists: .init(title: "Lists"),
|
|
|
|
.links: .init(title: "Trending Links"),
|
2024-05-04 11:19:19 +00:00
|
|
|
.post: .init(title: "New post")]
|
2024-05-02 09:37:38 +00:00
|
|
|
}
|
2024-05-04 11:19:19 +00:00
|
|
|
|
2024-05-02 09:37:38 +00:00
|
|
|
var toAppTab: Tab {
|
|
|
|
switch self {
|
|
|
|
case .timeline:
|
2024-05-04 11:19:19 +00:00
|
|
|
.timeline
|
2024-05-02 09:37:38 +00:00
|
|
|
case .notifications:
|
2024-05-04 11:19:19 +00:00
|
|
|
.notifications
|
2024-05-02 09:37:38 +00:00
|
|
|
case .mentions:
|
2024-05-04 11:19:19 +00:00
|
|
|
.mentions
|
2024-05-02 09:37:38 +00:00
|
|
|
case .explore:
|
2024-05-04 11:19:19 +00:00
|
|
|
.explore
|
2024-05-02 09:37:38 +00:00
|
|
|
case .messages:
|
2024-05-04 11:19:19 +00:00
|
|
|
.messages
|
2024-05-02 09:37:38 +00:00
|
|
|
case .settings:
|
2024-05-04 11:19:19 +00:00
|
|
|
.settings
|
2024-05-02 09:37:38 +00:00
|
|
|
case .trending:
|
2024-05-04 11:19:19 +00:00
|
|
|
.trending
|
2024-05-02 09:37:38 +00:00
|
|
|
case .federated:
|
2024-05-04 11:19:19 +00:00
|
|
|
.federated
|
2024-05-02 09:37:38 +00:00
|
|
|
case .local:
|
2024-05-04 11:19:19 +00:00
|
|
|
.local
|
2024-05-02 09:37:38 +00:00
|
|
|
case .profile:
|
2024-05-04 11:19:19 +00:00
|
|
|
.profile
|
2024-05-02 09:37:38 +00:00
|
|
|
case .bookmarks:
|
2024-05-04 11:19:19 +00:00
|
|
|
.bookmarks
|
2024-05-02 09:37:38 +00:00
|
|
|
case .favorites:
|
2024-05-04 11:19:19 +00:00
|
|
|
.favorites
|
2024-05-02 09:37:38 +00:00
|
|
|
case .post:
|
2024-05-04 11:19:19 +00:00
|
|
|
.post
|
2024-05-02 09:37:38 +00:00
|
|
|
case .followedTags:
|
2024-05-04 11:19:19 +00:00
|
|
|
.followedTags
|
2024-05-02 09:37:38 +00:00
|
|
|
case .lists:
|
2024-05-04 11:19:19 +00:00
|
|
|
.lists
|
2024-05-02 09:37:38 +00:00
|
|
|
case .links:
|
2024-05-04 11:19:19 +00:00
|
|
|
.links
|
2024-05-02 09:37:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct TabIntent: AppIntent {
|
|
|
|
static let title: LocalizedStringResource = "Open on a tab"
|
2024-05-05 11:12:19 +00:00
|
|
|
static let description: IntentDescription = "Open the app on a specific tab"
|
2024-05-02 09:37:38 +00:00
|
|
|
static let openAppWhenRun: Bool = true
|
2024-05-04 11:19:19 +00:00
|
|
|
|
2024-05-02 09:37:38 +00:00
|
|
|
@Parameter(title: "Selected tab")
|
|
|
|
var tab: TabEnum
|
2024-05-04 11:19:19 +00:00
|
|
|
|
2024-05-02 09:37:38 +00:00
|
|
|
@MainActor
|
|
|
|
func perform() async throws -> some IntentResult {
|
|
|
|
AppIntentService.shared.handledIntent = .init(intent: self)
|
|
|
|
return .result()
|
|
|
|
}
|
|
|
|
}
|