Implemented a feature that allows users without a family (or "Just Me" users) to create a family from the Settings screen. When they tap "Create Family", they go through the family onboarding flow and return to the Settings screen after completion.
- Added:
isCreatingFamilyFromSettingsflag to track if the family creation flow was initiated from Settings - Purpose: This flag helps the app know where to return the user after completing the family creation flow
// Track if family creation was initiated from Settings
var isCreatingFamilyFromSettings: Bool = false- Modified: The Create Family / Manage Family button logic
- Key Logic: Checks if family exists AND has other members
if let family = familyStore.family, !family.otherMembers.isEmpty- This ensures "Just Me" users (who have a family but no other members) see "Create Family"
- Behavior:
- When family has other members → Shows "Manage Family" and navigates to
ManageFamilyView - When no family OR "Just Me" family → Shows "Create Family" and:
- Sets
coordinator.isCreatingFamilyFromSettings = true - Navigates to
.letsMeetYourIngrediFamcanvas - Dismisses the Settings sheet
- Sets
- When family has other members → Shows "Manage Family" and navigates to
if let family = familyStore.family, !family.otherMembers.isEmpty {
// Family with other members -> Manage Family
NavigationLink { ManageFamilyView() } label: { ... }
} else {
// No family OR "Just Me" -> Create Family
Button {
coordinator.isCreatingFamilyFromSettings = true
coordinator.showCanvas(.letsMeetYourIngrediFam)
dismiss()
} label: { ... }
}- Added:
AppStateenvironment to access theactiveSheetproperty - Modified: The
.meetYourProfilecase completion handler - Behavior: Checks the
isCreatingFamilyFromSettingsflag and:- If
true:- Resets the flag
- Navigates to
.home - Waits 0.3 seconds for home to load
- Automatically reopens the Settings sheet (
appState.activeSheet = .settings)
- If
false: Normal flow - navigates to.home
- If
case .meetYourProfile:
MeetYourProfileView {
if coordinator.isCreatingFamilyFromSettings {
coordinator.isCreatingFamilyFromSettings = false
coordinator.showCanvas(.home)
Task { @MainActor in
try? await Task.sleep(nanoseconds: 300_000_000)
appState.activeSheet = .settings
}
} else {
coordinator.showCanvas(.home)
}
}- User opens Settings
- Sees "Create Family" button (even though they have a family, it's just them)
- Taps "Create Family"
- Goes through family creation flow
- Settings automatically reopens showing "Manage Family" ✨
- User opens Settings
- Sees "Create Family" button
- Taps "Create Family"
- Goes to "Let's meet your IngrediFam!" screen
- Sees "Your Family Overview" with their profile
- Adds family members
- Goes through dietary preferences
- Completes onboarding questions
- Sees AI chat and summary
- Returns to Home screen briefly
- Settings automatically reopens showing "Manage Family" instead of "Create Family" ✨
- User opens Settings
- Sees "Manage Family" button
- Taps it → Goes to ManageFamilyView (unchanged)
- When a user chooses "Just Me" during onboarding, the backend creates a family with only one member (themselves)
familyStore.family != nilwould betruefor these users- But they should still see "Create Family" to add more members
- Solution: Check
!family.otherMembers.isEmptyto distinguish between:- Just Me users:
family.otherMembers.isEmpty == true→ Show "Create Family" - Family users:
family.otherMembers.isEmpty == false→ Show "Manage Family"
- Just Me users:
- Minimal Changes: Reuses existing onboarding flow components
- Clean Separation: Uses a flag to track the source without modifying the entire flow
- Maintainable: Easy to understand and modify in the future
- Handles Edge Cases: Properly distinguishes between "Just Me" and actual families
- LetsMeetYourIngrediFamView: Shows "Your Family Overview" with the user's profile
- MeetYourIngrediFam: Shows "Let's meet your IngrediFam!" intro screen
- WhatsYourName: Allows user to enter their name
- AddMoreMembers: Allows adding family members
- DietaryPreferencesSheet: Dietary preferences selection
- MainCanvasView: Dynamic onboarding questions
- IngrediBotView: AI chat and summary
- MeetYourProfileView: Final profile review before completion
- "Just Me" user sees "Create Family" → Goes to family creation flow
- User with no family sees "Create Family" → Goes to family creation flow
- User completes family creation → Settings automatically reopens
- Settings shows "Manage Family" after adding members
- User with existing family (other members) sees "Manage Family" → Goes to ManageFamilyView
- Flag is properly reset after completion
- Normal onboarding flow (not from Settings) still works correctly
- The implementation leverages the existing family onboarding flow
- All UI components were already implemented - just needed proper navigation wiring
- The flag approach ensures clean separation between Settings-initiated and normal onboarding flows
- Critical Fix: Checking
otherMembers.isEmptyensures "Just Me" users can create a family