Initial commit
This commit is contained in:
40
.gitignore
vendored
Normal file
40
.gitignore
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# Expo
|
||||
.expo/
|
||||
dist/
|
||||
web-build/
|
||||
|
||||
# Native
|
||||
.kotlin/
|
||||
*.orig.*
|
||||
*.jks
|
||||
*.p8
|
||||
*.p12
|
||||
*.key
|
||||
*.mobileprovision
|
||||
|
||||
# Metro
|
||||
.metro-health-check*
|
||||
|
||||
# debug
|
||||
npm-debug.*
|
||||
yarn-debug.*
|
||||
yarn-error.*
|
||||
|
||||
# macOS
|
||||
.DS_Store
|
||||
*.pem
|
||||
|
||||
# local env files
|
||||
.env*.local
|
||||
|
||||
# typescript
|
||||
*.tsbuildinfo
|
||||
|
||||
# generated native folders
|
||||
/ios
|
||||
/android
|
||||
47
App.tsx
Normal file
47
App.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import React, { Suspense } from 'react';
|
||||
import { NavigationContainer, DefaultTheme } from '@react-navigation/native';
|
||||
import { createStackNavigator } from '@react-navigation/stack';
|
||||
import { Provider } from 'react-redux';
|
||||
import { store } from './store/store';
|
||||
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
||||
import { Text } from 'react-native';
|
||||
|
||||
const LoginScreen = React.lazy(() => import('./screens/LoginScreen'));
|
||||
const ProjectsScreen = React.lazy(() => import('./screens/ProjectsScreen'));
|
||||
const ProjectDetailsScreen = React.lazy(() => import('./screens/ProjectDetailsScreen'));
|
||||
|
||||
const Stack = createStackNavigator();
|
||||
|
||||
const DarkTheme = {
|
||||
...DefaultTheme,
|
||||
colors: {
|
||||
...DefaultTheme.colors,
|
||||
primary: '#ff00ff',
|
||||
background: '#000000',
|
||||
card: '#1a1a1a',
|
||||
text: '#ffffff',
|
||||
border: '#333333',
|
||||
},
|
||||
};
|
||||
|
||||
function LoadingScreen() {
|
||||
return <Text style={{ color: '#ffffff' }}>Betöltés...</Text>;
|
||||
}
|
||||
|
||||
export default function App() {
|
||||
return (
|
||||
<GestureHandlerRootView style={{ flex: 1 }}>
|
||||
<Provider store={store}>
|
||||
<NavigationContainer theme={DarkTheme}>
|
||||
<Suspense fallback={<LoadingScreen />}>
|
||||
<Stack.Navigator>
|
||||
<Stack.Screen name="Login" component={LoginScreen} options={{ title: 'Bejelentkezés' }} />
|
||||
<Stack.Screen name="Projects" component={ProjectsScreen} options={{ title: 'Projektek' }} />
|
||||
<Stack.Screen name="Details" component={ProjectDetailsScreen} options={{ title: 'Részletek' }} />
|
||||
</Stack.Navigator>
|
||||
</Suspense>
|
||||
</NavigationContainer>
|
||||
</Provider>
|
||||
</GestureHandlerRootView>
|
||||
);
|
||||
}
|
||||
28
app.json
Normal file
28
app.json
Normal file
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"expo": {
|
||||
"name": "feladat5-projektmenedzsment",
|
||||
"slug": "feladat5-projektmenedzsment",
|
||||
"version": "1.0.0",
|
||||
"orientation": "portrait",
|
||||
"icon": "./assets/icon.png",
|
||||
"userInterfaceStyle": "light",
|
||||
"newArchEnabled": true,
|
||||
"splash": {
|
||||
"image": "./assets/splash-icon.png",
|
||||
"resizeMode": "contain",
|
||||
"backgroundColor": "#ffffff"
|
||||
},
|
||||
"ios": {
|
||||
"supportsTablet": true
|
||||
},
|
||||
"android": {
|
||||
"adaptiveIcon": {
|
||||
"foregroundImage": "./assets/adaptive-icon.png",
|
||||
"backgroundColor": "#ffffff"
|
||||
}
|
||||
},
|
||||
"web": {
|
||||
"favicon": "./assets/favicon.png"
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
assets/adaptive-icon.png
Normal file
BIN
assets/adaptive-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
assets/favicon.png
Normal file
BIN
assets/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
BIN
assets/icon.png
Normal file
BIN
assets/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
BIN
assets/splash-icon.png
Normal file
BIN
assets/splash-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
16
config/firebase.ts
Normal file
16
config/firebase.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { getAuth } from 'firebase/auth';
|
||||
import { getFirestore } from 'firebase/firestore';
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: "AIzaSyCvVobBc9sBJRGygFedExwITXCFW13R4ds",
|
||||
authDomain: "gyakorlatifeladatok-6c7c0.firebaseapp.com",
|
||||
projectId: "gyakorlatifeladatok-6c7c0",
|
||||
storageBucket: "gyakorlatifeladatok-6c7c0.firebasestorage.app",
|
||||
messagingSenderId: "721534659717",
|
||||
appId: "1:721534659717:web:d7532753d6d6b0c009cdec"
|
||||
};
|
||||
|
||||
const app = initializeApp(firebaseConfig);
|
||||
export const auth = getAuth(app);
|
||||
export const db = getFirestore(app);
|
||||
8
index.ts
Normal file
8
index.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { registerRootComponent } from 'expo';
|
||||
|
||||
import App from './App';
|
||||
|
||||
// registerRootComponent calls AppRegistry.registerComponent('main', () => App);
|
||||
// It also ensures that whether you load the app in Expo Go or in a native build,
|
||||
// the environment is set up appropriately
|
||||
registerRootComponent(App);
|
||||
5
metro.config.js
Normal file
5
metro.config.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { getDefaultConfig } = require('expo/metro-config');
|
||||
|
||||
const config = getDefaultConfig(__dirname);
|
||||
|
||||
module.exports = config;
|
||||
9730
package-lock.json
generated
Normal file
9730
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
package.json
Normal file
30
package.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "feladat5-projektmenedzsment",
|
||||
"version": "1.0.0",
|
||||
"main": "index.ts",
|
||||
"scripts": {
|
||||
"start": "expo start",
|
||||
"android": "expo start --android",
|
||||
"ios": "expo start --ios",
|
||||
"web": "expo start --web"
|
||||
},
|
||||
"dependencies": {
|
||||
"@react-navigation/native": "^7.1.28",
|
||||
"@react-navigation/stack": "^7.7.2",
|
||||
"@reduxjs/toolkit": "^2.11.2",
|
||||
"expo": "~54.0.33",
|
||||
"expo-status-bar": "~3.0.9",
|
||||
"firebase": "^12.9.0",
|
||||
"react": "19.1.0",
|
||||
"react-native": "0.81.5",
|
||||
"react-native-gesture-handler": "~2.28.0",
|
||||
"react-native-safe-area-context": "~5.6.0",
|
||||
"react-native-screens": "~4.16.0",
|
||||
"react-redux": "^9.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "~19.1.0",
|
||||
"typescript": "~5.9.2"
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
48
screens/LoginScreen.tsx
Normal file
48
screens/LoginScreen.tsx
Normal file
@@ -0,0 +1,48 @@
|
||||
import React, { useState } from 'react';
|
||||
import { View, TextInput, Button, StyleSheet } from 'react-native';
|
||||
import { signInWithEmailAndPassword, createUserWithEmailAndPassword } from 'firebase/auth';
|
||||
import { auth } from '../config/firebase';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { setUser } from '../store/authSlice';
|
||||
|
||||
function LoginScreen({ navigation }: any) {
|
||||
const [email, setEmail] = useState('');
|
||||
const [password, setPassword] = useState('');
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const handleLogin = async () => {
|
||||
try {
|
||||
const userCredential = await signInWithEmailAndPassword(auth, email, password);
|
||||
dispatch(setUser({ uid: userCredential.user.uid, email: userCredential.user.email! }));
|
||||
navigation.replace('Projects');
|
||||
} catch (error: any) {
|
||||
alert(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRegister = async () => {
|
||||
try {
|
||||
const userCredential = await createUserWithEmailAndPassword(auth, email, password);
|
||||
dispatch(setUser({ uid: userCredential.user.uid, email: userCredential.user.email! }));
|
||||
navigation.replace('Projects');
|
||||
} catch (error: any) {
|
||||
alert(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TextInput style={styles.input} placeholder="Email" value={email} onChangeText={setEmail} />
|
||||
<TextInput style={styles.input} placeholder="Jelszó" value={password} onChangeText={setPassword} secureTextEntry />
|
||||
<Button title="Bejelentkezés" onPress={handleLogin} color="#ff00ff" />
|
||||
<Button title="Regisztráció" onPress={handleRegister} color="#ff00ff" />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1, padding: 16, justifyContent: 'center', backgroundColor: '#000000' },
|
||||
input: { borderWidth: 1, borderColor: '#333333', padding: 8, marginBottom: 16, borderRadius: 4, backgroundColor: '#1a1a1a', color: '#ffffff' },
|
||||
});
|
||||
|
||||
export default LoginScreen;
|
||||
36
screens/ProjectDetailsScreen.tsx
Normal file
36
screens/ProjectDetailsScreen.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import React, { useState } from 'react';
|
||||
import { View, Text, Button, TextInput, StyleSheet } from 'react-native';
|
||||
import { doc, updateDoc } from 'firebase/firestore';
|
||||
import { db } from '../config/firebase';
|
||||
|
||||
function ProjectDetailsScreen({ route, navigation }: any) {
|
||||
const { project } = route.params;
|
||||
const [name, setName] = useState(project.name);
|
||||
const [status, setStatus] = useState(project.status);
|
||||
|
||||
const updateProject = async () => {
|
||||
await updateDoc(doc(db, 'projects', project.id), { name, status });
|
||||
alert('Projekt frissítve');
|
||||
navigation.goBack();
|
||||
};
|
||||
|
||||
const toggleStatus = () => {
|
||||
setStatus(status === 'aktív' ? 'lezárt' : 'aktív');
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TextInput style={styles.input} value={name} onChangeText={setName} />
|
||||
<Text>Státusz: {status}</Text>
|
||||
<Button title="Státusz váltás" onPress={toggleStatus} />
|
||||
<Button title="Mentés" onPress={updateProject} />
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1, padding: 16 },
|
||||
input: { borderWidth: 1, padding: 8, marginBottom: 16, borderRadius: 4 },
|
||||
});
|
||||
|
||||
export default ProjectDetailsScreen;
|
||||
64
screens/ProjectsScreen.tsx
Normal file
64
screens/ProjectsScreen.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { View, Text, FlatList, TouchableOpacity, Button, TextInput, StyleSheet } from 'react-native';
|
||||
import { collection, addDoc, query, where, getDocs, deleteDoc, doc } from 'firebase/firestore';
|
||||
import { db, auth } from '../config/firebase';
|
||||
|
||||
function ProjectsScreen({ navigation }: any) {
|
||||
const [projects, setProjects] = useState<any[]>([]);
|
||||
const [name, setName] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
loadProjects();
|
||||
}, []);
|
||||
|
||||
const loadProjects = async () => {
|
||||
const q = query(collection(db, 'projects'), where('userId', '==', auth.currentUser!.uid));
|
||||
const snapshot = await getDocs(q);
|
||||
setProjects(snapshot.docs.map(doc => ({ id: doc.id, ...doc.data() })));
|
||||
};
|
||||
|
||||
const addProject = async () => {
|
||||
await addDoc(collection(db, 'projects'), {
|
||||
name,
|
||||
userId: auth.currentUser!.uid,
|
||||
status: 'aktív',
|
||||
});
|
||||
setName('');
|
||||
loadProjects();
|
||||
};
|
||||
|
||||
const deleteProject = async (id: string) => {
|
||||
await deleteDoc(doc(db, 'projects', id));
|
||||
loadProjects();
|
||||
};
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<TextInput style={styles.input} placeholder="Projekt név" value={name} onChangeText={setName} />
|
||||
<Button title="Hozzáadás" onPress={addProject} />
|
||||
<FlatList
|
||||
data={projects}
|
||||
keyExtractor={item => item.id}
|
||||
renderItem={({ item }) => (
|
||||
<TouchableOpacity
|
||||
style={styles.item}
|
||||
onPress={() => navigation.navigate('Details', { project: item })}
|
||||
>
|
||||
<Text>{item.name} - {item.status}</Text>
|
||||
<TouchableOpacity onPress={() => deleteProject(item.id)}>
|
||||
<Text>🗑️</Text>
|
||||
</TouchableOpacity>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: { flex: 1, padding: 16 },
|
||||
input: { borderWidth: 1, padding: 8, marginBottom: 8, borderRadius: 4 },
|
||||
item: { padding: 16, borderBottomWidth: 1, flexDirection: 'row', justifyContent: 'space-between' },
|
||||
});
|
||||
|
||||
export default ProjectsScreen;
|
||||
22
store/authSlice.ts
Normal file
22
store/authSlice.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
|
||||
interface AuthState {
|
||||
user: { uid: string; email: string } | null;
|
||||
}
|
||||
|
||||
const initialState: AuthState = {
|
||||
user: null,
|
||||
};
|
||||
|
||||
const authSlice = createSlice({
|
||||
name: 'auth',
|
||||
initialState,
|
||||
reducers: {
|
||||
setUser: (state, action: PayloadAction<{ uid: string; email: string } | null>) => {
|
||||
state.user = action.payload;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { setUser } = authSlice.actions;
|
||||
export default authSlice.reducer;
|
||||
11
store/store.ts
Normal file
11
store/store.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import authReducer from './authSlice';
|
||||
|
||||
export const store = configureStore({
|
||||
reducer: {
|
||||
auth: authReducer,
|
||||
},
|
||||
});
|
||||
|
||||
export type RootState = ReturnType<typeof store.getState>;
|
||||
export type AppDispatch = typeof store.dispatch;
|
||||
6
tsconfig.json
Normal file
6
tsconfig.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "expo/tsconfig.base",
|
||||
"compilerOptions": {
|
||||
"strict": true
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user