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/FinancialAdvice.tsx
2024-01-05 14:43:15 +01:00

59 lines
2.2 KiB
TypeScript

import React, { useState, useEffect } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { useTheme } from '../../app/contexts/ThemeContext';
const FinancialAdvice = () => {
const tips = [
"Maybe you shouldn't have bought that full-price video game. But who needs savings when you have high scores, right?",
"That daily gourmet coffee is essential, isn't it? Who needs a retirement fund when you've got caffeine!",
"Oh, another pair of designer shoes? Because the other twenty pairs just aren't enough.",
"A luxury car to drive two blocks? Obviously, walking is for peasants.",
"Sure, subscribe to all streaming services. Who needs to socialize outside when you can binge-watch shows alone forever?",
"A gym membership you never use? At least your wallet's getting a workout.",
"Booking another expensive vacation? It's not like you need to save for a rainy day or anything.",
"Another impulse purchase online? Because 'limited time offer' is definitely not a marketing tactic.",
"Eating out for every meal? Clearly, cooking at home is way too mainstream.",
"Upgrading to the latest phone model again? It must be tough having a phone that's 6 months old."
];
const { colors } = useTheme();
const [tip, setTip] = useState('');
useEffect(() => {
// Change the tip every 10 seconds
const intervalId = setInterval(() => {
const randomTip = tips[Math.floor(Math.random() * tips.length)];
setTip(randomTip);
}, 10000);
// Clear the interval on component unmount
return () => clearInterval(intervalId);
}, [tips]);
const styles = StyleSheet.create({
container: {
margin: 10,
borderRadius: 5,
alignItems: 'center',
justifyContent: 'center'
},
text: {
fontSize: 26,
color: colors.primaryText
},
boldText: {
fontWeight: 'bold'
}
});
return (
<View style={styles.container}>
<Text style={styles.text}>
{tip}
</Text>
</View>
);
};
export default FinancialAdvice;