2023-12-29 18:50:53 +01:00
|
|
|
import AppAccount
|
|
|
|
import DesignSystem
|
2024-02-14 12:48:14 +01:00
|
|
|
import Env
|
|
|
|
import SwiftUI
|
2023-12-29 18:50:53 +01:00
|
|
|
|
|
|
|
@MainActor
|
|
|
|
struct ToolbarTab: ToolbarContent {
|
|
|
|
@Environment(\.isSecondaryColumn) private var isSecondaryColumn: Bool
|
|
|
|
@Environment(\.horizontalSizeClass) private var horizontalSizeClass
|
2024-02-14 12:48:14 +01:00
|
|
|
|
2023-12-29 18:50:53 +01:00
|
|
|
@Environment(UserPreferences.self) private var userPreferences
|
2024-06-25 10:59:43 +02:00
|
|
|
@Environment(Theme.self) private var theme
|
2024-02-14 12:48:14 +01:00
|
|
|
|
2023-12-29 18:50:53 +01:00
|
|
|
@Binding var routerPath: RouterPath
|
2024-02-14 12:48:14 +01:00
|
|
|
|
2023-12-29 18:50:53 +01:00
|
|
|
var body: some ToolbarContent {
|
|
|
|
if !isSecondaryColumn {
|
2024-05-08 11:51:28 +02:00
|
|
|
ToolbarItem(placement: .topBarLeading) {
|
|
|
|
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
|
|
|
Button {
|
|
|
|
withAnimation {
|
|
|
|
userPreferences.isSidebarExpanded.toggle()
|
|
|
|
}
|
|
|
|
} label: {
|
|
|
|
if userPreferences.isSidebarExpanded {
|
|
|
|
Image(systemName: "sidebar.squares.left")
|
|
|
|
} else {
|
|
|
|
Image(systemName: "sidebar.left")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-12-29 18:50:53 +01:00
|
|
|
statusEditorToolbarItem(routerPath: routerPath,
|
|
|
|
visibility: userPreferences.postVisibility)
|
|
|
|
if UIDevice.current.userInterfaceIdiom != .pad ||
|
2024-02-14 12:48:14 +01:00
|
|
|
(UIDevice.current.userInterfaceIdiom == .pad && horizontalSizeClass == .compact)
|
|
|
|
{
|
2023-12-29 18:50:53 +01:00
|
|
|
ToolbarItem(placement: .navigationBarLeading) {
|
2024-06-25 10:59:43 +02:00
|
|
|
AppAccountsSelectorView(routerPath: routerPath, avatarConfig: theme.avatarShape == .circle ? .badge : .badgeRounded)
|
2023-12-29 18:50:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if UIDevice.current.userInterfaceIdiom == .pad && horizontalSizeClass == .regular {
|
|
|
|
if (!isSecondaryColumn && !userPreferences.showiPadSecondaryColumn) || isSecondaryColumn {
|
|
|
|
SecondaryColumnToolbarItem()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|