Devlog: Dec 5, 2022

I’m still spinning my wheels. Haven’t settled on a project I want to dig into yet. So nothing that exciting going on.

I toyed around with maybe bringing back Focuses—my habit tracking app I made a couple years ago and shut down about a year ago. So today, I started over. SwiftUI has come a bit farther than the first time, and I would like to try simplifying the model, a lot. I added a lot of features really fast the first go around and things broke down pretty quickly. So playing around with this and experimenting while I get my head on.

Made a little extension to give me the last 7 days. Just experimenting. I don’t think this will work though. If you’re in the app when the day changes, the static var will be out of date. So might go down the route of calculating on app start up and listening to an event for when the day changes or something like that.

extension Calendar {
    private static var _lastWeek: [Date]?
    var lastWeek: [Date] {
        get {
            if Calendar._lastWeek == nil {
                let today = self.startOfDay(for: Date())
                Calendar._lastWeek = (0...6).map { offset in
                    return .day, value: offset * -1, to: today)!
            return Calendar._lastWeek!


December 5, 2022