Skip to content

Commit 0b8a774

Browse files
Addressed comments
1 parent 99d0cc1 commit 0b8a774

2 files changed

Lines changed: 22 additions & 28 deletions

File tree

app/src/main/java/com/cornellappdev/uplift/MainActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ class MainActivity : ComponentActivity() {
4444
override fun onResume() {
4545
super.onResume()
4646
LocationRepository.startLocationUpdates(this)
47-
if (CHECK_IN_FLAG == true){
47+
if (CHECK_IN_FLAG){
4848
checkInViewModel.startLocationUpdates(this)
4949
}
5050
}
5151

5252
override fun onPause() {
5353
super.onPause()
5454
LocationRepository.stopLocationUpdates()
55-
if (CHECK_IN_FLAG == true){
55+
if (CHECK_IN_FLAG){
5656
checkInViewModel.stopLocationUpdates()
5757
}
5858
}

app/src/main/java/com/cornellappdev/uplift/ui/MainNavigationWrapper.kt

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ import androidx.compose.material.Text
1313
import androidx.compose.runtime.Composable
1414
import androidx.compose.runtime.LaunchedEffect
1515
import androidx.compose.runtime.getValue
16-
import androidx.compose.runtime.mutableStateOf
17-
import androidx.compose.runtime.remember
18-
import androidx.compose.runtime.setValue
1916
import androidx.compose.ui.Alignment
2017
import androidx.compose.ui.Modifier
21-
import androidx.compose.ui.geometry.Rect
2218
import androidx.compose.ui.graphics.Color
2319
import androidx.compose.ui.layout.boundsInRoot
2420
import 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

Comments
 (0)