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

Removed forced capitalization from most text, updated unified sidebar UX #274

Merged
merged 1 commit into from
Oct 7, 2024
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
2 changes: 1 addition & 1 deletion KlockWork/Views/Entities/Companies/CompanyBlock.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct CompanyBlock: View {
Image(systemName: "building.2")
.help("Default company")
}
Text(company.name!.capitalized)
Text(company.name!)
.font(.title3)
.fontWeight(.bold)
}
Expand Down
2 changes: 1 addition & 1 deletion KlockWork/Views/Entities/Companies/CompanyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct CompanyView: View {
VStack(alignment: .leading, spacing: 13) {
HStack {
Image(systemName: "building.2").font(Theme.fontTitle)
Title(text: "Editing: \(company.name!.capitalized)")
Title(text: "Editing: \(company.name!)")
Spacer()
}

Expand Down
4 changes: 1 addition & 3 deletions KlockWork/Views/Entities/People/PeopleDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,7 @@ extension PeopleDetail {

if let stored = self.state.session.company {
self.company = stored
}

if let stored = self.state.session.job {
} else if let stored = self.state.session.job {
self.company = stored.project?.company
}
}
Expand Down
2 changes: 1 addition & 1 deletion KlockWork/Views/Entities/Terms/TermsDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct TermBlock: View {
.opacity(highlighted ? 0.2 : 0.1)

VStack(alignment: .leading, spacing: 10) {
Text(self.definition.term?.name?.capitalized ?? "_TERM_NAME")
Text(self.definition.term?.name ?? "_TERM_NAME")
.font(.title3)
.fontWeight(.bold)
.padding([.leading, .trailing, .top])
Expand Down
199 changes: 181 additions & 18 deletions KlockWork/Views/Shared/AppSidebar/Widgets/JobsWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ struct UnifiedSidebar {
public let company: Company
@State private var isPresented: Bool = false
@State private var highlighted: Bool = false
@State private var bgColour: Color = .clear
@State private var fgColour: Color = .clear
@AppStorage("widget.jobs.showPublished") private var showPublished: Bool = true

var body: some View {
Expand Down Expand Up @@ -161,13 +163,16 @@ struct UnifiedSidebar {
}
}
}
.background(self.company.alive ? self.highlighted ? self.company.backgroundColor.opacity(0.9) : self.company.backgroundColor : .gray.opacity(0.8))
.foregroundStyle((self.company.alive ? self.company.backgroundColor : .gray).isBright() ? Theme.base : .white)
.onAppear(perform: {
if let job = self.state.session.job {
self.isPresented = job.project?.company == self.company
.background(self.highlighted ? self.bgColour.opacity(0.9) : self.bgColour)
.foregroundStyle(self.fgColour)
.onAppear(perform: self.actionOnAppear)
.onChange(of: self.state.session.company) { self.actionOnChangeEntity() }
.onChange(of: self.isPresented) {
// Group is minimized
if self.isPresented == false {
self.actionOnMinimize()
}
})
}
}
}

Expand All @@ -176,6 +181,8 @@ struct UnifiedSidebar {
public let project: Project
@State private var isPresented: Bool = false
@State private var highlighted: Bool = false
@State private var bgColour: Color = .clear
@State private var fgColour: Color = .clear
@AppStorage("widget.jobs.showPublished") private var showPublished: Bool = true

var body: some View {
Expand Down Expand Up @@ -225,13 +232,16 @@ struct UnifiedSidebar {
}
}
}
.background(self.project.alive ? self.highlighted ? self.project.backgroundColor.opacity(0.9) : self.project.backgroundColor : .gray.opacity(0.8))
.foregroundStyle((self.project.alive ? self.project.backgroundColor : .gray).isBright() ? Theme.base : .white)
.onAppear(perform: {
if let job = self.state.session.job {
self.isPresented = job.project == self.project
.background(self.highlighted ? self.bgColour.opacity(0.9) : self.bgColour)
.foregroundStyle(self.fgColour)
.onAppear(perform: self.actionOnAppear)
.onChange(of: self.state.session.project) { self.actionOnChangeEntity() }
.onChange(of: self.isPresented) {
// Group is minimized
if self.isPresented == false {
self.actionOnMinimize()
}
})
}
}
}

Expand All @@ -240,6 +250,8 @@ struct UnifiedSidebar {
public let job: Job
@State private var isPresented: Bool = false
@State private var highlighted: Bool = false
@State private var bgColour: Color = .clear
@State private var fgColour: Color = .clear
@AppStorage("widget.jobs.showPublished") private var showPublished: Bool = true

var body: some View {
Expand Down Expand Up @@ -299,13 +311,16 @@ struct UnifiedSidebar {
}
}
}
.background(self.job.alive ? self.highlighted ? self.job.backgroundColor.opacity(0.9) : self.job.backgroundColor : .gray.opacity(0.8))
.foregroundStyle((self.job.alive ? self.job.backgroundColor : .gray).isBright() ? Theme.base : .white)
.onAppear(perform: {
if self.state.session.job == self.job {
self.isPresented = true
.background(self.highlighted ? self.bgColour.opacity(0.9) : self.bgColour)
.foregroundStyle(self.fgColour)
.onAppear(perform: self.actionOnAppear)
.onChange(of: self.state.session.job) { self.actionOnChangeEntity() }
.onChange(of: self.isPresented) {
// Group is minimized
if self.isPresented == false {
self.actionOnMinimize()
}
})
}
}
}

Expand Down Expand Up @@ -613,6 +628,154 @@ struct UnifiedSidebar {
}
}

extension UnifiedSidebar.SingleCompany {
/// Onload handler. Sets background colour for the row
/// - Returns: Void
private func actionOnAppear() -> Void {
if self.company.alive {
self.bgColour = self.company.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
} else {
self.bgColour = .gray
self.fgColour = Theme.base
}

if let company = self.state.session.company {
self.isPresented = company == self.company
} else if let job = self.state.session.job {
self.isPresented = job.project?.company == self.company
}
}

/// Fires when state entity changes
/// - Returns: Void
private func actionOnChangeEntity() -> Void {
if self.state.session.company != nil {
if self.state.session.company != self.company {
self.isPresented = false
// @TODO: decide whether to attempt to finish this "focus on current open group" functionality
// self.bgColour = .gray
// self.fgColour = Theme.base
} else {
self.bgColour = self.company.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
} else {
self.bgColour = self.company.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
}

/// Fires when a group is minimized
/// - Returns: Void
private func actionOnMinimize() -> Void {
if self.state.session.company == self.company {
self.state.session.company = nil
self.state.session.project = nil
self.state.session.job = nil
}
self.bgColour = self.company.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
}

extension UnifiedSidebar.SingleProject {
/// Onload handler. Sets background colour for the row
/// - Returns: Void
private func actionOnAppear() -> Void {
if self.project.alive {
self.bgColour = self.project.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
} else {
self.bgColour = .gray
self.fgColour = Theme.base
}

if let project = self.state.session.project {
self.isPresented = project == self.project
} else if let job = self.state.session.job {
self.isPresented = job.project == self.project
}
}

/// Fires when state entity changes
/// - Returns: Void
private func actionOnChangeEntity() -> Void {
if self.state.session.project != nil {
if self.state.session.project != self.project {
self.isPresented = false
// @TODO: decide whether to attempt to finish this "focus on current open group" functionality
// self.bgColour = .gray
// self.fgColour = Theme.base
} else {
self.bgColour = self.project.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
} else {
self.bgColour = self.project.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
}

/// Fires when a group is minimized
/// - Returns: Void
private func actionOnMinimize() -> Void {
if self.state.session.project == self.project {
self.state.session.project = nil
self.state.session.job = nil
}
self.bgColour = self.project.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
}

extension UnifiedSidebar.SingleJob {
/// Onload handler. Sets background colour for the row
/// - Returns: Void
private func actionOnAppear() -> Void {
if self.job.alive {
self.bgColour = self.job.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
} else {
self.bgColour = .gray
self.fgColour = Theme.base
}

if let job = self.state.session.job {
self.isPresented = job == self.job
}
}

/// Fires when state entity changes
/// - Returns: Void
private func actionOnChangeEntity() -> Void {
if self.state.session.job != nil {
if self.state.session.job != self.job {
self.isPresented = false
// @TODO: decide whether to attempt to finish this "focus on current open group" functionality
// self.bgColour = .gray
// self.fgColour = Theme.base
} else {
self.bgColour = self.job.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
} else {
self.bgColour = self.job.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
}

/// Fires when a group is minimized
/// - Returns: Void
private func actionOnMinimize() -> Void {
if self.state.session.job == self.job {
self.state.session.job = nil
}
self.bgColour = self.job.backgroundColor
self.fgColour = self.bgColour.isBright() ? Theme.base : .white
}
}

extension UnifiedSidebar.EntityTypeRowButton {
/// Onload handler. Sets appropriate link data for the given Page
/// - Returns: Void
Expand Down
12 changes: 6 additions & 6 deletions KlockWork/Views/Shared/AppSidebar/Widgets/OutlineWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ struct OutlineWidget: View {
if company.isDefault {
Image(systemName: "building.2")
}
FancyTextLink(text: company.name!.capitalized, destination: AnyView(CompanyView(company: company)), pageType: .companies, sidebar: AnyView(DefaultCompanySidebar()))
.help("Edit company: \(company.name!.capitalized)")
FancyTextLink(text: company.name!, destination: AnyView(CompanyView(company: company)), pageType: .companies, sidebar: AnyView(DefaultCompanySidebar()))
.help("Edit company: \(company.name!)")
Spacer()
}
ProjectOutline(company: company)
Expand All @@ -67,8 +67,8 @@ struct OutlineWidget: View {
ForEach(unowned, id: \.objectID) { project in
HStack {
Image(systemName: "folder")
FancyTextLink(text: "[\(project.abbreviation != nil ? project.abbreviation!.uppercased() : "NOPE")] \(project.name!.capitalized)", destination: AnyView(ProjectView(project: project)), pageType: .companies, sidebar: AnyView(DefaultCompanySidebar()))
.help("Edit project: \(project.name!.capitalized)")
FancyTextLink(text: "[\(project.abbreviation != nil ? project.abbreviation!.uppercased() : "NOPE")] \(project.name!)", destination: AnyView(ProjectView(project: project)), pageType: .companies, sidebar: AnyView(DefaultCompanySidebar()))
.help("Edit project: \(project.name!)")
}
.padding([.leading], 10)
}
Expand Down Expand Up @@ -153,8 +153,8 @@ extension ProjectOutline {
Image(systemName: "folder.fill")
.foregroundStyle(project.backgroundColor)

FancyTextLink(text: "[\(project.abbreviation != nil ? project.abbreviation!.uppercased() : "XXX")] \(project.name!.capitalized)", destination: AnyView(ProjectView(project: project)), pageType: .companies, sidebar: AnyView(DefaultCompanySidebar()))
.help("Edit project: \(project.name!.capitalized)")
FancyTextLink(text: "[\(project.abbreviation != nil ? project.abbreviation!.uppercased() : "XXX")] \(project.name!)", destination: AnyView(ProjectView(project: project)), pageType: .companies, sidebar: AnyView(DefaultCompanySidebar()))
.help("Edit project: \(project.name!)")
Spacer()
FancyButtonv2(text: "Action", action: {aboutPanelOpen.toggle()}, icon: aboutPanelOpen ? "chevron.up.square.fill" : "chevron.down.square", showLabel: false, size: .tiny, type: .clear)
.useDefaultHover({_ in})
Expand Down
2 changes: 1 addition & 1 deletion KlockWork/Views/Shared/CompanyPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct CompanyPicker: View {
if company.name != nil {
items.append(
CustomPickerItem(
title: company.name!.capitalized,
title: company.name!,
tag: Int(company.pid)
)
)
Expand Down
8 changes: 4 additions & 4 deletions KlockWork/Views/Shared/PanelGroup/Panel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ struct CompanyPanel: View {
ForEach(firstColData, id: \.objectID) { company in
Panel.Row(
config: Panel.RowConfiguration(
text: company.name?.capitalized ?? "_COMPANY_NAME",
text: company.name ?? "_COMPANY_NAME",
action: {setMiddlePanel(data: company.projects!.allObjects)},
entity: company,
position: position,
Expand Down Expand Up @@ -180,7 +180,7 @@ struct CompanyPanel: View {
ForEach(nav.forms.tp.middle, id: \.objectID) { project in
Panel.Row(
config: Panel.RowConfiguration(
text: project.name!.capitalized,
text: project.name!,
action: {setLastPanel(data: project.jobs!.allObjects)},
entity: project,
position: position
Expand All @@ -204,7 +204,7 @@ struct CompanyPanel: View {
let job = job as! Job
Panel.Row(
config: Panel.RowConfiguration(
text: job.title?.capitalized ?? job.jid.string,
text: job.title ?? job.jid.string,
action: {nav.session.job = job},
entity: job,
position: position
Expand Down Expand Up @@ -433,7 +433,7 @@ public struct JobPanel: View {
let job = job as! Job
Panel.Row(
config: Panel.RowConfiguration(
text: job.title?.capitalized ?? job.jid.string,
text: job.title ?? job.jid.string,
action: {nav.session.job = job},
entity: job,
position: position
Expand Down
4 changes: 2 additions & 2 deletions KlockWork/Views/Shared/ProjectPickerUsing.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct ProjectPickerUsing: View {
if company.name != nil && company.projects?.count ?? 0 > 0 {
items.append(
CustomPickerItem(
title: company.name!.capitalized,
title: company.name!,
tag: Int(company.pid),
disabled: true
)
Expand All @@ -49,7 +49,7 @@ struct ProjectPickerUsing: View {
for project in (projects.allObjects as! [Project]).sorted(by: {$0.name! < $1.name!}) {
items.append(
CustomPickerItem(
title: " - \(project.name!.capitalized)",
title: " - \(project.name!)",
tag: Int(project.pid),
project: project
)
Expand Down