Roadmap icon indicating copy to clipboard operation
Roadmap copied to clipboard

Include multiple abstractions to enable custom implementations

Open shaps80 opened this issue 1 year ago • 8 comments

Hey mate, I love your work and I think is a great idea. But I'm curious if there's any reason you wouldn't have implemented this library as an easy way to add voting to the app (will show an example below) without enforcing specific UI?

// the AppStore rating implementation is a nice API IMO
@Environment(\.votingRequest) private var vote
// ...
try await vote("someId")

The UI elements could be an optional added-benefit for those that want to use them wholesale but I feel like the basic feature of just "voting" adds a lot of value as-is. In my experience the styling approach you've chosen doesn't scale well nor to everyone's needs, I think you can see this already in the Issues actually.

So if you were going to provide it as a convenience perhaps you could opt for a couple lower level APIs that you simply build on top of, but make it easy for consumers to build fully custom implementations of their own as well.

// Borrowing from `FetchRequest` CoreData property wrappers, namespace could also be provided, or defaulted perhaps to the Bundle ID
@FetchVotes("someId") private var votes

Then you could use the above to build UI on top, at which point I'd then provide a more SwiftUI-y Style as-in how ButtonStyle, etc are implemented.

Anyway, no criticism just genuinely inspired me a little here and I thought I'd share how I would have approached the problem, perhaps its helpful or inspires some new work 👍

shaps80 avatar Feb 21 '23 11:02 shaps80