Initial commit
This commit is contained in:
41
.gitignore
vendored
Normal file
41
.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# Learn more https://docs.github.com/en/get-started/getting-started-with-git/ignoring-files
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Expo
|
||||||
|
.expo/
|
||||||
|
dist/
|
||||||
|
web-build/
|
||||||
|
expo-env.d.ts
|
||||||
|
|
||||||
|
# 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
|
||||||
51
App.tsx
Normal file
51
App.tsx
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import React 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 EventsScreen from './screens/EventsScreen';
|
||||||
|
import DetailsScreen from './screens/DetailsScreen';
|
||||||
|
import FavoritesScreen from './screens/FavoritesScreen';
|
||||||
|
import { TouchableOpacity, Text } from 'react-native';
|
||||||
|
import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
||||||
|
|
||||||
|
const Stack = createStackNavigator();
|
||||||
|
|
||||||
|
const DarkTheme = {
|
||||||
|
...DefaultTheme,
|
||||||
|
colors: {
|
||||||
|
...DefaultTheme.colors,
|
||||||
|
primary: '#ff00ff',
|
||||||
|
background: '#000000',
|
||||||
|
card: '#1a1a1a',
|
||||||
|
text: '#ffffff',
|
||||||
|
border: '#333333',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function App() {
|
||||||
|
return (
|
||||||
|
<GestureHandlerRootView style={{ flex: 1 }}>
|
||||||
|
<Provider store={store}>
|
||||||
|
<NavigationContainer theme={DarkTheme}>
|
||||||
|
<Stack.Navigator>
|
||||||
|
<Stack.Screen
|
||||||
|
name="Events"
|
||||||
|
component={EventsScreen}
|
||||||
|
options={({ navigation }) => ({
|
||||||
|
title: 'Események',
|
||||||
|
headerRight: () => (
|
||||||
|
<TouchableOpacity onPress={() => navigation.navigate('Favorites')} style={{ marginRight: 16 }}>
|
||||||
|
<Text style={{ fontSize: 18, color: '#ff00ff' }}>like</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
),
|
||||||
|
})}
|
||||||
|
/>
|
||||||
|
<Stack.Screen name="Details" component={DetailsScreen} options={{ title: 'Részletek' }} />
|
||||||
|
<Stack.Screen name="Favorites" component={FavoritesScreen} options={{ title: 'Kedvencek' }} />
|
||||||
|
</Stack.Navigator>
|
||||||
|
</NavigationContainer>
|
||||||
|
</Provider>
|
||||||
|
</GestureHandlerRootView>
|
||||||
|
);
|
||||||
|
}
|
||||||
28
app.json
Normal file
28
app.json
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"expo": {
|
||||||
|
"name": "feladat1-esemenykezelo",
|
||||||
|
"slug": "feladat1-esemenykezelo",
|
||||||
|
"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 |
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);
|
||||||
9466
package-lock.json
generated
Normal file
9466
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
32
package.json
Normal file
32
package.json
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "feladat1-esemenykezelo",
|
||||||
|
"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-native-async-storage/async-storage": "2.2.0",
|
||||||
|
"@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",
|
||||||
|
"react": "19.1.0",
|
||||||
|
"react-dom": "19.1.0",
|
||||||
|
"react-native": "0.81.5",
|
||||||
|
"react-native-gesture-handler": "~2.28.0",
|
||||||
|
"react-native-safe-area-context": "^5.6.2",
|
||||||
|
"react-native-screens": "~4.16.0",
|
||||||
|
"react-native-web": "^0.21.0",
|
||||||
|
"react-redux": "^9.2.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/react": "~19.1.0",
|
||||||
|
"typescript": "~5.9.2"
|
||||||
|
},
|
||||||
|
"private": true
|
||||||
|
}
|
||||||
21
screens/DetailsScreen.tsx
Normal file
21
screens/DetailsScreen.tsx
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { View, Text, StyleSheet } from 'react-native';
|
||||||
|
|
||||||
|
export default function DetailsScreen({ route }: any) {
|
||||||
|
const { event } = route.params;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<Text style={styles.title}>{event.name}</Text>
|
||||||
|
<Text style={styles.date}>{new Date(event.date).toLocaleDateString()}</Text>
|
||||||
|
<Text style={styles.description}>{event.description}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: { flex: 1, padding: 16 },
|
||||||
|
title: { fontSize: 24, fontWeight: 'bold', marginBottom: 8 },
|
||||||
|
date: { fontSize: 14, color: '#666', marginBottom: 16 },
|
||||||
|
description: { fontSize: 16 },
|
||||||
|
});
|
||||||
54
screens/EventsScreen.tsx
Normal file
54
screens/EventsScreen.tsx
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import { View, Text, FlatList, TouchableOpacity, StyleSheet } from 'react-native';
|
||||||
|
import { useDispatch, useSelector } from 'react-redux';
|
||||||
|
import { setEvents, toggleFavorite } from '../store/eventsSlice';
|
||||||
|
import { RootState } from '../store/store';
|
||||||
|
|
||||||
|
export default function EventsScreen({ navigation }: any) {
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
const { events, favorites } = useSelector((state: RootState) => state.events);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetch('https://jsonplaceholder.typicode.com/posts')
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(data => {
|
||||||
|
const mappedEvents = data.slice(0, 20).map((item: any) => ({
|
||||||
|
id: item.id.toString(),
|
||||||
|
name: item.title,
|
||||||
|
description: item.body,
|
||||||
|
date: new Date().toISOString(),
|
||||||
|
}));
|
||||||
|
dispatch(setEvents(mappedEvents));
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
<FlatList
|
||||||
|
data={events}
|
||||||
|
keyExtractor={item => item.id}
|
||||||
|
renderItem={({ item }) => (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.item}
|
||||||
|
onPress={() => navigation.navigate('Details', { event: item })}
|
||||||
|
>
|
||||||
|
<Text style={styles.title}>{item.name}</Text>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => dispatch(toggleFavorite(item.id))}
|
||||||
|
style={styles.favBtn}
|
||||||
|
>
|
||||||
|
<Text>{favorites.includes(item.id) ? '❤️' : '🤍'}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: { flex: 1, padding: 16, backgroundColor: '#000000' },
|
||||||
|
item: { padding: 16, borderBottomWidth: 1, borderBottomColor: '#333333', flexDirection: 'row', justifyContent: 'space-between' },
|
||||||
|
title: { fontSize: 16, flex: 1, color: '#ffffff' },
|
||||||
|
favBtn: { padding: 8 },
|
||||||
|
});
|
||||||
37
screens/FavoritesScreen.tsx
Normal file
37
screens/FavoritesScreen.tsx
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { View, Text, FlatList, TouchableOpacity, StyleSheet } from 'react-native';
|
||||||
|
import { useSelector } from 'react-redux';
|
||||||
|
import { RootState } from '../store/store';
|
||||||
|
|
||||||
|
export default function FavoritesScreen({ navigation }: any) {
|
||||||
|
const { events, favorites } = useSelector((state: RootState) => state.events);
|
||||||
|
const favoriteEvents = events.filter(e => favorites.includes(e.id));
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
{favoriteEvents.length === 0 ? (
|
||||||
|
<Text style={styles.empty}>Nincs kedvenc esemény</Text>
|
||||||
|
) : (
|
||||||
|
<FlatList
|
||||||
|
data={favoriteEvents}
|
||||||
|
keyExtractor={item => item.id}
|
||||||
|
renderItem={({ item }) => (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={styles.item}
|
||||||
|
onPress={() => navigation.navigate('Details', { event: item })}
|
||||||
|
>
|
||||||
|
<Text style={styles.title}>{item.name}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: { flex: 1, padding: 16 },
|
||||||
|
item: { padding: 16, borderBottomWidth: 1 },
|
||||||
|
title: { fontSize: 16 },
|
||||||
|
empty: { textAlign: 'center', marginTop: 50, fontSize: 16, color: '#666' },
|
||||||
|
});
|
||||||
39
store/eventsSlice.ts
Normal file
39
store/eventsSlice.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||||
|
|
||||||
|
interface Event {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description: string;
|
||||||
|
date: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface EventsState {
|
||||||
|
events: Event[];
|
||||||
|
favorites: string[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const initialState: EventsState = {
|
||||||
|
events: [],
|
||||||
|
favorites: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const eventsSlice = createSlice({
|
||||||
|
name: 'events',
|
||||||
|
initialState,
|
||||||
|
reducers: {
|
||||||
|
setEvents: (state, action: PayloadAction<Event[]>) => {
|
||||||
|
state.events = action.payload;
|
||||||
|
},
|
||||||
|
toggleFavorite: (state, action: PayloadAction<string>) => {
|
||||||
|
const index = state.favorites.indexOf(action.payload);
|
||||||
|
if (index > -1) {
|
||||||
|
state.favorites.splice(index, 1);
|
||||||
|
} else {
|
||||||
|
state.favorites.push(action.payload);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const { setEvents, toggleFavorite } = eventsSlice.actions;
|
||||||
|
export default eventsSlice.reducer;
|
||||||
11
store/store.ts
Normal file
11
store/store.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { configureStore } from '@reduxjs/toolkit';
|
||||||
|
import eventsReducer from './eventsSlice';
|
||||||
|
|
||||||
|
export const store = configureStore({
|
||||||
|
reducer: {
|
||||||
|
events: eventsReducer,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
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