Skip to content

Commit

Permalink
Merge pull request #247 from aapis/feature/alt-mode-sidebar-icons
Browse files Browse the repository at this point in the history
Main app nav icons can change icons depending on the chosen display mode
  • Loading branch information
aapis authored May 17, 2024
2 parents 826143c + 448c42a commit 471207a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
2 changes: 1 addition & 1 deletion DLPrototype/Enums/TodayViewTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public enum TodayViewTab: CaseIterable {
var icon: String {
switch self {
case .chronologic:
return "tray.2.fill"
return "tray.fill"
case .grouped:
return "square.grid.3x1.fill.below.line.grid.1x2"
case .summarized:
Expand Down
11 changes: 9 additions & 2 deletions DLPrototype/Views/Home/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ struct Home: View {
@AppStorage("isDatePickerPresented") public var isDatePickerPresented: Bool = false
@AppStorage("CreateEntitiesWidget.isSearchStackShowing") private var isSearchStackShowing: Bool = false
@AppStorage("general.showSessionInspector") public var showSessionInspector: Bool = false
@AppStorage("general.experimental.cli") private var cliEnabled: Bool = false
@AppStorage("today.commandLineMode") private var commandLineMode: Bool = false

private var buttons: [PageGroup: [SidebarButton]] {
[
Expand All @@ -40,9 +42,14 @@ struct Home: View {
SidebarButton(
destination: AnyView(Today()),
pageType: .today,
icon: "doc.append",
icon: "tray",
label: "Today",
sidebar: AnyView(TodaySidebar())
sidebar: AnyView(TodaySidebar()),
altMode: PageAltMode(
name: "CLI Mode",
icon: "apple.terminal",
condition: cliEnabled && commandLineMode
)
)
],
.entities: [
Expand Down
21 changes: 16 additions & 5 deletions DLPrototype/Views/Shared/AppSidebar/SidebarButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@
import Foundation
import SwiftUI

struct PageAltMode: Identifiable {
var id: UUID = UUID()
var name: String
var icon: String
var condition: Bool
}

struct SidebarButton: View, Identifiable {
public let id: UUID = UUID()
public var destination: AnyView
Expand All @@ -18,6 +25,7 @@ struct SidebarButton: View, Identifiable {
public var sidebar: AnyView?
public var showLabel: Bool = true
public var size: ButtonSize? = .large
public var altMode: PageAltMode? = nil

@State private var highlighted: Bool = false

Expand Down Expand Up @@ -66,7 +74,9 @@ struct SidebarButton: View, Identifiable {
command: "@session.job=\(job.jid.string)",
status: .success,
message: "",
appType: .set)
appType: .set,
job: nav.session.job
)
)
}
}
Expand Down Expand Up @@ -111,10 +121,11 @@ struct SidebarButton: View, Identifiable {
.opacity(0.1)
}

Image(systemName: isDatePickerPresented && nav.parent == pageType ? "xmark" : icon)
.font(.title)
.symbolRenderingMode(.hierarchical)
.foregroundColor(isDatePickerPresented && nav.parent == pageType ? .black : highlighted ? .white : .white.opacity(0.8))
Image(systemName: isDatePickerPresented && nav.parent == pageType ? "xmark" : (altMode != nil ? (altMode!.condition ? altMode!.icon : icon) : icon))
.font(.title)
.symbolRenderingMode(.hierarchical)
.foregroundColor(isDatePickerPresented && nav.parent == pageType ? .black : highlighted ? .white : .white.opacity(0.8))

}
})
.help(label)
Expand Down

0 comments on commit 471207a

Please sign in to comment.