Skip to content

Commit

Permalink
feat: Remove tracking GPS and AQI history (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 authored Sep 20, 2019
1 parent fdd0131 commit 90b0393
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 1,311 deletions.
2 changes: 0 additions & 2 deletions App/Screens/About/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { NavigationInjectedProps } from 'react-navigation';

import { Box } from './Box';
import { BackButton } from '../../components';
import { Dev } from './Dev';
import { i18n } from '../../localization';
import * as theme from '../../util/theme';

Expand Down Expand Up @@ -186,7 +185,6 @@ export function About (props: AboutProps) {
</Text>
{/* Add languages https://github.com/amaurymartiny/shoot-i-smoke/issues/73 */}
</View>
<Dev />
</CustomScrollView>
);
}
Expand Down
130 changes: 0 additions & 130 deletions App/Screens/About/Dev/Dev.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions App/Screens/About/Dev/index.ts

This file was deleted.

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

import { distanceInWords } from 'date-fns';
import { formatDistanceToNow } from 'date-fns';
import React, { useContext } from 'react';
import {
GestureResponderEvent,
Expand Down Expand Up @@ -63,7 +63,7 @@ export function Header (props: HeaderProps) {
{lastUpdated &&
renderInfo(
i18n.t('details_header_latest_update_label'),
`${distanceInWords(lastUpdated, new Date())} ${i18n.t(
`${formatDistanceToNow(lastUpdated)} ${i18n.t(
'details_header_latest_update_ago'
)}`
)}
Expand Down
122 changes: 26 additions & 96 deletions App/Screens/Home/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,24 @@
// You should have received a copy of the GNU General Public License
// along with Sh**t! I Smoke. If not, see <http://www.gnu.org/licenses/>.

import * as O from 'fp-ts/lib/Option';
import { pipe } from 'fp-ts/lib/pipeable';
import React, { useContext } from 'react';
import { Share, StyleSheet, Text, View } from 'react-native';
import { NavigationInjectedProps } from 'react-navigation';

import { aboutSections } from '../../About';
import { Button } from '../../../components';
import { i18n } from '../../../localization';
import { AqiHistory } from '../../../managers';
import { Frequency } from '../SelectFrequency';
import { ApiContext, CurrentLocationContext } from '../../../stores';
import { isStationTooFar } from '../../../util/station';
import * as theme from '../../../util/theme';

interface FooterProps extends NavigationInjectedProps {
aqiHistory: O.Option<AqiHistory>;
frequency: Frequency;
}

export function Footer (props: FooterProps) {
const { aqiHistory, frequency } = props;
const { frequency } = props;
const { api } = useContext(ApiContext)!;
const { currentLocation } = useContext(CurrentLocationContext);

Expand All @@ -45,12 +41,6 @@ export function Footer (props: FooterProps) {
props.navigation.navigate('About');
}

function goToAboutAqiHistory () {
props.navigation.navigate('About', {
scrollInto: aboutSections.about_how_results
});
}

function goToAboutWhySoFar () {
props.navigation.navigate('About', {
scrollInto: aboutSections.about_why_is_the_station_so_far_title
Expand All @@ -61,13 +51,6 @@ export function Footer (props: FooterProps) {
props.navigation.navigate('Details');
}

function goToPastStations () {
props.navigation.navigate('PastStations', {
aqiHistory,
frequency
});
}

function handleShare () {
return Share.share({
title: i18n.t('home_share_title'),
Expand All @@ -78,87 +61,34 @@ export function Footer (props: FooterProps) {
}

const renderBigButton = () => {
switch (frequency) {
case 'daily': {
return isTooFar ? (
<Button onPress={goToAboutWhySoFar}>
{i18n.t('home_btn_why_is_station_so_far').toUpperCase()}
</Button>
) : (
<Button onPress={goToDetails}>
{i18n.t('home_btn_see_detailed_info').toUpperCase()}
</Button>
);
}
case 'weekly':
case 'monthly': {
return pipe(
aqiHistory,
O.map(history => history[frequency]),
O.filter(({ isCorrect }) => isCorrect),
O.map(() => (
<Button onPress={goToPastStations}>
{i18n.t('home_btn_see_detailed_info').toUpperCase()}
</Button>
)),
O.getOrElse(() => (
<Button onPress={goToAboutAqiHistory}>
{i18n.t('home_btn_see_how_it_works').toUpperCase()}
</Button>
))
);
}
}
return isTooFar ? (
<Button onPress={goToAboutWhySoFar}>
{i18n.t('home_btn_why_is_station_so_far').toUpperCase()}
</Button>
) : (
<Button onPress={goToDetails}>
{i18n.t('home_btn_see_detailed_info').toUpperCase()}
</Button>
);
};

const renderSmallButtons = () => {
switch (frequency) {
case 'daily': {
return (
<View style={styles.smallButtons}>
{isTooFar ? (
<Button icon="plus-circle" onPress={goToDetails} type="secondary">
{i18n.t('home_btn_more_details').toUpperCase()}
</Button>
) : (
<Button
icon="question-circle"
onPress={goToAbout}
type="secondary"
>
{i18n.t('home_btn_faq_about').toUpperCase()}
</Button>
)}
<Button icon="share-alt" onPress={handleShare} type="secondary">
{i18n.t('home_btn_share').toUpperCase()}
</Button>
</View>
);
}
case 'weekly':
case 'monthly': {
return pipe(
aqiHistory,
O.map(history => history[frequency]),
O.filter(({ isCorrect }) => isCorrect),
O.map(() => (
<View style={styles.smallButtons}>
<Button
icon="question-circle"
onPress={goToAbout}
type="secondary"
>
{i18n.t('home_btn_faq_about').toUpperCase()}
</Button>
<Button icon="share-alt" onPress={handleShare} type="secondary">
{i18n.t('home_btn_share').toUpperCase()}
</Button>
</View>
)),
O.getOrElse<JSX.Element | null>(() => null)
);
}
}
return (
<View style={styles.smallButtons}>
{isTooFar ? (
<Button icon="plus-circle" onPress={goToDetails} type="secondary">
{i18n.t('home_btn_more_details').toUpperCase()}
</Button>
) : (
<Button icon="question-circle" onPress={goToAbout} type="secondary">
{i18n.t('home_btn_faq_about').toUpperCase()}
</Button>
)}
<Button icon="share-alt" onPress={handleShare} type="secondary">
{i18n.t('home_btn_share').toUpperCase()}
</Button>
</View>
);
};

return (
Expand Down
Loading

0 comments on commit 90b0393

Please sign in to comment.