Ode to laziness - displaying rating stars ⭐️ using emoji 😍
I am wokring on dogspot, which is an application for reviewing dog friendly spots. One of the feature is ability to rate the spots by users.
Now I create read-only app - a kind of radar for finding dog-friendly spots nearby and showing it on map.
ODE:
Backend: My python/django api is returning float representing friendly_rate.
IOS: There is a lot of cool libs for ratings, e.g:
BUT: This have to be read-only app for now. So I decided to mocke rating with static stars. First idea: use static star images. Better idea: use emoji 😍! I am using Google Maps iOS SDK. I was afraid it will have problems with rendering snippet containg emoji but it worked like a charm!
I am rounding float, and want display only integer rating. Then I need only display ⭐️ as many times as value of rating.
Emoji [@"⭐️" length]
is 2 not 1!
I added labs, because my backend returns -1.00 for non-rated spots.
Another aproach, prepare text stars on backend in django-rest-frameworks serializers to_represenation
method
and then just make simply replacment: