From 2d069894ead7494619be3ca2d4fe26f49403e3b8 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Mon, 7 Oct 2024 15:11:33 -0600 Subject: [PATCH 1/4] fixes bug preventing escape key from closing inspector --- KlockWork/Views/Home/Home.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/KlockWork/Views/Home/Home.swift b/KlockWork/Views/Home/Home.swift index 1bb37e24..9fc12b7d 100644 --- a/KlockWork/Views/Home/Home.swift +++ b/KlockWork/Views/Home/Home.swift @@ -147,6 +147,7 @@ struct Home: View { } } } + .onAppear(perform: self.onAppear) } @ViewBuilder var Sidebar: some View { From c9d7e8a1e72753c51b5b727847c82382468cf40a Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Mon, 7 Oct 2024 15:11:54 -0600 Subject: [PATCH 2/4] a little bit of refactoring, removed unused code --- KlockWork/Views/Home/Home.swift | 139 +------------------------------- 1 file changed, 4 insertions(+), 135 deletions(-) diff --git a/KlockWork/Views/Home/Home.swift b/KlockWork/Views/Home/Home.swift index 9fc12b7d..1e3ef723 100644 --- a/KlockWork/Views/Home/Home.swift +++ b/KlockWork/Views/Home/Home.swift @@ -266,140 +266,9 @@ struct Home: View { } } } +} - var body2: some View { - VStack(alignment: .leading) { - HStack(alignment: .top, spacing: 0) { - VStack(alignment: .leading) { - ZStack(alignment: .topTrailing) { - Theme.toolbarColour - LinearGradient(gradient: Gradient(colors: [Color.black, Theme.toolbarColour]), startPoint: .topTrailing, endPoint: .topLeading) - .opacity(0.25) - - VStack(alignment: .trailing, spacing: 5) { - FancyDivider() - ForEach(buttons[.views]!) { button in button.environmentObject(nav) } - - FancyDivider() - ForEach(buttons[.entities]!) { button in button.environmentObject(nav) } - } - } - } - .frame(width: 100) - - HStack(alignment: .top, spacing: 0) { - if nav.sidebar != nil { - VStack(alignment: .leading, spacing: 0) { - GlobalSidebarWidgets() - - if !isSearchStackShowing && !isUpcomingTaskStackShowing { - if isDatePickerPresented { - ZStack { - nav.sidebar - Color.black.opacity(0.7) - } - } else { - nav.sidebar - } - } - } - .frame(width: 320) - .background(nav.parent != nil ? nav.parent!.colour : Theme.tabActiveColour) - } else { - HorizontalSeparator // TODO: maybe remove? - } - - if nav.inspector != nil { - ZStack(alignment: .topLeading) { - nav.view - .navigationTitle(nav.pageTitle()) - .disabled(isDatePickerPresented) - Color.black.opacity(0.7) - - ZStack(alignment: .topLeading) { - LinearGradient(gradient: Gradient(colors: [Color.clear, Color.black]), startPoint: .topTrailing, endPoint: .topLeading) - .opacity(0.25) - .frame(width: 20) - - Theme.subHeaderColour - - nav.inspector - - if isDatePickerPresented { - Color.black.opacity(0.7) - } - } - .background(Theme.base) - .frame(width: 340) - } - } else { - VStack { -// if nav.history.recent.count > 0 { -// HStack { -// Button { -// if let previous = nav.history.previous() { -// nav.to(previous.page) -// } -// } label: { -// HStack(spacing: 5) { -// Image(systemName: "arrow.left") -// Text("Back") -// } -// } -// .buttonStyle(.plain) -// .background(Theme.subHeaderColour) -// -// Spacer() -// Button { -// if let next = nav.history.next() { -// nav.to(next.page) -// } -// } label: { -// HStack(spacing: 5) { -// Text("Next") -// Image(systemName: "arrow.right") -// } -// } -// .buttonStyle(.plain) -// .background(Theme.subHeaderColour) -// } -// .background(Theme.base) -// .frame(height: 70) -// } - - ZStack { - nav.view - .navigationTitle(nav.pageTitle()) - .disabled(isDatePickerPresented) - (isDatePickerPresented ? Color.black.opacity(0.7) : .clear) - } - } - } - - if showSessionInspector { - SessionInspector() - } - } - } - } - .background(Theme.base) - .onAppear(perform: onAppear) - .onChange(of: nav.parent!) { buttonToHighlight in - selectedSidebarButton = buttonToHighlight - } - .onChange(of: nav.session.eventStatus) { status in - - } - } - - var HorizontalSeparator: some View { - // TODO: make draggable - ZStack { - Theme.headerColour - } - .frame(width: 3) - } - +extension Home { private func onAppear() -> Void { nav.parent = selectedSidebarButton checkForEvents() @@ -430,8 +299,8 @@ struct Home: View { nav.session.eventStatus = updateIndicator() } } - - /// Updates the dashboard icon upcoming event indicator + + /// Updates the dashboard icon upcoming event indicator /// - Returns: EventIndicatorStatus private func updateIndicator() -> EventIndicatorStatus { let ce = CoreDataCalendarEvent(moc: moc) From ccb39c15ebd58c0e134356412ca93b6432d41659 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Mon, 7 Oct 2024 15:14:51 -0600 Subject: [PATCH 3/4] inspector background colour changed to fit current page style better --- KlockWork/Views/Home/Home.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KlockWork/Views/Home/Home.swift b/KlockWork/Views/Home/Home.swift index 1e3ef723..c3bf5caa 100644 --- a/KlockWork/Views/Home/Home.swift +++ b/KlockWork/Views/Home/Home.swift @@ -211,7 +211,7 @@ struct Home: View { .opacity(0.25) .frame(width: 20) - Theme.subHeaderColour + self.nav.parent?.appPage.primaryColour.opacity(0.2) ?? Theme.subHeaderColour nav.inspector From 1ab2c681d85f6aeb80e3746dcd6222154c532d4d Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Mon, 7 Oct 2024 15:14:59 -0600 Subject: [PATCH 4/4] a bit more refactoring --- KlockWork/Views/Home/Home.swift | 64 ++++++++++++++++----------------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/KlockWork/Views/Home/Home.swift b/KlockWork/Views/Home/Home.swift index c3bf5caa..0cd00c2f 100644 --- a/KlockWork/Views/Home/Home.swift +++ b/KlockWork/Views/Home/Home.swift @@ -224,38 +224,38 @@ struct Home: View { } } else { VStack { - // if nav.history.recent.count > 0 { - // HStack { - // Button { - // if let previous = nav.history.previous() { - // nav.to(previous.page) - // } - // } label: { - // HStack(spacing: 5) { - // Image(systemName: "arrow.left") - // Text("Back") - // } - // } - // .buttonStyle(.plain) - // .background(Theme.subHeaderColour) - // - // Spacer() - // Button { - // if let next = nav.history.next() { - // nav.to(next.page) - // } - // } label: { - // HStack(spacing: 5) { - // Text("Next") - // Image(systemName: "arrow.right") - // } - // } - // .buttonStyle(.plain) - // .background(Theme.subHeaderColour) - // } - // .background(Theme.base) - // .frame(height: 70) - // } +// if nav.history.recent.count > 0 { +// HStack { +// Button { +// if let previous = nav.history.previous() { +// nav.to(previous.page) +// } +// } label: { +// HStack(spacing: 5) { +// Image(systemName: "arrow.left") +// Text("Back") +// } +// } +// .buttonStyle(.plain) +// .background(Theme.subHeaderColour) +// +// Spacer() +// Button { +// if let next = nav.history.next() { +// nav.to(next.page) +// } +// } label: { +// HStack(spacing: 5) { +// Text("Next") +// Image(systemName: "arrow.right") +// } +// } +// .buttonStyle(.plain) +// .background(Theme.subHeaderColour) +// } +// .background(Theme.base) +// .frame(height: 70) +// } ZStack { nav.view