Skip to content

Update calorie bar in dashboard when switching from nutrition #414

@georgegeorge2525

Description

@georgegeorge2525

--- a/composeApp/src/commonMain/kotlin/com/evolvefit/app/ui/screen/home/HomeScreen.kt
+++ b/composeApp/src/commonMain/kotlin/com/evolvefit/app/ui/screen/home/HomeScreen.kt
@@ -1,6 +1,7 @@
package com.evolvefit.app.ui.screen.home

import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import com.evolvefit.app.ui.navigation.NavBarRoute
@@ -19,6 +20,11 @@
) {
val state by homeViewModel.screenState.collectAsState()

  • // This LaunchedEffect will re-fetch nutrition data when the screen becomes active
  • LaunchedEffect(Unit) {
  •    homeViewModel.onReturnToScreen()
    
  • }
  • HandleHomeEffects(
    homeViewModel = homeViewModel,
    navigateToWorkout = navigateToWorkout,

--- a/composeApp/src/commonMain/kotlin/com/evolvefit/app/viewmodel/home/HomeViewModel.kt
+++ b/composeApp/src/commonMain/kotlin/com/evolvefit/app/viewmodel/home/HomeViewModel.kt
@@ -29,6 +29,11 @@
loadAllData()
}

  • // New function to be called when the screen becomes active
  • fun onReturnToScreen() {
  •    loadNutrition()
    
  • }
  • private fun loadAllData() {
    startLoading()
    loadUserInfo()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions