@@ -13,12 +13,8 @@ import androidx.compose.material.Text
1313import androidx.compose.runtime.Composable
1414import androidx.compose.runtime.LaunchedEffect
1515import androidx.compose.runtime.getValue
16- import androidx.compose.runtime.mutableStateOf
17- import androidx.compose.runtime.remember
18- import androidx.compose.runtime.setValue
1916import androidx.compose.ui.Alignment
2017import androidx.compose.ui.Modifier
21- import androidx.compose.ui.geometry.Rect
2218import androidx.compose.ui.graphics.Color
2319import androidx.compose.ui.layout.boundsInRoot
2420import androidx.compose.ui.layout.onGloballyPositioned
@@ -89,13 +85,6 @@ fun MainNavigationWrapper(
8985 val navController = rememberNavController()
9086 val systemUiController: SystemUiController = rememberSystemUiController()
9187
92- val checkInViewModel: CheckInViewModel ? =
93- if (CHECK_IN_FLAG ) hiltViewModel() else null
94- val confettiViewModel: ConfettiViewModel ? =
95- if (CHECK_IN_FLAG ) hiltViewModel() else null
96- val checkInUiState = checkInViewModel?.collectUiStateValue() ? : CheckInUiState ()
97- val confettiUiState = confettiViewModel?.collectUiStateValue()
98-
9988 val yourShimmerTheme = defaultShimmerTheme.copy(
10089 shaderColors = listOf (
10190 Color .Unspecified .copy(alpha = 1f ),
@@ -264,8 +253,13 @@ fun MainNavigationWrapper(
264253 composable<UpliftRootRoute .Favorites > {}
265254 }
266255
267- Box (modifier = Modifier .fillMaxSize()){
268- if (CHECK_IN_FLAG ){
256+ Box (modifier = Modifier .fillMaxSize()) {
257+ if (CHECK_IN_FLAG ) {
258+ val checkInViewModel: CheckInViewModel = hiltViewModel()
259+ val confettiViewModel: ConfettiViewModel = hiltViewModel()
260+ val checkInUiState = checkInViewModel.collectUiStateValue()
261+ val confettiUiState = confettiViewModel.collectUiStateValue()
262+
269263 AnimatedVisibility (
270264 visible = checkInUiState.showPopUp && isMainScreen(),
271265 modifier = Modifier
@@ -276,29 +270,29 @@ fun MainNavigationWrapper(
276270 end = 9 .dp,
277271 bottom = it.calculateBottomPadding() + 13 .dp
278272 )
279- ){
273+ ) {
280274 Box (
281275 modifier = Modifier .onGloballyPositioned { coords ->
282- confettiViewModel? .setConfettiBounds(coords.boundsInRoot())
276+ confettiViewModel.setConfettiBounds(coords.boundsInRoot())
283277 }
284- ){
278+ ) {
285279 CheckInPopUp (
286280 gymName = checkInUiState.gymName,
287281 currentTimeText = checkInUiState.timeText,
288- onDismiss = { checkInViewModel?. onDismiss() } ,
289- onCheckIn = { checkInViewModel?. onCheckIn() } ,
290- onClosePopUp = { checkInViewModel?. onClose() } ,
282+ onDismiss = checkInViewModel:: onDismiss,
283+ onCheckIn = checkInViewModel:: onCheckIn,
284+ onClosePopUp = checkInViewModel:: onClose,
291285 mode = checkInUiState.mode,
292286 )
293287 }
294288 }
295- if (confettiViewModel != null ){
296- ConfettiBurst (
297- confettiViewModel = confettiViewModel,
298- particleSpawningBounds = confettiUiState? .confettiBounds,
299- modifier = Modifier
300- )
301- }
289+
290+ ConfettiBurst (
291+ confettiViewModel = confettiViewModel,
292+ particleSpawningBounds = confettiUiState.confettiBounds,
293+ modifier = Modifier
294+ )
295+
302296 }
303297 }
304298
0 commit comments