Devlog: January 16, 2023
Today I implemented history. Building off of my recent selections work, I created a new little model and store and save each comparison that is run. The idea is that you can look back and use those to initiate a new comparison. This feature was pretty fun to make. With Boutique and reusing some SwiftUI views, it was fast to implement.
So far, I’m fairly happy with this flow. I added a new menu button to hold some other views, and made the reset button match the style. I like that a lot more than it was before. I might adjust the padding/alignment around the search buttons to make it feel more balanced.
I’m planning on adding deletion to history items (as well as a way to delete all.) I’m also considering if I should remove duplicate history items and only show the most recent one. Right now, I’m not showing the timestamp of the history item, but I do have that available.
With the help of the internet, I made a little extension to Sequence
to allow sorting by the key path of an element. I find this to be incredibly useful and intuitive to use.
extension Sequence {
func sorted<T: Comparable>(by keyPath: KeyPath<Element, T>, _ comparator: (_ lhs: T, _ rhs: T) -> Bool) -> [Element] {
return sorted {
return comparator($0[keyPath: keyPath], $1[keyPath: keyPath])
}
}
}
I like this implementation because you can also pass in a comparator function like <
or >
, or something even more custom since it’s a closure.
Less interestingly—or maybe more interestingly depending on what you’re into—I’m trying to figure out the best way to keep track of tasks/ideas I have for this app. Right now I just keep a list in Tot. It works, but it’s not great. I might give TaskPaper another try—I was using it for a while as part of Setapp, but I got rid of my Setapp subscription. I’ve tried pretty much everything out there (including starting to make my own,) and I get caught up in the details of “project planning.” So I want to keep things simple…ish. But I’m getting to the point in this project where it’s small polish details that I can’t always keep in my head. When it’s the broad, big features, my head is fine.