-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🚨 Fixed prop type shadowStyle is invalid warning
- Loading branch information
1 parent
c94d54c
commit 830576b
Showing
5 changed files
with
225 additions
and
207 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,93 +1,134 @@ | ||
import React from 'react'; | ||
import { Dimensions, StyleSheet, Text, View, Button } from 'react-native'; | ||
import SegmentedControl from 'rn-segmented-control'; | ||
import React from "react"; | ||
import { Dimensions, StyleSheet, Text, View, Button } from "react-native"; | ||
import SegmentedControl from "../components/segmentedControl"; | ||
|
||
const AppRoot = () => { | ||
const [tabIndex, setTabIndex] = React.useState(1); | ||
const [theme, setTheme] = React.useState('LIGHT'); | ||
const toggleTheme = () => theme === 'LIGHT' ? setTheme('DARK') : setTheme('LIGHT'); | ||
const handleTabsChange = index => { | ||
const [theme, setTheme] = React.useState("LIGHT"); | ||
const toggleTheme = () => | ||
theme === "LIGHT" ? setTheme("DARK") : setTheme("LIGHT"); | ||
const handleTabsChange = (index) => { | ||
setTabIndex(index); | ||
}; | ||
return ( | ||
<View style={[styles.container, { backgroundColor: theme === 'LIGHT' ? 'white' : 'black' }]}> | ||
<Text style={[styles.textStyle, { color: theme === 'LIGHT' ? 'black' : 'white' }]}>Hello,World !</Text> | ||
<Button title='Toggle Theme' onPress={toggleTheme}></Button> | ||
<Text style={[styles.textStyle, { color: theme === 'LIGHT' ? 'black' : 'white' }]}>Segmented Control with 2 labels</Text> | ||
<View | ||
style={[ | ||
styles.container, | ||
{ backgroundColor: theme === "LIGHT" ? "white" : "black" }, | ||
]} | ||
> | ||
<Text | ||
style={[ | ||
styles.textStyle, | ||
{ color: theme === "LIGHT" ? "black" : "white" }, | ||
]} | ||
> | ||
Hello,World ! | ||
</Text> | ||
<Button title="Toggle Theme" onPress={toggleTheme}></Button> | ||
<Text | ||
style={[ | ||
styles.textStyle, | ||
{ color: theme === "LIGHT" ? "black" : "white" }, | ||
]} | ||
> | ||
Segmented Control with 2 labels | ||
</Text> | ||
{/* Default Segmented Control */} | ||
<SegmentedControl | ||
tabs={['Label', 'Label']} | ||
onChange={() => { }} | ||
tabs={["Label", "Label"]} | ||
onChange={() => {}} | ||
paddingVertical={6} | ||
containerStyle={{ | ||
marginVertical: 20 | ||
marginVertical: 20, | ||
}} | ||
currentIndex={tabIndex} | ||
onChange={handleTabsChange} | ||
theme={theme} | ||
/> | ||
<Text style={[styles.textStyle, { color: theme === 'LIGHT' ? 'black' : 'white' }]}> Segmented Control with 3 labels</Text> | ||
<Text | ||
style={[ | ||
styles.textStyle, | ||
{ color: theme === "LIGHT" ? "black" : "white" }, | ||
]} | ||
> | ||
{" "} | ||
Segmented Control with 3 labels | ||
</Text> | ||
{/* Segmented Control with a custom width */} | ||
<SegmentedControl | ||
tabs={['Label', 'Label', 'Label']} | ||
onChange={() => { }} | ||
tabs={["Label", "Label", "Label"]} | ||
onChange={() => {}} | ||
paddingVertical={10} | ||
containerStyle={{ | ||
marginVertical: 20 | ||
marginVertical: 20, | ||
}} | ||
width={Dimensions.get('screen').width - 200} | ||
width={Dimensions.get("screen").width - 200} | ||
theme={theme} | ||
/> | ||
<Text style={[styles.textStyle, { color: theme === 'LIGHT' ? 'black' : 'white' }]}> Segmented Control with 4 labels</Text> | ||
<Text | ||
style={[ | ||
styles.textStyle, | ||
{ color: theme === "LIGHT" ? "black" : "white" }, | ||
]} | ||
> | ||
{" "} | ||
Segmented Control with 4 labels | ||
</Text> | ||
<SegmentedControl | ||
tabs={['Label', 'Label', 'Label', 'Label']} | ||
onChange={() => { }} | ||
tabs={["Label", "Label", "Label", "Label"]} | ||
onChange={() => {}} | ||
paddingVertical={14} | ||
width={Dimensions.get('screen').width - 90} | ||
width={Dimensions.get("screen").width - 90} | ||
containerStyle={{ | ||
marginVertical: 20 | ||
marginVertical: 20, | ||
}} | ||
textStyle={{ | ||
fontWeight: '300', | ||
fontSize: 24 | ||
fontWeight: "300", | ||
fontSize: 24, | ||
}} | ||
theme={theme} | ||
/> | ||
<Text style={[styles.textStyle, { color: theme === 'LIGHT' ? 'black' : 'white' }]}>Customised Segmented Control</Text> | ||
<Text | ||
style={[ | ||
styles.textStyle, | ||
{ color: theme === "LIGHT" ? "black" : "white" }, | ||
]} | ||
> | ||
Customised Segmented Control | ||
</Text> | ||
{/* Segmented Control with a custom width, container style and font weight */} | ||
<SegmentedControl | ||
tabs={['Shop', 'Explore', 'Search']} | ||
segmentedControlBackgroundColor='#86c4fD' | ||
activeSegmentBackgroundColor='#0482f7' | ||
activeTextColor='white' | ||
textColor='black' | ||
tabs={["Shop", "Explore", "Search"]} | ||
segmentedControlBackgroundColor="#86c4fD" | ||
activeSegmentBackgroundColor="#0482f7" | ||
activeTextColor="white" | ||
textColor="black" | ||
paddingVertical={10} | ||
width={Dimensions.get('screen').width - 100} | ||
width={Dimensions.get("screen").width - 100} | ||
containerStyle={{ | ||
marginVertical: 20 | ||
marginVertical: 20, | ||
}} | ||
textStyle={{ | ||
fontWeight: '300' | ||
fontWeight: "300", | ||
}} | ||
/> | ||
</View > | ||
) | ||
} | ||
|
||
</View> | ||
); | ||
}; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
flex: 1, | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
justifyContent: "center", | ||
alignItems: "center", | ||
paddingHorizontal: 16, | ||
}, | ||
textStyle: { | ||
fontSize: 24, | ||
textAlign: 'center', | ||
paddingVertical: 10 | ||
} | ||
}) | ||
|
||
textAlign: "center", | ||
paddingVertical: 10, | ||
}, | ||
}); | ||
|
||
export default AppRoot; | ||
export default AppRoot; |
Oops, something went wrong.