hold my beer des wird a katastrophe
This commit is contained in:
parent
bdc2ca22f6
commit
85e92c85b4
1 changed files with 31 additions and 5 deletions
|
|
@ -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,8 +65,16 @@ 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>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Reference in a new issue