Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ fun EmptyProfileScreen(modifier: Modifier = Modifier) {
var selectedPicture by rememberSaveable { mutableStateOf(ProfilePicture.BLANK) }
var editingPicture by rememberSaveable { mutableStateOf(false) }

BackHandler(enabled = editingPicture) { editingPicture = false }
var showingSettings by rememberSaveable { mutableStateOf(false) }
BackHandler(enabled = editingPicture || showingSettings) {
editingPicture = false
showingSettings = false
}
Column(modifier
.fillMaxSize()
.background(Color.White)) {
Box(Modifier.weight(1f)) {
if (editingPicture) {
if (showingSettings) {
SettingsScreen(onBack = { showingSettings = false })
} else if (editingPicture) {
EditProfileScreen(
selectedPicture = selectedPicture,
onPictureSelected = { selectedPicture = it },
Expand All @@ -67,11 +73,12 @@ fun EmptyProfileScreen(modifier: Modifier = Modifier) {
} else {
EmptyProfileContent(
selectedPicture = selectedPicture,
onEditProfilePicture = { editingPicture = true }
onEditProfilePicture = { editingPicture = true },
onSettings = { showingSettings = true }
)
}
}
ProfileTabBar()
if (!showingSettings) ProfileTabBar()
}
}

Expand All @@ -80,7 +87,8 @@ fun EmptyProfileScreen(modifier: Modifier = Modifier) {
fun EmptyProfileContent(
selectedPicture: ProfilePicture,
onEditProfilePicture: () -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
onSettings: () -> Unit = {}
) {
Column(
modifier
Expand All @@ -89,7 +97,7 @@ fun EmptyProfileContent(
.padding(horizontal = 24.dp)
.padding(top = 8.dp, bottom = 32.dp)
) {
ProfileIdentityHeader(selectedPicture, onEditProfilePicture)
ProfileIdentityHeader(selectedPicture, onEditProfilePicture, onSettings = onSettings)
ProfileSectionDivider()
ProfileSectionHeading(R.string.profile_favorite_sports, R.string.profile_edit, Color.Black)
Spacer(Modifier.height(16.dp))
Expand Down Expand Up @@ -163,7 +171,8 @@ internal fun ProfileIdentityHeader(
selectedPicture: ProfilePicture,
onEditProfilePicture: () -> Unit,
compact: Boolean = false,
displayName: String = stringResource(R.string.profile_placeholder_name)
displayName: String = stringResource(R.string.profile_placeholder_name),
onSettings: () -> Unit = {}
) {
Column {
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
Expand All @@ -181,7 +190,7 @@ internal fun ProfileIdentityHeader(
Icon(
painterResource(R.drawable.profile_settings),
stringResource(R.string.profile_settings),
Modifier.size(32.dp),
Modifier.size(32.dp).clickable(role = Role.Button, onClick = onSettings),
tint = Color.Unspecified
)
}
Expand Down
18 changes: 12 additions & 6 deletions app/src/main/java/com/cornellappdev/score/screen/ProfileScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ fun ProfileScreen(
var selectedPicture by rememberSaveable { mutableStateOf(ProfilePicture.TENNIS) }
var editingPicture by rememberSaveable { mutableStateOf(false) }

var showingSettings by rememberSaveable { mutableStateOf(false) }
var editingSports by rememberSaveable { mutableStateOf(false) }
var favorites by rememberSaveable(data.favorites, stateSaver = listSaver<List<ProfileFavorite>, String>(
save = { list -> list.map { "${it.sport.name}:${it.gender.name}" } },
Expand All @@ -83,13 +84,16 @@ fun ProfileScreen(
} }
)) { mutableStateOf(data.favorites) }

BackHandler(enabled = editingPicture || editingSports) {
BackHandler(enabled = editingPicture || editingSports || showingSettings) {
editingPicture = false
editingSports = false
showingSettings = false
}
Column(modifier.fillMaxSize().background(Color.White)) {
Box(Modifier.weight(1f)) {
if (editingSports) {
if (showingSettings) {
SettingsScreen(onBack = { showingSettings = false })
} else if (editingSports) {
EditFavoriteSportsScreen(
favorites = favorites,
onToggleFavorite = { favorite ->
Expand All @@ -108,11 +112,12 @@ fun ProfileScreen(
editingSports = true
onEditSports()
},
onShowAllBookmarks = onShowAllBookmarks
onShowAllBookmarks = onShowAllBookmarks,
onSettings = { showingSettings = true }
)
}
}
if (!editingSports) ProfileTabBar()
if (!editingSports && !showingSettings) ProfileTabBar()
}
}

Expand All @@ -124,11 +129,12 @@ fun ProfileContent(
onEditProfilePicture: () -> Unit,
onEditSports: () -> Unit,
onShowAllBookmarks: () -> Unit,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
onSettings: () -> Unit = {}
) {
Column(modifier.fillMaxSize().verticalScroll(rememberScrollState()).padding(top = 24.dp, bottom = 32.dp)) {
Column(Modifier.padding(horizontal = 24.dp)) {
ProfileIdentityHeader(selectedPicture, onEditProfilePicture, compact = true, displayName = data.name)
ProfileIdentityHeader(selectedPicture, onEditProfilePicture, compact = true, displayName = data.name, onSettings = onSettings)
ProfileSectionDivider()
ProfileActionHeading(R.string.profile_favorite_sports, R.string.profile_edit, onEditSports)
}
Expand Down
105 changes: 105 additions & 0 deletions app/src/main/java/com/cornellappdev/score/screen/SettingsScreen.kt

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you format this file?

Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package com.cornellappdev.score.screen

import androidx.annotation.DrawableRes
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
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.semantics.Role
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.cornellappdev.score.R
import com.cornellappdev.score.components.NavigationHeader
import com.cornellappdev.score.theme.CrimsonPrimary
import com.cornellappdev.score.theme.GrayMedium
import com.cornellappdev.score.theme.GrayPrimary
import com.cornellappdev.score.theme.GrayStroke
import com.cornellappdev.score.theme.Style

@Composable
fun SettingsScreen(onBack: () -> Unit, modifier: Modifier = Modifier) {
Column(modifier.fillMaxSize().background(Color.White)) {
NavigationHeader(stringResource(R.string.profile_settings), onBack)
Column(
Modifier.fillMaxWidth().verticalScroll(rememberScrollState()).padding(24.dp, 32.dp),
verticalArrangement = Arrangement.spacedBy(28.dp)
) {
SettingsSection(stringResource(R.string.settings_preferences)) {
SettingsRow(stringResource(R.string.profile_favorite_sports), R.drawable.settings_star)
HorizontalDivider(color = GrayStroke)
SettingsRow(stringResource(R.string.profile_notifications), R.drawable.settings_notifications, iconSize = 28.dp)
}
SettingsSection(stringResource(R.string.settings_help)) {
SettingsRow(stringResource(R.string.settings_about), R.drawable.settings_info, iconSize = 33.dp)
HorizontalDivider(color = GrayStroke)
SettingsRow(stringResource(R.string.settings_report), R.drawable.settings_flag)
HorizontalDivider(color = GrayStroke)
SettingsRow(stringResource(R.string.settings_logout), R.drawable.settings_logout, destructive = true)
HorizontalDivider(color = GrayStroke)
SettingsRow(stringResource(R.string.settings_delete), R.drawable.settings_delete, destructive = true)
}
}
}
}

@Composable
private fun SettingsSection(title: String, content: @Composable () -> Unit) {
Column(verticalArrangement = Arrangement.spacedBy(12.dp)) {
Text(title, style = Style.bodyMedium, color = GrayPrimary)
Column(
Modifier.fillMaxWidth().border(1.dp, GrayStroke, RoundedCornerShape(16.dp))
.padding(start = 16.dp, end = 20.dp),
content = { content() }
)
}
}

@Composable
private fun SettingsRow(
title: String,
@DrawableRes icon: Int,
iconSize: Dp = 30.dp,
destructive: Boolean = false
) {
// Placeholder actions intentionally do nothing until the settings flows are implemented.
Row(
Modifier.fillMaxWidth().clickable(role = Role.Button, onClick = {}).padding(vertical = 16.dp),
verticalAlignment = Alignment.CenterVertically
) {
Icon(painterResource(icon), null, Modifier.size(iconSize), tint = Color.Unspecified)
Spacer(Modifier.width(10.dp))
Text(title, style = Style.bodyMedium.copy(fontSize = 16.sp),
color = if (destructive) CrimsonPrimary else GrayPrimary, modifier = Modifier.weight(1f))
if (!destructive) {
Icon(painterResource(R.drawable.ic_right_chevron), null, Modifier.size(24.dp), tint = GrayMedium)
}
}
}

@Preview(showBackground = true, widthDp = 393, heightDp = 805)
@Composable
private fun SettingsScreenPreview() {
SettingsScreen(onBack = {})
}
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/settings_delete.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:pathData="M7.5,23.75C7.5,25.125 8.625,26.25 10,26.25H20C21.375,26.25 22.5,25.125 22.5,23.75V11.25C22.5,9.875 21.375,8.75 20,8.75H10C8.625,8.75 7.5,9.875 7.5,11.25V23.75ZM11.25,11.25H18.75C19.438,11.25 20,11.813 20,12.5V22.5C20,23.188 19.438,23.75 18.75,23.75H11.25C10.563,23.75 10,23.188 10,22.5V12.5C10,11.813 10.563,11.25 11.25,11.25ZM19.375,5L18.487,4.113C18.263,3.888 17.938,3.75 17.612,3.75H12.387C12.063,3.75 11.738,3.888 11.512,4.113L10.625,5H7.5C6.813,5 6.25,5.563 6.25,6.25C6.25,6.938 6.813,7.5 7.5,7.5H22.5C23.188,7.5 23.75,6.938 23.75,6.25C23.75,5.563 23.188,5 22.5,5H19.375Z"
android:fillColor="#A5210D"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/settings_flag.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:pathData="M16.875,6.875L15.975,5.063C15.762,4.637 15.325,4.375 14.85,4.375H6.875C6.188,4.375 5.625,4.938 5.625,5.625V24.375C5.625,25.063 6.188,25.625 6.875,25.625C7.563,25.625 8.125,25.063 8.125,24.375V16.875H14.375L15.275,18.688C15.488,19.112 15.925,19.375 16.388,19.375H23.125C23.813,19.375 24.375,18.813 24.375,18.125V8.125C24.375,7.438 23.813,6.875 23.125,6.875H16.875ZM21.875,16.875H16.875L15.625,14.375H8.125V6.875H14.375L15.625,9.375H21.875V16.875Z"
android:fillColor="#333333"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/settings_info.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="33dp"
android:height="33dp"
android:viewportWidth="33"
android:viewportHeight="33">
<path
android:pathData="M15.125,9.625H17.875V12.375H15.125V9.625ZM15.125,15.125H17.875V23.375H15.125V15.125ZM16.5,2.75C8.91,2.75 2.75,8.91 2.75,16.5C2.75,24.09 8.91,30.25 16.5,30.25C24.09,30.25 30.25,24.09 30.25,16.5C30.25,8.91 24.09,2.75 16.5,2.75ZM16.5,27.5C10.436,27.5 5.5,22.564 5.5,16.5C5.5,10.436 10.436,5.5 16.5,5.5C22.564,5.5 27.5,10.436 27.5,16.5C27.5,22.564 22.564,27.5 16.5,27.5Z"
android:fillColor="#333333"/>
</vector>
12 changes: 12 additions & 0 deletions app/src/main/res/drawable/settings_logout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:pathData="M6.38,6.25H13.88C14.568,6.25 15.13,5.688 15.13,5C15.13,4.313 14.568,3.75 13.88,3.75H6.38C5.005,3.75 3.88,4.875 3.88,6.25V23.75C3.88,25.125 5.005,26.25 6.38,26.25H13.88C14.568,26.25 15.13,25.688 15.13,25C15.13,24.313 14.568,23.75 13.88,23.75H6.38V6.25Z"
android:fillColor="#A5210D"/>
<path
android:pathData="M25.943,14.563L22.455,11.075C22.056,10.675 21.381,10.95 21.381,11.512V13.75H12.63C11.943,13.75 11.38,14.313 11.38,15C11.38,15.688 11.943,16.25 12.63,16.25H21.381V18.487C21.381,19.05 22.056,19.325 22.443,18.925L25.931,15.438C26.181,15.2 26.181,14.8 25.943,14.563Z"
android:fillColor="#A5210D"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/settings_notifications.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="28dp"
android:height="28dp"
android:viewportWidth="28"
android:viewportHeight="28">
<path
android:pathData="M5.833,22.167C5.503,22.167 5.226,22.055 5.002,21.831C4.778,21.608 4.667,21.331 4.667,21C4.667,20.669 4.778,20.392 5.002,20.169C5.226,19.945 5.503,19.833 5.833,19.833H7V11.667C7,10.053 7.486,8.619 8.458,7.365C9.431,6.11 10.694,5.289 12.25,4.9V4.083C12.25,3.597 12.42,3.184 12.76,2.844C13.101,2.503 13.514,2.333 14,2.333C14.486,2.333 14.899,2.503 15.24,2.844C15.58,3.184 15.75,3.597 15.75,4.083V4.9C17.306,5.289 18.569,6.11 19.542,7.365C20.514,8.619 21,10.053 21,11.667V19.833H22.167C22.497,19.833 22.774,19.945 22.998,20.169C23.222,20.392 23.333,20.669 23.333,21C23.333,21.331 23.222,21.608 22.998,21.831C22.774,22.055 22.497,22.167 22.167,22.167H5.833ZM14,25.667C13.358,25.667 12.809,25.438 12.352,24.981C11.895,24.524 11.667,23.975 11.667,23.333H16.333C16.333,23.975 16.105,24.524 15.648,24.981C15.191,25.438 14.642,25.667 14,25.667ZM9.333,19.833H18.667V11.667C18.667,10.383 18.21,9.285 17.296,8.371C16.382,7.457 15.283,7 14,7C12.717,7 11.618,7.457 10.704,8.371C9.79,9.285 9.333,10.383 9.333,11.667V19.833Z"
android:fillColor="#333333"/>
</vector>
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/settings_star.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="30dp"
android:height="30dp"
android:viewportWidth="30"
android:viewportHeight="30">
<path
android:pathData="M24.561,11.618L18.511,11.093L16.148,5.531C15.723,4.518 14.273,4.518 13.848,5.531L11.486,11.106L5.448,11.618C4.348,11.706 3.898,13.081 4.736,13.806L9.323,17.781L7.948,23.681C7.698,24.756 8.861,25.606 9.811,25.031L14.998,21.906L20.186,25.043C21.136,25.618 22.298,24.768 22.048,23.693L20.673,17.781L25.261,13.806C26.098,13.081 25.661,11.706 24.561,11.618ZM14.998,19.568L10.298,22.406L11.548,17.056L7.398,13.456L12.873,12.981L14.998,7.943L17.136,12.993L22.611,13.468L18.461,17.068L19.711,22.418L14.998,19.568Z"
android:fillColor="#333333"/>
</vector>
6 changes: 6 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,10 @@
<string name="profile_scores">Scores</string>
<string name="profile_highlights">Highlights</string>
<string name="edit_favorite_sports">Edit Favorite Sports</string>
<string name="settings_preferences">Preferences</string>
<string name="settings_help">Help</string>
<string name="settings_about">About Score</string>
<string name="settings_report">Report an Issue</string>
<string name="settings_logout">Log Out</string>
<string name="settings_delete">Delete Account</string>
</resources>
Loading