2023-12-28 09:37:02 +01:00
|
|
|
import SwiftUI
|
|
|
|
import Env
|
2023-12-28 11:26:00 +01:00
|
|
|
import AppAccount
|
|
|
|
import DesignSystem
|
2023-12-28 09:37:02 +01:00
|
|
|
|
|
|
|
@MainActor
|
|
|
|
struct NavigationTab<Content: View>: View {
|
2023-12-28 11:26:00 +01:00
|
|
|
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
|
|
|
|
|
|
|
@Environment(AppAccountsManager.self) private var appAccount
|
|
|
|
@Environment(CurrentAccount.self) private var currentAccount
|
|
|
|
@Environment(UserPreferences.self) private var userPreferences
|
|
|
|
@Environment(Theme.self) private var theme
|
|
|
|
|
2023-12-28 09:37:02 +01:00
|
|
|
var content: () -> Content
|
|
|
|
|
|
|
|
@State private var routerPath = RouterPath()
|
|
|
|
|
|
|
|
init(@ViewBuilder content: @escaping () -> Content) {
|
|
|
|
self.content = content
|
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
NavigationStack(path: $routerPath.path) {
|
|
|
|
content()
|
|
|
|
.withEnvironments()
|
|
|
|
.withAppRouter()
|
2023-12-28 11:26:00 +01:00
|
|
|
.withSheetDestinations(sheetDestinations: $routerPath.presentedSheet)
|
|
|
|
.toolbar {
|
|
|
|
if !isSecondaryColumn {
|
|
|
|
statusEditorToolbarItem(routerPath: routerPath,
|
|
|
|
visibility: userPreferences.postVisibility)
|
|
|
|
if UIDevice.current.userInterfaceIdiom != .pad {
|
|
|
|
ToolbarItem(placement: .navigationBarLeading) {
|
|
|
|
AppAccountsSelectorView(routerPath: routerPath)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if UIDevice.current.userInterfaceIdiom == .pad {
|
|
|
|
if (!isSecondaryColumn && !userPreferences.showiPadSecondaryColumn) || isSecondaryColumn {
|
|
|
|
SecondaryColumnToolbarItem()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .navigationBar)
|
2023-12-28 09:37:02 +01:00
|
|
|
}
|
2023-12-28 11:26:00 +01:00
|
|
|
.environment(routerPath)
|
2023-12-28 09:37:02 +01:00
|
|
|
}
|
|
|
|
}
|