Skip to content

Commit

Permalink
Merge pull request #185 from aapis/feature/company-ux-01
Browse files Browse the repository at this point in the history
Another UX pass
  • Loading branch information
aapis authored Dec 14, 2023
2 parents a335a11 + 34730b1 commit 74cae79
Show file tree
Hide file tree
Showing 15 changed files with 253 additions and 138 deletions.
24 changes: 18 additions & 6 deletions DLPrototype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@
5334F2662B28FA520079D2E7 /* Outline.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F2652B28FA520079D2E7 /* Outline.swift */; };
5334F2682B2963B60079D2E7 /* StringHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F2672B2963B60079D2E7 /* StringHelper.swift */; };
5334F26A2B2A14F90079D2E7 /* ManageOwnedProjects.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F2692B2A14F90079D2E7 /* ManageOwnedProjects.swift */; };
5334F26C2B2A5BD60079D2E7 /* FancyToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F26B2B2A5BD60079D2E7 /* FancyToggle.swift */; };
5334F26C2B2A5BD60079D2E7 /* FancyProjectActiveToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F26B2B2A5BD60079D2E7 /* FancyProjectActiveToggle.swift */; };
5334F26E2B2A5CC50079D2E7 /* FancyLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F26D2B2A5CC50079D2E7 /* FancyLabel.swift */; };
5334F2702B2B83190079D2E7 /* FancyColourPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F26F2B2B83190079D2E7 /* FancyColourPicker.swift */; };
5334F2722B2B95240079D2E7 /* FancyJobActiveToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F2712B2B95240079D2E7 /* FancyJobActiveToggle.swift */; };
5334F2742B2B958D0079D2E7 /* FancyJobSredToggle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5334F2732B2B958D0079D2E7 /* FancyJobSredToggle.swift */; };
5335A5AE296CFF83000051B1 /* FileHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5335A5AD296CFF83000051B1 /* FileHelper.swift */; };
5335A5B3296D17EB000051B1 /* TaskDashboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5335A5B2296D17EB000051B1 /* TaskDashboard.swift */; };
5335A5B5296D1FA7000051B1 /* TaskView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5335A5B4296D1FA7000051B1 /* TaskView.swift */; };
Expand Down Expand Up @@ -250,8 +253,11 @@
5334F2652B28FA520079D2E7 /* Outline.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Outline.swift; sourceTree = "<group>"; };
5334F2672B2963B60079D2E7 /* StringHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringHelper.swift; sourceTree = "<group>"; };
5334F2692B2A14F90079D2E7 /* ManageOwnedProjects.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ManageOwnedProjects.swift; sourceTree = "<group>"; };
5334F26B2B2A5BD60079D2E7 /* FancyToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyToggle.swift; sourceTree = "<group>"; };
5334F26B2B2A5BD60079D2E7 /* FancyProjectActiveToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyProjectActiveToggle.swift; sourceTree = "<group>"; };
5334F26D2B2A5CC50079D2E7 /* FancyLabel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyLabel.swift; sourceTree = "<group>"; };
5334F26F2B2B83190079D2E7 /* FancyColourPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyColourPicker.swift; sourceTree = "<group>"; };
5334F2712B2B95240079D2E7 /* FancyJobActiveToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyJobActiveToggle.swift; sourceTree = "<group>"; };
5334F2732B2B958D0079D2E7 /* FancyJobSredToggle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FancyJobSredToggle.swift; sourceTree = "<group>"; };
5335A5AD296CFF83000051B1 /* FileHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FileHelper.swift; sourceTree = "<group>"; };
5335A5B2296D17EB000051B1 /* TaskDashboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskDashboard.swift; sourceTree = "<group>"; };
5335A5B4296D1FA7000051B1 /* TaskView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TaskView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -850,8 +856,11 @@
5372C0292A105AA1008CB120 /* FancyChip.swift */,
53FBCC8D2A61D59B00B88539 /* FancyStaticTextField.swift */,
53E202752A81F2E100B4DF70 /* FancyStar.swift */,
5334F26B2B2A5BD60079D2E7 /* FancyToggle.swift */,
5334F26B2B2A5BD60079D2E7 /* FancyProjectActiveToggle.swift */,
5334F26D2B2A5CC50079D2E7 /* FancyLabel.swift */,
5334F26F2B2B83190079D2E7 /* FancyColourPicker.swift */,
5334F2712B2B95240079D2E7 /* FancyJobActiveToggle.swift */,
5334F2732B2B958D0079D2E7 /* FancyJobSredToggle.swift */,
);
path = Fancy;
sourceTree = "<group>";
Expand Down Expand Up @@ -1211,6 +1220,7 @@
53EDDFA22963502A008D34C7 /* LogRowEmpty.swift in Sources */,
5371BA342A7B2B8F00DEEC21 /* JobRowPlain.swift in Sources */,
533AB3F2296CA34600E91A9F /* ManageRecords.swift in Sources */,
5334F2702B2B83190079D2E7 /* FancyColourPicker.swift in Sources */,
53DFF075296F124E0051DA91 /* ManageTasks.swift in Sources */,
5334F26A2B2A14F90079D2E7 /* ManageOwnedProjects.swift in Sources */,
53790C102A74D54C00D3FFD4 /* JobFormValidator.swift in Sources */,
Expand Down Expand Up @@ -1245,6 +1255,7 @@
537628AC29665B4E00DE8ECF /* NoteView.swift in Sources */,
53B0BE8829726400007CB663 /* GenericToolbar.swift in Sources */,
53E24C412A844BC800EB21FD /* EKEvent.swift in Sources */,
5334F2722B2B95240079D2E7 /* FancyJobActiveToggle.swift in Sources */,
53D5E29A2A85E38A00FE293A /* WidgetLocation.swift in Sources */,
53999C1F29669C4E00125E65 /* NoteCreate.swift in Sources */,
53E202682A802D0900B4DF70 /* ButtonSize.swift in Sources */,
Expand Down Expand Up @@ -1289,7 +1300,7 @@
5371BA2B2A7B279800DEEC21 /* NoteViewSidebar.swift in Sources */,
53B0BE90297333C3007CB663 /* ManageProjects.swift in Sources */,
53B0BE8129725B52007CB663 /* CoreDataProjects.swift in Sources */,
5334F26C2B2A5BD60079D2E7 /* FancyToggle.swift in Sources */,
5334F26C2B2A5BD60079D2E7 /* FancyProjectActiveToggle.swift in Sources */,
53D5E2982A85A75C00FE293A /* Planning.swift in Sources */,
53967D8629EC7DEB006616A0 /* ViewModeSelector.swift in Sources */,
53152CCC2969453000A14E43 /* DateHelper.swift in Sources */,
Expand All @@ -1303,6 +1314,7 @@
53521E54296FBDAE002E7F21 /* CoreDataNoteVersions.swift in Sources */,
53967D8429EC6D14006616A0 /* TodaySettings.swift in Sources */,
531E2F752A140533009CA230 /* CalendarToday.swift in Sources */,
5334F2742B2B958D0079D2E7 /* FancyJobSredToggle.swift in Sources */,
5326AE982B27FA02009F1349 /* DefaultCompanySidebar.swift in Sources */,
537AEB9F29627DCC00385787 /* LogTable.swift in Sources */,
5335A5AE296CFF83000051B1 /* FileHelper.swift in Sources */,
Expand Down Expand Up @@ -1494,7 +1506,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 149;
CURRENT_PROJECT_VERSION = 150;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down Expand Up @@ -1529,7 +1541,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 149;
CURRENT_PROJECT_VERSION = 150;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
14 changes: 13 additions & 1 deletion DLPrototype/Extensions/Color.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extension Color {

return colour
}

static func randomStorable() -> [Double] {
return [Double.random(in: 0...1), Double.random(in: 0...1), Double.random(in: 0...1)]
}
Expand All @@ -43,4 +43,16 @@ extension Color {
let brightness = ((components[0] * 299) + (components[1] * 587) + (components[2] * 114)) / 1000
return (brightness > 0.5)
}

public func toStored() -> [Double] {
if let components = cgColor?.components {
let r = components[0] * 1.0
let g = components[1] * 1.0
let b = components[2] * 1.0

return [r,g,b]
}

return [0.0, 0.0, 0.0]
}
}
9 changes: 8 additions & 1 deletion DLPrototype/Helpers/StringHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ import SwiftUI

public final class StringHelper {
static public func abbreviate(_ data: String) -> String {
return String(data.split(separator: " ").map {$0.first!}).uppercased()
let letters = data.split(separator: " ").map {$0.first!}

// get the first 3 characters if there's only one word
if letters.count == 1 {
return String(data.prefix(4)).uppercased()
}

return String(letters).uppercased()
}
}
6 changes: 3 additions & 3 deletions DLPrototype/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ struct MainMenu: Commands {
.keyboardShortcut("n", modifiers: .command)
Button("Note") {
nav.view = AnyView(NoteCreate())
nav.parent = .today
nav.parent = .notes
}
.keyboardShortcut("n", modifiers: [.command, .shift])
Button("Task") {
nav.view = AnyView(TaskDashboard())
nav.parent = .today
nav.parent = .tasks
}
.keyboardShortcut("t", modifiers: [.command, .shift])
Button("Project") {
nav.view = AnyView(ProjectCreate())
nav.parent = .today
nav.parent = .companies
}
.keyboardShortcut("p", modifiers: [.command, .shift])
Button("Job") {
Expand Down
10 changes: 2 additions & 8 deletions DLPrototype/Views/Companies/CompanyBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ struct CompanyBlock: View {
} label: {
VStack(spacing: 0) {
ZStack(alignment: .topLeading) {
(company.alive ? Color.yellow : Color.white)
(company.alive ? Color.fromStored(company.colour!) : Color.white)
.shadow(color: .black.opacity(1), radius: 3)
.opacity(highlighted ? 0.2 : 0.1)
.opacity(highlighted ? 0.4 : 0.3)

VStack(alignment: .leading, spacing: 10) {
HStack {
Expand All @@ -50,9 +50,3 @@ struct CompanyBlock: View {
.buttonStyle(.plain)
}
}

//struct CompanyBlock_Previews: PreviewProvider {
// static var previews: some View {
// CompanyBlock()
// }
//}
8 changes: 1 addition & 7 deletions DLPrototype/Views/Companies/CompanyDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extension CompanyDashboard {
init(company: Company? = nil) {
let request: NSFetchRequest<Company> = Company.fetchRequest()
request.sortDescriptors = [
NSSortDescriptor(keyPath: \Company.name?, ascending: false)
NSSortDescriptor(keyPath: \Company.name, ascending: true)
]

request.predicate = NSPredicate(format: "alive = true")
Expand Down Expand Up @@ -120,9 +120,3 @@ extension CompanyDashboard {
}
}
}

//struct CompanyDashboard_Previews: PreviewProvider {
// static var previews: some View {
// Company()
// }
//}
21 changes: 13 additions & 8 deletions DLPrototype/Views/Companies/CompanyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct CompanyView: View {
@State private var abbreviation: String = ""
@State private var created: Date? = nil
@State private var updated: Date? = nil
@State private var colour: Color = .clear
@State private var isDeleteAlertShowing: Bool = false

@Environment(\.managedObjectContext) var moc
Expand All @@ -35,7 +36,8 @@ struct CompanyView: View {

FancyTextField(placeholder: "Legal name", lineLimit: 1, onSubmit: {}, showLabel: true, text: $name)
FancyTextField(placeholder: "Abbreviation", lineLimit: 1, onSubmit: {}, showLabel: true, text: $abbreviation)

FancyColourPicker(initialColour: company.colour ?? Theme.rowColourAsDouble, onChange: {newColour in colour = newColour})

if let created = created {
HStack {
FancyLabel(text: "Created")
Expand Down Expand Up @@ -83,7 +85,7 @@ struct CompanyView: View {

Spacer()
FancyButtonv2(
text: "Save",
text: "Save & Close",
action: save,
size: .medium,
redirect: AnyView(CompanyDashboard()),
Expand Down Expand Up @@ -112,6 +114,13 @@ struct CompanyView: View {
abbreviation = newCompany.abbreviation!
created = newCompany.createdDate!
updated = newCompany.lastUpdate!

if let c = newCompany.colour {
colour = Color.fromStored(c)
}
}
.onChange(of: colour) { newColour in
self.save()
}
}
}
Expand All @@ -121,6 +130,7 @@ extension CompanyView {
name = company.name!
abbreviation = company.abbreviation!
created = company.createdDate!
colour = Color.fromStored(company.colour ?? Theme.rowColourAsDouble)

if let updatedAt = company.lastUpdate {
updated = updatedAt
Expand All @@ -131,6 +141,7 @@ extension CompanyView {
company.name = name
company.abbreviation = abbreviation
company.lastUpdate = Date()
company.colour = colour.toStored()

PersistenceController.shared.save()
}
Expand Down Expand Up @@ -164,9 +175,3 @@ extension CompanyView {
nav.setSidebar(AnyView(DefaultCompanySidebar()))
}
}

//struct CompanyView_Previews: PreviewProvider {
// static var previews: some View {
// CompanyView()
// }
//}
70 changes: 17 additions & 53 deletions DLPrototype/Views/Jobs/JobView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct JobView: View {
@State private var pName: String = ""
@State private var pId: String = ""
@State private var url: String = ""
@State private var colour: String = ""
@State private var colour: Color = .clear
@State private var alive: Bool = true
@State private var shredable: Bool = false
@State private var validJob: Bool = false
Expand All @@ -33,19 +33,14 @@ struct JobView: View {
topSpace

fieldProjectLink
fieldIsOn
fieldIsShredable

FancyTextField(placeholder: "URL", lineLimit: 1, onSubmit: {}, showLabel: true, text: $url)
.background(validUrl ? Color.clear : Color.red)
FancyTextField(placeholder: "Job ID", lineLimit: 1, onSubmit: {}, showLabel: true, text: $id)
.background(validJob ? Color.clear : Color.red)


HStack {
FancyRandomJobColourPicker(job: job, colour: $colour)
Spacer()
}
FancyJobActiveToggle(entity: job)
FancyJobSredToggle(entity: job)
FancyColourPicker(initialColour: job.colour ?? Theme.rowColourAsDouble, onChange: {newColour in colour = newColour})

buttonSubmit
}
Expand Down Expand Up @@ -75,52 +70,21 @@ struct JobView: View {

@ViewBuilder private var fieldProjectLink: some View {
if let project = job.project {
FancyLink(
icon: "folder",
label: "Project: \(project.name!)",
showLabel: true,
colour: Color.fromStored(job.project!.colour ?? Theme.rowColourAsDouble),
destination: AnyView(ProjectView(project: project)),
pageType: .projects,
sidebar: AnyView(ProjectsDashboardSidebar())
)
}
}

@ViewBuilder private var fieldIsOn: some View {
FancyDivider()

HStack {
Toggle("Job is active", isOn: $alive)
// .onAppear(perform: {
// if job.alive {
// alive = true
// } else {
// alive = false
// }
//
// update()
// })
Spacer()
}
}

@ViewBuilder private var fieldIsShredable: some View {
HStack {
Toggle("Eligible for SR&ED", isOn: $shredable)
// .onAppear(perform: {
// if job.shredable {
// shredable = true
// } else {
// shredable = false
// }
//
// update()
// })
Spacer()
HStack {
FancyLabel(text: "Project")
FancyLink(
icon: "folder",
label: project.name!,
showLabel: true,
colour: Color.fromStored(job.project!.colour ?? Theme.rowColourAsDouble),
destination: AnyView(ProjectView(project: project)),
pageType: .projects,
sidebar: AnyView(ProjectsDashboardSidebar())
)
}
}
}

@ViewBuilder private var buttonSubmit: some View {
HStack {
FancyButtonv2(
Expand Down
Loading

0 comments on commit 74cae79

Please sign in to comment.