Skip to content

Commit

Permalink
Merge pull request #337 from aapis/feature/1.18/project-dash-rebuild
Browse files Browse the repository at this point in the history
Project dashboard UI updates, Search suggestion UI tweaks, "View" page background colours updated
  • Loading branch information
aapis authored Nov 13, 2024
2 parents e986eff + 89b18f9 commit 5fc0133
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extension WidgetLibrary.UI {

// MARK: Timeline.Widget
struct Widget: View {
@EnvironmentObject public var nav: Navigation
@EnvironmentObject public var state: Navigation
private var tabs: [ToolbarButton] = []

var body: some View {
Expand All @@ -100,7 +100,12 @@ extension WidgetLibrary.UI {
)
}
.padding()
.background(Theme.toolbarColour)
.background(
ZStack {
self.state.session.appPage.primaryColour
Theme.base.opacity(0.6)
}
)
}

init() {
Expand Down
12 changes: 7 additions & 5 deletions KlockWork/Views/Dashboard/Dashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import SwiftUI
import KWCore

struct Dashboard: View {
@EnvironmentObject public var nav: Navigation
@EnvironmentObject public var updater: ViewUpdater
@AppStorage("GlobalSidebarWidgets.isSearchStackShowing") private var isSearchStackShowing: Bool = false
private let page: PageConfiguration.AppPage = .find
@EnvironmentObject public var state: Navigation

var body: some View {
VStack(alignment: .leading, spacing: 0) {
FindDashboard(location: .content)
Spacer()
}
.padding()
.background(Theme.toolbarColour)
.background(
ZStack {
self.state.session.appPage.primaryColour
Theme.base.blendMode(.softLight).opacity(0.4)
}
)
}
}
15 changes: 7 additions & 8 deletions KlockWork/Views/Entities/Projects/ProjectConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,16 @@ import SwiftUI
import KWCore

struct ProjectConfig: View {
@EnvironmentObject private var state: Navigation
@EnvironmentObject public var updater: ViewUpdater
public var project: Project?

@State private var bannedWords: [BannedWord] = []
@State private var bannedWord: String = ""

static private var exportFormatPickerItems: [CustomPickerItem] = [
CustomPickerItem(title: "Choose an export format", tag: 0),
CustomPickerItem(title: "Standard", tag: 1)
]

@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var updater: ViewUpdater

// MARK: body view
var body: some View {
VStack(alignment: .leading) {
Expand All @@ -50,6 +47,8 @@ struct ProjectConfig: View {

Spacer()
}
.padding()
.background(self.state.session.appPage.primaryColour)
.onAppear(perform: onAppear)
.id(updater.ids["pc.form"])
}
Expand All @@ -75,10 +74,10 @@ struct ProjectConfig: View {
}

private func createBannedWord() -> Void {
let matches = CoreDataProjectConfiguration(moc: moc).byWord(bannedWord)
let matches = CoreDataProjectConfiguration(moc: self.state.moc).byWord(bannedWord)

if matches.count == 0 {
let bword = BannedWord(context: moc)
let bword = BannedWord(context: self.state.moc)
bword.word = bannedWord
bword.created = Date()
bword.id = UUID()
Expand Down
53 changes: 26 additions & 27 deletions KlockWork/Views/Entities/Projects/ProjectView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ struct ProjectView: View {
.padding()
}
.id(updater.get("project.view"))
.background(self.nav.session.appPage.primaryColour)
.background(
ZStack {
self.nav.session.appPage.primaryColour
Theme.base.opacity(0.6)
}
)
.onAppear(perform: onAppear)
.onChange(of: selectAllToggleAssociated) {
if self.selectAllToggleAssociated {
Expand Down Expand Up @@ -105,11 +110,7 @@ struct ProjectView: View {
// MARK: form view
@ViewBuilder
var form: some View {
HStack {
Image(systemName: "folder").font(Theme.fontTitle)
Title(text: "Editing: \($name.wrappedValue)")
Spacer()
}
Title(text: "Editing: \($name.wrappedValue)", image: "folder")
FancyTextField(placeholder: "Name", lineLimit: 1, onSubmit: update, showLabel: true, text: $name)
FancyTextField(placeholder: "Abbreviation", lineLimit: 1, onSubmit: {}, showLabel: true, text: $abbreviation)
CompanyPicker(onChange: {company,_ in selectedCompany = company}, selected: project?.company != nil ? Int(project?.company?.pid ?? 0) : 0)
Expand All @@ -129,6 +130,7 @@ struct ProjectView: View {
}
.background(Theme.textBackground)
}
.disabled(true)
}

if let updated = lastUpdate {
Expand All @@ -142,6 +144,7 @@ struct ProjectView: View {
}
.background(Theme.textBackground)
}
.disabled(true)
}

FancyDivider()
Expand All @@ -156,6 +159,7 @@ struct ProjectView: View {
VStack(alignment: .leading, spacing: 1) {
VStack(alignment: .leading, spacing: 20) {
FancySubTitle(text: "Associated jobs", image: "checkmark")
.padding([.leading, .top])
Divider()
HStack(spacing: 1) {
Text("\(selectedJobs.count)/\(all.count) selected")
Expand All @@ -169,13 +173,12 @@ struct ProjectView: View {
if selectedJobs.count > 0 {
associatedJobs
}

Spacer()
}

VStack(alignment: .leading, spacing: 1) {
VStack(alignment: .leading, spacing: 20) {
FancySubTitle(text: "Unowned jobs", image: "questionmark")
.padding([.leading, .top])
Divider()
HStack(spacing: 1) {
Text("\(allUnOwned.count)/\(all.count) selected")
Expand All @@ -189,17 +192,23 @@ struct ProjectView: View {
if allUnOwned.count > 0 {
unOwnedJobs
}

Spacer()
}
}
.background(self.nav.session.appPage.primaryColour)
}

// MARK: toolbar view
@ViewBuilder
var toolbar: some View {
FancyGenericToolbar(buttons: buttons)
.onAppear(perform: createToolbar)
FancyGenericToolbar(
buttons: self.buttons,
standalone: true,
location: .content,
mode: .compact,
page: .explore,
alwaysShowTab: true
)
.onAppear(perform: self.createToolbar)
}

// MARK: associated jobs view
Expand Down Expand Up @@ -407,29 +416,19 @@ extension ProjectView {
// }

private func createToolbar() -> Void {
buttons = [
self.buttons = [
ToolbarButton(
id: 0,
helpText: "Assign jobs to the project",
label: AnyView(
HStack {
Image(systemName: "square.grid.3x1.fill.below.line.grid.1x2")
.font(.title2)
Text("Jobs")
}
),
icon: "square.grid.3x1.fill.below.line.grid.1x2",
labelText: "Jobs",
contents: AnyView(jobAssignment)
),
ToolbarButton(
id: 1,
helpText: "Create/assign configurations to the project",
label: AnyView(
HStack {
Image(systemName: "circles.hexagongrid.fill")
.font(.title2)
Text("Configurations")
}
),
icon: "circles.hexagongrid.fill",
labelText: "Configuration",
contents: AnyView(ProjectConfig(project: project))
)
]
Expand Down
8 changes: 6 additions & 2 deletions KlockWork/Views/Explore/Explore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import SwiftUI
import KWCore

struct Explore: View {
typealias UI = WidgetLibrary.UI
@EnvironmentObject public var state: Navigation

var body: some View {
Expand All @@ -27,7 +26,12 @@ struct Explore: View {
Spacer()
}
.padding()
.background(Theme.toolbarColour)
.background(
ZStack {
self.state.session.appPage.primaryColour
Theme.base.opacity(0.6)
}
)
}
}

Expand Down
72 changes: 54 additions & 18 deletions KlockWork/Views/Find/Suggestions/Suggestions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,12 @@ extension FindDashboard.Suggestions.SuggestedJobs {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}
}
Expand All @@ -949,8 +953,12 @@ extension FindDashboard.Suggestions.SuggestedProjects {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}
}
Expand Down Expand Up @@ -984,8 +992,12 @@ extension FindDashboard.Suggestions.SuggestedNotes {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}
}
Expand All @@ -996,8 +1008,12 @@ extension FindDashboard.Suggestions.SuggestedTasks {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}

Expand Down Expand Up @@ -1032,8 +1048,12 @@ extension FindDashboard.Suggestions.SuggestedCompanies {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}

Expand All @@ -1058,8 +1078,12 @@ extension FindDashboard.Suggestions.SuggestedPeople {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}
}
Expand All @@ -1070,8 +1094,12 @@ extension FindDashboard.Suggestions.SuggestedRecords {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}

Expand All @@ -1098,8 +1126,12 @@ extension FindDashboard.Suggestions.SuggestedTerms {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}
}
Expand All @@ -1110,8 +1142,12 @@ extension FindDashboard.Suggestions.SuggestedDefinitions {
}

private func appear() -> Void {
if items.count <= 5 {
showChildren = true
if self.items.count <= 5 {
if self.items.count > 1 {
self.showChildren = true
} else {
self.showChildren = false
}
}
}
}
7 changes: 6 additions & 1 deletion KlockWork/Views/Planning/Planning.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,12 @@ struct Planning: View {
)
}
.padding()
.background(Theme.toolbarColour)
.background(
ZStack {
self.nav.session.appPage.primaryColour
Theme.base.opacity(0.6)
}
)
.onAppear(perform: actionOnAppear)
.onChange(of: nav.planning.jobs) { self.actionOnChangeJobs()}
}
Expand Down
Loading

0 comments on commit 5fc0133

Please sign in to comment.