import React, { useState } from 'react'; import { View, ScrollView, Text, StyleSheet, Pressable } from 'react-native'; import { Ux4gStepper, Ux4gCompactStepper, Ux4gStepItem, } from '../components'; import { useUx4gTheme } from '../theme/Ux4gThemeContext'; /** * Showcase matching the Flutter showcase_app.dart stepper sections exactly: * - Section 26: Stepper Component (Horizontal, Vertical, Error State) * - Section 29: Compact Stepper (Linear, RightAligned, Centered, Split) */ export const StepperShowcase = () => { const theme = useUx4gTheme(); // Matches `_currentStep` in Flutter showcase (1-indexed, total 4) const [currentStep, setCurrentStep] = useState(2); // Matches `_capsuleStep` in Flutter showcase (1-indexed, total 12) const [capsuleStep, setCapsuleStep] = useState(2); // ── Steps data matching Flutter showcase_app.dart ── const horizontalSteps: Ux4gStepItem[] = [ { title: 'Label', description: 'Write description here' }, { title: 'Label', description: 'Write description here' }, { title: 'Label', description: 'Write description here' }, { title: 'Label', description: 'Write description here' }, ]; const verticalSteps: Ux4gStepItem[] = [ { title: 'Label', description: 'Write description here' }, { title: 'Label', description: 'Write description here' }, { title: 'Label', description: 'Write description here' }, { title: 'Label', description: 'Write description here' }, ]; const errorSteps: Ux4gStepItem[] = [ { title: 'Account', description: 'Completed' }, { title: 'Profile', description: 'Completed' }, { title: 'Payment', description: 'Transaction failed', isError: true }, { title: 'Done', description: 'Pending' }, ]; return ( {/* ─── 26. Stepper Component ─── */} Stepper Component {/* Horizontal Stepper */} Horizontal Stepper {/* Dashed Line Stepper */} Horizontal Stepper — Dashed Line {/* Vertical Stepper */} Vertical Stepper {/* Previous / Next buttons */} setCurrentStep(s => Math.max(1, s - 1))} disabled={currentStep <= 1} style={[ styles.navButton, { backgroundColor: currentStep > 1 ? '#333333' : '#CCCCCC', flex: 1, marginRight: 4, }, ]} > Previous setCurrentStep(s => Math.min(4, s + 1))} disabled={currentStep >= 4} style={[ styles.navButton, { backgroundColor: currentStep < 4 ? theme.colors.primary : '#CCCCCC', flex: 1, marginLeft: 4, }, ]} > Next {/* Error State */} Stepper with Error State {/* Bottom Lines */} Stepper — Bottom Lines 1 ? 'Completed' : currentStep === 1 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 2 ? 'Completed' : currentStep === 2 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 3 ? 'Completed' : currentStep === 3 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 4 ? 'Completed' : currentStep === 4 ? 'In progress' : 'Label', }, ]} /> {/* Bottom Lines with Active Step Background */} Bottom Lines + Active Background 1 ? 'Completed' : currentStep === 1 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 2 ? 'Completed' : currentStep === 2 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 3 ? 'Completed' : currentStep === 3 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 4 ? 'Completed' : currentStep === 4 ? 'In progress' : 'Label', }, ]} /> {/* Edge Label Alignment */} Horizontal Stepper — Edge Label Alignment 1 ? 'Completed' : currentStep === 1 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 2 ? 'Completed' : currentStep === 2 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 3 ? 'Completed' : currentStep === 3 ? 'In progress' : 'Label', }, { title: 'Label', description: 'Write description here', statusLabel: currentStep > 4 ? 'Completed' : currentStep === 4 ? 'In progress' : 'Label', }, ]} /> {/* ─── 29. Compact Stepper ─── */} Compact Stepper {/* Linear */} Layout: Linear (Default) setCapsuleStep(s => s + 1) : undefined} onPrevious={capsuleStep > 1 ? () => setCapsuleStep(s => s - 1) : undefined} /> {/* Right Aligned */} Layout: Right Aligned setCapsuleStep(s => s + 1) : undefined} onPrevious={capsuleStep > 1 ? () => setCapsuleStep(s => s - 1) : undefined} /> {/* Centered */} Layout: Centered setCapsuleStep(s => s + 1) : undefined} onPrevious={capsuleStep > 1 ? () => setCapsuleStep(s => s - 1) : undefined} /> {/* Centered (Arrows Outside) */} Layout: Centered (Arrows Outside) setCapsuleStep(s => s + 1) : undefined} onPrevious={capsuleStep > 1 ? () => setCapsuleStep(s => s - 1) : undefined} /> {/* Split */} Layout: Split setCapsuleStep(s => s + 1) : undefined} onPrevious={capsuleStep > 1 ? () => setCapsuleStep(s => s - 1) : undefined} /> ); }; const styles = StyleSheet.create({ container: { flex: 1, }, content: { padding: 16, }, card: { borderWidth: 1, borderRadius: 12, padding: 16, marginBottom: 24, }, cardTitle: { fontSize: 20, fontWeight: 'bold', marginBottom: 16, }, sectionLabel: { fontSize: 14, fontWeight: 'bold', }, layoutLabel: { fontSize: 12, fontWeight: 'bold', }, navButton: { paddingVertical: 12, borderRadius: 8, alignItems: 'center', }, navButtonText: { color: '#FFFFFF', fontWeight: 'bold', fontSize: 14, }, });