Skip to content

Commit

Permalink
Merge pull request #209 from aapis/feature/create-entities-v2
Browse files Browse the repository at this point in the history
Entity creation sidebar widget overhaul
  • Loading branch information
aapis authored Dec 31, 2023
2 parents db48226 + 6b332e7 commit 1439c6b
Show file tree
Hide file tree
Showing 35 changed files with 327 additions and 324 deletions.
4 changes: 2 additions & 2 deletions DLPrototype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 159;
CURRENT_PROJECT_VERSION = 160;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down Expand Up @@ -1581,7 +1581,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 159;
CURRENT_PROJECT_VERSION = 160;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
4 changes: 0 additions & 4 deletions DLPrototype/Utils/Navigation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ public class Navigation: Identifiable, ObservableObject {
}

public func setParent(_ newParent: Page) -> Void {
parent = nil
parent = newParent
}

Expand All @@ -127,17 +126,14 @@ public class Navigation: Identifiable, ObservableObject {
}

public func setTitle(_ newTitle: String) -> Void {
title = nil
title = newTitle
}

public func setId() -> Void {
pageId = nil
pageId = UUID()
}

public func setInspector(_ newInspector: AnyView? = nil) -> Void {
inspector = nil
inspector = newInspector
}

Expand Down
17 changes: 0 additions & 17 deletions DLPrototype/Views/Companies/Sidebars/DefaultCompanySidebar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,6 @@ extension DefaultCompanySidebar {
}
),
contents: AnyView(OutlineWidget())
),
ToolbarButton(
id: 1,
helpText: "Search",
label: AnyView(
HStack {
Image(systemName: "magnifyingglass").padding(.leading)
Text("Search")
}
),
contents: AnyView(
VStack(alignment: .leading) {
FindDashboard(searching: $searching, location: .sidebar)
}
.padding(8)
.background(Theme.base.opacity(0.2))
)
)
]
}
Expand Down
28 changes: 10 additions & 18 deletions DLPrototype/Views/Dashboard/Dashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,44 @@ struct Dashboard: View {

@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var nav: Navigation
@EnvironmentObject public var crm: CoreDataRecords
@StateObject public var ce: CoreDataCalendarEvent = CoreDataCalendarEvent(moc: PersistenceController.shared.container.viewContext)
@EnvironmentObject public var updater: ViewUpdater

@FocusState private var primaryTextFieldInFocus: Bool

var body: some View {
VStack(alignment: .leading, spacing: 0) {
Header()
.environmentObject(ce)
.environmentObject(updater)

VStack(alignment: .leading, spacing: 0) {
FindDashboard(searching: $searching)
FindDashboard(searching: $searching, location: .content)
FancyDivider()
// Button("State test") {
// print("DERPO state.phase=\(nav.state.get())")
//// nav.state.set(.transitioning)
// nav.state.advance()
// print("DERPO state.phase=\(nav.state.get())")
// nav.state.advance()
// print("DERPO state.phase=\(nav.state.get())")
// }

if !searching {
Widgets()
.environmentObject(crm)
}
}
.font(Theme.font)
.padding()
.focused($primaryTextFieldInFocus)
.background(Theme.toolbarColour)
.onAppear {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.75) {
self.primaryTextFieldInFocus = true
}
}
}
}
}

extension Dashboard {

}

extension Dashboard {
struct Header: View {
@State private var upcomingEvents: [EKEvent] = []
@State private var calendarName: String = ""

@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var nav: Navigation
@EnvironmentObject public var ce: CoreDataCalendarEvent
@StateObject public var ce: CoreDataCalendarEvent = CoreDataCalendarEvent(moc: PersistenceController.shared.container.viewContext)
@EnvironmentObject public var updater: ViewUpdater

@AppStorage("today.calendar") public var calendar: Int = -1
Expand Down
10 changes: 0 additions & 10 deletions DLPrototype/Views/Dashboard/Widgets.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ struct Widgets: View {
@AppStorage("dashboard.widget.thismonth") public var showWidgetThisMonth: Bool = true
@AppStorage("dashboard.widget.thisyear") public var showWidgetThisYear: Bool = true

@EnvironmentObject public var crm: CoreDataRecords
@EnvironmentObject public var ce: CoreDataCalendarEvent
@EnvironmentObject public var jm: CoreDataJob

private var columns: [GridItem] = Array(repeating: .init(.flexible(minimum: 100)), count: 3)

var body: some View {
Expand All @@ -40,20 +36,14 @@ struct Widgets: View {
LazyVGrid(columns: columns, alignment: .leading) {
if showWidgetThisWeek {
ThisWeek()
.environmentObject(crm)
.environmentObject(ce)
}

if showWidgetThisMonth {
ThisMonth()
.environmentObject(crm)
.environmentObject(ce)
}

if showWidgetThisYear {
ThisYear()
.environmentObject(crm)
.environmentObject(ce)
}
}

Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Dashboard/Widgets/ThisMonth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct ThisMonth: View {
@State private var recordCount: Int = 0

@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var crm: CoreDataRecords
@StateObject public var crm: CoreDataRecords = CoreDataRecords(moc: PersistenceController.shared.container.viewContext)

var body: some View {
VStack(alignment: .leading) {
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Dashboard/Widgets/ThisWeek.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct ThisWeek: View {
@State private var recordCount: Int = 0

@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var crm: CoreDataRecords
@StateObject public var crm: CoreDataRecords = CoreDataRecords(moc: PersistenceController.shared.container.viewContext)

var body: some View {
VStack(alignment: .leading) {
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Dashboard/Widgets/ThisYear.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ struct ThisYear: View {
@State private var recordCount: Int = 0

@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var crm: CoreDataRecords
@StateObject public var crm: CoreDataRecords = CoreDataRecords(moc: PersistenceController.shared.container.viewContext)

var body: some View {
VStack(alignment: .leading) {
Expand Down
4 changes: 2 additions & 2 deletions DLPrototype/Views/Find/FindDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct FindDashboard: View {
@State private var showingTypes: Bool = false

@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var jm: CoreDataJob
@StateObject public var jm: CoreDataJob = CoreDataJob(moc: PersistenceController.shared.container.viewContext)
@EnvironmentObject public var nav: Navigation

private var columns: [GridItem] {
Expand Down Expand Up @@ -152,7 +152,7 @@ struct FindDashboard: View {
Loading()
} else {
FancyDivider()
FancyGenericToolbar(buttons: buttons, standalone: true, location: .content)
FancyGenericToolbar(buttons: buttons, standalone: true, location: location)
Spacer()
}
}
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Find/Results/JobResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct JobResult: View {
@State private var showChildren: Bool = true
@State private var minimizeIcon: String = "arrowtriangle.down"

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

var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Find/Results/NoteResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct NoteResult: View {
@State private var showChildren: Bool = true
@State private var minimizeIcon: String = "arrowtriangle.down"

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

var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Find/Results/ProjectResult.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct ProjectResult: View {
@State private var showChildren: Bool = true
@State private var minimizeIcon: String = "arrowtriangle.down"

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

var body: some View {
Expand Down
2 changes: 1 addition & 1 deletion DLPrototype/Views/Find/Results/Results.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct Results: View {
@FetchRequest private var projects: FetchedResults<Project>
@FetchRequest private var jobs: FetchedResults<Job>

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

var body: some View {
Expand Down
2 changes: 0 additions & 2 deletions DLPrototype/Views/Find/Suggestions/Suggestions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ extension FindDashboard {
text: item.jid.string,
action: {choose(item)},
icon: "questionmark.square.fill",
fgColour: .white,
showIcon: true,
size: .link,
type: .clear
Expand All @@ -106,7 +105,6 @@ extension FindDashboard {
text: item.jid.string,
action: {nav.session.job = item},
icon: "arrow.right.square.fill",
fgColour: .white,
showLabel: false,
showIcon: true,
size: .tinyLink,
Expand Down
Loading

0 comments on commit 1439c6b

Please sign in to comment.