added orai

This commit is contained in:
szabomarton
2025-03-12 12:47:18 +01:00
parent 69b41e57cf
commit 5092aedfca
54 changed files with 14870 additions and 19639 deletions

View File

@@ -0,0 +1,5 @@
import { Stack } from "expo-router";
export default function RootLayout() {
return <Stack />;
}

View File

@@ -0,0 +1,31 @@
import React, {createContext, useContext, useState} from "react";
interface CounterContextProps {
count: number,
increment: () => void,
decrement: () => void,
}
const CounterContext = createContext<CounterContextProps | undefined>(undefined);
export const CounterProvider: React.FC<{children: React.ReactNode}> = ({children}) => {
const [count, setCount] = useState(0);
const increment = () => setCount(count + 1);
const decrement = () => setCount(count - 1);
return (
<CounterContext.Provider value={{ count, increment, decrement }}>
{children}
</CounterContext.Provider>
);
};
export const useCounter = () => {
const context = useContext(CounterContext);
if(!context) {
throw new Error("useContext must be used within a CounterProvider");
}
return context;
};

View File

@@ -0,0 +1,75 @@
import React, {useState} from 'react';
import { View, Text, Button, TextInput, StyleSheet } from 'react-native';
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
import { CounterProvider, useCounter } from './components/CounterContext';
const Stack = createStackNavigator();
const HomeScreen = ({ navigation }: any) => {
const [userInput, setUserInput] = useState("");
return (
<View style={styles.container}>
<Text style={styles.title}>Kezdőképernyő</Text>
<TextInput
style={styles.input}
placeholder="Írj be valamit..."
value={userInput}
onChangeText={setUserInput}
/>
<Button
title="További részletekhez"
onPress={() => navigation.navigate("Details", {text: userInput})}
/>
</View>
);
}
const DetailsScreen = ({ route, navigation}: any)=> {
const {text} = route.params;
return(
<View style={styles.container}>
<Text style={styles.title}>Részletek képernyő</Text>
<Text style={styles.text}>Beírt szöveg: {text}</Text>
<Button title="Vissza" onPress={() => navigation.goBack()}/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
padding: 20,
alignItems: 'center',
justifyContent: 'center',
},
title:{
fontSize: 24,
fontWeight: "bold",
marginBottom: 20,
},
input: {
width: "80%",
borderWidth: 1,
borderColor: "#ccc",
padding: 10,
marginBottom: 20,
borderRadius: 5,
backgroundColor: "#ff00ff"
},
text: {
fontSize: 18,
marginBottom: 20,
},
});
export default function Index() {
return(
<Stack.Navigator>
<Stack.Screen name="Home" component={HomeScreen} options={{ title: "Kezdőlap"}}/>
<Stack.Screen name="Details" component={DetailsScreen} options={{ title: "Részletek"}}/>
</Stack.Navigator>
);
}