5.6 KiB
5.6 KiB
28. iOS App — SwiftUI Foundation, Navigation, and Shared Theme
meta: id: kordant-unified-restructure-28 feature: kordant-unified-restructure priority: P1 depends_on: [kordant-unified-restructure-01, kordant-unified-restructure-02] tags: [ios, swiftui, foundation, navigation, mobile]
objective:
- Establish the iOS app foundation in
iOS/Kordant/: a SwiftUI project with app entry point, navigation architecture, and a shared theme system that mirrors the web app's Kordant brand palette and auto-shifting dark mode.
deliverables:
iOS/Kordant/KordantApp.swift— App entry point:@mainapp struct withWindowGroup- Initializes dependency container (if using DI)
- Sets up appearance (tint color, navigation bar style)
iOS/Kordant/ContentView.swift— Root view:TabViewwith 5 tabs: Dashboard, Services, Alerts, Settings, Account- Or
NavigationStackwith sidebar for iPad - Handles auth state: shows
AuthViewif unauthenticated,MainViewif authenticated
iOS/Kordant/Navigation/— Navigation infrastructure:AppRouter.swift— Navigation path manager usingNavigationPathRoute.swift— Enum of all app routes with associated valuesRouterViewModifier.swift— View modifier for deep linking
iOS/Kordant/Theme/— Shared theme system:KordantTheme.swift— Theme protocol/struct with colors, fonts, spacingColor+Kordant.swift— SwiftUI Color extensions for all brand tokens:brandPrimary,brandPrimaryLight,brandPrimaryDarkbrandAccent,brandAccentLight,brandAccentDarkbgPrimary,bgSecondary,bgTertiarytextPrimary,textSecondary,textTertiaryborder,success,warning,error
Font+Kordant.swift— Typography scale matching web appThemeManager.swift— Observable object managing light/dark/system mode
iOS/Kordant/Info.plistandAssets.xcassets/:- App icon set (reuse web app SVGs converted to PNG/AppIcon)
- Color assets for dynamic light/dark variants
- Launch screen storyboard or SwiftUI launch view
- Project configuration:
- Xcode project or Swift Package Manager setup
- Minimum iOS version: 16.0 (SwiftUI 2.0+ features, NavigationStack)
- Target devices: iPhone + iPad
steps:
- Verify
iOS/Kordant/exists and has a valid Xcode project or Package.swift. - Create
KordantApp.swift:- Set global accent color to
brandPrimary - Configure navigation bar appearance
- Inject
ThemeManageras environment object
- Set global accent color to
- Create
ContentView.swift:- Use
@StateObjectfor auth state - If unauthenticated: present full-screen
AuthView(task 30) - If authenticated: show
TabViewwith tabs
- Use
- Create navigation system:
Routeenum with cases:.dashboard,.service(ShieldService),.alertDetail(Alert),.settings,.profile, etc.AppRouterclass withNavigationPathandnavigate(to:),pop(),popToRoot()- Support deep linking via URL scheme (
kordant://dashboard,kordant://alert/123)
- Create theme system:
- Define all colors as static properties on
Colorextension - Use
UIColordynamic colors for light/dark variants:static let bgPrimary = Color(UIColor { traitCollection in traitCollection.userInterfaceStyle == .dark ? UIColor(hex: "#111827") : UIColor(hex: "#fafbfc") }) - Define font scale:
.caption,.body,.headline,.title,.largeTitle - Define spacing scale:
.xs(4),.sm(8),.md(16),.lg(24),.xl(32),.xxl(48)
- Define all colors as static properties on
- Create
ThemeManager.swift:@Published var colorScheme: ColorScheme?(nil = system)- Methods:
setLight(),setDark(),setSystem() - Persist preference in
UserDefaults - Apply to root view using
.preferredColorScheme()
- Set up assets:
- Convert Kordant logo SVG to PDF or PNG for Xcode assets
- Create color assets for all theme tokens with "Any, Dark" variants
- Add AppIcon set for all required sizes
- Build and run on iOS Simulator to verify app launches with correct theme.
steps:
- Unit: ThemeManager correctly toggles between light/dark/system
- Unit: Color extensions return correct values for light and dark traits
- Unit: AppRouter pushes and pops routes correctly
- Visual: App launches with Kordant branding and correct tab structure
- Visual: Theme shifts correctly when device dark mode toggles
acceptance_criteria:
- iOS app launches without crashes on iPhone and iPad simulators
- Tab navigation has 5 tabs with correct icons and labels
- Theme colors match web app palette in both light and dark modes
- Theme manager persists user preference across app restarts
- Navigation stack works for pushing and popping views
- Deep linking supports
kordant://URL scheme - App icon and launch screen display correctly
validation:
- Build and run on iPhone 15 Pro simulator (iOS 17+)
- Toggle device dark mode and verify all colors shift
- Test navigation by tapping through all tabs and sub-pages
- Verify deep link:
xcrun simctl openurl booted kordant://dashboard - Run unit tests via Xcode Cmd+U
notes:
- The iOS app should feel like a native sibling to the web app, not a port. Use native iOS patterns (tab bar, navigation bar, sheets, context menus).
- SwiftUI's
NavigationStack(iOS 16+) replaces the olderNavigationView. Use it for proper path-based navigation. - For iPad, consider a sidebar (
NavigationSplitView) instead of tab bar for better space utilization. - The theme system should be the single source of truth for all visual values. No hardcoded colors anywhere in the app.
- Use SF Symbols for icons where possible. For custom icons (Kordant logo), use vector PDFs in assets.