Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar standardization #202

Merged
merged 3 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 8 additions & 8 deletions DLPrototype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
5363B6802A6DE87000C2FBB8 /* View.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5363B67F2A6DE87000C2FBB8 /* View.swift */; };
536FBF6E2A68F77100F00CE4 /* NoteBlock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 536FBF6D2A68F77100F00CE4 /* NoteBlock.swift */; };
5371BA222A7B1C9D00DEEC21 /* RecentNotesWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5371BA212A7B1C9D00DEEC21 /* RecentNotesWidget.swift */; };
5371BA242A7B1DBF00DEEC21 /* FavouriteNotesWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5371BA232A7B1DBF00DEEC21 /* FavouriteNotesWidget.swift */; };
5371BA282A7B264900DEEC21 /* NoteRowPlain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5371BA272A7B264900DEEC21 /* NoteRowPlain.swift */; };
5371BA2B2A7B279800DEEC21 /* NoteViewSidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5371BA2A2A7B279800DEEC21 /* NoteViewSidebar.swift */; };
5371BA2D2A7B27BB00DEEC21 /* NoteDashboardSidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5371BA2C2A7B27BB00DEEC21 /* NoteDashboardSidebar.swift */; };
Expand Down Expand Up @@ -154,6 +153,7 @@
53C000962B3A7BD500D5EC04 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C000952B3A7BD500D5EC04 /* String.swift */; };
53C000982B3A821D00D5EC04 /* FancyHelpText.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C000972B3A821D00D5EC04 /* FancyHelpText.swift */; };
53C0009A2B3A90DF00D5EC04 /* PostingInterface.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C000992B3A90DF00D5EC04 /* PostingInterface.swift */; };
53C0009E2B3F6B5200D5EC04 /* TabbedWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C0009D2B3F6B5200D5EC04 /* TabbedWidget.swift */; };
53C036EF29F8A59900539C3C /* DashboardSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C036EE29F8A59900539C3C /* DashboardSettings.swift */; };
53C3418C299960310071B855 /* JobDashboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C3418B299960310071B855 /* JobDashboard.swift */; };
53C3418E299968160071B855 /* JobView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C3418D299968160071B855 /* JobView.swift */; };
Expand All @@ -165,7 +165,7 @@
53DCA3422803BBBF0032FD60 /* CalendarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53DCA3412803BBBF0032FD60 /* CalendarView.swift */; };
53DFF075296F124E0051DA91 /* ManageTasks.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53DFF074296F124E0051DA91 /* ManageTasks.swift */; };
53E202562A7E0F1700B4DF70 /* ProjectsDashboardSidebar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E202552A7E0F1700B4DF70 /* ProjectsDashboardSidebar.swift */; };
53E202582A7E19B900B4DF70 /* NoteSearchWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E202572A7E19B900B4DF70 /* NoteSearchWidget.swift */; };
53E202582A7E19B900B4DF70 /* NotesWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E202572A7E19B900B4DF70 /* NotesWidget.swift */; };
53E2025A2A7EAE5B00B4DF70 /* ProjectsWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E202592A7EAE5B00B4DF70 /* ProjectsWidget.swift */; };
53E2025C2A7EAF6100B4DF70 /* ProjectRowPlain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E2025B2A7EAF6100B4DF70 /* ProjectRowPlain.swift */; };
53E2025E2A7EB20500B4DF70 /* SidebarWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53E2025D2A7EB20500B4DF70 /* SidebarWidget.swift */; };
Expand Down Expand Up @@ -315,7 +315,6 @@
5363B67F2A6DE87000C2FBB8 /* View.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = View.swift; sourceTree = "<group>"; };
536FBF6D2A68F77100F00CE4 /* NoteBlock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteBlock.swift; sourceTree = "<group>"; };
5371BA212A7B1C9D00DEEC21 /* RecentNotesWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RecentNotesWidget.swift; sourceTree = "<group>"; };
5371BA232A7B1DBF00DEEC21 /* FavouriteNotesWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FavouriteNotesWidget.swift; sourceTree = "<group>"; };
5371BA272A7B264900DEEC21 /* NoteRowPlain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteRowPlain.swift; sourceTree = "<group>"; };
5371BA2A2A7B279800DEEC21 /* NoteViewSidebar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteViewSidebar.swift; sourceTree = "<group>"; };
5371BA2C2A7B27BB00DEEC21 /* NoteDashboardSidebar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteDashboardSidebar.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -372,6 +371,7 @@
53C000952B3A7BD500D5EC04 /* String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
53C000972B3A821D00D5EC04 /* FancyHelpText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyHelpText.swift; sourceTree = "<group>"; };
53C000992B3A90DF00D5EC04 /* PostingInterface.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostingInterface.swift; sourceTree = "<group>"; };
53C0009D2B3F6B5200D5EC04 /* TabbedWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabbedWidget.swift; sourceTree = "<group>"; };
53C036EE29F8A59900539C3C /* DashboardSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DashboardSettings.swift; sourceTree = "<group>"; };
53C3418B299960310071B855 /* JobDashboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobDashboard.swift; sourceTree = "<group>"; };
53C3418D299968160071B855 /* JobView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobView.swift; sourceTree = "<group>"; };
Expand All @@ -383,7 +383,7 @@
53DCA3412803BBBF0032FD60 /* CalendarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarView.swift; sourceTree = "<group>"; };
53DFF074296F124E0051DA91 /* ManageTasks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageTasks.swift; sourceTree = "<group>"; };
53E202552A7E0F1700B4DF70 /* ProjectsDashboardSidebar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectsDashboardSidebar.swift; sourceTree = "<group>"; };
53E202572A7E19B900B4DF70 /* NoteSearchWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteSearchWidget.swift; sourceTree = "<group>"; };
53E202572A7E19B900B4DF70 /* NotesWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotesWidget.swift; sourceTree = "<group>"; };
53E202592A7EAE5B00B4DF70 /* ProjectsWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectsWidget.swift; sourceTree = "<group>"; };
53E2025B2A7EAF6100B4DF70 /* ProjectRowPlain.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProjectRowPlain.swift; sourceTree = "<group>"; };
53E2025D2A7EB20500B4DF70 /* SidebarWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SidebarWidget.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -906,16 +906,16 @@
53B0DC112A79D7FC00DA1679 /* NoteVersionNavigationWidget.swift */,
5371BA212A7B1C9D00DEEC21 /* RecentNotesWidget.swift */,
5371BA312A7B2ADE00DEEC21 /* JobsWidget.swift */,
5371BA232A7B1DBF00DEEC21 /* FavouriteNotesWidget.swift */,
5371BA3A2A7B490C00DEEC21 /* TasksWidget.swift */,
53E202572A7E19B900B4DF70 /* NoteSearchWidget.swift */,
53E202572A7E19B900B4DF70 /* NotesWidget.swift */,
53E202592A7EAE5B00B4DF70 /* ProjectsWidget.swift */,
53E202622A7ECC6500B4DF70 /* TodayInHistoryWidget.swift */,
53E202692A80389500B4DF70 /* JobPickerWidget.swift */,
53E2026F2A80984400B4DF70 /* DateSelectorWidget.swift */,
532C5FE42A83024900F2AAD4 /* CreateEntitiesWidget.swift */,
530168162A887B0A000AF4FD /* AllJobsPickerWidget.swift */,
5334F2652B28FA520079D2E7 /* OutlineWidget.swift */,
53C0009D2B3F6B5200D5EC04 /* TabbedWidget.swift */,
);
path = Widgets;
sourceTree = "<group>";
Expand Down Expand Up @@ -1238,6 +1238,7 @@
5326AE9C2B27FFE2009F1349 /* CoreDataCompanies.swift in Sources */,
53E2026A2A80389500B4DF70 /* JobPickerWidget.swift in Sources */,
53152CE4296BC8A100A14E43 /* NoteDashboard.swift in Sources */,
53C0009E2B3F6B5200D5EC04 /* TabbedWidget.swift in Sources */,
536FBF6E2A68F77100F00CE4 /* NoteBlock.swift in Sources */,
5334F2662B28FA520079D2E7 /* OutlineWidget.swift in Sources */,
53B0BE86297261A3007CB663 /* ProjectCreate.swift in Sources */,
Expand Down Expand Up @@ -1279,7 +1280,6 @@
5371BA2D2A7B27BB00DEEC21 /* NoteDashboardSidebar.swift in Sources */,
53790C0B2A747E0300D3FFD4 /* JobCreate.swift in Sources */,
5376289E29664F8C00DE8ECF /* Theme.swift in Sources */,
5371BA242A7B1DBF00DEEC21 /* FavouriteNotesWidget.swift in Sources */,
53FBCC902A630CBE00B88539 /* MainMenu.swift in Sources */,
53790C142A758A7200D3FFD4 /* RecordTableColumn.swift in Sources */,
533E406A2970F5610007785A /* SearchHelper.swift in Sources */,
Expand Down Expand Up @@ -1387,7 +1387,7 @@
53152CDA296B849200A14E43 /* FancyPickerWithRelativeNavigation.swift in Sources */,
53EFCE7B29637F49004E45EC /* Settings.swift in Sources */,
5371BA322A7B2ADE00DEEC21 /* JobsWidget.swift in Sources */,
53E202582A7E19B900B4DF70 /* NoteSearchWidget.swift in Sources */,
53E202582A7E19B900B4DF70 /* NotesWidget.swift in Sources */,
537628A8296659DC00DE8ECF /* PersistenceController.swift in Sources */,
532C5FE32A83019C00F2AAD4 /* GlobalSidebarWidgets.swift in Sources */,
53790C072A74408D00D3FFD4 /* Navigation.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Models/CoreData/CoreDataJob.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class CoreDataJob: ObservableObject {
let fetch: NSFetchRequest<Job> = Job.fetchRequest()
fetch.predicate = NSPredicate(format: "alive == true && project != nil && project.alive == true")
fetch.sortDescriptors = [
NSSortDescriptor(keyPath: \Job.lastUpdate?, ascending: false),
NSSortDescriptor(keyPath: \Job.project?, ascending: false),
NSSortDescriptor(keyPath: \Job.jid, ascending: false)
]

Expand Down
10 changes: 5 additions & 5 deletions DLPrototype/Models/CoreData/CoreDataNotes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,19 @@ public class CoreDataNotes {
return FetchRequest(fetchRequest: fetch, animation: .easeInOut)
}

static public func fetchNotes() -> FetchRequest<Note> {
static public func fetchNotes(favouritesOnly: Bool = false) -> FetchRequest<Note> {
let descriptors = [
NSSortDescriptor(keyPath: \Note.mJob?.project?.id, ascending: false),
NSSortDescriptor(keyPath: \Note.mJob?.id, ascending: false),
NSSortDescriptor(keyPath: \Note.title, ascending: true)
]

let fetch: NSFetchRequest<Note> = Note.fetchRequest()
// if let txt = text {
// fetch.predicate = NSPredicate(format: "alive == true && title CONTAINS[c] %s", txt.wrappedValue)
// } else {
if favouritesOnly {
fetch.predicate = NSPredicate(format: "alive == true && starred == true")
} else {
fetch.predicate = NSPredicate(format: "alive == true && mJob != nil")
// }
}
fetch.sortDescriptors = descriptors
fetch.fetchLimit = 1000

Expand Down
8 changes: 8 additions & 0 deletions DLPrototype/Utils/Navigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,14 @@ extension Navigation.Session {
var moc: NSManagedObjectContext
var hasResults: Bool = false
var inspectingEntity: NSManagedObject? = nil

mutating func inspect(_ obj: NSManagedObject) -> Void {
inspectingEntity = obj
}

mutating func cancel() -> Void {
inspectingEntity = nil
}
}

public struct Toolbar: Identifiable {
Expand Down
28 changes: 3 additions & 25 deletions DLPrototype/Views/Find/FindDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -708,17 +708,17 @@ extension FindDashboard {
}

Spacer()
// @TODO: link to the specific note
HStack(alignment: .top, spacing: 10) {
FancyButtonv2(
text: "Open",
action: {nav.session.search.cancel()},
icon: "arrow.right.square.fill",
showLabel: true,
size: .link,
type: .clear,
redirect: AnyView(NoteDashboard()),
redirect: AnyView(NoteView(note: item, moc: PersistenceController.shared.container.viewContext)),
pageType: .notes,
sidebar: AnyView(NoteDashboardSidebar())
sidebar: AnyView(NoteViewSidebar(note: item, moc: PersistenceController.shared.container.viewContext))
)
}
}
Expand Down Expand Up @@ -1066,17 +1066,6 @@ extension FindDashboard {
type: .clear
)
.help("Inspect")
FancyButtonv2(
text: item.title ?? "",
action: {nav.session.setJob(item.mJob)},
icon: "arrow.right.square.fill",
fgColour: .white,
showLabel: false,
showIcon: true,
size: .tinyLink,
type: .clear
)
.help("Set as Active Job")
Spacer()
}
}
Expand Down Expand Up @@ -1163,17 +1152,6 @@ extension FindDashboard {
type: .clear
)
.help("Inspect")
FancyButtonv2(
text: "",
action: {nav.session.setJob(item.owner)},
icon: "arrow.right.square.fill",
fgColour: .white,
showLabel: false,
showIcon: true,
size: .tinyLink,
type: .clear
)
.help("Set as Active Job")
Spacer()
}
}
Expand Down
45 changes: 44 additions & 1 deletion DLPrototype/Views/Jobs/Sidebars/JobDashboardSidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,56 @@
import SwiftUI

struct JobDashboardSidebar: View {
@State private var tabs: [ToolbarButton] = []
@State private var searching: Bool = false

var body: some View {
ScrollView(showsIndicators: false) {
VStack(alignment: .leading, spacing: 5) {
JobsWidget()
FancyGenericToolbar(
buttons: tabs,
standalone: true,
location: .sidebar,
mode: .compact
)
}
Spacer()
}
.padding()
.onAppear(perform: createToolbar)
}
}

extension JobDashboardSidebar {
private func createToolbar() -> Void {
tabs = [
ToolbarButton(
id: 0,
helpText: "Recent jobs",
icon: "clock",
labelText: "Recent jobs",
contents: AnyView(JobPickerWidget())
),
ToolbarButton(
id: 1,
helpText: "All jobs",
icon: "hammer",
labelText: "All Jobs",
contents: AnyView(JobsWidget())
),
ToolbarButton(
id: 2,
helpText: "Search",
icon: "magnifyingglass",
labelText: "Search",
contents: AnyView(
VStack(alignment: .leading) {
FindDashboard(searching: $searching, location: .sidebar)
}
.padding(8)
.background(Theme.base.opacity(0.2))
)
)
]
}
}
3 changes: 2 additions & 1 deletion DLPrototype/Views/Notes/NoteDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import SwiftUI
struct NoteDashboard: View {
public var defaultSelectedJob: Job? = nil
public var project: Project? = nil

@StateObject public var jm: CoreDataJob = CoreDataJob(moc: PersistenceController.shared.container.viewContext)

@State private var searchText: String = ""
@State private var selected: Int = 0
Expand All @@ -21,7 +23,6 @@ struct NoteDashboard: View {
@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var nav: Navigation
@EnvironmentObject public var updater: ViewUpdater
@EnvironmentObject public var jm: CoreDataJob

@FetchRequest public var notes: FetchedResults<Note>

Expand Down
31 changes: 17 additions & 14 deletions DLPrototype/Views/Notes/NoteRowPlain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,33 @@ struct NoteRowPlain: View {
var body: some View {
VStack(alignment: .leading) {
HStack(alignment: .firstTextBaseline, spacing: 0) {
Image(systemName: icon)
.padding(.trailing, 10)
.opacity(0.4)
if let job = note.mJob {
Image(systemName: icon)
.padding(.trailing, 10)
.opacity(0.4)
.foregroundColor(job.colour_from_stored().isBright() ? .black : .white)

FancyButtonv2(
text: note.title!,
action: actionOpenNote,
fgColour: note.mJob != nil && Color.fromStored(note.mJob!.colour!).isBright() ? .black : .white,
showIcon: false,
size: .link,
redirect: AnyView(NoteView(note: note, moc: moc)),
pageType: .notes,
sidebar: AnyView(NoteViewSidebar(note: note, moc: moc))
)
FancyButtonv2(
text: note.title!,
action: actionOpenNote,
fgColour: job.colour_from_stored().isBright() ? .black : .white,
showIcon: false,
size: .link,
redirect: AnyView(NoteView(note: note, moc: moc)),
pageType: .notes,
sidebar: AnyView(NoteViewSidebar(note: note, moc: moc))
)
}
Spacer()
}
.padding(5)
.background(note.mJob != nil ? note.mJob!.colour_from_stored() : .clear)
}
}
}

extension NoteRowPlain {
private func actionOpenNote() -> Void {
nav.reset()
nav.setId()
nav.setParent(.today)
nav.session.note = note
Expand Down
2 changes: 2 additions & 0 deletions DLPrototype/Views/Notes/NoteView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ extension NoteView {
showLabel: false,
type: .destructive,
redirect: AnyView(NoteDashboard()),
pageType: .notes,
sidebar: AnyView(NoteDashboardSidebar())
)

Expand All @@ -188,6 +189,7 @@ extension NoteView {
icon: "xmark",
showLabel: false,
redirect: AnyView(NoteDashboard()),
pageType: .notes,
sidebar: AnyView(NoteDashboardSidebar())
)
if ref.revisionNotLatest() {
Expand Down
Loading