Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions Presentation/RootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,16 @@ struct RootView: View {
)
.navigationSplitViewColumnWidth(min: 220, ideal: 250, max: 340)
} detail: {
detail
.safeAreaInset(edge: .top, spacing: 0) {
if studIPViewModel.sessionExpired, !isSessionBannerDismissed {
StudIPSessionBanner(viewModel: studIPViewModel) { isSessionBannerDismissed = true }
}
// The banner sits above the content instead of in a top safe-area inset: changing that inset
// under the window toolbar made SwiftUI rebuild the toolbar in an endless loop at launch.
VStack(spacing: 0) {
if studIPViewModel.sessionExpired, !isSessionBannerDismissed {
StudIPSessionBanner(viewModel: studIPViewModel) { isSessionBannerDismissed = true }
}
}
.toolbar { historyButtons }
.toolbar {
ToolbarItem(placement: .primaryAction) {
StudyTimerToolbarButton(
viewModel: studyTimerViewModel,
modules: viewModel.activeModules,
currentModuleID: navigation.selectedModuleID
)
detail
}
}
.toolbar { windowToolbar }
.sheet(item: $assignmentsViewModel.editor) { draft in
AssignmentEditorSheet(
draft: draft,
Expand Down Expand Up @@ -228,10 +221,11 @@ struct RootView: View {
)
}

// MARK: Verlauf
// MARK: Toolbar

/// One toolbar for the whole window; separate `.toolbar` modifiers have to be merged on every update.
@ToolbarContentBuilder
private var historyButtons: some ToolbarContent {
private var windowToolbar: some ToolbarContent {
ToolbarItemGroup(placement: .navigation) {
Button { navigation.goBack() } label: {
Label("Zurück", systemImage: "chevron.backward")
Expand All @@ -251,5 +245,12 @@ struct RootView: View {
}
.help("Gehe zu Modul oder Notiz (⌘K)")
}
ToolbarItem(placement: .primaryAction) {
StudyTimerToolbarButton(
viewModel: studyTimerViewModel,
modules: viewModel.activeModules,
currentModuleID: navigation.selectedModuleID
)
}
}
}
Loading