This repository has been archived on 2026-04-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
interaktive-systeme/components/stats/Widget.tsx
2024-01-05 14:52:20 +01:00

67 lines
No EOL
1.9 KiB
TypeScript

import React, { ReactNode } from 'react';
import { View, StyleSheet, Text, Image } from 'react-native';
import { useTheme } from '../../app/contexts/ThemeContext';
interface WidgetProps {
title?: string;
text?: string;
children?: ReactNode;
image?: any;
backgroundColor?: string;
}
const Widget: React.FC<WidgetProps> = ({ title, text, children, image, backgroundColor }) => {
const { colors } = useTheme();
const actualBackgroundColor = backgroundColor ? backgroundColor : colors.widgetBackgroundColor;
const styles = StyleSheet.create({
widgetContainer: {
backgroundColor: actualBackgroundColor,
borderColor: colors.widgetBorderColor,
borderRadius: 5,
padding: 16,
marginVertical: 8,
marginHorizontal: 10,
shadowColor: '#000',
shadowOffset: {
width: 0,
height: 1,
},
shadowOpacity: 0.22,
shadowRadius: 2.22,
elevation: 3,
},
widgetTitle: {
color: colors.primaryText,
fontSize: 26,
fontWeight: 'bold',
marginBottom: 8,
textAlign: 'center',
},
widgetText: {
color: colors.primaryText,
fontSize: 16,
marginBottom: 8,
textAlign: 'center',
},
imageStyle: {
width: '100%',
height: 500,
borderRadius: 5,
marginBottom: 8,
},
});
return (
<View style={styles.widgetContainer}>
{!!title && <Text style={styles.widgetTitle}>{title}</Text>}
{!!text && <Text style={styles.widgetText}>{text}</Text>}
{!!image && <Image source={image} style={styles.imageStyle} />}
{children}
</View>
);
};
export default Widget;