-
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Replace share text with an image on iOS (#242)
* Moved Cigarette in to a common component * Made frequency terms global (not screen specific) * Moved the cigarette count calculation to the cigarette block * Moved frequency from Home state to global context * Linting * Added a share screen and share image * Added a ShareScreen modal overlay * i18n for the close button * Fixed a circular import * Replaced previous share with the image * Keep the existing text notification on Android * Linting * Resolved Merge Conflict * 👌🏻 Renamed currentFrequency as frequency * 👌🏻 Added a blank line between relative and absolute imports * 👌🏻 Removed the hard coded values (replaced with theme values) * 👌🏻 Linting
- Loading branch information
1 parent
8fdf14b
commit 3250390
Showing
19 changed files
with
339 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Sh**t! I Smoke | ||
// Copyright (C) 2018-2019 Marcelo S. Coelho, Amaury Martiny | ||
|
||
// Sh**t! I Smoke is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Sh**t! I Smoke is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Sh**t! I Smoke. If not, see <http:https://www.gnu.org/licenses/>. | ||
|
||
import React, { useContext } from 'react'; | ||
import { | ||
StyleSheet, | ||
Text, | ||
View | ||
} from 'react-native'; | ||
|
||
import { CigaretteBlock, CurrentLocation } from '../../../components'; | ||
import { ApiContext, CurrentLocationContext, FrequencyContext } from '../../../stores'; | ||
import * as theme from '../../../util/theme'; | ||
|
||
export function ShareImage () { | ||
const { api } = useContext(ApiContext)!; | ||
const { currentLocation } = useContext(CurrentLocationContext); | ||
const { frequency } = useContext(FrequencyContext); | ||
|
||
const cigarettesPerDay = api!.shootISmoke.cigarettes; | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<CigaretteBlock cigarettesPerDay={cigarettesPerDay} frequency={frequency} displayFrequency style={{ paddingHorizontal: 0 }} /> | ||
<View> | ||
<CurrentLocation api={api!} currentLocation={currentLocation!} numberOfLines={2} /> | ||
</View> | ||
|
||
<Text style={styles.urlText}>https://shootismoke.github.io/</Text> | ||
|
||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
...theme.withPadding, | ||
alignItems: 'flex-start', | ||
flexDirection: 'column', | ||
paddingTop: theme.spacing.normal, | ||
paddingBottom: theme.spacing.normal, | ||
width: 400, | ||
backgroundColor: 'white' | ||
}, | ||
|
||
urlText: { | ||
...theme.text, | ||
alignSelf: 'center', | ||
marginTop: theme.spacing.mini | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Sh**t! I Smoke | ||
// Copyright (C) 2018-2019 Marcelo S. Coelho, Amaury Martiny | ||
|
||
// Sh**t! I Smoke is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Sh**t! I Smoke is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Sh**t! I Smoke. If not, see <http:https://www.gnu.org/licenses/>. | ||
|
||
export * from './ShareImage'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Sh**t! I Smoke | ||
// Copyright (C) 2018-2019 Marcelo S. Coelho, Amaury Martiny | ||
|
||
// Sh**t! I Smoke is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// Sh**t! I Smoke is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with Sh**t! I Smoke. If not, see <http:https://www.gnu.org/licenses/>. | ||
|
||
import React, { useEffect, createRef } from 'react'; | ||
import { Share, StyleSheet, View } from 'react-native'; | ||
import { NavigationInjectedProps } from 'react-navigation'; | ||
import { captureRef } from 'react-native-view-shot'; | ||
|
||
import { ShareImage } from './ShareImage'; | ||
import { i18n } from '../../localization'; | ||
import { Button } from '../../components'; | ||
import * as theme from '../../util/theme'; | ||
|
||
interface ShareScreenProps extends NavigationInjectedProps { } | ||
|
||
export function ShareScreen (props: ShareScreenProps) { | ||
const refViewShot = createRef(); | ||
|
||
useEffect(() => { | ||
setTimeout(async () => { | ||
try { | ||
const uri = await captureRef(refViewShot, { | ||
format: 'png', | ||
quality: 1 | ||
}); | ||
|
||
await Share.share({ | ||
url: uri | ||
}); | ||
} catch (error) { | ||
} | ||
|
||
handleDismiss(); | ||
}, 750); | ||
}); | ||
|
||
const handleDismiss = () => { | ||
props.navigation.goBack(); | ||
}; | ||
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> | ||
</View> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
...theme.fullScreen, | ||
...theme.withPadding, | ||
flexGrow: 1, | ||
flexDirection: 'column', | ||
backgroundColor: 'rgba(0,0,0,0.8)' | ||
}, | ||
|
||
buttonContainer: { | ||
paddingVertical: theme.spacing.normal | ||
}, | ||
|
||
button: { | ||
paddingHorizontal: theme.spacing.mini | ||
}, | ||
|
||
imageContainer: { | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
transform: [ | ||
{ scale: 0.8 } | ||
] | ||
} | ||
}); |
Oops, something went wrong.