made it possible to pass an override backgroundcolor to widget

This commit is contained in:
Walcher 2024-01-05 14:50:33 +01:00
parent 7e29e4f016
commit 8b68a7b7b0

View file

@ -1,5 +1,5 @@
import React, { ReactNode } from 'react'; import React, { ReactNode } from 'react';
import { View, StyleSheet, Text, Image } from 'react-native'; // Add the missing import statement for Image import { View, StyleSheet, Text, Image } from 'react-native';
import { useTheme } from '../../app/contexts/ThemeContext'; import { useTheme } from '../../app/contexts/ThemeContext';
interface WidgetProps { interface WidgetProps {
@ -7,14 +7,17 @@ interface WidgetProps {
text?: string; text?: string;
children?: ReactNode; children?: ReactNode;
image?: any; image?: any;
backgroundColor?: string;
} }
const Widget: React.FC<WidgetProps> = ({ title, text, children, image }) => { // Add the 'image' prop to the destructuring const Widget: React.FC<WidgetProps> = ({ title, text, children, image, backgroundColor }) => {
const { colors } = useTheme(); const { colors } = useTheme();
const actualBackgroundColor = backgroundColor ? backgroundColor : colors.widgetBackgroundColor;
const styles = StyleSheet.create({ const styles = StyleSheet.create({
widgetContainer: { widgetContainer: {
backgroundColor: colors.widgetBackgroundColor, backgroundColor: actualBackgroundColor,
borderColor: colors.widgetBorderColor, borderColor: colors.widgetBorderColor,
borderRadius: 5, borderRadius: 5,
padding: 16, padding: 16,