-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add share buttons to share part or full requests, including cURL
Closes #2
- Loading branch information
1 parent
d637893
commit 3425d7d
Showing
4 changed files
with
105 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react'; | ||
import { | ||
View, | ||
Text, | ||
StyleSheet, | ||
TouchableOpacity, | ||
Share, | ||
Image, | ||
} from 'react-native'; | ||
import { useThemedStyles, Theme } from './theme'; | ||
|
||
interface Props { | ||
children: string; | ||
shareContent?: string; | ||
} | ||
|
||
const Header: React.FC<Props> = ({ children, shareContent }) => { | ||
const styles = useThemedStyles(themedStyles); | ||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.header}>{children}</Text> | ||
|
||
{shareContent && ( | ||
<TouchableOpacity | ||
onPress={() => { | ||
Share.share({ message: shareContent }); | ||
}} | ||
> | ||
<Image | ||
source={require('./share.png')} | ||
resizeMode="contain" | ||
style={styles.shareIcon} | ||
/> | ||
</TouchableOpacity> | ||
)} | ||
</View> | ||
); | ||
}; | ||
|
||
const themedStyles = (theme: Theme) => | ||
StyleSheet.create({ | ||
header: { | ||
fontWeight: 'bold', | ||
fontSize: 20, | ||
marginTop: 10, | ||
marginBottom: 5, | ||
marginHorizontal: 10, | ||
color: theme.colors.text, | ||
}, | ||
shareIcon: { width: 24, height: 24, marginRight: 10 }, | ||
container: { | ||
justifyContent: 'space-between', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}, | ||
}); | ||
|
||
export default Header; |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.