Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement miles/kilometer selector #252

Merged
merged 11 commits into from
Oct 6, 2019
Prev Previous commit
Next Next commit
fix: add missing whitespaces
  • Loading branch information
matepapp committed Oct 5, 2019
commit b457cc9c1978afe6985eeedba8275abcf1aaeae9
2 changes: 1 addition & 1 deletion App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if (Constants.manifest.extra.sentryPublicDsn) {
}
}

export function App() {
export function App () {
const [ready, setReady] = useState(false);
useEffect(() => {
Promise.all([
Expand Down
4 changes: 2 additions & 2 deletions App/Screens/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Sh**t! I Smoke. If not, see <http:https://www.gnu.org/licenses/>.

import Constants from 'expo-constants';
import React, { useState } from 'react';
import React from 'react';
import { Linking, Platform, ScrollView, StyleSheet, Switch, Text, View } from 'react-native';
import { ScrollIntoView, wrapScrollView } from 'react-native-scroll-into-view';
import { scale } from 'react-native-size-matters';
Expand Down Expand Up @@ -67,7 +67,7 @@ interface AboutProps
scrollInto?: keyof typeof aboutSections;
}> {}

export function About(props: AboutProps) {
export function About (props: AboutProps) {
const { navigation } = props;
const { distanceUnit, setDistanceUnit, localizedDistanceUnit } = useDistanceUnit();
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved

Expand Down
2 changes: 1 addition & 1 deletion App/Screens/Details/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ interface DetailsProps extends NavigationInjectedProps {}
// Holds the ref to the MapView.Marker representing the AQI station
let stationMarker: Marker | undefined;

export function Details(props: DetailsProps) {
export function Details (props: DetailsProps) {
const { navigation } = props;

const [showMap, setShowMap] = useState(false);
Expand Down
2 changes: 1 addition & 1 deletion App/Screens/Details/Distance/Distance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ interface DistanceProps {
distance: number;
}

export function Distance(props: DistanceProps) {
export function Distance (props: DistanceProps) {
const { localizedDistanceUnit } = useDistanceUnit();
const distanceUnit = localizedDistanceUnit('short');

Expand Down
2 changes: 1 addition & 1 deletion App/Screens/Home/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface HeaderProps {
onChangeLocationClick: (event: GestureResponderEvent) => void;
}

export function Header(props: HeaderProps) {
export function Header (props: HeaderProps) {
const { api } = useContext(ApiContext)!;
const { currentLocation, isGps } = useContext(CurrentLocationContext);
const { localizedDistanceUnit, distanceUnit } = useDistanceUnit();
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
5 changes: 2 additions & 3 deletions App/stores/distanceUnit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { AsyncStorage } from 'react-native';
import React, { useState, useEffect, createContext, FC, useContext } from 'react';
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved

import { i18n } from '../localization';
import { noop } from '../util/noop';

export type DistanceUnit = 'km' | 'mile';
type DistanceUnitFormat = 'short' | 'long';
Expand All @@ -17,8 +16,8 @@ type ContextType = {

const Context = createContext<ContextType>({
distanceUnit: 'km',
localizedDistanceUnit: (format: DistanceUnitFormat) => '',
setDistanceUnit: (unit: DistanceUnit) => {}
localizedDistanceUnit: () => '',
setDistanceUnit: () => {}
});

export const DistanceUnitProvider: FC = ({ children }) => {
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
4 changes: 2 additions & 2 deletions App/util/station.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const MAX_DISTANCE_TO_STATION = 10;
* @param api - The api object returned by remote data.
* @param unit - The unit of measure returned.
*/
export function distanceToStation(currentLocation: LatLng, api: Api, unit: DistanceUnit = 'km') {
export function distanceToStation (currentLocation: LatLng, api: Api, unit: DistanceUnit = 'km') {
return Math.round(
haversine(
currentLocation,
Expand All @@ -50,7 +50,7 @@ export function distanceToStation(currentLocation: LatLng, api: Api, unit: Dista
* @param currentLocation - The current location of the user.
* @param api - The api object returned by remote data.
*/
export function isStationTooFar(currentLocation: LatLng, api: Api) {
export function isStationTooFar (currentLocation: LatLng, api: Api) {
return distanceToStation(currentLocation, api) > MAX_DISTANCE_TO_STATION;
}

Expand Down