import React, { useState } from 'react'; import { View, Text, ScrollView, StyleSheet, Pressable, } from 'react-native'; import { Ux4gBadge, Ux4gBadgeLimit, Ux4gBadgeAlignment } from '../components/badge/Badge'; import { Ux4gButton } from '../components/button/Button'; import { Ux4gIcons } from '../foundation/icons'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; export const BadgeShowcase: React.FC = () => { const theme = useUx4gTheme(); const colors = theme.colors; const [count, setCount] = useState(5); const [limit, setLimit] = useState('singleDigit'); const [label, setLabel] = useState('NEW'); const [showBorder, setShowBorder] = useState(false); const cardStyle = [ styles.card, { backgroundColor: theme.isDark ? '#1F1F1F' : '#FFFFFF', borderColor: theme.isDark ? '#333333' : '#E4E4E7', }, ]; const titleStyle = [ styles.sectionTitle, { color: theme.isDark ? '#F4F4F5' : '#18181B' }, ]; const subtitleStyle = [ styles.subText, { color: theme.isDark ? '#A1A1AA' : '#71717A' }, ]; const semanticColors = theme.isDark ? ['#93C5FD', '#22C55E', '#F97316', '#FCA5A5', '#71717A', '#06B6D4'] : ['#2563EB', '#16A34A', '#EA580C', '#DC2626', '#D4D4D8', '#0891B2']; return ( 🔴 Badge Component (`Ux4gBadge`) 100% exact parity with Flutter `badge.dart` & `badge_stories.dart`. Supports compound named constructors (`Ux4gBadge.dot()`, `Ux4gBadge.count()`, `Ux4gBadge.label()`, `Ux4gBadge.icon()`) and limit formatting (`9+` / `99+`). {/* 1. Dot Use Case */} 1. Dot (`Ux4gBadge.dot`) Simple presence indicator anchored to an icon or widget. 🔔 } /> {/* 2. Count Use Case */} 2. Count (`Ux4gBadge.count`) Shows a numeric count (`{count}`) with active limit (`{limit}`). ✉️ } /> setCount((c) => c + 1)} style={styles.controlBtn} /> setCount((c) => c + 10)} style={styles.controlBtn} /> setCount(5)} style={styles.controlBtn} /> setLimit(limit === 'singleDigit' ? 'doubleDigit' : 'singleDigit')} style={[styles.togglePill, { borderColor: colors.primary }]} > Limit: {limit} setShowBorder(!showBorder)} style={[styles.togglePill, { borderColor: colors.primary }]} > Border: {showBorder ? 'ON' : 'OFF'} {/* 3. Label Use Case */} 3. Label (`Ux4gBadge.label`) Displays a short text string as a badge. ⭐ } /> setLabel('NEW')} style={styles.controlBtn} /> setLabel('PRO')} style={styles.controlBtn} /> setLabel('BETA')} style={styles.controlBtn} /> {/* 4. Standalone variants */} 4. Standalone Variants (`Badge — Standalone`) Badges rendered without a child widget exactly matching `badge_stories.dart` (`verification`, `star`, and `shield` icons with `showBorder: true`). {/* 5. Semantic Colors & Border */} 5. Semantic Colors & Border (`showBorder: true`) Showcasing the border stroke across semantic colors matching Flutter use case. {semanticColors.map((color, idx) => ( ))} {semanticColors.map((color, idx) => ( ✓} /> ))} {semanticColors.map((color, idx) => ( ))} ); }; const styles = StyleSheet.create({ container: { flex: 1, }, contentContainer: { padding: 16, paddingBottom: 40, }, header: { marginBottom: 16, }, title: { fontSize: 22, fontWeight: '800', marginBottom: 6, }, subText: { fontSize: 14, lineHeight: 20, }, card: { borderWidth: 1, borderRadius: 16, padding: 16, marginBottom: 16, overflow: 'visible', }, sectionTitle: { fontSize: 16, fontWeight: '700', marginBottom: 4, }, showcaseItemBox: { alignItems: 'center', marginVertical: 20, overflow: 'visible', }, dummyIconBox: { width: 56, height: 56, borderRadius: 16, alignItems: 'center', justifyContent: 'center', }, rowControls: { flexDirection: 'row', flexWrap: 'wrap', justifyContent: 'center', gap: 8, marginTop: 10, }, controlBtn: { marginHorizontal: 4, }, togglePill: { paddingHorizontal: 12, paddingVertical: 8, borderWidth: 1, borderRadius: 999, marginHorizontal: 4, }, standaloneWrap: { flexDirection: 'row', flexWrap: 'wrap', gap: 16, marginTop: 16, alignItems: 'center', }, semanticBox: { padding: 20, borderRadius: 12, marginTop: 12, gap: 24, }, semanticRow: { flexDirection: 'row', justifyContent: 'space-around', alignItems: 'center', }, });