From 62526e9e84cf9124586cc5e5fbc2129be0bafd50 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:13:01 -0600 Subject: [PATCH 1/9] add format string to method args --- KWCore/Sources/Helpers/DateHelper.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/KWCore/Sources/Helpers/DateHelper.swift b/KWCore/Sources/Helpers/DateHelper.swift index 334e6518..112c8bfd 100644 --- a/KWCore/Sources/Helpers/DateHelper.swift +++ b/KWCore/Sources/Helpers/DateHelper.swift @@ -76,10 +76,15 @@ final public class DateHelper { return entries } - - static public func todayShort(_ date: Date? = Date()) -> String { + + /// Format today's date + /// - Parameters: + /// - date: Date + /// - format: String + /// - Returns: Void + static public func todayShort(_ date: Date? = Date(), format: String = "yyyy-MM-dd") -> String { let formatter = DateFormatter() - formatter.dateFormat = "yyyy-MM-dd" + formatter.dateFormat = format formatter.timeZone = TimeZone.autoupdatingCurrent formatter.locale = NSLocale.current From 620d9c2b356835c740c47b7b2cbd3df416c09820 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:13:22 -0600 Subject: [PATCH 2/9] disable back button if there's no history --- .../UI/WidgetLibrary/WidgetLibrary.UI.swift | 189 +++++++++++++++--- 1 file changed, 156 insertions(+), 33 deletions(-) diff --git a/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift b/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift index deb64bc4..3f5451a1 100644 --- a/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift +++ b/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift @@ -223,6 +223,7 @@ extension WidgetLibrary { public var onAction: (() -> Void)? = {} @State private var isHighlighted: Bool = false @State private var selectedPage: Page = .dashboard + private var isEmpty: Bool { self.state.history.recent.count == 0 } var body: some View { Button { @@ -242,9 +243,10 @@ extension WidgetLibrary { .clipShape(.rect(cornerRadius: 5)) .padding([.top, .bottom], 10) } + .disabled(self.isEmpty) .keyboardShortcut(KeyEquivalent.leftArrow, modifiers: [.command]) .buttonStyle(.plain) - .useDefaultHover({ hover in self.isHighlighted = hover}) + .useDefaultHover({ hover in !self.isEmpty ? self.isHighlighted = hover : nil}) } } @@ -393,50 +395,171 @@ extension WidgetLibrary { @EnvironmentObject public var state: Navigation var body: some View { - if self.state.history.recent.count > 0 { - ZStack { - Theme.toolbarColour - LinearGradient(colors: [Theme.base, .clear], startPoint: .bottom, endPoint: .top) - .opacity(0.6) - .blendMode(.softLight) - - VStack(alignment: .leading, spacing: 0) { - HStack { - Buttons.HistoryPrevious() - Spacer() - ForEach(self.state.navButtons, id: \.self) { type in - switch type { - case .CLIMode: Buttons.CLIMode() - case .historyPrevious: Buttons.HistoryPrevious() - case .resetUserChoices: Buttons.ResetUserChoices() - case .settings: Buttons.Settings() - case .createJob: Buttons.CreateJob() - case .createNote: Buttons.CreateNote() + ZStack { + Theme.toolbarColour + LinearGradient(colors: [Theme.base, .clear], startPoint: .bottom, endPoint: .top) + .opacity(0.6) + .blendMode(.softLight) + + VStack(alignment: .leading, spacing: 0) { + HStack { + Buttons.HistoryPrevious() + Spacer() + SimpleDateSelector() + Spacer() + ForEach(self.state.navButtons, id: \.self) { type in + switch type { + case .CLIMode: Buttons.CLIMode() + case .historyPrevious: Buttons.HistoryPrevious() + case .resetUserChoices: Buttons.ResetUserChoices() + case .settings: Buttons.Settings() + case .createJob: Buttons.CreateJob() + case .createNote: Buttons.CreateNote() // case .createTask: Buttons.CreateTask() - case .createTerm: Buttons.CreateTerm() - case .createPerson: Buttons.CreatePerson() - case .createRecord: Buttons.CreateRecord() - case .createCompany: Buttons.CreateCompany() - case .createProject: Buttons.CreateProject() - case .createDefinition: Buttons.CreateDefinition() - default: EmptyView() + case .createTerm: Buttons.CreateTerm() + case .createPerson: Buttons.CreatePerson() + case .createRecord: Buttons.CreateRecord() + case .createCompany: Buttons.CreateCompany() + case .createProject: Buttons.CreateProject() + case .createDefinition: Buttons.CreateDefinition() + default: EmptyView() + } + } + } + .padding([.leading, .trailing]) + Divider() + } + } + .frame(height: 55) + } + } + + struct SimpleDateSelector: View { + @EnvironmentObject private var state: Navigation + @AppStorage("today.numPastDates") public var numPastDates: Int = 20 + @AppStorage("isDatePickerPresented") public var isDatePickerPresented: Bool = false + @State private var isToday: Bool = false + @State private var isHighlighted: Bool = false + @State private var date: String = "" + @State private var showDateOverlay: Bool = false + @State private var sDate: Date = Date() + + var body: some View { + HStack(alignment: .center) { + FancyButtonv2( + text: "Previous day", + action: self.actionPreviousDay, + icon: "chevron.left", + fgColour: .gray, + showLabel: false, + size: .titleLink, + type: .titleLink + ) + .help("Previous day") + + Button { + self.showDateOverlay.toggle() + } label: { + HStack(alignment: .center) { + ZStack { + RoundedRectangle(cornerRadius: 5) + .strokeBorder(self.isToday ? .yellow.opacity(0.6) : .gray, lineWidth: 1) + .fill(.white.opacity(self.isHighlighted ? 0.2 : 0.1)) + if !self.showDateOverlay { + HStack { + Image(systemName: "calendar") + .foregroundStyle(.gray) + Text(self.date) } } -// Buttons.Settings() -// Buttons.CLIMode() -// Buttons.ResetUserChoices(onActionClear: {}) } - .padding([.leading, .trailing]) - Divider() + .frame(width: 200) + } + } + .foregroundStyle(self.isHighlighted ? .white : self.isToday ? .yellow.opacity(0.6) : .gray) + .buttonStyle(.plain) + .useDefaultHover({ hover in self.isHighlighted = hover}) + .overlay { + if self.showDateOverlay { + HStack { + DatePicker("", selection: $sDate) + Image(systemName: "xmark") + } } } - .frame(height: 55) + + FancyButtonv2( + text: "Next day", + action: self.actionNextDay, + icon: "chevron.right", + fgColour: .gray, + showLabel: false, + size: .titleLink, + type: .titleLink + ) + .help("Next day") } + .padding(12) + .onAppear(perform: self.actionOnAppear) + .onChange(of: self.state.session.date) { self.actionOnChangeDate() } + .onChange(of: self.sDate) { self.state.session.date = self.sDate } } } } } +extension WidgetLibrary.UI.SimpleDateSelector { + /// Onload handler. Sets up a timer to advance to the next day and sets view state + /// - Returns: Void + private func actionOnAppear() -> Void { + self.actionOnChangeDate() + + // Auto-advance date to tomorrow when the clock strikes midnight + Timer.scheduledTimer(withTimeInterval: 3600, repeats: true) { timer in + let components = Calendar.autoupdatingCurrent.dateComponents([.hour], from: Date()) + + if let hour = components.hour { + if hour == 24 { + self.actionNextDay() + } + } + } + } + + /// Fires when the date is changed. + /// - Returns: Void + private func actionOnChangeDate() -> Void { + self.date = DateHelper.todayShort(self.state.session.date, format: "MMMM d, yyyy") + self.isToday = self.areSameDate(self.state.session.date, Date()) + } + + /// Determine if two dates are the same + /// - Parameters: + /// - lhs: Date + /// - rhs: Date + /// - Returns: Void + private func areSameDate(_ lhs: Date, _ rhs: Date) -> Bool { + let df = DateFormatter() + df.dateFormat = "MMMM d" + let fmtDate = df.string(from: lhs) + let fmtSessionDate = df.string(from: rhs) + + return fmtDate == fmtSessionDate + } + + /// Decrement the current day + /// - Returns: Void + private func actionPreviousDay() -> Void { + self.state.session.date -= 86400 + } + + /// Increment the current day + /// - Returns: Void + private func actionNextDay() -> Void { + self.state.session.date += 86400 + } +} + extension WidgetLibrary.UI.Buttons.ResetUserChoices { private func defaultClearAction() -> Void { self.state.session.job = nil From a7022d72fb8f8145157c11a1d987a3def2215fa6 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:13:37 -0600 Subject: [PATCH 3/9] removed old dateselectorwidget --- .../Views/Shared/AppSidebar/GlobalSidebarWidgets.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/KlockWork/Views/Shared/AppSidebar/GlobalSidebarWidgets.swift b/KlockWork/Views/Shared/AppSidebar/GlobalSidebarWidgets.swift index e2eec80c..2a398968 100644 --- a/KlockWork/Views/Shared/AppSidebar/GlobalSidebarWidgets.swift +++ b/KlockWork/Views/Shared/AppSidebar/GlobalSidebarWidgets.swift @@ -13,10 +13,6 @@ struct GlobalSidebarWidgets: View { @EnvironmentObject public var nav: Navigation var body: some View { - ZStack(alignment: .topLeading) { - CreateEntitiesWidget() - .padding(.top, 53) - DateSelectorWidget() - } + CreateEntitiesWidget() } } From 6a9428086ab6805740ab434b21dc8d98b43ea585 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:13:50 -0600 Subject: [PATCH 4/9] moved padding to the rows that need it --- .../Shared/AppSidebar/Widgets/CreateEntitiesWidget.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/KlockWork/Views/Shared/AppSidebar/Widgets/CreateEntitiesWidget.swift b/KlockWork/Views/Shared/AppSidebar/Widgets/CreateEntitiesWidget.swift index dfe8b175..15d2ee1d 100644 --- a/KlockWork/Views/Shared/AppSidebar/Widgets/CreateEntitiesWidget.swift +++ b/KlockWork/Views/Shared/AppSidebar/Widgets/CreateEntitiesWidget.swift @@ -24,6 +24,7 @@ struct CreateEntitiesWidget: View { var body: some View { VStack(alignment: .leading, spacing: 0) { Buttons + .padding(.bottom, isSearchStackShowing || isCreateStackShowing || isUpcomingTaskStackShowing ? 16 : 0) if isSearchStackShowing || isCreateStackShowing || isUpcomingTaskStackShowing { VStack(alignment: .leading, spacing: 0) { @@ -53,8 +54,7 @@ struct CreateEntitiesWidget: View { } private var Buttons: some View { - HStack(alignment: .center, spacing: 5) { - Spacer() + HStack(alignment: .center, spacing: 8) { PlanButton(doesPlanExist: $doesPlanExist) PrivacyModeButton() CreateButton(active: $isCreateStackShowing) From e26408617f1ac2f95e2cc18d91a2ab1d339108af Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:14:02 -0600 Subject: [PATCH 5/9] moved padding to the rows that need it --- KlockWork/Views/Shared/TaskForecast.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/KlockWork/Views/Shared/TaskForecast.swift b/KlockWork/Views/Shared/TaskForecast.swift index dd29d658..a811dac7 100644 --- a/KlockWork/Views/Shared/TaskForecast.swift +++ b/KlockWork/Views/Shared/TaskForecast.swift @@ -69,13 +69,14 @@ struct Forecast: View, Identifiable { switch self.type { case .member: ForecastTypeMember(date: self.date, callback: self.callback, upcomingTasks: _upcomingTasks) + .padding(8) case .button: ForecastTypeButton(date: self.date, callback: self.callback, upcomingTasks: _upcomingTasks) case .row: ForecastTypeRow(date: self.date, callback: self.callback, upcomingTasks: _upcomingTasks) + .padding(8) } } - .padding(8) } init(date: Date, callback: (() -> Void)? = nil, type: ForecastUIType = .member, page: PageConfiguration.AppPage) { @@ -168,7 +169,7 @@ struct Forecast: View, Identifiable { var body: some View { VStack(alignment: .center, spacing: 0) { - HStack(alignment: .center, spacing: 8) { + HStack(alignment: .center, spacing: 0) { Button { self.isCreateStackShowing = false self.isSearchStackShowing = false @@ -189,10 +190,10 @@ struct Forecast: View, Identifiable { Color.green } } - .mask(Circle().frame(width: 40)) + .mask(Circle().frame(width: 44)) (self.isHighlighted ? Color.white : Theme.base) - .mask(Circle().frame(width: 29)) + .mask(Circle().frame(width: 30)) Text(String(self.itemsDue)) .multilineTextAlignment(.leading) @@ -200,18 +201,15 @@ struct Forecast: View, Identifiable { .bold() .foregroundStyle(self.itemsDue == 0 ? .gray : self.isHighlighted ? Theme.base : .white) } + .frame(width: 50, height: 50) .useDefaultHover({ hover in self.isHighlighted = hover }) } .buttonStyle(.plain) } - .frame(height: 40) - .padding(.top, 4) Text("Tasks") - .padding(.top, 6) .opacity(0.4) } - .frame(width: 40) .onAppear(perform: self.actionOnAppear) .onChange(of: self.state.session.date) { self.actionOnAppear() From 85ccfa1e6a151e2364ad98e605fd957e8895280b Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:22:27 -0600 Subject: [PATCH 6/9] hide CLI mode button when disabled, remove extra exit CLI mode button --- .../UI/WidgetLibrary/WidgetLibrary.UI.swift | 28 ++++++++++--------- .../Entities/Today/CommandLineInterface.swift | 11 -------- 2 files changed, 15 insertions(+), 24 deletions(-) diff --git a/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift b/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift index 3f5451a1..aba96c30 100644 --- a/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift +++ b/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift @@ -274,25 +274,27 @@ extension WidgetLibrary { struct CLIMode: View { @EnvironmentObject public var state: Navigation + @AppStorage("general.experimental.cli") private var cliEnabled: Bool = false @AppStorage("today.commandLineMode") private var commandLineMode: Bool = false - @AppStorage("general.experimental.cli") private var allowCLIMode: Bool = false public var onAction: (() -> Void)? = {} @State private var isHighlighted: Bool = false @State private var selectedPage: Page = .dashboard var body: some View { - FancyButtonv2( - text: "Command line mode", - action: {commandLineMode.toggle() ; self.onAction?()}, - icon: self.commandLineMode ? "apple.terminal.fill" : "apple.terminal", - iconWhenHighlighted: self.commandLineMode ? "apple.terminal" : "apple.terminal.fill", - showLabel: false, - size: .small, - type: .clear, - font: .title - ) - .help("Enter CLI mode") - .frame(width: 25) + if self.cliEnabled { + FancyButtonv2( + text: "Command line mode", + action: {self.commandLineMode.toggle() ; self.onAction?()}, + icon: self.commandLineMode ? "apple.terminal.fill" : "apple.terminal", + iconWhenHighlighted: self.commandLineMode ? "apple.terminal" : "apple.terminal.fill", + showLabel: false, + size: .small, + type: .clear, + font: .title + ) + .help(self.commandLineMode ? "Exit CLI mode" : "Enter CLI mode") + .frame(width: 25) + } } } } diff --git a/KlockWork/Views/Entities/Today/CommandLineInterface.swift b/KlockWork/Views/Entities/Today/CommandLineInterface.swift index 72e79e2b..386390f1 100644 --- a/KlockWork/Views/Entities/Today/CommandLineInterface.swift +++ b/KlockWork/Views/Entities/Today/CommandLineInterface.swift @@ -46,17 +46,6 @@ struct CommandLineInterface: View { } HStack { Spacer() - FancyButtonv2( - text: "Exit CLI mode", - action: {commandLineMode.toggle()}, - icon: "apple.terminal", - fgColour: .white, - showLabel: false, - size: .tiny, - type: .clear - ) - .help("Exit CLI mode") - .frame(width: 30, height: 30) } .padding(.trailing) } From 0b2413f4e16b831baebc1456696093a183a14f76 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:22:50 -0600 Subject: [PATCH 7/9] removed record create button from today view (I don't think it's necessary) --- KlockWork/Utils/Navigation.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KlockWork/Utils/Navigation.swift b/KlockWork/Utils/Navigation.swift index 4b6c33aa..641b836e 100644 --- a/KlockWork/Utils/Navigation.swift +++ b/KlockWork/Utils/Navigation.swift @@ -557,7 +557,7 @@ extension Navigation { public let all: [HistoryPage] = [ HistoryPage(page: .dashboard, view: AnyView(Dashboard()), sidebar: AnyView(DashboardSidebar()), title: "Dashboard"), HistoryPage(page: .planning, view: AnyView(Planning()), sidebar: AnyView(DefaultPlanningSidebar()), title: "Planning"), - HistoryPage(page: .today, view: AnyView(Today()), sidebar: AnyView(TodaySidebar()), title: "Today", navButtons: [.CLIMode, .createRecord, .resetUserChoices]), + HistoryPage(page: .today, view: AnyView(Today()), sidebar: AnyView(TodaySidebar()), title: "Today", navButtons: [.CLIMode, .resetUserChoices]), HistoryPage(page: .companies, view: AnyView(CompanyDashboard()), sidebar: AnyView(DefaultCompanySidebar()), title: "Companies & Projects", navButtons: [.createCompany, .createProject]), HistoryPage(page: .companyDetail, view: AnyView(CompanyView()), sidebar: AnyView(DefaultCompanySidebar()), title: "Company"), HistoryPage(page: .jobs, view: AnyView(JobDashboardRedux()), sidebar: AnyView(JobDashboardSidebar()), title: "Jobs", navButtons: [.resetUserChoices, .createJob]), From 7ffc47c8b1b9ad1cab63eaa85a2b6f35d51944b3 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:38:58 -0600 Subject: [PATCH 8/9] moved CLI filter action button to CLI mode app nav --- .../UI/WidgetLibrary/WidgetLibrary.UI.swift | 25 +++++++++++++++++- KlockWork/Utils/Navigation.swift | 2 +- .../Entities/Today/CommandLineInterface.swift | 26 ++++++------------- 3 files changed, 33 insertions(+), 20 deletions(-) diff --git a/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift b/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift index aba96c30..2703ecf9 100644 --- a/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift +++ b/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift @@ -23,7 +23,7 @@ extension WidgetLibrary { public struct Buttons { public enum UIButtonType { case resetUserChoices, createNote, createTask, createRecord, createPerson, createCompany, createProject, - createJob, createTerm, createDefinition, historyPrevious, settings, CLIMode + createJob, createTerm, createDefinition, historyPrevious, settings, CLIMode, CLIFilter } struct ResetUserChoices: View { @@ -297,6 +297,28 @@ extension WidgetLibrary { } } } + + struct CLIFilter: View { + @EnvironmentObject public var state: Navigation + @AppStorage("general.experimental.cli") private var cliEnabled: Bool = false + @AppStorage("today.commandLineMode") private var commandLineMode: Bool = false + @AppStorage("today.cli.showFilter") private var showCLIFilter: Bool = false + + var body: some View { + if self.cliEnabled && self.commandLineMode { + FancyButtonv2( + text: "Filter", + action: {self.showCLIFilter.toggle()}, + icon: "line.3.horizontal.decrease", + bgColour: self.state.session.appPage.primaryColour.opacity(0.2), + showLabel: false, + size: .small, + type: .clear + ) + .mask(Circle()) + } + } + } } struct ActiveIndicator: View { @@ -412,6 +434,7 @@ extension WidgetLibrary { ForEach(self.state.navButtons, id: \.self) { type in switch type { case .CLIMode: Buttons.CLIMode() + case .CLIFilter: Buttons.CLIFilter() case .historyPrevious: Buttons.HistoryPrevious() case .resetUserChoices: Buttons.ResetUserChoices() case .settings: Buttons.Settings() diff --git a/KlockWork/Utils/Navigation.swift b/KlockWork/Utils/Navigation.swift index 641b836e..89eb63bf 100644 --- a/KlockWork/Utils/Navigation.swift +++ b/KlockWork/Utils/Navigation.swift @@ -557,7 +557,7 @@ extension Navigation { public let all: [HistoryPage] = [ HistoryPage(page: .dashboard, view: AnyView(Dashboard()), sidebar: AnyView(DashboardSidebar()), title: "Dashboard"), HistoryPage(page: .planning, view: AnyView(Planning()), sidebar: AnyView(DefaultPlanningSidebar()), title: "Planning"), - HistoryPage(page: .today, view: AnyView(Today()), sidebar: AnyView(TodaySidebar()), title: "Today", navButtons: [.CLIMode, .resetUserChoices]), + HistoryPage(page: .today, view: AnyView(Today()), sidebar: AnyView(TodaySidebar()), title: "Today", navButtons: [.CLIFilter, .CLIMode, .resetUserChoices]), HistoryPage(page: .companies, view: AnyView(CompanyDashboard()), sidebar: AnyView(DefaultCompanySidebar()), title: "Companies & Projects", navButtons: [.createCompany, .createProject]), HistoryPage(page: .companyDetail, view: AnyView(CompanyView()), sidebar: AnyView(DefaultCompanySidebar()), title: "Company"), HistoryPage(page: .jobs, view: AnyView(JobDashboardRedux()), sidebar: AnyView(JobDashboardSidebar()), title: "Jobs", navButtons: [.resetUserChoices, .createJob]), diff --git a/KlockWork/Views/Entities/Today/CommandLineInterface.swift b/KlockWork/Views/Entities/Today/CommandLineInterface.swift index 386390f1..a4bb9692 100644 --- a/KlockWork/Views/Entities/Today/CommandLineInterface.swift +++ b/KlockWork/Views/Entities/Today/CommandLineInterface.swift @@ -20,7 +20,6 @@ struct CommandLineInterface: View { @State private var selected: CLIApp.AppType = .log @State private var command: String = "" @State private var showSelectorPanel: Bool = false - @State private var showSearch: Bool = false @AppStorage("today.commandLineMode") private var commandLineMode: Bool = false @AppStorage("CreateEntitiesWidget.isSearchStackShowing") private var isSearching: Bool = false @@ -30,8 +29,9 @@ struct CommandLineInterface: View { var body: some View { VStack(alignment: .leading, spacing: 1) { - Filters(showSearch: $showSearch) - Display(showSearch: $showSearch) + // @TODO: maybe uncomment when other filters have been implemented? +// Filters() + Display() // Prompt + app selector if showSelectorPanel { @@ -320,7 +320,7 @@ extension CommandLineInterface { // @TODO: https://github.com/aapis/KlockWork/issues/240 struct Filters: View { - @Binding public var showSearch: Bool + @AppStorage("today.cli.showFilter") private var showCLIFilter: Bool = false @EnvironmentObject public var nav: Navigation @@ -331,15 +331,6 @@ extension CommandLineInterface { // FancyDropdown(label: "Type", items: App.AppType.allCases) // FancyDropdown(label: "Date format", items: ["Date: Abbreviated, Time: Complete", "Date: Complete, Time: Complete"]) Spacer() - FancyButtonv2( - text: "Filter", - action: {showSearch.toggle()}, - icon: "line.3.horizontal.decrease", - bgColour: .white.opacity(0.15), - showLabel: false, - showIcon: true - ) - .mask(Circle()) } .padding([.leading, .trailing]) .frame(height: 78) @@ -433,7 +424,7 @@ extension CommandLineInterface { } struct Display: View { - @Binding public var showSearch: Bool + @AppStorage("today.cli.showFilter") private var showCLIFilter: Bool = false @State private var searchText: String = "" @State private var searchFilteredResults: [Navigation.CommandLineSession.History] = [] @State private var searchResults: [Navigation.CommandLineSession.History] = [] @@ -446,11 +437,11 @@ extension CommandLineInterface { .opacity(0.25) .frame(height: 100) VStack { - if showSearch { + if self.showCLIFilter { SearchBar(text: $searchText, placeholder: "Filter entries...", onReset: onReset) .border(width: 1, edges: [.bottom], color: Theme.cPurple) - .onChange(of: searchText) { text in - onSearch(text) + .onChange(of: searchText) { + onSearch(self.searchText) } } @@ -507,7 +498,6 @@ extension CommandLineInterface { } } } - .padding() .font(Theme.fontTextField) } } From 8a95a3343a175942a05b006545e3fe0d0de37274 Mon Sep 17 00:00:00 2001 From: Ryan Priebe Date: Thu, 10 Oct 2024 17:42:16 -0600 Subject: [PATCH 9/9] minor padding issue fix --- KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift b/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift index 2703ecf9..2e33d033 100644 --- a/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift +++ b/KWCore/Sources/UI/WidgetLibrary/WidgetLibrary.UI.swift @@ -476,11 +476,13 @@ extension WidgetLibrary { action: self.actionPreviousDay, icon: "chevron.left", fgColour: .gray, + highlightColour: .white, showLabel: false, size: .titleLink, type: .titleLink ) .help("Previous day") + .frame(height: 20) Button { self.showDateOverlay.toggle() @@ -523,6 +525,7 @@ extension WidgetLibrary { type: .titleLink ) .help("Next day") + .frame(height: 20) } .padding(12) .onAppear(perform: self.actionOnAppear)