-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/sort by distance #382
Conversation
ffcaa69
to
1b51684
Compare
1b51684
to
26ee0d4
Compare
User should be able to sort events by distance ascending or descending. By default, events are sorted by date, so the distance sort is applied on top, but this doesn't really matter as it is unlikely to have two events at the same coordinates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Left some minor comments, but can be merged into the main regardless due to time constraints.
@Provides | ||
fun provideGPSService(application: Application): GPSService { | ||
val context = application.applicationContext | ||
return GPSServiceImpl(context) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Knitpick/Suggestion for next time: Maybe instead of defining context as a variable, use its declaration directly in the return statement since we only use it once?
val fmt = { format: String, value: Double -> | ||
String.format(Locale.getDefault(), format, value) | ||
} | ||
if (it < 1000) fmt("%.0fm", it) else fmt("%.1fkm", it / 1000.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Knitpick: good practise to not Magic values in the code: 1000.0 can be extracted into a variable?
canModifyEvent = canModifyEvent, | ||
distance = userLocation?.let { event.location.toLatLng().distanceTo(it) }, | ||
) | ||
Spacer(modifier = Modifier.height(12.dp)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly for the height value, could be extracted into a variable to b e able to make modifications easily by someone else in the future
Those are good points! I have addressed them. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes requested by @srsingh04 have been made
Quality Gate passedIssues Measures |
Sort events by distance.
Display distance to user in
EventListItem
, but only on theHomeScreen
.Closes #383 and #384.