frontend-app/app/MainContent.tsx
2025-09-30 15:29:12 +02:00

95 lines
2.0 KiB
TypeScript

import React from 'react';
import { Linking, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { Item } from 'types/Item';
type MainContentProps = {
selected: string;
onToggleMenu: () => void;
data: Item[];
};
export default function MainContent({ selected, onToggleMenu, data }: MainContentProps) {
const getTitle = () => {
switch (selected) {
case 'home': return 'Welcome to Home!';
case 'royal-road': return 'Royal Road Updates';
case 'podcasts': return 'Latest Podcasts';
case 'mixtapes': return 'Mixtapes';
default: return '';
}
};
return (
<View style={styles.mainContent}>
<TouchableOpacity style={styles.menuButton} onPress={onToggleMenu}>
<Text style={styles.menuButtonText}></Text>
</TouchableOpacity>
<Text style={styles.title}>{getTitle()}</Text>
<ScrollView style={styles.dataContainer}>
{data.map(item => (
<TouchableOpacity key={item.timestamp} onPress={() => Linking.openURL(item.link)}>
<View style={styles.dataItem}>
<Text style={styles.dataTitle}>{item.title}</Text>
<Text style={styles.dataDescription}>{item.info}</Text>
</View>
</TouchableOpacity>
))}
</ScrollView>
</View>
);
}
const styles = StyleSheet.create({
mainContent: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
position: 'relative',
backgroundColor: '#f2f2f2',
},
menuButton: {
position: 'absolute',
top: 40,
left: 16,
zIndex: 1,
backgroundColor: '#333',
borderRadius: 20,
padding: 8,
},
menuButtonText: {
color: '#fff',
fontSize: 24,
},
title: {
fontSize: 24,
fontWeight: 'bold',
color: '#333',
marginTop: 60,
marginBottom: 16,
},
dataContainer: {
width: '90%',
},
dataItem: {
backgroundColor: '#fff',
borderRadius: 8,
padding: 16,
marginBottom: 12,
shadowColor: '#000',
shadowOpacity: 0.05,
shadowRadius: 4,
elevation: 2,
},
dataTitle: {
fontSize: 18,
fontWeight: 'bold',
color: '#222',
marginBottom: 4,
},
dataDescription: {
fontSize: 15,
color: '#555',
},
});