Skip to content

Commit

Permalink
Merge pull request #194 from aapis/feature/today-performance-refactor
Browse files Browse the repository at this point in the history
Today performance refactor
  • Loading branch information
aapis authored Dec 26, 2023
2 parents 73efcef + 3e1f20b commit 6597be7
Show file tree
Hide file tree
Showing 28 changed files with 837 additions and 748 deletions.
30 changes: 27 additions & 3 deletions DLPrototype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@
53B0BE90297333C3007CB663 /* ManageProjects.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B0BE8F297333C3007CB663 /* ManageProjects.swift */; };
53B0DC122A79D7FC00DA1679 /* NoteVersionNavigationWidget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B0DC112A79D7FC00DA1679 /* NoteVersionNavigationWidget.swift */; };
53B446B72A7D8CB100FA79E5 /* TaskGroup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53B446B62A7D8CB100FA79E5 /* TaskGroup.swift */; };
53C000922B38E34C00D5EC04 /* FancyLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C000912B38E34C00D5EC04 /* FancyLoader.swift */; };
53C000942B38E5C500D5EC04 /* TodayViewTab.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53C000932B38E5C500D5EC04 /* TodayViewTab.swift */; };
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 */; };
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 Down Expand Up @@ -362,6 +367,11 @@
53B0BE8F297333C3007CB663 /* ManageProjects.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageProjects.swift; sourceTree = "<group>"; };
53B0DC112A79D7FC00DA1679 /* NoteVersionNavigationWidget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NoteVersionNavigationWidget.swift; sourceTree = "<group>"; };
53B446B62A7D8CB100FA79E5 /* TaskGroup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskGroup.swift; sourceTree = "<group>"; };
53C000912B38E34C00D5EC04 /* FancyLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyLoader.swift; sourceTree = "<group>"; };
53C000932B38E5C500D5EC04 /* TodayViewTab.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TodayViewTab.swift; sourceTree = "<group>"; };
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>"; };
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 Down Expand Up @@ -451,6 +461,7 @@
5371BA352A7B410D00DEEC21 /* Sidebars */,
53EFCE7729637EA0004E45EC /* LogTable */,
537368D024B93DB600193E88 /* Today.swift */,
53C000992B3A90DF00D5EC04 /* PostingInterface.swift */,
);
path = Today;
sourceTree = "<group>";
Expand Down Expand Up @@ -864,6 +875,7 @@
53B0BE822972610C007CB663 /* Fancy */ = {
isa = PBXGroup;
children = (
53C000912B38E34C00D5EC04 /* FancyLoader.swift */,
53152CD3296A296A00A14E43 /* FancyButton.swift */,
53152CD5296A2DA300A14E43 /* FancyPicker.swift */,
53152CD9296B849200A14E43 /* FancyPickerWithRelativeNavigation.swift */,
Expand All @@ -883,6 +895,7 @@
5334F26F2B2B83190079D2E7 /* FancyColourPicker.swift */,
5334F2712B2B95240079D2E7 /* FancyJobActiveToggle.swift */,
5334F2732B2B958D0079D2E7 /* FancyJobSredToggle.swift */,
53C000972B3A821D00D5EC04 /* FancyHelpText.swift */,
);
path = Fancy;
sourceTree = "<group>";
Expand Down Expand Up @@ -1005,6 +1018,7 @@
53E202672A802D0900B4DF70 /* ButtonSize.swift */,
53E202712A80BAD500B4DF70 /* ButtonType.swift */,
53D5E2992A85E38A00FE293A /* WidgetLocation.swift */,
53C000932B38E5C500D5EC04 /* TodayViewTab.swift */,
);
path = Enums;
sourceTree = "<group>";
Expand Down Expand Up @@ -1037,6 +1051,7 @@
5363B67F2A6DE87000C2FBB8 /* View.swift */,
53E24C402A844BC800EB21FD /* EKEvent.swift */,
534B7C2A2B3220E40017C155 /* DispatchQueue.swift */,
53C000952B3A7BD500D5EC04 /* String.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -1121,7 +1136,7 @@
attributes = {
BuildIndependentTargetsInParallel = YES;
LastSwiftUpdateCheck = 1150;
LastUpgradeCheck = 1430;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = YegCollective;
TargetAttributes = {
53218D4324B7F6EB0088ABE9 = {
Expand Down Expand Up @@ -1255,6 +1270,7 @@
5334F2642B28F14C0079D2E7 /* CompanyCreate.swift in Sources */,
5334F2762B2CBF130079D2E7 /* ManagePeople.swift in Sources */,
53790C052A72F45900D3FFD4 /* EdgeBorder.swift in Sources */,
53C0009A2B3A90DF00D5EC04 /* PostingInterface.swift in Sources */,
53814A8B2A95151000A5A015 /* CoreDataPlan.swift in Sources */,
5371BA3D2A7B7F1200DEEC21 /* TaskViewPlain.swift in Sources */,
533E40682970DD170007785A /* AutoFixJobs.swift in Sources */,
Expand All @@ -1275,6 +1291,7 @@
5363B6752A6B4A9A00C2FBB8 /* NoteDashboardSettings.swift in Sources */,
530318472A11DD13009CA90B /* CoreDataCalendarEvent.swift in Sources */,
535C1AE129F48EF700CD95FD /* Dashboard.swift in Sources */,
53C000962B3A7BD500D5EC04 /* String.swift in Sources */,
537628A22966525500DE8ECF /* ToolbarButtons.swift in Sources */,
537AEBA1296287B900385787 /* LogRow.swift in Sources */,
53C3419029996C070071B855 /* FancyRandomJobColourPicker.swift in Sources */,
Expand All @@ -1296,11 +1313,13 @@
533E40652970DA640007785A /* ViewUpdater.swift in Sources */,
5334F2682B2963B60079D2E7 /* StringHelper.swift in Sources */,
53F589682998437D00843B32 /* JobResult.swift in Sources */,
53C000922B38E34C00D5EC04 /* FancyLoader.swift in Sources */,
535DDE5E2A7982F3008350D4 /* SidebarItem.swift in Sources */,
53E202702A80984400B4DF70 /* DateSelectorWidget.swift in Sources */,
53EDDFA02963487A008D34C7 /* CustomPickerItem.swift in Sources */,
53E2026C2A80457400B4DF70 /* JobProjectGroup.swift in Sources */,
535C1AE329F48F6800CD95FD /* Widgets.swift in Sources */,
53C000942B38E5C500D5EC04 /* TodayViewTab.swift in Sources */,
53C6D08F2964E25F00EA6129 /* Column.swift in Sources */,
532A7228298EE9E80038C18B /* FindDashboard.swift in Sources */,
53C036EF29F8A59900539C3C /* DashboardSettings.swift in Sources */,
Expand Down Expand Up @@ -1337,6 +1356,7 @@
534B7C2B2B3220E40017C155 /* DispatchQueue.swift in Sources */,
535C0E3529F729320053AD6A /* Keywords.swift in Sources */,
53F5896229983EEB00843B32 /* TaskResult.swift in Sources */,
53C000982B3A821D00D5EC04 /* FancyHelpText.swift in Sources */,
5354C8ED2AA03C9D001C1779 /* Tasks.Row.swift in Sources */,
532C5FE52A83024900F2AAD4 /* CreateEntitiesWidget.swift in Sources */,
53521E54296FBDAE002E7F21 /* CoreDataNoteVersions.swift in Sources */,
Expand Down Expand Up @@ -1410,6 +1430,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -1444,6 +1465,7 @@
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -1472,6 +1494,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
Expand Down Expand Up @@ -1506,6 +1529,7 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down Expand Up @@ -1534,7 +1558,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 156;
CURRENT_PROJECT_VERSION = 157;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down Expand Up @@ -1569,7 +1593,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 156;
CURRENT_PROJECT_VERSION = 157;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
39 changes: 26 additions & 13 deletions DLPrototype/DLPrototype.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ struct DLPrototype: App {
@StateObject public var nav: Navigation = Navigation()
@StateObject public var ce: CoreDataCalendarEvent = CoreDataCalendarEvent(moc: PersistenceController.shared.container.viewContext)

@State private var searching: Bool = false

@Environment(\.scenePhase) var scenePhase

var body: some Scene {
Expand All @@ -25,14 +27,17 @@ struct DLPrototype: App {
.environmentObject(nav)
.environmentObject(ce)
.onAppear(perform: onAppear)
.onChange(of: scenePhase) { _ in
persistenceController.save()
.defaultAppStorage(.standard)
.onChange(of: scenePhase) { phase in
if phase == .background || phase == .inactive {
// @TODO: serialize/deserialize previous session data here
persistenceController.save()
}
}
}
// TODO: still shows the window close/minimize/zoom,
// see https://stackoverflow.com/questions/70501890/how-can-i-hide-title-bar-in-swiftui-for-macos-app
// .windowStyle(.hiddenTitleBar)
// TODO: need to define the commands we want to implement
.commands {
MainMenu(moc: persistenceController.container.viewContext, nav: nav)
}
Expand All @@ -46,19 +51,27 @@ struct DLPrototype: App {
}

// TODO: temp commented out, too early to include this
// MenuBarExtra("name", systemImage: "keyboard.macwindow") {
MenuBarExtra("name", systemImage: "clock.fill") {
let appName = Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String
// @TODO: temp commented out until I build a compatible search view
// FindDashboard(searching: $searching)
// .environmentObject(nav)
// Button("Quick Record") {
// print("TODO: implement quick record")
// }.keyboardShortcut("1")
// Button("Quick Search") {
// print("TODO: implement quick search")
// }.keyboardShortcut("2")
//
// Divider()
// Button("Quit") {
// NSApplication.shared.terminate(nil)
// }.keyboardShortcut("q")
// }

Button("Search") {
nav.setView(AnyView(Dashboard()))
nav.setSidebar(AnyView(DashboardSidebar()))
nav.setParent(.dashboard)
}

Divider()
Button("Quit \(appName ?? "ClockWork")") {
NSApplication.shared.terminate(nil)
}.keyboardShortcut("q")
}
// .menuBarExtraStyle(.window)
#endif
}

Expand Down
97 changes: 97 additions & 0 deletions DLPrototype/Enums/TodayViewTab.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// Tab.swift
// DLPrototype
//
// Created by Ryan Priebe on 2023-12-24.
// Copyright © 2023 YegCollective. All rights reserved.
//

import SwiftUI

public enum TodayViewTab: CaseIterable {
case chronologic, grouped, summarized, calendar

var icon: String {
switch self {
case .chronologic:
return "tray.2.fill"
case .grouped:
return "square.grid.3x1.fill.below.line.grid.1x2"
case .summarized:
return "star.circle.fill"
case .calendar:
return "calendar"
}
}

var id: Int {
switch self {
case .chronologic:
return 0
case .grouped:
return 1
case .summarized:
return 2
case .calendar:
return 3
}
}

var help: String {
switch self {
case .chronologic:
return "Sorted by time, ascending"
case .grouped:
return "Grouped by job ID"
case .summarized:
return "Summarized results"
case .calendar:
return "Today's events"
}
}

var title: String {
switch self {
case .chronologic: return "Chronologic"
case .grouped: return "Grouped"
case .summarized: return "Summarized"
case .calendar: return "Events"
}
}

var description: String {
switch self {
case .chronologic:
return "Shows records in chronological order, sorted by timestamp"
case .grouped:
return "Groups records by job ID, sorted by timestamp"
case .summarized:
return "Shows only relevant records, sorted by timestamp"
case .calendar:
return "Events happening today"
}
}

var view: AnyView {
switch self {
case .chronologic:
return AnyView(Today.LogTable.TabContent.Chronologic())
case .grouped:
return AnyView(Today.LogTable.TabContent.Grouped())
case .summarized:
return AnyView(Today.LogTable.TabContent.Summarized())
case .calendar:
return AnyView(Today.LogTable.TabContent.Calendar())
}
}

var button: ToolbarButton {
ToolbarButton(
id: self.id,
helpText: self.help,
icon: self.icon,
labelText: self.title,
contents: self.view
)
}
}
6 changes: 3 additions & 3 deletions DLPrototype/Extensions/DispatchQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
import Foundation

extension DispatchQueue {
static func background(delay: Double = 0.0, background: (()->Void)? = nil, completion: (() -> Void)? = nil) {
static func with<T>(delay: Double = 0.0, background: (()->[T]?)? = nil, completion: (([T]?) -> Void)? = nil) {
DispatchQueue.global(qos: .background).async {
background?()
let bg = background?()
if let completion = completion {
DispatchQueue.main.asyncAfter(deadline: .now() + delay, execute: {
completion()
completion(bg)
})
}
}
Expand Down
15 changes: 15 additions & 0 deletions DLPrototype/Extensions/String.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// String.swift
// DLPrototype
//
// Created by Ryan Priebe on 2023-12-25.
// Copyright © 2023 YegCollective. All rights reserved.
//

import Foundation

extension String {
func ints() -> String {
return self.filter { "0123456789".contains($0) }
}
}
2 changes: 1 addition & 1 deletion DLPrototype/Helpers/UrlHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public final class UrlHelper {
jobId = String(identifier.suffix(6))
}
} else {
jobId = String(url.absoluteString.suffix(6))
jobId = String(url.absoluteString.ints().suffix(6))
}

let defaultJid = 11.0
Expand Down
6 changes: 6 additions & 0 deletions DLPrototype/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ struct MainMenu: Commands {
}
.keyboardShortcut("j", modifiers: [.command, .shift])
}

Divider()
Button("Previous day") {nav.session.date -= 86400}
.keyboardShortcut(.leftArrow, modifiers: [.command])
Button("Next day") {nav.session.date += 86400}
.keyboardShortcut(.rightArrow, modifiers: [.command])
}
}
}
Loading

0 comments on commit 6597be7

Please sign in to comment.