Repository navigation
[2/3] Onboarding profile picture selection screen #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
64ed51c
first draft of onboarding animation
amjiao f7bd25d
Complete animation
amjiao 571bcac
Complete onboarding animation
amjiao cdfaf5e
remove onboarding preview screen from commit
amjiao 2e6d25b
Clean up OnboardingScreen.kt
amjiao 70345f9
Merge branch 'main' of https://github.com/cuappdev/score-android into…
amjiao 539833c
Merge branch 'main' into onboarding
amjiao 5a9d900
Onboarding profile picture selection
amjiao 617b178
Onboarding profile picture selection
amjiao 996fcf7
Merge branch 'onboarding2' of https://github.com/cuappdev/score-andro…
amjiao a645f2d
Make screen name more informative
amjiao f69c41e
Rename file
amjiao 122ab35
Fix profile selector defaults
amjiao dc900f2
Change onboarding state representation from int to enum
amjiao ed21b71
Change manual scaling to adaptive
amjiao d580f98
Onboarding profile picture selection
amjiao 3ebccad
Make screen name more informative
amjiao 62db4eb
Rename file
amjiao 247fd88
Fix profile selector defaults
amjiao 39a605e
Change onboarding state representation from int to enum
amjiao dda86eb
Change manual scaling to adaptive
amjiao 24d68df
Merge branch 'onboarding2' of https://github.com/cuappdev/score-andro…
amjiao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
166 changes: 166 additions & 0 deletions
166
app/src/main/java/com/cornellappdev/score/screen/OnboardingProfileSelectScreen.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| package com.cornellappdev.score.screen | ||
|
|
||
| import androidx.compose.foundation.Image | ||
| import androidx.compose.foundation.background | ||
| import androidx.compose.foundation.layout.Arrangement | ||
| import androidx.compose.foundation.layout.Box | ||
| import androidx.compose.foundation.layout.BoxWithConstraints | ||
| import androidx.compose.foundation.layout.Column | ||
| import androidx.compose.foundation.layout.Spacer | ||
| import androidx.compose.foundation.layout.fillMaxSize | ||
| import androidx.compose.foundation.layout.fillMaxWidth | ||
| import androidx.compose.foundation.layout.height | ||
| import androidx.compose.foundation.layout.padding | ||
| import androidx.compose.foundation.layout.size | ||
| import androidx.compose.foundation.shape.CircleShape | ||
| import androidx.compose.material3.Button | ||
| import androidx.compose.material3.ButtonDefaults | ||
| import androidx.compose.material3.Text | ||
| import androidx.compose.runtime.Composable | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.saveable.rememberSaveable | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.Alignment | ||
| import androidx.compose.ui.Modifier | ||
| import androidx.compose.ui.graphics.Color | ||
| import androidx.compose.ui.res.painterResource | ||
| import androidx.compose.ui.res.stringResource | ||
| import androidx.compose.ui.text.style.TextAlign | ||
| import androidx.compose.ui.tooling.preview.Preview | ||
| import androidx.compose.ui.unit.Dp | ||
| import androidx.compose.ui.unit.dp | ||
| import com.cornellappdev.score.R | ||
| import com.cornellappdev.score.theme.CrimsonPrimary | ||
| import com.cornellappdev.score.theme.GrayStroke | ||
| import com.cornellappdev.score.theme.Style | ||
|
|
||
| @Composable | ||
| fun OnboardingProfileSelectScreen( | ||
| onNext: (ProfilePicture) -> Unit, | ||
| modifier: Modifier = Modifier, | ||
| displayName: String? = null | ||
| ) { | ||
| var selectedPicture by rememberSaveable { mutableStateOf(ProfilePicture.BLANK) } | ||
| val name = displayName ?: stringResource(R.string.onboarding_default_name) | ||
|
amjiao marked this conversation as resolved.
Resolved
|
||
|
|
||
| Box( | ||
| modifier = modifier | ||
| .fillMaxSize() | ||
| .background(Color.White) | ||
| ) { | ||
| Column(modifier = Modifier.fillMaxSize()) { | ||
| Column( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding(top = 80.dp), | ||
| horizontalAlignment = Alignment.CenterHorizontally | ||
| ) { | ||
| Text( | ||
| text = stringResource(R.string.edit_profile), | ||
| style = Style.heading1, | ||
| color = Color(0xFF333333) | ||
| ) | ||
| Spacer(Modifier.height(4.dp)) | ||
| Text( | ||
| text = stringResource(R.string.onboarding_profile_subtitle), | ||
| style = Style.bodyMedium, | ||
| color = Color(0xFF333333) | ||
| ) | ||
|
|
||
| Spacer(Modifier.height(40.dp)) | ||
| Image( | ||
| painter = painterResource(selectedPicture.drawable), | ||
| contentDescription = stringResource( | ||
| R.string.selected_profile_picture, | ||
| stringResource(selectedPicture.label) | ||
| ), | ||
| modifier = Modifier.size(100.dp) | ||
| ) | ||
| Spacer(Modifier.height(16.dp)) | ||
| Text( | ||
| text = name, | ||
| style = Style.bodyMedium, | ||
| color = Color.Black | ||
| ) | ||
|
|
||
| Spacer(Modifier.height(60.dp)) | ||
| Text( | ||
| text = stringResource(R.string.onboarding_select_profile_picture), | ||
| style = Style.metricMedium, | ||
| color = Color.Black, | ||
| textAlign = TextAlign.Center, | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding(horizontal = 24.dp) | ||
| ) | ||
| Spacer(Modifier.height(24.dp)) | ||
| ProfilePictureOptions( | ||
| selectedPicture = selectedPicture, | ||
| onPictureSelected = { selectedPicture = it }, | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) | ||
| } | ||
|
|
||
| Spacer(Modifier.weight(1f)) | ||
| OnboardingProfileFooter( | ||
| onNext = { onNext(selectedPicture) } | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun OnboardingProfileFooter( | ||
| onNext: () -> Unit, | ||
| ) { | ||
| Column( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .padding( | ||
| start = 24.dp, | ||
| end = 24.dp, | ||
| top = 24.dp, | ||
| bottom = 60.dp | ||
| ), | ||
| horizontalAlignment = Alignment.CenterHorizontally | ||
| ) { | ||
| Button( | ||
| onClick = onNext, | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .height(48.dp), | ||
| shape = CircleShape, | ||
| colors = ButtonDefaults.buttonColors( | ||
| containerColor = CrimsonPrimary, | ||
| contentColor = Color.White | ||
| ) | ||
| ) { | ||
| Text( | ||
| text = stringResource(R.string.next), | ||
| style = Style.heading3, | ||
| color = Color.White | ||
| ) | ||
| } | ||
|
|
||
| Spacer(Modifier.height(16.dp)) | ||
| RowProgressDots() | ||
| } | ||
| } | ||
|
|
||
| @Composable | ||
| private fun RowProgressDots() { | ||
| androidx.compose.foundation.layout.Row( | ||
| horizontalArrangement = Arrangement.spacedBy(4.dp), | ||
| verticalAlignment = Alignment.CenterVertically | ||
| ) { | ||
| Box(Modifier.size(8.dp).background(CrimsonPrimary, CircleShape)) | ||
|
amjiao marked this conversation as resolved.
Resolved
|
||
| Box(Modifier.size(8.dp).background(GrayStroke, CircleShape)) | ||
| } | ||
| } | ||
|
|
||
| @Preview(showBackground = true) | ||
| @Composable | ||
| private fun OnboardingProfileSelectScreenPreview() { | ||
| OnboardingProfileSelectScreen(onNext = {}) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.