This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="item-screen"> | |
<div class="bag"> | |
<div class="bag-details"> | |
<div class="bag-section-title"></div> | |
<div class="bag-section-image"> | |
<img src="img/item-shadow.png" /> | |
</div> | |
</div> | |
<div class="item-list"> | |
<ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftData | |
@Model | |
final class ApproachModel { | |
var title: String | |
var date: Date | |
var granularity: DateGranularity | |
var year: Int { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fetchMonthData() { | |
do { | |
let calendar = Calendar.init(identifier: .iso8601) | |
let date = calendar.date(from: DateComponents(year: year, month: month: day: 1))! | |
let weekOfMonth = calendar.component(.weekOfMonth, from: date) | |
var predicate: Predicate<ApproachModel> | |
if (weekOfMonth == 0) { | |
let weekOfYear = calendar.component(.weekOfYear, from: date) | |
predicate = #Predicate { todo in | |
((todo.year == year && todo.month == month) || (todo.week == weekOfYear)) && todo.shownInMonth == true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fetchDayData() { | |
do { | |
let descriptor = FetchDescriptor<ApproachModel>(predicate: #Predicate { todo in | |
todo.year == year && todo.month == month && todo.day == day && todo.shownInDay == true | |
}) | |
todos = try modelContext.fetch(descriptor) | |
} catch { | |
print("Failed to fetch day data") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApproachTodoListViewModel: Identifiable { | |
var modelContext: ModelContext | |
var title: String | |
var todos = [ApproachModel]() | |
var granularity: DateGranularity | |
var year: Int | |
var month: Int? | |
var week: Int? | |
var day: Int? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftData | |
@Model | |
final class ApproachModel { | |
var title: String | |
var year: Int | |
var month: Int? = nil | |
var week: Int? = nil | |
var day: Int? = nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fetchMonthData() { | |
do { | |
let descriptor = FetchDescriptor<ApproachModel>(predicate: #Predicate { todo in | |
((todo.startDate >= startDate && todo.startDate <= endDate) || (todo.endDate >= startDate && todo.endDate <= endDate)) && todo.shownInWeek == true | |
}, sortBy: [SortDescriptor(\.endDate)]) | |
todos = try modelContext.fetch(descriptor) | |
} catch { | |
print("Failed to fetch month data") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fetchWeekData() { | |
do { | |
let descriptor = FetchDescriptor<ApproachModel>(predicate: #Predicate { todo in | |
todo.startDate >= startDate && todo.endDate <= endDate && todo.shownInWeek == true | |
}, sortBy: [SortDescriptor(\.endDate)]) | |
todos = try modelContext.fetch(descriptor) | |
} catch { | |
print("Failed to fetch week data") | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApproachTodoListViewModel: Identifiable { | |
var modelContext: ModelContext | |
var title: String | |
var todos = [ApproachModel]() | |
var startDate: Date | |
var endDate: Date | |
var granularity: DateGranularity | |
// rest of the implementation | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import SwiftData | |
@Model | |
final class ApproachModel { | |
var title: String | |
var startDate: Date | |
var endDate: Date | |
// rest of implementation | |
} |