Skip to content

Commit

Permalink
Merge pull request #94 from aapis/feature/link-aggregator-for-reals
Browse files Browse the repository at this point in the history
QOL improvements
  • Loading branch information
aapis authored Apr 12, 2023
2 parents 7c263a6 + 5743e90 commit cd96fc1
Show file tree
Hide file tree
Showing 15 changed files with 281 additions and 117 deletions.
8 changes: 6 additions & 2 deletions DLPrototype.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
533E40682970DD170007785A /* AutoFixJobs.swift in Sources */ = {isa = PBXBuildFile; fileRef = 533E40672970DD170007785A /* AutoFixJobs.swift */; };
533E406A2970F5610007785A /* SearchHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 533E40692970F5610007785A /* SearchHelper.swift */; };
53521E54296FBDAE002E7F21 /* CoreDataNoteVersions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53521E53296FBDAE002E7F21 /* CoreDataNoteVersions.swift */; };
53529A07299F38C0000D2FCB /* JobPickerUsing.swift in Sources */ = {isa = PBXBuildFile; fileRef = 53529A06299F38C0000D2FCB /* JobPickerUsing.swift */; };
5361DDED2971E1DF00437064 /* CoreDataNotes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5361DDEC2971E1DF00437064 /* CoreDataNotes.swift */; };
5367FAF0296772730060D2AA /* Split.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5367FAEF296772730060D2AA /* Split.swift */; };
537368D124B93DB600193E88 /* Today.swift in Sources */ = {isa = PBXBuildFile; fileRef = 537368D024B93DB600193E88 /* Today.swift */; };
Expand Down Expand Up @@ -162,6 +163,7 @@
533E40672970DD170007785A /* AutoFixJobs.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AutoFixJobs.swift; sourceTree = "<group>"; };
533E40692970F5610007785A /* SearchHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchHelper.swift; sourceTree = "<group>"; };
53521E53296FBDAE002E7F21 /* CoreDataNoteVersions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataNoteVersions.swift; sourceTree = "<group>"; };
53529A06299F38C0000D2FCB /* JobPickerUsing.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = JobPickerUsing.swift; sourceTree = "<group>"; };
5361DDEC2971E1DF00437064 /* CoreDataNotes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CoreDataNotes.swift; sourceTree = "<group>"; };
5367FAEF296772730060D2AA /* Split.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Split.swift; sourceTree = "<group>"; };
537368D024B93DB600193E88 /* Today.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Today.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -568,6 +570,7 @@
5376289A2966467100DE8ECF /* SearchBar.swift */,
53B0BE8729726400007CB663 /* GenericToolbar.swift */,
53B0BE9129733A86007CB663 /* JobPicker.swift */,
53529A06299F38C0000D2FCB /* JobPickerUsing.swift */,
);
path = Shared;
sourceTree = "<group>";
Expand Down Expand Up @@ -766,6 +769,7 @@
5376289E29664F8C00DE8ECF /* Theme.swift in Sources */,
53C6D09829654F4C00EA6129 /* DetailGroup.swift in Sources */,
533E406A2970F5610007785A /* SearchHelper.swift in Sources */,
53529A07299F38C0000D2FCB /* JobPickerUsing.swift in Sources */,
5376289B2966467100DE8ECF /* SearchBar.swift in Sources */,
537628A22966525500DE8ECF /* ToolbarButtons.swift in Sources */,
537AEBA1296287B900385787 /* LogRow.swift in Sources */,
Expand Down Expand Up @@ -977,7 +981,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 80;
CURRENT_PROJECT_VERSION = 81;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down Expand Up @@ -1008,7 +1012,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 80;
CURRENT_PROJECT_VERSION = 81;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"DLPrototype/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
27 changes: 24 additions & 3 deletions DLPrototype/Views/Find/FindDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct RecentSearch: Identifiable {

struct FindDashboard: View {
@State private var searchText: String = ""
@State private var activeSearchText: String = ""
@State private var showRecords: Bool = true
@State private var showNotes: Bool = true
@State private var showTasks: Bool = true
Expand Down Expand Up @@ -48,10 +49,14 @@ struct FindDashboard: View {
Grid(horizontalSpacing: 0, verticalSpacing: 1) {
GridRow {
SearchBar(
text: $searchText,
text: $activeSearchText,
disabled: false,
placeholder: "Search"
placeholder: "Hit enter to search",
onSubmit: onSubmit
)
.onChange(of: searchText) { _ in
onSubmit()
}
}

GridRow {
Expand Down Expand Up @@ -84,7 +89,23 @@ struct FindDashboard: View {
showJobs: $showJobs,
allowAlive: $allowAlive
)
.environmentObject(jm)
.environmentObject(jm)
}
}

@ViewBuilder
var loading: some View {
VStack(alignment: .leading, spacing: 0) {
HStack {
Spacer()
ProgressView("Searching...")
Spacer()
}
.padding([.top, .bottom], 20)
}
}

private func onSubmit() -> Void {
searchText = activeSearchText
}
}
3 changes: 1 addition & 2 deletions DLPrototype/Views/Home/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2020 YegCollective. All rights reserved.
//

import Combine
import SwiftUI

struct Category: Identifiable {
Expand Down Expand Up @@ -94,7 +93,7 @@ struct Home: View {
NavigationLink {
TaskDashboard()
.navigationTitle("Tasks")
.environmentObject(rm)
.environmentObject(jm)
.environmentObject(updater)
.toolbar {
if showExperimentalFeatures {
Expand Down
18 changes: 13 additions & 5 deletions DLPrototype/Views/Jobs/JobDashboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct JobDashboard: View {

@State private var selectedJob: Int = 0
@State private var job: Job?
@State private var jobId: String = ""

@Environment(\.managedObjectContext) var moc

Expand All @@ -38,11 +39,13 @@ struct JobDashboard: View {
Spacer()
}

JobPicker(onChange: change)
.onAppear(perform: setJob)
.onChange(of: selectedJob) { _ in
setJob()
}
VStack {
JobPicker(onChange: change)
.onAppear(perform: setJob)
.onChange(of: selectedJob) { _ in
setJob()
}
}

if selectedJob > 0 || defaultSelectedJob! > 0.0 {
JobView(job: $job)
Expand All @@ -57,6 +60,11 @@ struct JobDashboard: View {
if selectedJob > 0 {
job = CoreDataJob(moc: moc).byId(Double(selectedJob))
}

if job != nil {
jobId = job!.jid.string
print("JID sj \(jobId)")
}
}

private func change(selected: Int, sender: String?) -> Void {
Expand Down
2 changes: 2 additions & 0 deletions DLPrototype/Views/Settings/GeneralSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ struct GeneralSettings: View {
@AppStorage("enableAutoCorrection") public var enableAutoCorrection: Bool = false
@AppStorage("autoFixJobs") public var autoFixJobs: Bool = false
@AppStorage("showSidebar") public var showSidebar: Bool = true
@AppStorage("showTodaySearch") public var showSearch: Bool = true
@AppStorage("defaultHome") public var defaultHome: Int = 0

var body: some View {
Form {
Toggle("Tiger stripe table rows", isOn: $tigerStriped)
Toggle("Auto-correct text in text boxes", isOn: $enableAutoCorrection)
Toggle("Show sidebar", isOn: $showSidebar)
Toggle("Show search on Today", isOn: $showSearch)

Group {
Toggle("Experimental features (may tank performance)", isOn: $showExperimentalFeatures)
Expand Down
9 changes: 5 additions & 4 deletions DLPrototype/Views/Shared/Fancy/FancyTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import SwiftUI
struct FancyTextField: View {
public var placeholder: String
public var lineLimit: Int
public var onSubmit: () -> Void
// public var onSubmit: () -> Void
public var onSubmit: (() -> Void)? = nil
public var transparent: Bool? = false
public var disabled: Bool? = false
public var fgColour: Color? = Color.white
Expand Down Expand Up @@ -40,7 +41,7 @@ struct FancyTextField: View {
.textFieldStyle(.plain)
.disableAutocorrection(enableAutoCorrection)
.padding()
.onSubmit(onSubmit)
.onSubmit(onSubmit ?? {})
.background(transparent! ? Color.clear : bgColour)
.frame(height: 45)
.lineLimit(1)
Expand All @@ -55,7 +56,7 @@ struct FancyTextField: View {
.textFieldStyle(.plain)
.disableAutocorrection(enableAutoCorrection)
.padding()
.onSubmit(onSubmit)
.onSubmit(onSubmit ?? {})
.background(transparent! ? Color.clear : bgColour)
.lineLimit(lineLimit...)
.disabled(disabled ?? false)
Expand All @@ -69,7 +70,7 @@ struct FancyTextField: View {
.textFieldStyle(.plain)
.disableAutocorrection(enableAutoCorrection)
.padding()
.onSubmit(onSubmit)
.onSubmit(onSubmit ?? {})
.background(transparent! ? Color.black.opacity(0.1) : bgColour)
.scrollContentBackground(.hidden)
.lineLimit(lineLimit...)
Expand Down
105 changes: 48 additions & 57 deletions DLPrototype/Views/Shared/JobPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,20 @@

import Foundation
import SwiftUI
import Combine

struct JobPicker: View {
public var onChange: (Int, String?) -> Void
public var transparent: Bool? = false
public var labelText: String?
public var showLabel: Bool? = false

@State private var jobId: String = ""
@State private var jobIdFieldColour: Color = Color.clear
@State private var jobIdFieldTextColour: Color = Color.white

@Environment(\.managedObjectContext) var moc
@EnvironmentObject public var jm: CoreDataJob

private var pickerItems: [CustomPickerItem] {
var items: [CustomPickerItem] = [CustomPickerItem(title: "Choose a job", tag: 0)]
Expand All @@ -44,66 +47,54 @@ struct JobPicker: View {
}

var body: some View {
// HStack {
// ZStack {
// FancyTextField(
// placeholder: "Job ID",
// lineLimit: 1,
// onSubmit: {},
// fgColour: jobIdFieldTextColour,
// bgColour: jobIdFieldColour,
// text: $jobId
// )
// .border(jobIdFieldColour == Color.clear ? Color.black.opacity(0.1) : Color.clear, width: 2)
// .onChange(of: jobId) { _ in
// if jobId != "" {
// if let iJid = Int(jobId) {
// pickerChange(selected: iJid, sender: nil)
// }
// }
// }
// HStack {
// if !jobId.isEmpty {
// FancyButton(text: "Reset", action: resetJobUi, icon: "xmark", showLabel: false)
// }
// JobPicker(onChange: pickerChange)
// }
// .padding([.leading], 100)
// }
// .frame(width: 350, height: 40)
//
// Text("Or").font(Theme.font)
//
// FancyTextField(placeholder: "Task URL", lineLimit: 1, onSubmit: {}, text: $taskUrl)
// .onReceive(Just(jobId)) { input in
// let filtered = input.filter { "0123456789".contains($0) }
// if filtered != input {
// jobId = filtered
// }
// }
// }

HStack {
ZStack {
FancyTextField(
placeholder: "Job ID",
lineLimit: 1,
onSubmit: {},
fgColour: jobIdFieldTextColour,
bgColour: jobIdFieldColour,
text: $jobId
)
.border(jobIdFieldColour == Color.clear ? Color.black.opacity(0.1) : Color.clear, width: 2)
.onChange(of: jobId) { _ in
if jobId != "" {
if let iJid = Int(jobId) {
pickerChange(selected: iJid, sender: nil)
}
}
}
HStack {
if !jobId.isEmpty {
FancyButton(text: "Reset", action: resetJobUi, icon: "xmark", showLabel: false)
}
FancyPicker(onChange: pickerChange, items: pickerItems, transparent: transparent, labelText: labelText, showLabel: showLabel)
}
.padding([.leading], 100)
}
}
.frame(width: 350, height: 40)
}

private func pickerChange(selected: Int, sender: String?) -> Void {
jobId = String(selected)


if let selectedJob = jm.byId(Double(jobId)!) {
jobIdFieldColour = Color.fromStored(selectedJob.colour ?? Theme.rowColourAsDouble)
jobIdFieldTextColour = jobIdFieldColour.isBright() ? Color.black : Color.white
} else {
jobIdFieldColour = Color.clear
jobIdFieldTextColour = Color.white
}

FancyPicker(onChange: onChange, items: pickerItems, transparent: transparent, labelText: labelText, showLabel: showLabel)
onChange(selected, sender)
}

// private func pickerChange(selected: Int, sender: String?) -> Void {
// jobId = String(selected)
//
// if let selectedJob = jobModel.byId(Double(jobId)!) {
// jobIdFieldColour = Color.fromStored(selectedJob.colour ?? Theme.rowColourAsDouble)
// jobIdFieldTextColour = jobIdFieldColour.isBright() ? Color.black : Color.white
// } else {
// jobIdFieldColour = Color.clear
// jobIdFieldTextColour = Color.white
// }
// }
//
// private func resetJobUi() -> Void {
// jobId = ""
// jobIdFieldColour = Color.clear
// jobIdFieldTextColour = Color.white
// }
private func resetJobUi() -> Void {
jobId = ""
jobIdFieldColour = Color.clear
jobIdFieldTextColour = Color.white
}
}
Loading

0 comments on commit cd96fc1

Please sign in to comment.