2024-01-10 13:26:55 +01:00
|
|
|
import DesignSystem
|
|
|
|
import Env
|
|
|
|
import SwiftUI
|
|
|
|
|
2024-03-11 08:59:29 +01:00
|
|
|
@MainActor
|
2024-01-10 13:26:55 +01:00
|
|
|
struct SidebarEntriesSettingsView: View {
|
|
|
|
@Environment(Theme.self) private var theme
|
|
|
|
@Environment(UserPreferences.self) private var userPreferences
|
2024-02-14 12:48:14 +01:00
|
|
|
|
2024-01-10 13:26:55 +01:00
|
|
|
@State private var sidebarTabs = SidebarTabs.shared
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
@Bindable var userPreferences = userPreferences
|
|
|
|
Form {
|
|
|
|
Section {
|
|
|
|
ForEach($sidebarTabs.tabs, id: \.tab) { $tab in
|
|
|
|
if tab.tab != .profile && tab.tab != .settings {
|
|
|
|
Toggle(isOn: $tab.enabled) {
|
|
|
|
tab.tab.label
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.onMove(perform: move)
|
|
|
|
}
|
|
|
|
#if !os(visionOS)
|
|
|
|
.listRowBackground(theme.primaryBackgroundColor)
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
.environment(\.editMode, .constant(.active))
|
|
|
|
.navigationTitle("settings.general.sidebarEntries")
|
|
|
|
#if !os(visionOS)
|
2024-02-14 12:48:14 +01:00
|
|
|
.scrollContentBackground(.hidden)
|
|
|
|
.background(theme.secondaryBackgroundColor)
|
2024-01-10 13:26:55 +01:00
|
|
|
#endif
|
|
|
|
}
|
2024-02-14 12:48:14 +01:00
|
|
|
|
2024-01-10 13:26:55 +01:00
|
|
|
func move(from source: IndexSet, to destination: Int) {
|
|
|
|
sidebarTabs.tabs.move(fromOffsets: source, toOffset: destination)
|
|
|
|
}
|
|
|
|
}
|