Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonSpirit committed Dec 21, 2019
2 parents dce3fb5 + 4529e02 commit e73777c
Show file tree
Hide file tree
Showing 80 changed files with 2,094 additions and 1,157 deletions.
24 changes: 1 addition & 23 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,23 +1 @@
module.exports = {
env: {
jest: true
},
extends: [
'plugin:react/recommended',
'plugin:@typescript-eslint/recommended',
'prettier/@typescript-eslint',
'plugin:prettier/recommended'
],
parser: '@typescript-eslint/parser',
plugins: ['react', '@typescript-eslint', 'prettier'],
rules: {
// disable the rule for all files
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/no-explicit-any': 'off'
},
settings: {
react: {
version: 'detect'
}
}
};
module.exports = require('@amaurymartiny/eslintrc');
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# These are supported funding model platforms

github: amaurymartiny
patreon: amaurymartiny
open_collective: amaurymartiny
liberapay: amaurymartiny
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: pr

on: [pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Lint
run: |
yarn install
yarn lint
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Test
run: |
yarn install
yarn test
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

29 changes: 18 additions & 11 deletions App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Sh**t! I Smoke. If not, see <https://www.gnu.org/licenses/>.

import * as Font from 'expo-font';
import { ApolloProvider } from '@apollo/react-hooks';
import Constants from 'expo-constants';
import * as Font from 'expo-font';
import React, { useEffect, useState } from 'react';
import { AppState } from 'react-native';
import { AppState, Platform, StatusBar } from 'react-native';
import * as Sentry from 'sentry-expo';

import { Screens } from './Screens';
Expand All @@ -30,6 +31,7 @@ import {
LocationContextProvider
} from './stores';
import { setupAmplitude, track } from './util/amplitude';
import { client } from './util/apollo';

// Add Sentry if available
if (Constants.manifest.extra.sentryPublicDsn) {
Expand All @@ -43,7 +45,7 @@ if (Constants.manifest.extra.sentryPublicDsn) {
}
}

export function App() {
export function App(): React.ReactElement {
const [ready, setReady] = useState(false);
useEffect(() => {
Promise.all([
Expand All @@ -56,7 +58,7 @@ export function App() {
])

.then(() => setReady(true))
.catch(console.error);
.catch(error => console.error(error));
}, []);

useEffect(() => {
Expand All @@ -72,13 +74,18 @@ export function App() {
return ready ? (
<ErrorContextProvider>
<LocationContextProvider>
<ApiContextProvider>
<FrequencyContextProvider>
<DistanceUnitProvider>
<Screens />
</DistanceUnitProvider>
</FrequencyContextProvider>
</ApiContextProvider>
<ApolloProvider client={client}>
<ApiContextProvider>
<FrequencyContextProvider>
<DistanceUnitProvider>
{Platform.select({
ios: <StatusBar barStyle="dark-content" />
})}
<Screens />
</DistanceUnitProvider>
</FrequencyContextProvider>
</ApiContextProvider>
</ApolloProvider>
</LocationContextProvider>
</ErrorContextProvider>
) : (
Expand Down
29 changes: 21 additions & 8 deletions App/Screens/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ import {
import { ScrollIntoView, wrapScrollView } from 'react-native-scroll-into-view';
import { scale } from 'react-native-size-matters';
import { NavigationInjectedProps } from 'react-navigation';

import { BackButton } from '../../components';
import { i18n } from '../../localization';
import { useDistanceUnit } from '../../stores/distanceUnit';
import { trackScreen } from '../../util/amplitude';
import * as theme from '../../util/theme';
import { SelectNotifications } from '../Home/SelectNotifications';
import { Box } from './Box';

const CustomScrollView = wrapScrollView(ScrollView);
Expand All @@ -49,25 +51,25 @@ export const aboutSections = {
aboutWhyIsTheStationSoFarTitle: 'aboutWhyIsTheStationSoFarTitle'
};

const handleOpenAmaury = () => {
const handleOpenAmaury = (): void => {
Linking.openURL('https://twitter.com/amaurymartiny');
};

const handleOpenAqi = () => {
const handleOpenAqi = (): void => {
Linking.openURL('https://aqicn.org/');
};

const handleOpenArticle = () => {
const handleOpenArticle = (): void => {
Linking.openURL(
'https://berkeleyearth.org/air-pollution-and-cigarette-equivalence/'
);
};

const handleOpenGithub = () => {
const handleOpenGithub = (): void => {
Linking.openURL('https://github.com/amaurymartiny/shoot-i-smoke');
};

const handleOpenMarcelo = () => {
const handleOpenMarcelo = (): void => {
Linking.openURL('https://www.behance.net/marceloscoelho');
};

Expand Down Expand Up @@ -129,7 +131,7 @@ const styles = StyleSheet.create({
}
});

export function About(props: AboutProps) {
export function About(props: AboutProps): React.ReactElement {
const { navigation } = props;
const {
distanceUnit,
Expand All @@ -139,7 +141,7 @@ export function About(props: AboutProps) {

trackScreen('ABOUT');

const toggleDistanceSwitch = (value: boolean) =>
const toggleDistanceSwitch = (value: boolean): void =>
setDistanceUnit(value ? 'km' : 'mile');

return (
Expand All @@ -148,7 +150,9 @@ export function About(props: AboutProps) {
style={theme.withPadding}
>
<BackButton
onPress={() => navigation.goBack()}
onPress={(): void => {
navigation.goBack();
}}
style={styles.backButton}
/>

Expand Down Expand Up @@ -231,6 +235,15 @@ export function About(props: AboutProps) {
</Text>
</View>

<View style={styles.distance}>
<Text style={styles.h2}>Notifications (alpha)</Text>
<Text style={theme.text}>
This section is an alpha testing stage of the new notifications
feature.
</Text>
<SelectNotifications />
</View>

<View style={styles.distance}>
<Text style={styles.h2}>{i18n.t('about_distance_unit_title')}</Text>
<View style={styles.distanceSwitchWrapper}>
Expand Down
3 changes: 2 additions & 1 deletion App/Screens/About/Box/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import React from 'react';
import { Image, Platform, StyleSheet, Text, View } from 'react-native';
import { scale } from 'react-native-size-matters';

import cigarette from '../../../../assets/images/cigarette.png';
import { i18n } from '../../../localization';
import * as theme from '../../../util/theme';
Expand Down Expand Up @@ -91,7 +92,7 @@ const styles = StyleSheet.create({
}
});

export function Box() {
export function Box(): React.ReactElement {
return (
<View style={styles.box}>
<View style={styles.equivalence}>
Expand Down
5 changes: 3 additions & 2 deletions App/Screens/About/Language/Language.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import React, { useContext } from 'react';
import { Picker, StyleSheet, Text, View } from 'react-native';

import { i18n } from '../../../localization';
import { ApiContext } from '../../../stores';
import * as theme from '../../../util/theme';
Expand All @@ -33,10 +34,10 @@ const styles = StyleSheet.create({
}
});

export function Language() {
export function Language(): React.ReactElement {
const { reloadApp } = useContext(ApiContext);

const handleValueChange = (itemValue: string) => {
const handleValueChange = (itemValue: string): void => {
i18n.locale = itemValue;

// Reload app for changes to take effect
Expand Down
22 changes: 12 additions & 10 deletions App/Screens/Details/Details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { StyleSheet, View } from 'react-native';
import MapView, { Marker } from 'react-native-maps';
import { NavigationInjectedProps } from 'react-navigation';
import truncate from 'truncate';

import homeIcon from '../../../assets/images/home.png';
import stationIcon from '../../../assets/images/station.png';
import { i18n } from '../../localization';
Expand Down Expand Up @@ -46,7 +47,7 @@ const styles = StyleSheet.create({
// 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): React.ReactElement {
const { navigation } = props;

const [showMap, setShowMap] = useState(false);
Expand All @@ -63,11 +64,11 @@ export function Details(props: DetailsProps) {
setTimeout(() => setShowMap(true), 500);
}, []);

const handleMapReady = () => {
const handleMapReady = (): void => {
stationMarker && stationMarker.showCallout && stationMarker.showCallout();
};

const handleStationRef = (ref: Marker) => {
const handleStationRef = (ref: Marker): void => {
stationMarker = ref;
};

Expand All @@ -91,17 +92,18 @@ export function Details(props: DetailsProps) {
const distance = distanceToStation(currentLocation, api, distanceUnit);

const station = {
description: api.shootISmoke.station || '',
title: api.shootISmoke.station || '',
...getCorrectLatLng(currentLocation, {
latitude: api.city.geo[0],
longitude: api.city.geo[1]
})
description: api.closestStation.name,
title: api.closestStation.name,
...getCorrectLatLng(currentLocation, api.closestStation.gps)
};

return (
<View style={styles.container}>
<Header onBackClick={() => navigation.goBack()} />
<Header
onBackClick={(): void => {
navigation.goBack();
}}
/>
<View style={styles.mapContainer}>
{showMap && (
<MapView
Expand Down
3 changes: 2 additions & 1 deletion App/Screens/Details/Distance/Distance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import React from 'react';
import { StyleSheet, Text } from 'react-native';

import { Banner } from '../../../components';
import { i18n } from '../../../localization';
import { useDistanceUnit } from '../../../stores/distanceUnit';
Expand All @@ -36,7 +37,7 @@ const styles = StyleSheet.create({
}
});

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

Expand Down
Loading

0 comments on commit e73777c

Please sign in to comment.