Skip to content

Commit 7cb5155

Browse files
committed
Addressed comments
1 parent ed24fba commit 7cb5155

File tree

4 files changed

+38
-33
lines changed

4 files changed

+38
-33
lines changed

app/src/main/java/com/cornellappdev/uplift/ui/components/capacityreminder/CapacityReminderLoading.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fun CapacityReminderLoading() {
5353

5454
val rotationAngle by infiniteTransition.animateFloat(
5555
initialValue = 0f,
56-
targetValue = 360f,animationSpec = infiniteRepeatable(
56+
targetValue = 360f, animationSpec = infiniteRepeatable(
5757
animation = tween(durationMillis = 2000, easing = LinearEasing),
5858
repeatMode = RepeatMode.Restart
5959
),
@@ -62,8 +62,8 @@ fun CapacityReminderLoading() {
6262

6363
val logoYOffset by infiniteTransition.animateValue(
6464
initialValue = 0.dp,
65-
targetValue = (-20).dp,animationSpec = infiniteRepeatable(
66-
animation = tween(durationMillis = 750, easing= EaseInOut),
65+
targetValue = (-20).dp, animationSpec = infiniteRepeatable(
66+
animation = tween(durationMillis = 750, easing = EaseInOut),
6767
repeatMode = RepeatMode.Reverse
6868
),
6969
label = "logoYOffset",
@@ -72,7 +72,7 @@ fun CapacityReminderLoading() {
7272

7373
val componentSize by infiniteTransition.animateFloat(
7474
initialValue = 1f,
75-
targetValue = 0.97f,animationSpec = infiniteRepeatable(
75+
targetValue = 0.97f, animationSpec = infiniteRepeatable(
7676
animation = tween(durationMillis = 750, easing = EaseInOut),
7777
repeatMode = RepeatMode.Reverse
7878
),
@@ -81,8 +81,8 @@ fun CapacityReminderLoading() {
8181

8282
val textOpacity by infiniteTransition.animateFloat(
8383
initialValue = 1f,
84-
targetValue = 0.5f,animationSpec = infiniteRepeatable(
85-
animation = tween(durationMillis = 750,easing = EaseInOut),
84+
targetValue = 0.5f, animationSpec = infiniteRepeatable(
85+
animation = tween(durationMillis = 750, easing = EaseInOut),
8686
repeatMode = RepeatMode.Reverse
8787
),
8888
label = "textOpacity"
@@ -95,17 +95,18 @@ fun CapacityReminderLoading() {
9595
animationSpec = infiniteRepeatable(
9696
animation = tween(
9797
durationMillis = 1500,
98-
easing = { fraction ->
99-
val step = 0.25f
100-
(fraction / step).toInt() * step
101-
}
98+
easing = LinearEasing
10299
),
103100
repeatMode = RepeatMode.Restart
104101
),
105102
label = "dotCount"
106103
)
107104

108-
Box(modifier = Modifier.fillMaxSize().background(Color(0xFFD9D9D9).copy(alpha=0.5f))){
105+
Box(
106+
modifier = Modifier
107+
.fillMaxSize()
108+
.background(Color(0xFFD9D9D9).copy(alpha = 0.5f))
109+
) {
109110
Box(
110111
modifier = Modifier
111112
.height((270 * componentSize).toInt().dp)

app/src/main/java/com/cornellappdev/uplift/ui/components/capacityreminder/CapacityReminderTutorial.kt

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,19 @@ fun CapacityReminderTutorial(
5050
LaunchedEffect(Unit) {
5151
offsetY.animateTo(
5252
targetValue = 0f,
53-
animationSpec = tween(durationMillis = 1000)
53+
animationSpec = tween(durationMillis = 1500)
5454
)
5555
}
5656
Column(
5757
modifier = Modifier
5858
.width(300.dp)
5959
.clip(RoundedCornerShape(20.dp))
6060
) {
61-
Box(modifier = Modifier
62-
.height(175.dp)
63-
.clipToBounds()) {
61+
Box(
62+
modifier = Modifier
63+
.height(175.dp)
64+
.clipToBounds()
65+
) {
6466
Box(
6567
modifier = Modifier
6668
.matchParentSize()
@@ -161,21 +163,23 @@ fun CapacityReminderTutorial(
161163
containerColor = PRIMARY_BLACK,
162164
contentColor = Color.White,
163165
modifier = Modifier.fillMaxWidth(),
164-
onClick = onAccept)
166+
onClick = onAccept
167+
)
165168
Spacer(modifier = Modifier.height(8.dp))
166169
UpliftButton(
167170
text = "Maybe later",
168171
containerColor = Color.White,
169172
contentColor = GRAY03,
170173
modifier = Modifier.fillMaxWidth(),
171174
elevation = 0.dp,
172-
onClick = onDismiss)
175+
onClick = onDismiss
176+
)
173177
}
174178
}
175179
}
176180

177181
@Preview
178182
@Composable
179183
fun CapacityReminderTutorialPreview() {
180-
CapacityReminderTutorial({},{})
184+
CapacityReminderTutorial({}, {})
181185
}

app/src/main/java/com/cornellappdev/uplift/ui/screens/gyms/HomeScreen.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.cornellappdev.uplift.ui.screens.gyms
22

3-
import android.annotation.SuppressLint
43
import androidx.compose.animation.Crossfade
54
import androidx.compose.foundation.background
65
import androidx.compose.foundation.layout.Box
@@ -33,7 +32,6 @@ import kotlinx.coroutines.delay
3332
/**
3433
* The home page of Uplift.
3534
*/
36-
@SuppressLint("UnusedCrossfadeTargetStateParameter")
3735
@OptIn(ExperimentalPermissionsApi::class)
3836
@Composable
3937
fun HomeScreen(
@@ -68,7 +66,7 @@ fun HomeScreen(
6866
LocationRepository.instantiate(context)
6967
}
7068

71-
Box(modifier = Modifier.fillMaxSize()){
69+
Box(modifier = Modifier.fillMaxSize()) {
7270
Crossfade(targetState = gymsState, label = "Main") {
7371
when {
7472
gymsLoading -> MainLoading(loadingShimmer)
@@ -86,14 +84,17 @@ fun HomeScreen(
8684
}
8785
}
8886

89-
if(showTutorial) {
90-
Box(modifier = Modifier.fillMaxSize().background(GRAY04.copy(alpha=0.5f))){
91-
Box(modifier = Modifier.align(Alignment.Center)) {
92-
CapacityReminderTutorial(
93-
onAccept = { homeViewModel.navigateToCapacityReminders() },
94-
onDismiss = { homeViewModel.onTutorialDismissed() },
95-
)
96-
}
87+
if (showTutorial) {
88+
Box(
89+
modifier = Modifier
90+
.fillMaxSize()
91+
.background(GRAY04.copy(alpha = 0.5f)),
92+
contentAlignment = Alignment.Center
93+
) {
94+
CapacityReminderTutorial(
95+
onAccept = { homeViewModel.navigateToCapacityReminders() },
96+
onDismiss = { homeViewModel.onTutorialDismissed() },
97+
)
9798
}
9899
}
99100
}

app/src/main/java/com/cornellappdev/uplift/ui/viewmodels/gyms/HomeViewModel.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import com.cornellappdev.uplift.util.getSystemTime
1515
import dagger.hilt.android.lifecycle.HiltViewModel
1616
import kotlinx.coroutines.flow.SharingStarted
1717
import kotlinx.coroutines.flow.StateFlow
18-
import kotlinx.coroutines.flow.first
18+
import kotlinx.coroutines.flow.firstOrNull
1919
import kotlinx.coroutines.flow.map
2020
import kotlinx.coroutines.flow.stateIn
2121
import kotlinx.coroutines.launch
@@ -106,7 +106,7 @@ class HomeViewModel @Inject constructor(
106106

107107
fun navigateToCapacityReminders() {
108108
viewModelScope.launch {
109-
if (!datastoreRepository.hasShownCapacityTutorial().first()) {
109+
if (datastoreRepository.hasShownCapacityTutorial().firstOrNull() == false) {
110110
datastoreRepository.storePreference(
111111
key = PreferencesKeys.CAPACITY_REMINDERS_TUTORIAL_SHOWN,
112112
value = true
@@ -122,7 +122,7 @@ class HomeViewModel @Inject constructor(
122122
}
123123
.stateIn(
124124
scope = viewModelScope,
125-
started = SharingStarted.WhileSubscribed(5_000),
125+
started = SharingStarted.Eagerly,
126126
initialValue = false
127127
)
128128

@@ -133,6 +133,5 @@ class HomeViewModel @Inject constructor(
133133
value = true
134134
)
135135
}
136-
rootNavigationRepository.navigateUp()
137136
}
138137
}

0 commit comments

Comments
 (0)