This file contains 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
.bag { | |
/* hoist the item list scroll progress scope to the parent so can be shared */ | |
timeline-scope: --item-list-scroll-timeline; | |
} | |
.item-list { | |
/* make the item lists y-axis scroll progress available as a variable */ | |
scroll-timeline: --item-list-scroll-timeline y; | |
} |
This file contains 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
.bag { | |
/* hoist the item list scroll progress scope to the parent so can be shared */ | |
timeline-scope: --item-list-scroll-timeline; | |
} | |
.item-list { | |
/* make the item lists y-axis scroll progress available as a variable */ | |
scroll-timeline: --item-list-scroll-timeline y; | |
} |
This file contains 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
.item-list { | |
/* make the item lists y-axis scroll progress available as a variable */ | |
scroll-timeline: --item-list-scroll-timeline y; | |
} | |
.bag-section-image { | |
/* The animation(s) to drive using the scroll progress */ | |
animation: item-bag-image linear; | |
/* Hook up the item lists scroll progress to drive the animation */ | |
animation-timeline: --item-list-scroll-timeline; |
This file contains 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 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 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 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 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 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 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") | |
} | |
} |
NewerOlder