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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Replace share text with an image on iOS #242

Merged
merged 17 commits into from
Oct 3, 2019
Merged
Prev Previous commit
Next Next commit
Resolved Merge Conflict
  • Loading branch information
James Pearson committed Oct 3, 2019
commit f2157b213a9c7da22f5cef31f4deaad8764f69b5
6 changes: 3 additions & 3 deletions App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export function App () {
<ErrorContextProvider>
<LocationContextProvider>
<ApiContextProvider>
<FrequencyContextProvider>
<Screens />
</FrequencyContextProvider>
<FrequencyContextProvider>
<Screens />
</FrequencyContextProvider>
</ApiContextProvider>
</LocationContextProvider>
</ErrorContextProvider>
Expand Down
32 changes: 16 additions & 16 deletions App/Screens/Home/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ export function Footer (props: FooterProps) {
props.navigation.navigate('ShareModal');
} else {
Share.share({
title: i18n.t('home_share_title'),
message: i18n.t('home_share_message', {
cigarettes: api!.shootISmoke.cigarettes
})
title: i18n.t('home_share_title'),
message: i18n.t('home_share_message', {
cigarettes: parseFloat(api!.shootISmoke.cigarettes).toFixed(2)
})
});
}
}

const renderBigButton = () => {
return isTooFar ? (
<Button onPress={goToAboutWhySoFar}>
{i18n.t('home_btn_why_is_station_so_far').toUpperCase()}
{i18n.t('home_btn_why_is_station_so_far').toUpperCase()}
</Button>
) : (
<Button onPress={goToDetails}>
{i18n.t('home_btn_see_detailed_info').toUpperCase()}
{i18n.t('home_btn_see_detailed_info').toUpperCase()}
</Button>
);
};
Expand All @@ -86,16 +86,16 @@ export function Footer (props: FooterProps) {
<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>
{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>
);
};
Expand Down
4 changes: 2 additions & 2 deletions App/Screens/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function Home (props: HomeProps) {
/>
<ScrollView bounces={false}>
<CigaretteBlock
cigarettesPerDay={cigarettesPerDay}
cigarettesPerDay={cigarettesPerDay}
frequency={frequency}
style={styles.withMargin}
/>
Expand All @@ -64,7 +64,7 @@ export function Home (props: HomeProps) {
track('HOME_SCREEN_MONTHLY_CLICK');
}

setFrequency(freq);
setFrequency(freq);
}}
style={styles.withMargin}
/>
Expand Down
6 changes: 3 additions & 3 deletions App/Screens/Home/SelectFrequency/SelectFrequency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function SelectFrequency (props: SelectFrequencyProps) {
}}
style={styles.boxButton}
>
{i18n.t('frequency_daily')}
{i18n.t('frequency_daily')}
</BoxButton>
<BoxButton
active={frequency === 'weekly'}
Expand All @@ -78,7 +78,7 @@ export function SelectFrequency (props: SelectFrequencyProps) {
}}
style={styles.boxButton}
>
{i18n.t('frequency_weekly')}
{i18n.t('frequency_weekly')}
</BoxButton>

<BoxButton
Expand All @@ -93,7 +93,7 @@ export function SelectFrequency (props: SelectFrequencyProps) {
}}
style={styles.boxButton}
>
{i18n.t('frequency_monthly')}
{i18n.t('frequency_monthly')}
</BoxButton>
</ScrollView>
);
Expand Down
4 changes: 2 additions & 2 deletions App/Screens/Screens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ const RootStack = createAppContainer(
createStackNavigator(
{
Main: {
screen: MainStack
screen: MainStack
},
ShareModal: {
screen: ShareScreen
screen: ShareScreen
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion App/Screens/ShareScreen/ShareImage/ShareImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export function ShareImage () {
<View style={styles.container}>
<CigaretteBlock cigarettesPerDay={cigarettesPerDay} frequency={currentFrequency} displayFrequency style={{ paddingHorizontal: 0 }} />
<View>
<CurrentLocation api={api!} currentLocation={currentLocation!} numberOfLines={2} />
<CurrentLocation api={api!} currentLocation={currentLocation!} numberOfLines={2} />
</View>

<Text style={styles.urlText}>https://shootismoke.github.io/</Text>
Expand Down
26 changes: 13 additions & 13 deletions App/Screens/ShareScreen/ShareScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ export function ShareScreen (props: ShareScreenProps) {
useEffect(() => {
setTimeout(async () => {
try {
const uri = await captureRef(refViewShot, {
format: 'png',
quality: 1
});
const uri = await captureRef(refViewShot, {
format: 'png',
quality: 1
});

await Share.share({
url: uri
});
await Share.share({
url: uri
});
} catch (error) {
}

Expand All @@ -52,12 +52,12 @@ export function ShareScreen (props: ShareScreenProps) {
return (
<View style={styles.container}>
<View style={styles.imageContainer}>
<View ref={refViewShot} collapsable={false}>
<ShareImage />
</View>
<View style={styles.buttonContainer}>
<Button onPress={handleDismiss} style={styles.button}>{i18n.t('close_button').toUpperCase()}</Button>
</View>
<View ref={refViewShot} collapsable={false}>
<ShareImage />
</View>
<View style={styles.buttonContainer}>
<Button onPress={handleDismiss} style={styles.button}>{i18n.t('close_button').toUpperCase()}</Button>
</View>
</View>
</View>
);
Expand Down
22 changes: 11 additions & 11 deletions App/components/CigaretteBlock/CigaretteBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ export function CigaretteBlock (props: CigaretteBlockProps) {
const text = i18n.t('home_smoked_cigarette_title', {
swearWord: getSwearWord(cigaretteCount),
presentPast:
isGps && frequency === 'daily'
? i18n.t('home_common_you_smoke')
: i18n.t('home_common_you_d_smoke'),
isGps && frequency === 'daily'
? i18n.t('home_common_you_smoke')
: i18n.t('home_common_you_d_smoke'),
singularPlural:
cigarettes === 1
? i18n.t('home_common_cigarette').toLowerCase()
: i18n.t('home_common_cigarettes').toLowerCase(),
cigarettes === 1
? i18n.t('home_common_cigarette').toLowerCase()
: i18n.t('home_common_cigarettes').toLowerCase(),
cigarettes
});

Expand All @@ -82,11 +82,11 @@ export function CigaretteBlock (props: CigaretteBlockProps) {

return (
<Text style={styles.shit}>
{firstPartText}
<Text style={styles.cigarettesCount}>
{secondPartText.split('>')[0]}
</Text>
{secondPartText.split('>')[1]} {frequencyText}
{firstPartText}
<Text style={styles.cigarettesCount}>
{secondPartText.split('>')[0]}
</Text>
{secondPartText.split('>')[1]} {frequencyText}
</Text>
);
};
Expand Down
4 changes: 2 additions & 2 deletions App/stores/frequency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ export function FrequencyContextProvider ({
return (
<FrequencyContext.Provider
value={{
currentFrequency,
setFrequency
currentFrequency,
setFrequency
}}
>
{children}
Expand Down