Mobile App design
This commit is contained in:
@@ -1,27 +1,32 @@
|
||||
import React from 'react';
|
||||
import { View, Text, StyleSheet } from 'react-native';
|
||||
import { colors, borderRadius, spacing } from '../constants/theme';
|
||||
import { useThemeContext } from './ThemeProvider';
|
||||
import { borderRadius, spacing } from '../constants/theme';
|
||||
|
||||
interface StockBadgeProps {
|
||||
stock: number;
|
||||
}
|
||||
|
||||
export function StockBadge({ stock }: StockBadgeProps) {
|
||||
const getBadgeStyle = () => {
|
||||
if (stock === 0) return styles.danger;
|
||||
if (stock < 5) return styles.warning;
|
||||
return styles.success;
|
||||
const { colors, isDark } = useThemeContext();
|
||||
|
||||
const getBadgeColors = () => {
|
||||
if (stock === 0) {
|
||||
return { bg: isDark ? '#3a1a1a' : '#feecec', text: isDark ? '#ef9a9a' : '#b91c1c' };
|
||||
}
|
||||
if (stock < 5) {
|
||||
return { bg: isDark ? '#3a3010' : '#fff3cd', text: isDark ? '#ffd54f' : '#FF9500' };
|
||||
}
|
||||
return { bg: isDark ? '#1a3a1c' : '#eaf7ec', text: isDark ? '#81c784' : '#34C759' };
|
||||
};
|
||||
|
||||
const getText = () => {
|
||||
if (stock === 0) return 'Sin stock';
|
||||
if (stock < 5) return `Bajo (${stock})`;
|
||||
return `Disponible (${stock})`;
|
||||
};
|
||||
const badgeColors = getBadgeColors();
|
||||
|
||||
return (
|
||||
<View style={[styles.badge, getBadgeStyle()]}>
|
||||
<Text style={styles.text}>{getText()}</Text>
|
||||
<View style={[styles.badge, { backgroundColor: badgeColors.bg }]}>
|
||||
<Text style={[styles.text, { color: badgeColors.text }]}>
|
||||
{stock === 0 ? 'Sin stock' : stock < 5 ? `Bajo (${stock})` : `Disponible (${stock})`}
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
@@ -32,15 +37,6 @@ const styles = StyleSheet.create({
|
||||
paddingVertical: spacing.xs,
|
||||
borderRadius: borderRadius.sm,
|
||||
},
|
||||
success: {
|
||||
backgroundColor: '#eaf7ec',
|
||||
},
|
||||
warning: {
|
||||
backgroundColor: '#fff3cd',
|
||||
},
|
||||
danger: {
|
||||
backgroundColor: '#feecec',
|
||||
},
|
||||
text: {
|
||||
fontSize: 12,
|
||||
fontWeight: '600',
|
||||
|
||||
Reference in New Issue
Block a user