Commit 8016585d authored by W.D.R.P. Sandeepa's avatar W.D.R.P. Sandeepa

change reuseable code

parent f7d471e2
...@@ -2,12 +2,13 @@ import { useNavigation } from "@react-navigation/native"; ...@@ -2,12 +2,13 @@ import { useNavigation } from "@react-navigation/native";
import React from "react"; import React from "react";
import {Text, TouchableOpacity, StyleSheet} from 'react-native' import {Text, TouchableOpacity, StyleSheet} from 'react-native'
export default function ImageButton({ title}){ export default function ImageButton(props){
const navigation = useNavigation(); const navigation = useNavigation();
const {title, path} = props;
return( return(
<TouchableOpacity onPress={()=> {navigation.navigate("Color")}} style={styles.ImageButton}> <TouchableOpacity onPress={()=> {navigation.navigate(path)}} style={styles.ImageButton}>
<Text style={styles.text}>{title}</Text> <Text style={styles.text}>{title}</Text>
</TouchableOpacity> </TouchableOpacity>
); );
......
...@@ -15,7 +15,7 @@ const Stack = createNativeStackNavigator(); ...@@ -15,7 +15,7 @@ const Stack = createNativeStackNavigator();
const AppRouter = () => { const AppRouter = () => {
return( return(
<NavigationContainer> <NavigationContainer>
<Stack.Navigator initialRouteName="Color"> <Stack.Navigator initialRouteName="Splash">
<Stack.Screen options={{headerShown:false}} name="Home" component={Home} /> <Stack.Screen options={{headerShown:false}} name="Home" component={Home} />
<Stack.Screen options={{headerShown:false}} name="Splash" component={Splash} /> <Stack.Screen options={{headerShown:false}} name="Splash" component={Splash} />
<Stack.Screen options={{headerShown:false}} name="Register" component={Register} /> <Stack.Screen options={{headerShown:false}} name="Register" component={Register} />
......
...@@ -15,7 +15,7 @@ export default function Home({ navigation }){ ...@@ -15,7 +15,7 @@ export default function Home({ navigation }){
<View style={styles.imageView}> <View style={styles.imageView}>
<Image style={styles.image} source={require('../assets/color/background.png')} resizeMode="contain"> <Image style={styles.image} source={require('../assets/color/background.png')} resizeMode="contain">
</Image> </Image>
<ImageButton title="Color Activity"/> <ImageButton path="Color" title="Color Activity"/>
</View> </View>
</View> </View>
</ScrollView> </ScrollView>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment