6.3 KiB
6.3 KiB
29. iOS App — Design System Components Matching Web Theme
meta: id: shieldai-unified-restructure-29 feature: shieldai-unified-restructure priority: P1 depends_on: [shieldai-unified-restructure-28] tags: [ios, swiftui, design-system, components, mobile]
objective:
- Build a comprehensive set of reusable SwiftUI components that mirror the web app's UI primitives (Button, Card, Input, Badge, Modal, Toast) using the iOS theme system from task 28. These components should feel native to iOS while maintaining visual consistency with the web app.
deliverables:
iOS/ShieldAI/Components/ShieldButton.swift— Button component:- Styles: primary (filled), secondary (outlined), ghost (text only), danger
- Sizes: small, medium, large
- States: enabled, disabled, loading (shows
ProgressView) - Supports icons (leading/trailing)
iOS/ShieldAI/Components/ShieldCard.swift— Card container:- Gradient background matching web
.gradient-card - Border with corner radius
- Optional header and footer content
- Tap gesture support
- Gradient background matching web
iOS/ShieldAI/Components/ShieldTextField.swift— Text input:- Label, placeholder, validation state
- Secure text entry toggle for passwords
- Error message display
- Focus state styling
iOS/ShieldAI/Components/ShieldBadge.swift— Status badge:- Variants: default, success, warning, error, info
- Small rounded pill shape
- Icon + text or text only
iOS/ShieldAI/Components/ShieldModal.swift— Modal/sheet presentation:.sheetwrapper with consistent styling- Title, content, and action buttons
- Dismiss gesture support
iOS/ShieldAI/Components/ShieldToast.swift— Toast notification:- Slide-in from top or bottom
- Auto-dismiss after 3-4 seconds
- Variants: success, error, warning, info
- Tap to dismiss
- Uses
overlaymodifier on root view
iOS/ShieldAI/Components/ShieldAvatar.swift— User avatar:- Displays image or initials fallback
- Sizes: small, medium, large
- Online/away status indicator dot
iOS/ShieldAI/Components/ShieldProgressBar.swift— Progress indicator:- Linear progress bar with percentage label
- Color variants
iOS/ShieldAI/Components/ShieldEmptyState.swift— Empty state view:- Icon, title, description, action button
iOS/ShieldAI/Components/ShieldSkeleton.swift— Skeleton loading:- Shimmer animation using
LinearGradientmask - Text line and rectangle shapes
- Shimmer animation using
steps:
- Create
iOS/ShieldAI/Components/directory. - ShieldButton:
- Use
Buttonwith custom label - Primary:
brandPrimarybackground, white text - Secondary: transparent with
brandPrimaryborder and text - Ghost: transparent,
brandPrimarytext - Danger: red gradient background
- Loading: replace label with
ProgressView+ reduce opacity - Use
.frame(maxWidth: .infinity)for full-width buttons
- Use
- ShieldCard:
ZStackwith gradient background shape.overlayfor borderVStackfor content with padding- Corner radius: 16pt (matching web
rounded-2xl)
- ShieldTextField:
VStackwith label +TextField/SecureField+ error text- Custom background using
bgSecondarywith border - Focus ring using
.overlaywithbrandPrimarystroke on focus - Eye icon button for password visibility toggle
- ShieldBadge:
TextinsideCapsule()background- Colors from semantic tokens
- Small padding and font size
- ShieldModal:
- View extension
.shieldModal(isPresented:content:) - Wraps
.sheetwith consistent header and button bar - Uses
ShieldCardstyling for sheet background
- View extension
- ShieldToast:
- Create
ToastManageras@Observableclass (iOS 17+) orObservableObject showToast(message, variant, duration)method- Root view applies
.overlaywithToastContainer ToastContaineranimates toast in/out withwithAnimation
- Create
- ShieldAvatar:
AsyncImageorImagewith circular clip- Fallback:
Textwith initials onbrandPrimarycircle - Status dot overlay
- ShieldProgressBar:
GeometryReaderwith filledRectangle- Percentage label overlay
- ShieldEmptyState:
VStackwith icon (Image(systemName:)), title, description, optionalShieldButton
- ShieldSkeleton:
RectangleorRoundedRectanglewith shimmer animation- Use
LinearGradientmasked withmaskmodifier - Animate gradient position with
withAnimation(.linear(duration: 1.5).repeatForever())
- Create a preview/test view showing all components in light and dark mode.
steps:
- Unit: Each component renders correctly in previews
- Unit: ShieldButton action fires on tap
- Unit: ShieldTextField validation shows error state
- Unit: ShieldToast auto-dismisses after specified duration
- Visual: All components match web app appearance in both color schemes
- Visual: Components adapt to Dynamic Type (accessibility font sizes)
acceptance_criteria:
- All 10 component types exist in
iOS/ShieldAI/Components/ - Each component supports light and dark modes
- Button supports all 4 styles, 3 sizes, and loading state
- TextField supports validation, secure entry, and focus styling
- Toast system can queue and auto-dismiss multiple toasts
- Card uses gradient background matching web theme
- Skeleton has smooth shimmer animation
- All components use theme tokens (no hardcoded colors)
- Components adapt to accessibility font sizes
validation:
- Open preview canvas for each component and verify appearance
- Run app on simulator and navigate to component test screen
- Toggle dark mode and verify all components shift colors
- Enable large text in Accessibility settings and verify layouts don't break
- Run unit tests via Xcode Cmd+U
notes:
- SwiftUI previews are invaluable for component development. Create a
ComponentsPreview.swiftthat shows all variants side by side. - Use
@ViewBuilderclosures for content slots inShieldCard,ShieldModal, etc. to allow flexible content. - For the toast system, consider using the new
@Observablemacro (iOS 17+) instead ofObservableObjectfor better performance. - The shimmer animation can be implemented using a
LinearGradientthat moves across the view. Reference: https://swiftuirecipes.com/blog/swiftui-shimmer-effect - Keep components generic — they should not import service-specific types or business logic.