Skip to content

Commit

Permalink
fix: change displayed name to name
Browse files Browse the repository at this point in the history
  • Loading branch information
taghizadlaura committed Oct 16, 2024
1 parent 9e746c8 commit 29b24bb
Showing 1 changed file with 72 additions and 58 deletions.
130 changes: 72 additions & 58 deletions app/src/main/java/com/android/periodpals/ui/profile/ProfileScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,86 +42,100 @@ import com.bumptech.glide.integration.compose.GlideImage
// @Preview
@Composable
fun ProfileScreen() {
// Declare and remember the profile image URI
var profileImageUri by remember {
mutableStateOf<Uri?>(
Uri.parse("android.resource://com.android.periodpals/${R.drawable.generic_avatar}"))
}
// Declare and remember the profile image URI
var profileImageUri by remember {
mutableStateOf<Uri?>(
Uri.parse("android.resource://com.android.periodpals/${R.drawable.generic_avatar}")
)
}

Scaffold(
modifier = Modifier.fillMaxSize().testTag("profileScreen"),
topBar = { TopAppBar("Your Profile") },
content = { padding ->
Column(
modifier = Modifier.padding(padding).padding(40.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
) {
// Display the user's profile image.
GlideImage(
model = profileImageUri,
contentDescription = "Avatar Imagee",
contentScale = ContentScale.Crop,
modifier =
Modifier.size(190.dp)
.testTag("profileAvatar")
.background(
color = MaterialTheme.colorScheme.background, shape = CircleShape),
)
Scaffold(
modifier = Modifier
.fillMaxSize()
.testTag("profileScreen"),
topBar = { TopAppBar("Your Profile") },
content = { padding ->
Column(
modifier = Modifier
.padding(padding)
.padding(40.dp),
verticalArrangement = Arrangement.spacedBy(16.dp),
horizontalAlignment = Alignment.CenterHorizontally,
) {
// Display the user's profile image.
GlideImage(
model = profileImageUri,
contentDescription = "Avatar Imagee",
contentScale = ContentScale.Crop,
modifier =
Modifier
.size(190.dp)
.testTag("profileAvatar")
.background(
color = MaterialTheme.colorScheme.background, shape = CircleShape
),
)

ProfileName() // Display the user's profile name.
ProfileDetails() // Display additional details like description and reviews.
}
})
ProfileName() // Display the user's profile name.
ProfileDetails() // Display additional details like description and reviews.
}
})
}

@Composable
private fun ProfileName() {
Text(
text = "Displayed Name",
modifier = Modifier.testTag("profileName"),
fontSize = 24.sp, // Font size for the name.
fontWeight = FontWeight.Bold // Make the text bold.
)
Text(
text = "Name",
modifier = Modifier.testTag("profileName"),
fontSize = 24.sp, // Font size for the name.
fontWeight = FontWeight.Bold // Make the text bold.
)
}

@Composable
private fun ProfileDetails() {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp) // Space items by 8dp vertically.
) {
Column(
modifier = Modifier.fillMaxWidth(),
verticalArrangement = Arrangement.spacedBy(8.dp) // Space items by 8dp vertically.
) {
// Box for the description.
Text(text = "Description", fontSize = 20.sp, modifier = Modifier.padding(vertical = 8.dp))
ProfileInfoBox(text = "", minHeight = 100.dp, Modifier.testTag("Description"))
Text(
text = "Description",
fontSize = 20.sp,
modifier = Modifier
.padding(vertical = 8.dp)
.testTag("Description")
)
ProfileInfoBox(text = "", minHeight = 100.dp, Modifier)
Text(
text = "New user / Number of interactions",
fontSize = 16.sp,
color = Color(101, 116, 193))
color = Color(101, 116, 193)
)
Text(text = "Reviews", fontSize = 20.sp, modifier = Modifier.padding(vertical = 8.dp))
// Boxes for reviews.
ProfileInfoBox(text = "", minHeight = 20.dp, Modifier.testTag("reviewOne"))
ProfileInfoBox(text = "", minHeight = 20.dp, Modifier.testTag("reviewTwo"))
}
}
}

@Composable
private fun ProfileInfoBox(text: String, minHeight: Dp, modifier: Modifier) {
// Reusable composable for displaying information inside a bordered box.
Box(
modifier =
modifier
.fillMaxWidth() // Make the box fill the available width.
.clip(RoundedCornerShape(8.dp)) // Clip the box to have rounded corners.
.border(
1.dp,
MaterialTheme.colorScheme.onSurface, // Color of the border.
RoundedCornerShape(8.dp) // Rounded corners for the border.
)
.padding(8.dp) // Padding inside the box.
.heightIn(min = minHeight) // Set a minimum height for the box.
) {
// Reusable composable for displaying information inside a bordered box.
Box(
modifier =
modifier
.fillMaxWidth() // Make the box fill the available width.
.clip(RoundedCornerShape(8.dp)) // Clip the box to have rounded corners.
.border(
1.dp,
MaterialTheme.colorScheme.onSurface, // Color of the border.
RoundedCornerShape(8.dp) // Rounded corners for the border.
)
.padding(8.dp) // Padding inside the box.
.heightIn(min = minHeight) // Set a minimum height for the box.
) {
// Text inside the box
Text(text = text, fontSize = 20.sp, textAlign = TextAlign.Start)
}
}
}

0 comments on commit 29b24bb

Please sign in to comment.