Skip to content
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
30 changes: 17 additions & 13 deletions TaskBlock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
19254BB12BE3F41800D4D0C5 /* CalendarAndReminderSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19254BB02BE3F41800D4D0C5 /* CalendarAndReminderSettings.swift */; };
192B535C2BE7488200CF53ED /* BlocksSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192B535B2BE7488200CF53ED /* BlocksSettings.swift */; };
192B535E2BE74B6100CF53ED /* iCloudSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192B535D2BE74B6100CF53ED /* iCloudSettings.swift */; };
192B53602BE74C6A00CF53ED /* DaySettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192B535F2BE74C6A00CF53ED /* DaySettings.swift */; };
192B53622BE74C7200CF53ED /* AboutSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192B53612BE74C7200CF53ED /* AboutSettings.swift */; };
192B53602BE74C6A00CF53ED /* AboutSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192B535F2BE74C6A00CF53ED /* AboutSettings.swift */; };
192B53622BE74C7200CF53ED /* MainSettingsMenu.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192B53612BE74C7200CF53ED /* MainSettingsMenu.swift */; };
192B53642BEA65AD00CF53ED /* settings.plist in Resources */ = {isa = PBXBuildFile; fileRef = 192B53632BEA65AD00CF53ED /* settings.plist */; };
192C7D212B85A2FB00DBA8FB /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192C7D202B85A2FB00DBA8FB /* AppDelegate.swift */; };
192C7D232B85A2FB00DBA8FB /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 192C7D222B85A2FB00DBA8FB /* SceneDelegate.swift */; };
192C7D282B85A2FB00DBA8FB /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 192C7D262B85A2FB00DBA8FB /* Main.storyboard */; };
Expand All @@ -31,7 +32,7 @@
19B521192BDC2A36007727F5 /* BlockItem+CoreDataClass.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B521172BDC2A36007727F5 /* BlockItem+CoreDataClass.swift */; };
19B5211A2BDC2A36007727F5 /* BlockItem+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19B521182BDC2A36007727F5 /* BlockItem+CoreDataProperties.swift */; };
19DA03162B8EE1E900303FE2 /* DetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19DA03152B8EE1E900303FE2 /* DetailViewController.swift */; };
19E0DF3D2BDA8B390094575E /* Day.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E0DF3C2BDA8B390094575E /* Day.swift */; };
19E0DF3D2BDA8B390094575E /* DaySettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E0DF3C2BDA8B390094575E /* DaySettings.swift */; };
19E478C52BD20E6300557640 /* CategoriesTableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19E478C42BD20E6300557640 /* CategoriesTableViewController.swift */; };
19ED78572B9AC32700BDA1A7 /* ToDoModel.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 19ED78552B9AC32700BDA1A7 /* ToDoModel.xcdatamodeld */; };
/* End PBXBuildFile section */
Expand All @@ -53,8 +54,9 @@
19254BB02BE3F41800D4D0C5 /* CalendarAndReminderSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CalendarAndReminderSettings.swift; sourceTree = "<group>"; };
192B535B2BE7488200CF53ED /* BlocksSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BlocksSettings.swift; sourceTree = "<group>"; };
192B535D2BE74B6100CF53ED /* iCloudSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iCloudSettings.swift; sourceTree = "<group>"; };
192B535F2BE74C6A00CF53ED /* DaySettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaySettings.swift; sourceTree = "<group>"; };
192B53612BE74C7200CF53ED /* AboutSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutSettings.swift; sourceTree = "<group>"; };
192B535F2BE74C6A00CF53ED /* AboutSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutSettings.swift; sourceTree = "<group>"; };
192B53612BE74C7200CF53ED /* MainSettingsMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainSettingsMenu.swift; sourceTree = "<group>"; };
192B53632BEA65AD00CF53ED /* settings.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = settings.plist; sourceTree = "<group>"; };
192C7D1D2B85A2FB00DBA8FB /* TaskBlock.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TaskBlock.app; sourceTree = BUILT_PRODUCTS_DIR; };
192C7D202B85A2FB00DBA8FB /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
192C7D222B85A2FB00DBA8FB /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -74,7 +76,7 @@
19B521172BDC2A36007727F5 /* BlockItem+CoreDataClass.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BlockItem+CoreDataClass.swift"; sourceTree = "<group>"; };
19B521182BDC2A36007727F5 /* BlockItem+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BlockItem+CoreDataProperties.swift"; sourceTree = "<group>"; };
19DA03152B8EE1E900303FE2 /* DetailViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailViewController.swift; sourceTree = "<group>"; };
19E0DF3C2BDA8B390094575E /* Day.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Day.swift; sourceTree = "<group>"; };
19E0DF3C2BDA8B390094575E /* DaySettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DaySettings.swift; sourceTree = "<group>"; };
19E478C42BD20E6300557640 /* CategoriesTableViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CategoriesTableViewController.swift; sourceTree = "<group>"; };
19ED78562B9AC32700BDA1A7 /* ToDoModel.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = ToDoModel.xcdatamodel; sourceTree = "<group>"; };
/* End PBXFileReference section */
Expand Down Expand Up @@ -109,6 +111,7 @@
192C7D142B85A2FB00DBA8FB = {
isa = PBXGroup;
children = (
192B53632BEA65AD00CF53ED /* settings.plist */,
192C7D1F2B85A2FB00DBA8FB /* TaskBlock */,
19B5210E2BDC2531007727F5 /* TaskBlockTests */,
192C7D1E2B85A2FB00DBA8FB /* Products */,
Expand Down Expand Up @@ -148,12 +151,13 @@
children = (
198ECE9D2BE1D6EF00B9062D /* SettingModel.swift */,
198ECEA02BE1DBDF00B9062D /* SettingsUIComponent.swift */,
192B53612BE74C7200CF53ED /* MainSettingsMenu.swift */,
192B535F2BE74C6A00CF53ED /* AboutSettings.swift */,
19254BAE2BE2D7A500D4D0C5 /* AppearaceSettings.swift */,
19254BB02BE3F41800D4D0C5 /* CalendarAndReminderSettings.swift */,
192B535B2BE7488200CF53ED /* BlocksSettings.swift */,
19254BB02BE3F41800D4D0C5 /* CalendarAndReminderSettings.swift */,
192B535D2BE74B6100CF53ED /* iCloudSettings.swift */,
192B535F2BE74C6A00CF53ED /* DaySettings.swift */,
192B53612BE74C7200CF53ED /* AboutSettings.swift */,
19E0DF3C2BDA8B390094575E /* DaySettings.swift */,
);
path = SettingModel;
sourceTree = "<group>";
Expand Down Expand Up @@ -200,7 +204,6 @@
isa = PBXGroup;
children = (
198ECE9F2BE1DBB300B9062D /* SettingModel */,
19E0DF3C2BDA8B390094575E /* Day.swift */,
);
path = Models;
sourceTree = "<group>";
Expand Down Expand Up @@ -287,6 +290,7 @@
buildActionMask = 2147483647;
files = (
192C7D2D2B85A30000DBA8FB /* LaunchScreen.storyboard in Resources */,
192B53642BEA65AD00CF53ED /* settings.plist in Resources */,
192C7D2A2B85A30000DBA8FB /* Assets.xcassets in Resources */,
192C7D282B85A2FB00DBA8FB /* Main.storyboard in Resources */,
);
Expand All @@ -307,7 +311,7 @@
buildActionMask = 2147483647;
files = (
198ECE9C2BE1D44500B9062D /* SettingsDetailViewController.swift in Sources */,
19E0DF3D2BDA8B390094575E /* Day.swift in Sources */,
19E0DF3D2BDA8B390094575E /* DaySettings.swift in Sources */,
192B535E2BE74B6100CF53ED /* iCloudSettings.swift in Sources */,
192B535C2BE7488200CF53ED /* BlocksSettings.swift in Sources */,
198ECEA12BE1DBDF00B9062D /* SettingsUIComponent.swift in Sources */,
Expand All @@ -316,13 +320,13 @@
19254BAF2BE2D7A500D4D0C5 /* AppearaceSettings.swift in Sources */,
19B521192BDC2A36007727F5 /* BlockItem+CoreDataClass.swift in Sources */,
19B5211A2BDC2A36007727F5 /* BlockItem+CoreDataProperties.swift in Sources */,
192B53622BE74C7200CF53ED /* AboutSettings.swift in Sources */,
192B53622BE74C7200CF53ED /* MainSettingsMenu.swift in Sources */,
199782232B85B5BC00BCA16F /* SettingsViewController.swift in Sources */,
19E478C52BD20E6300557640 /* CategoriesTableViewController.swift in Sources */,
19DA03162B8EE1E900303FE2 /* DetailViewController.swift in Sources */,
19254BB12BE3F41800D4D0C5 /* CalendarAndReminderSettings.swift in Sources */,
192C7D232B85A2FB00DBA8FB /* SceneDelegate.swift in Sources */,
192B53602BE74C6A00CF53ED /* DaySettings.swift in Sources */,
192B53602BE74C6A00CF53ED /* AboutSettings.swift in Sources */,
19ED78572B9AC32700BDA1A7 /* ToDoModel.xcdatamodeld in Sources */,
199782252B85B5CC00BCA16F /* InboxViewController.swift in Sources */,
19683B112BBCFAC400457BFA /* ToDoCell.swift in Sources */,
Expand Down
5 changes: 3 additions & 2 deletions TaskBlock/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<barButtonItem key="rightBarButtonItem" systemItem="add" id="aDT-0d-ery">
<connections>
<action selector="addButtonTapped:" destination="d8q-oa-1mt" id="hHo-Fu-lqt"/>
<segue destination="VBt-tN-PE0" kind="show" identifier="showDetails" destinationCreationSelector="showDetails:" id="8pe-GG-DVX"/>
</connections>
</barButtonItem>
</navigationItem>
Expand Down Expand Up @@ -521,7 +522,7 @@
<color key="backgroundColor" systemColor="systemGroupedBackgroundColor"/>
<prototypes>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" selectionStyle="default" indentationWidth="10" reuseIdentifier="categoryCell" id="dNy-Z7-SJ1">
<rect key="frame" x="20" y="55.333332061767578" width="390" height="43.666667938232422"/>
<rect key="frame" x="20" y="38" width="390" height="43.666667938232422"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="dNy-Z7-SJ1" id="Vhu-HE-8u1">
<rect key="frame" x="0.0" y="0.0" width="390" height="43.666667938232422"/>
Expand Down Expand Up @@ -688,7 +689,7 @@
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="Og4-AO-UVm"/>
<segue reference="8pe-GG-DVX"/>
</inferredMetricsTieBreakers>
<resources>
<image name="arrow.up.and.down.and.sparkles" catalog="system" width="128" height="89"/>
Expand Down
75 changes: 63 additions & 12 deletions TaskBlock/BlockItem/BlockItem+CoreDataProperties.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,71 @@ extension BlockItem {
@NSManaged public var end: Date

func addToDoItemsToBlock(_ toDos: [ToDoItem]) -> [ToDoItem] {
// var manuallyAssignedToDos = [ToDoItem]()
// We only want to evaluate the assigned block property if it's been set
// for toDo in toDos {
// if toDo.assignedBlock != nil && toDo.assignedBlock == id {
// manuallyAssignedToDos.append(todo)
// } else {
// manuallyAssignedToDos = toDos
// }
// }
// let manuallyAssignedToDos = toDos.filter { $0.assignedBlock != nil && $0.assignedBlock == id }
let toDosMatchingPreferredCategory = toDos.filter { $0.category == preferredCategory }
let toDosInBlockTimeRange = toDosMatchingPreferredCategory.filter { $0.start ?? .now >= start && $0.start ?? .now <= end }
var toDosInBlockTimeRange = [ToDoItem]()

for toDo in toDos {
if toDo.assignedBlock == nil {
guard let startTime = toDo.start else {
return toDosInBlockTimeRange
}
if startTime >= start && startTime <= end {
toDosInBlockTimeRange.append(toDo)
toDo.assignedBlock = id
}
} else {
return toDosInBlockTimeRange
}
}

// toDos.forEach { $0.assignedBlock = id }
return toDosInBlockTimeRange
}

func autoScheduleToDos(_ toDos: [ToDoItem]) -> [ToDoItem] {
// TODO: Add UI for maually assigning a block, then evaulate it here
// 1. Evaluate manually assigned blocks
// Initialize toDos as a variable
print("Input toDos for scheduleBlock (Block \(id)")
//21. Filter for toDos that match the preferred category
var toDosMatchingCategory = toDos.filter { $0.category == preferredCategory }
// If no toDos were matching the category, just grab all the toDos
if toDosMatchingCategory.isEmpty {
toDosMatchingCategory = toDos
}
print("Categorized toDos for block ID \(id)")

// 3. Sort toDos that by preferred difficulty of the block
let toDosSortedByDifficulty = sortByDifficulty(toDos: toDosMatchingCategory, preferredDifficulty: Int(preferredDifficulty))

//toDos = toDos.filter { $0.difficulty == block.preferredDifficulty }
print("toDos sorted by difficulty for block ID \(id)")

// 4. Sort the remaining toDos by their priority, from highest to lowest
let prioritizedtoDos = prioritizeToDos(toDos: toDosSortedByDifficulty)
print("Prioritized toDos for block ID \(id)")

// 5. Fit as many toDos into the block as we can given the time constraints
// let scheduledtoDos = fittoDosIntoBlock(toDos: prioritizedtoDos, duration: block.duration)
// print("Added the following toDos to Block \(block.id)\n\(printtoDos(toDos: scheduledtoDos))")
return prioritizedtoDos
}

private func sortByDifficulty(toDos: [ToDoItem], preferredDifficulty: Int) -> [ToDoItem] {
// Copy the list of tasks into a new array to be filtered for positive category matches
var tasksMatchingDifficulty = toDos
// Copy the list of tasks into a new array for the rest of the tasks that don't match
var tasksNotMatchingDifficulty = toDos
tasksMatchingDifficulty.removeAll(where: { $0.difficulty != preferredDifficulty })
tasksNotMatchingDifficulty.removeAll(where: { $0.difficulty == preferredDifficulty })
// Combine the two array so that the matching tasks are placed at the top
let sortedTasks = tasksMatchingDifficulty + tasksNotMatchingDifficulty
return sortedTasks
}

func prioritizeToDos(toDos: [ToDoItem]) -> [ToDoItem] {
let prioritizedToDos = toDos.sorted { $0.priority < $1.priority }
return prioritizedToDos
}

}

Expand Down
9 changes: 0 additions & 9 deletions TaskBlock/Models/Day.swift

This file was deleted.

26 changes: 20 additions & 6 deletions TaskBlock/Models/SettingModel/AboutSettings.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AboutSettings.swift
// DaySettings.swift
// TaskBlock
//
// Created by Camden Webster on 5/5/24.
Expand All @@ -8,16 +8,30 @@
import Foundation
import UIKit

struct AboutSettings: SettingsSubMenu {
var settings: [[Setting]] {
struct AboutSettings: SettingsSubMenuConfig {
var sections: [String]? = ["Version Details", "Contact"]
var settings: [[SettingsSubMenuItem]] {
[
[
Setting(identifier: "currentVersion", title: "1.0", description: "Version number", symbol: nil, type: .text)
SettingsSubMenuItem(identifier: "currentVersion", title: "1.0", description: "Version number", symbol: nil, type: .text)
],
[
Setting(identifier: "contactButton", title: "Contact", description: "Tap here to reach out!", symbol: nil, type: .button),
Setting(identifier: "reportBugButton", title: "Repot a Bug", description: "Tap here to report a bug", symbol: nil, type: .button),
SettingsSubMenuItem(identifier: "contactButton", title: "Contact", description: "Tap here to reach out!", symbol: nil, type: .button),
SettingsSubMenuItem(identifier: "reportBugButton", title: "Repot a Bug", description: "Tap here to report a bug", symbol: nil, type: .button),
]
]
}



var iCloudSettings: [[SettingsSubMenuItem]] {
[
[
SettingsSubMenuItem(identifier: "syncStatus", title: "Fully Synced", description: "Current sync status", symbol: nil, type: .text),
SettingsSubMenuItem(identifier: "syncNowButton", title: "Sync Now", description: "Tap to sync with iCloud", symbol: nil, type: .button)
]
]
}


}
17 changes: 9 additions & 8 deletions TaskBlock/Models/SettingModel/AppearaceSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@
import Foundation
import UIKit

struct AppearaceSettings: SettingsSubMenu {
var settings: [[Setting]] = [
struct AppearaceSettings: SettingsSubMenuConfig {
var sections: [String]? = ["Theme", "Inbox Placement"]
var settings: [[SettingsSubMenuItem]] = [
[
Setting(identifier: "matchSystem", title: "Match System", description: "Sets display theme to match system setting", symbol: nil, type: .checkmark),
Setting(identifier: "light", title: "Light", description: "Sets display theme to Light Mode", symbol: nil, type: .checkmark),
Setting(identifier: "dark", title: "Dark", description: "Sets display theme to Dark Mode", symbol: nil, type: .checkmark)
SettingsSubMenuItem(identifier: "matchSystem", title: "Match System", description: "Sets display theme to match system setting", accessory: .checkmark, symbol: nil, type: .checkmark),
SettingsSubMenuItem(identifier: "light", title: "Light", description: "Sets display theme to Light Mode", accessory: .checkmark, symbol: nil, type: .checkmark),
SettingsSubMenuItem(identifier: "dark", title: "Dark", description: "Sets display theme to Dark Mode", accessory: .checkmark, symbol: nil, type: .checkmark)
],
[
Setting(identifier: "inboxAbove", title: "Above Schedule", description: "Places the inbox above the schedule", symbol: nil, type: .checkmark),
Setting(identifier: "inboxBelow", title: "Below Schedule", description: "Places the inbox Below the schedule", symbol: nil, type: .checkmark)
SettingsSubMenuItem(identifier: "inboxAbove", title: "Above Schedule", description: "Places the inbox above the schedule", accessory: .checkmark, symbol: nil, type: .checkmark),
SettingsSubMenuItem(identifier: "inboxBelow", title: "Below Schedule", description: "Places the inbox Below the schedule", accessory: .checkmark, symbol: nil, type: .checkmark)
]
]

func switchAppearance(_ setting: Setting) {
func switchAppearance(_ setting: SettingsSubMenuItem) {
var mode: UIUserInterfaceStyle

switch setting.identifier {
Expand Down
7 changes: 4 additions & 3 deletions TaskBlock/Models/SettingModel/BlocksSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
import Foundation
import UIKit

struct BlocksSettings: SettingsSubMenu {
var settings: [[Setting]] = [
struct BlocksSettings: SettingsSubMenuConfig {
var sections: [String]? = ["Blocks", "Add"]
var settings: [[SettingsSubMenuItem]] = [
[

],
[
Setting(identifier: "addBlock", title: "Add Block", description: "Tap button to add a new block", symbol: nil, type: .button)
SettingsSubMenuItem(identifier: "addBlock", title: "Add Block", description: "Tap button to add a new block", symbol: nil, type: .button)
]
]
}
Loading