Skip to content

mishagray/FIExample

Repository files navigation

FIExample

Some Example Code.

NOTES:

I was trying to use OpenCombine (which is a backward compatible open source implementation of Swift 5's combine).
However I had issues with it (it's new). For now this code still requires iOS 13 combine via XCode 11 beta 7. NOTE: Xcode 11 beta 7 reports itself as Version 11.0 beta 6 (11M392r) in the about page.
So if you install beta 7 and it CLAIMES it's beta 6 check for build (11M392r)

The design is very basic.

There is a Restaurant.swift that contains a JSONDecodable struct that should mirror one-to-one the API structure.
This was modified from a swift file generated by quicktype.io based on the API's current responses.

I have left the enum Cuisine, although it should really just be a simple String.
This was mostly to make the filtering logic easier since I could use allCases from the enum, as opposed to generating the cusines list dynamically (which is the right way to do this). It would not be hard to refactor away the 'hard coded' list of cuisines to accept anything. The weird misspelled version of 'cafe' has been left in for now (it's only in one resturant)

API.Swift - wraps the HTTP call and gives us loadResturants() operation.

Model.swift - A baby reactive Model object, with a bindable 'resturants' property.

The 'heart' of the display logic of the logic is in MapViewModel. It computes a reactive list of Annotation objects derived from both the latest Model results, and the user's filtered selections. Using DeepDiff to compute 'changes' to the list of visible Annotations to try and make the appropriate 'addAnnotations'/'removeAnnotations' logic more optimal.

Currently .. resturants are clustered by 'latest grade' (the last grade received).

The colors 'match' the NYC Resturant grade letter colors (as you would see them in the window). Tapping on a grouped cluster should just zoom you in until they separate into individual 'letters'.

The Letter indicates the 'grade'. Tapping on it should show you a resturant Detail page, with it's inspection history.

Items are 'clustered' by the 'last' grade received. It's still not optimal to zoom out too much. 25k+ Annotations maybe pushing the MapKit clustering logic. I've tweaked it a bunch to try and increase performance, but we maybe pushing it with this number of Annotations.

There is a simple 'filter' screen that let's you filter by Cuisines and by Grades.
It wouldn't have been hard to add 'near an address', but getting the 'zoom to somewhere else on the map' is always trickier than it seems.

There is a very simple Resturant Detail page.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published