hold my beer des wird a katastrophe

This commit is contained in:
Walcher 2024-01-25 17:49:24 +01:00 committed by Jakob Stornig
parent bdc2ca22f6
commit 85e92c85b4

View file

@ -5,15 +5,33 @@ import useFetch from '../../hooks/useFetch';
import { CategoryType } from '../../services/database'; import { CategoryType } from '../../services/database';
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: {
margin: 10,
borderRadius: 5,
alignItems: 'center',
justifyContent: 'center'
},
text: { text: {
fontSize: 26, fontSize: 26,
}, },
boldText: { boldText: {
fontWeight: 'bold', fontWeight: 'bold'
},
negativeText: {
color: 'red',
},
positiveText: {
color: 'green',
}, },
}); });
const BudgetRemaining = () => {
interface BudgetRemainingProps {
goodColor?: string;
badColor?: string;
}
const BudgetRemaining: React.FC<BudgetRemainingProps> = ({ goodColor = 'green', badColor = 'red' }) => {
const { colors } = useTheme(); const { colors } = useTheme();
const [spent, setSpent] = useState(0); const [spent, setSpent] = useState(0);
const [budget, setBudget] = useState(0); const [budget, setBudget] = useState(0);
@ -47,10 +65,18 @@ const BudgetRemaining = () => {
} }
return ( return (
<Text style={[styles.text, {color: colors.primaryText}]}> <Text style={[styles.text, { color: colors.primaryText }]}>
You have <Text style={styles.boldText}>{remaining.toFixed(2)}</Text> left. {remaining >= 0 ? (
<>
Your remaining Budget is <Text style={[styles.boldText, { color: goodColor }]}>{remaining.toFixed(2)}</Text>.
</>
) : (
<>
Your Budget is overspent by by <Text style={[styles.boldText, { color: badColor }]}>-{Math.abs(remaining).toFixed(2)}</Text>.
</>
)}
</Text> </Text>
); );
}; };
export default BudgetRemaining; export default BudgetRemaining;