|
| 1 | +package com.cornellappdev.uplift.ui.screens.onboarding |
| 2 | + |
| 3 | +import androidx.compose.foundation.background |
| 4 | +import androidx.compose.foundation.layout.Arrangement |
| 5 | +import androidx.compose.foundation.layout.Column |
| 6 | +import androidx.compose.foundation.layout.fillMaxSize |
| 7 | +import androidx.compose.foundation.layout.height |
| 8 | +import androidx.compose.foundation.layout.padding |
| 9 | +import androidx.compose.foundation.rememberScrollState |
| 10 | +import androidx.compose.foundation.verticalScroll |
| 11 | +import androidx.compose.material3.ExperimentalMaterial3Api |
| 12 | +import androidx.compose.material3.Scaffold |
| 13 | +import androidx.compose.material3.Text |
| 14 | +import androidx.compose.material3.TopAppBar |
| 15 | +import androidx.compose.material3.TopAppBarDefaults |
| 16 | +import androidx.compose.runtime.Composable |
| 17 | +import androidx.compose.runtime.getValue |
| 18 | +import androidx.compose.runtime.mutableFloatStateOf |
| 19 | +import androidx.compose.runtime.remember |
| 20 | +import androidx.compose.runtime.setValue |
| 21 | +import androidx.compose.ui.Modifier |
| 22 | +import androidx.compose.ui.draw.shadow |
| 23 | +import androidx.compose.ui.graphics.Color |
| 24 | +import androidx.compose.ui.text.font.FontWeight |
| 25 | +import androidx.compose.ui.text.style.TextAlign |
| 26 | +import androidx.compose.ui.tooling.preview.Preview |
| 27 | +import androidx.compose.ui.unit.dp |
| 28 | +import androidx.compose.ui.unit.sp |
| 29 | +import com.cornellappdev.uplift.ui.components.goalsetting.GoalSlider |
| 30 | +import com.cornellappdev.uplift.util.GRAY01 |
| 31 | +import com.cornellappdev.uplift.util.montserratFamily |
| 32 | + |
| 33 | +/** |
| 34 | + * @param goalValue: value of the goal slider |
| 35 | + * @param onGoalValueChange: callback for when the goal slider value is changed |
| 36 | + * @return GoalPromptScreen composable |
| 37 | + */ |
| 38 | +@OptIn(ExperimentalMaterial3Api::class) |
| 39 | +@Composable |
| 40 | +fun GoalPromptScreen( |
| 41 | + /* TODO: Replace functions with viewmodel calls */ |
| 42 | + goalValue: Float, |
| 43 | + onGoalValueChange: (Float) -> Unit |
| 44 | +) { |
| 45 | + |
| 46 | + Scaffold( |
| 47 | + topBar = { |
| 48 | + TopAppBar( |
| 49 | + title = { |
| 50 | + Text( |
| 51 | + text = "Set your goals.", |
| 52 | + modifier = Modifier.padding(top = 20.dp), |
| 53 | + fontSize = 24.sp, |
| 54 | + fontFamily = montserratFamily, |
| 55 | + fontWeight = FontWeight.Bold, |
| 56 | + textAlign = TextAlign.Left |
| 57 | + ) |
| 58 | + }, |
| 59 | + modifier = Modifier |
| 60 | + .height(120.dp) |
| 61 | + .shadow(elevation = 20.dp, ambientColor = GRAY01), |
| 62 | + colors = TopAppBarDefaults.topAppBarColors( |
| 63 | + containerColor = Color.White, |
| 64 | + ) |
| 65 | + |
| 66 | + ) |
| 67 | + }, |
| 68 | + modifier = Modifier.fillMaxSize(), |
| 69 | + ) { padding -> |
| 70 | + Column( |
| 71 | + modifier = Modifier |
| 72 | + .background(color = Color.White) |
| 73 | + .padding( |
| 74 | + top = padding.calculateTopPadding(), |
| 75 | + ) |
| 76 | + .fillMaxSize() |
| 77 | + .verticalScroll(rememberScrollState()), |
| 78 | + verticalArrangement = Arrangement.SpaceBetween |
| 79 | + ) { |
| 80 | + /* Groups the goal slider and workout reminders together */ |
| 81 | + Column { |
| 82 | + GoalSlider(value = goalValue, onValueChange = onGoalValueChange) |
| 83 | + |
| 84 | + } |
| 85 | + } |
| 86 | + |
| 87 | + } |
| 88 | +} |
| 89 | + |
| 90 | + |
| 91 | +@Preview(showBackground = true) |
| 92 | +@Composable |
| 93 | +fun GoalPromptScreenPreview() { |
| 94 | + var sliderVal by remember { mutableFloatStateOf(1f) } |
| 95 | + GoalPromptScreen(goalValue = sliderVal, onGoalValueChange = { sliderVal = it }) |
| 96 | +} |
0 commit comments