Skip to content

Commit

Permalink
show in km when distance >= 1000
Browse files Browse the repository at this point in the history
  • Loading branch information
vzts committed Nov 23, 2022
1 parent 60dd298 commit fdc3b4e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
5 changes: 4 additions & 1 deletion src/store/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ export class LocationStore {

getDistance(loc: GpsLocation, accuracy?: number) {
if (!this._location) return null
return getDistance(this._location, loc, accuracy)
const distance = getDistance(this._location, loc, accuracy || 10)
return distance >= 1000
? `${Number(distance / 1000).toFixed(1)}km`
: `${distance}m`
}
}
6 changes: 1 addition & 5 deletions src/ui/group/group-detail-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,7 @@ export const GroupDetailScreen: React.FC<GroupDetailScreenProps> = (props) => {
>
<ContentCard>
<Caption style={{ color: Colors.gray.v400 }}>
{locationStore.getDistance(
geoinfoToGpsLocation(data.gps_geoinfo),
10,
)}
m
{locationStore.getDistance(geoinfoToGpsLocation(data.gps_geoinfo))}
</Caption>
<H1 style={{ marginBottom: 8 }}>{data.title}</H1>
<GroupDesc
Expand Down
2 changes: 0 additions & 2 deletions src/ui/group/selected-group-overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ export const SelectedGroupOverlay: React.FC<{
<Caption style={{ color: Colors.primary.red }}>
{locationStore.getDistance(
geoinfoToGpsLocation(data.gps_geoinfo),
10,
)}
m
</Caption>
<H3 style={{ marginBottom: 2 }}>{data.title}</H3>
<GroupDesc data={data} />
Expand Down
2 changes: 0 additions & 2 deletions src/ui/match/match-request-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ export const MatchRequestItem: React.FC<{
<Distance>
{locationStore.getDistance(
geoinfoToGpsLocation(group.gps_geoinfo),
10,
)}
m
</Distance>
) : (
<MatchRequestStatusLabel status={status} type={type} />
Expand Down

0 comments on commit fdc3b4e

Please sign in to comment.