IceCubes/IceCubesApp/App/AppRouteur.swift

81 lines
2.8 KiB
Swift
Raw Normal View History

2022-11-29 11:46:02 +01:00
import Account
2023-01-17 11:36:01 +01:00
import AppAccount
2022-12-20 09:37:07 +01:00
import DesignSystem
2023-01-17 11:36:01 +01:00
import Env
import Lists
2023-01-17 11:36:01 +01:00
import Status
import SwiftUI
import Timeline
2022-11-29 11:46:02 +01:00
@MainActor
2022-11-29 11:46:02 +01:00
extension View {
func withAppRouter() -> some View {
navigationDestination(for: RouterDestinations.self) { destination in
2022-11-29 11:46:02 +01:00
switch destination {
case let .accountDetail(id):
2022-11-29 12:18:06 +01:00
AccountDetailView(accountId: id)
2022-12-17 13:37:46 +01:00
case let .accountDetailWithAccount(account):
AccountDetailView(account: account)
2022-11-29 11:46:02 +01:00
case let .statusDetail(id):
StatusDetailView(statusId: id)
case let .remoteStatusDetail(url):
StatusDetailView(remoteStatusURL: url)
2022-12-21 20:26:38 +01:00
case let .hashTag(tag, accountId):
2022-12-31 12:28:27 +01:00
TimelineView(timeline: .constant(.hashtag(tag: tag, accountId: accountId)), scrollToTopSignal: .constant(0))
case let .list(list):
TimelineView(timeline: .constant(.list(list: list)), scrollToTopSignal: .constant(0))
2022-12-23 18:47:19 +01:00
case let .following(id):
2022-12-28 10:08:41 +01:00
AccountsListView(mode: .following(accountId: id))
2022-12-23 18:47:19 +01:00
case let .followers(id):
2022-12-24 13:41:25 +01:00
AccountsListView(mode: .followers(accountId: id))
case let .favouritedBy(id):
AccountsListView(mode: .favouritedBy(statusId: id))
case let .rebloggedBy(id):
AccountsListView(mode: .rebloggedBy(statusId: id))
2022-11-29 11:46:02 +01:00
}
}
}
2023-01-17 11:36:01 +01:00
2022-12-20 09:37:07 +01:00
func withSheetDestinations(sheetDestinations: Binding<SheetDestinations?>) -> some View {
2023-01-17 11:36:01 +01:00
sheet(item: sheetDestinations) { destination in
2022-12-20 09:37:07 +01:00
switch destination {
2022-12-26 08:24:55 +01:00
case let .replyToStatusEditor(status):
StatusEditorView(mode: .replyTo(status: status))
.withEnvironments()
case let .newStatusEditor(visibility):
StatusEditorView(mode: .new(visibility: visibility))
.withEnvironments()
2022-12-26 08:24:55 +01:00
case let .editStatusEditor(status):
StatusEditorView(mode: .edit(status: status))
.withEnvironments()
2022-12-27 07:51:44 +01:00
case let .quoteStatusEditor(status):
StatusEditorView(mode: .quote(status: status))
.withEnvironments()
2023-01-04 18:37:58 +01:00
case let .mentionStatusEditor(account, visibility):
StatusEditorView(mode: .mention(account: account, visibility: visibility))
.withEnvironments()
case let .listEdit(list):
ListEditView(list: list)
.withEnvironments()
case let .listAddAccount(account):
ListAddAccountView(account: account)
.withEnvironments()
case .addAccount:
AddAccountView()
.withEnvironments()
2023-01-06 17:14:34 +01:00
case .addRemoteLocalTimeline:
AddRemoteTimelineView()
.withEnvironments()
2022-12-20 09:37:07 +01:00
}
}
}
2023-01-17 11:36:01 +01:00
func withEnvironments() -> some View {
2023-01-17 11:36:01 +01:00
environmentObject(CurrentAccount.shared)
.environmentObject(UserPreferences.shared)
.environmentObject(CurrentInstance.shared)
.environmentObject(Theme.shared)
.environmentObject(AppAccountsManager.shared)
}
2022-11-29 11:46:02 +01:00
}