openfoodfacts / openfoodfacts-swift

Apache License 2.0
5 stars 3 forks source link

Initial version Swift-OFF-SDK #3

Closed hrabkin closed 5 months ago

hrabkin commented 8 months ago

What

See README.md of the fork

Screenshot

See README.md of the fork repo

Uses

Swift, SwiftUI+Combine, SPM. Minimum dependencies.

Based on https://github.com/openfoodfacts/openfoodfacts-dart repo, this doc https://openfoodfacts.github.io/openfoodfacts-server/api/ and many questions in Slack of OFF community =)

This repo doesn't cover all TO-DO points for now but has a great start and some usability at least for me and my pet project.

aleene commented 8 months ago

It looks like you wrote a lot of code. Any demo app that is working? I could try to run a fork of this. I think Pierre should answer if your approach covers what he asks for. For me an SDK is only the basic implementation of an API, like I created for the Robotoff and Folksonomy API. Things like scanning a barcode would not be part of that SDK. So where should the division lie? But great that you got this far. Where do you want do end up?

hrabkin commented 8 months ago

@aleene you may try examples (folder Example in root of my fork). I've seen Pierre's to-do list, the SDK covers only some points from it. Scanner not part of the SDK but used in examples. Yes there's some OFF model described in Swift without any additional dependecies for decoding/encoding and also API endpoints covered in OpenFoodAPIClient class: for retrieving taxonomies for nutrients, getting ordered nutrients, suggestions for categories, saving product, sending images. As I said before I needed some native OFF SDK which I would integrate via SPM into my iOS project with submit new product functionality. I don't need translations and not interested in eco score or nova groups therefore I skipped them for now. I tried your apps before starting to write the SDK but I wasn't able to build project quickly. I checked that your native projects have many dependencies via cocoapods, some of them outdated so much that I it would take for me a lot of time to rewrite and adapt for my needs what you have in comparison of writing everything from scratch by myself. You confirmed this in Slack. So I have ended up with the project. I could keep it privately but decided to share my work in case someone will need something similar I asked OFF.

aleene commented 8 months ago

I need to check it out in Xcode. By the way I was talking about the repositories on my personal space.

The off ios app has indeed to many dependencies. I did not program it, but helped debugging it.

hrabkin commented 8 months ago

@aleene yes I talked about your repositories, I don't understand why you needed ObjectMapper or some additional framework for handling networking

aleene commented 8 months ago

Yes, a bit of an experiment needed for the example, so to get an ordered List in SwiftUI. Probably can solved without it as well.

hrabkin commented 8 months ago

@aleene list is ordered by default always, it is ordered data structure, unique id of each element at the same time represents its position.

aleene commented 8 months ago

I will take it out. It is not needed for a demo.

Not sure what you mean by the fact that a list is ordered. On what key, up or down? Everything is always unordered, unless you specifically order it the way you want.

I do not remember why I used it though. Maybe there were doubles and I wanted to ensure uniqueness with a set.

teolemon commented 8 months ago

The "What can I work on" issue is indicative, and you're very welcome to edit it.

teolemon commented 5 months ago

@hrabkin @aleene can I merge this PR ?

teolemon commented 5 months ago

My approach is "Release early, release often" ;-)

hrabkin commented 5 months ago

@teolemon yes, @aleene wanted example how to use OpenFoodFactsAPIClient class (which is open/public) but I don't have time on this, I can access any pull requests if you do or maybe later I will add more examples myself.

teolemon commented 5 months ago

Congratulations on your first PR 🤗 @hrabkin