Skip to content

Commit

Permalink
Merge pull request #38 from aapis/feature/note-link-fix
Browse files Browse the repository at this point in the history
Bug fix: Note/task links in job selector, New feature: Planning > Upcoming Tasks
  • Loading branch information
aapis authored Aug 1, 2024
2 parents 1de381b + acde93d commit 1a4fc61
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 5 deletions.
4 changes: 2 additions & 2 deletions KlockWork-iOS/KlockWork-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "KlockWork-iOS/KlockWork_iOS.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 16;
CURRENT_PROJECT_VERSION = 17;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"KlockWork-iOS/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down Expand Up @@ -859,7 +859,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = "KlockWork-iOS/KlockWork_iOS.entitlements";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 16;
CURRENT_PROJECT_VERSION = 17;
DEAD_CODE_STRIPPING = YES;
DEVELOPMENT_ASSET_PATHS = "\"KlockWork-iOS/Preview Content\"";
DEVELOPMENT_TEAM = 6DT7L2N5X6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ struct PageConfiguration {

extension PageConfiguration {
enum PlanType: CaseIterable, Equatable {
case daily, feature
case daily, feature, upcoming

/// Interface-friendly representation
var label: String {
switch self {
case .daily: "Daily"
case .feature: "Feature"
case .upcoming: "Upcoming"
}
}

Expand All @@ -33,6 +34,7 @@ extension PageConfiguration {
switch self {
case .daily: "Day"
case .feature: "Feature"
case .upcoming: "Upcoming"
}
}

Expand All @@ -41,6 +43,7 @@ extension PageConfiguration {
switch self {
case .daily: Image(systemName: "calendar")
case .feature: Image(systemName: "list.bullet.below.rectangle")
case .upcoming: Image(systemName: "hourglass")
}
}
}
Expand Down
70 changes: 68 additions & 2 deletions KlockWork-iOS/KlockWork-iOS/SharedViews/PlanTabs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ extension PlanTabs {
)
case .feature:
Feature()
case .upcoming:
Upcoming()
}
}
}
Expand Down Expand Up @@ -373,7 +375,7 @@ extension PlanTabs {
}
} else {
NavigationLink {

TaskDetail()
} label: {
HStack(spacing: 8) {
Image(systemName: "plus")
Expand All @@ -398,7 +400,7 @@ extension PlanTabs {
}
} else {
NavigationLink {

NoteDetail.Sheet()
} label: {
HStack(spacing: 8) {
Image(systemName: "plus")
Expand Down Expand Up @@ -541,4 +543,68 @@ extension PlanTabs {
.padding()
}
}

struct Upcoming: View {
typealias Row = Tabs.Content.Individual.SingleTaskChecklistItem

@FetchRequest private var tasks: FetchedResults<LogTask>
@State private var upcoming: [UpcomingRow] = []

var body: some View {
NavigationStack {
ScrollView {
VStack(alignment: .leading, spacing: 1) {
if !tasks.isEmpty {
ForEach(self.upcoming, id: \.self) { row in
HStack {
Spacer()
Text(row.date)
.padding(5)
.font(.caption)
}
.background(.black.opacity(0.2))

ForEach(row.tasks) { task in
Row(task: task)
}
}
} else {
HStack {
Text("No upcoming due dates")
Spacer()
}
.padding()
.background(Theme.textBackground)
.clipShape(.rect(cornerRadius: 16))
Spacer()
}
}
}
}
.onAppear(perform: self.actionOnAppear)
}

init() {
_tasks = CoreDataTasks.fetchUpcoming()
}

/// Onload handler
/// - Returns: Void
private func actionOnAppear() -> Void {
self.upcoming = []
let grouped = Dictionary(grouping: self.tasks, by: {$0.due?.formatted(date: .abbreviated, time: .omitted) ?? "No Date"})
let sorted = Array(grouped)
.sorted(by: {$0.key < $1.key})

for group in sorted {
self.upcoming.append(UpcomingRow(date: group.key, tasks: group.value))
}
}

struct UpcomingRow: Identifiable, Hashable {
var id: UUID = UUID()
var date: String
var tasks: [LogTask]
}
}
}

0 comments on commit 1a4fc61

Please sign in to comment.