Skip to content

Commit 1a4fc61

Browse files
authored
Merge pull request #38 from aapis/feature/note-link-fix
Bug fix: Note/task links in job selector, New feature: Planning > Upcoming Tasks
2 parents 1de381b + acde93d commit 1a4fc61

File tree

3 files changed

+74
-5
lines changed

3 files changed

+74
-5
lines changed

KlockWork-iOS/KlockWork-iOS.xcodeproj/project.pbxproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@
817817
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
818818
CODE_SIGN_ENTITLEMENTS = "KlockWork-iOS/KlockWork_iOS.entitlements";
819819
CODE_SIGN_STYLE = Automatic;
820-
CURRENT_PROJECT_VERSION = 16;
820+
CURRENT_PROJECT_VERSION = 17;
821821
DEAD_CODE_STRIPPING = YES;
822822
DEVELOPMENT_ASSET_PATHS = "\"KlockWork-iOS/Preview Content\"";
823823
DEVELOPMENT_TEAM = 6DT7L2N5X6;
@@ -859,7 +859,7 @@
859859
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
860860
CODE_SIGN_ENTITLEMENTS = "KlockWork-iOS/KlockWork_iOS.entitlements";
861861
CODE_SIGN_STYLE = Automatic;
862-
CURRENT_PROJECT_VERSION = 16;
862+
CURRENT_PROJECT_VERSION = 17;
863863
DEAD_CODE_STRIPPING = YES;
864864
DEVELOPMENT_ASSET_PATHS = "\"KlockWork-iOS/Preview Content\"";
865865
DEVELOPMENT_TEAM = 6DT7L2N5X6;

KlockWork-iOS/KlockWork-iOS/SharedEnums/PageConfiguration.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ struct PageConfiguration {
1818

1919
extension PageConfiguration {
2020
enum PlanType: CaseIterable, Equatable {
21-
case daily, feature
21+
case daily, feature, upcoming
2222

2323
/// Interface-friendly representation
2424
var label: String {
2525
switch self {
2626
case .daily: "Daily"
2727
case .feature: "Feature"
28+
case .upcoming: "Upcoming"
2829
}
2930
}
3031

@@ -33,6 +34,7 @@ extension PageConfiguration {
3334
switch self {
3435
case .daily: "Day"
3536
case .feature: "Feature"
37+
case .upcoming: "Upcoming"
3638
}
3739
}
3840

@@ -41,6 +43,7 @@ extension PageConfiguration {
4143
switch self {
4244
case .daily: Image(systemName: "calendar")
4345
case .feature: Image(systemName: "list.bullet.below.rectangle")
46+
case .upcoming: Image(systemName: "hourglass")
4447
}
4548
}
4649
}

KlockWork-iOS/KlockWork-iOS/SharedViews/PlanTabs.swift

+68-2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ extension PlanTabs {
149149
)
150150
case .feature:
151151
Feature()
152+
case .upcoming:
153+
Upcoming()
152154
}
153155
}
154156
}
@@ -373,7 +375,7 @@ extension PlanTabs {
373375
}
374376
} else {
375377
NavigationLink {
376-
378+
TaskDetail()
377379
} label: {
378380
HStack(spacing: 8) {
379381
Image(systemName: "plus")
@@ -398,7 +400,7 @@ extension PlanTabs {
398400
}
399401
} else {
400402
NavigationLink {
401-
403+
NoteDetail.Sheet()
402404
} label: {
403405
HStack(spacing: 8) {
404406
Image(systemName: "plus")
@@ -541,4 +543,68 @@ extension PlanTabs {
541543
.padding()
542544
}
543545
}
546+
547+
struct Upcoming: View {
548+
typealias Row = Tabs.Content.Individual.SingleTaskChecklistItem
549+
550+
@FetchRequest private var tasks: FetchedResults<LogTask>
551+
@State private var upcoming: [UpcomingRow] = []
552+
553+
var body: some View {
554+
NavigationStack {
555+
ScrollView {
556+
VStack(alignment: .leading, spacing: 1) {
557+
if !tasks.isEmpty {
558+
ForEach(self.upcoming, id: \.self) { row in
559+
HStack {
560+
Spacer()
561+
Text(row.date)
562+
.padding(5)
563+
.font(.caption)
564+
}
565+
.background(.black.opacity(0.2))
566+
567+
ForEach(row.tasks) { task in
568+
Row(task: task)
569+
}
570+
}
571+
} else {
572+
HStack {
573+
Text("No upcoming due dates")
574+
Spacer()
575+
}
576+
.padding()
577+
.background(Theme.textBackground)
578+
.clipShape(.rect(cornerRadius: 16))
579+
Spacer()
580+
}
581+
}
582+
}
583+
}
584+
.onAppear(perform: self.actionOnAppear)
585+
}
586+
587+
init() {
588+
_tasks = CoreDataTasks.fetchUpcoming()
589+
}
590+
591+
/// Onload handler
592+
/// - Returns: Void
593+
private func actionOnAppear() -> Void {
594+
self.upcoming = []
595+
let grouped = Dictionary(grouping: self.tasks, by: {$0.due?.formatted(date: .abbreviated, time: .omitted) ?? "No Date"})
596+
let sorted = Array(grouped)
597+
.sorted(by: {$0.key < $1.key})
598+
599+
for group in sorted {
600+
self.upcoming.append(UpcomingRow(date: group.key, tasks: group.value))
601+
}
602+
}
603+
604+
struct UpcomingRow: Identifiable, Hashable {
605+
var id: UUID = UUID()
606+
var date: String
607+
var tasks: [LogTask]
608+
}
609+
}
544610
}

0 commit comments

Comments
 (0)