-
Notifications
You must be signed in to change notification settings - Fork 1
Closes #10 #24
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
Closes #10 #24
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,104 @@ | ||||||||||||||||||||||||||
| package com.uniandes.ecobites.ui.screens | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import androidx.compose.material3.Text | ||||||||||||||||||||||||||
| import androidx.compose.runtime.Composable | ||||||||||||||||||||||||||
| import androidx.compose.foundation.Image | ||||||||||||||||||||||||||
| import androidx.compose.foundation.background | ||||||||||||||||||||||||||
| import androidx.compose.foundation.layout.* | ||||||||||||||||||||||||||
| import androidx.compose.foundation.shape.CircleShape | ||||||||||||||||||||||||||
| import androidx.compose.material.icons.Icons | ||||||||||||||||||||||||||
| import androidx.compose.material.icons.outlined.DateRange | ||||||||||||||||||||||||||
| import androidx.compose.material3.* | ||||||||||||||||||||||||||
| import androidx.compose.runtime.* | ||||||||||||||||||||||||||
| import androidx.compose.ui.Alignment | ||||||||||||||||||||||||||
| import androidx.compose.ui.Modifier | ||||||||||||||||||||||||||
| import androidx.compose.ui.draw.clip | ||||||||||||||||||||||||||
| import androidx.compose.ui.graphics.Color | ||||||||||||||||||||||||||
| import androidx.compose.ui.graphics.ColorFilter | ||||||||||||||||||||||||||
| import androidx.compose.ui.res.painterResource | ||||||||||||||||||||||||||
| import androidx.compose.ui.text.input.VisualTransformation | ||||||||||||||||||||||||||
| import androidx.compose.ui.unit.dp | ||||||||||||||||||||||||||
| import androidx.compose.ui.unit.sp | ||||||||||||||||||||||||||
| import androidx.compose.ui.tooling.preview.Preview | ||||||||||||||||||||||||||
| import com.uniandes.ecobites.R | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| @Composable | ||||||||||||||||||||||||||
| fun ProfileScreen() { | ||||||||||||||||||||||||||
| Text(text = "Profile Screen") | ||||||||||||||||||||||||||
| var name by remember { mutableStateOf("Pepito Andrés") } | ||||||||||||||||||||||||||
| var surname by remember { mutableStateOf("Rincon Arismendy") } | ||||||||||||||||||||||||||
| var citizenId by remember { mutableStateOf("1005634120") } | ||||||||||||||||||||||||||
| var email by remember { mutableStateOf("p.rincon@uniandes.edu.co") } | ||||||||||||||||||||||||||
| var phone by remember { mutableStateOf("p.rincon@uniandes.edu.co") } | ||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct the initial value of 'phone'; currently set to an email address The Suggested fix: - var phone by remember { mutableStateOf("p.rincon@uniandes.edu.co") }
+ var phone by remember { mutableStateOf("123-456-7890") }📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
| var birthdate by remember { mutableStateOf("08/17/2023") } | ||||||||||||||||||||||||||
|
Comment on lines
+25
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid hardcoding personal data; use placeholders or fetch from a data source Hardcoding personally identifiable information (PII) such as names, email addresses, citizen IDs, and phone numbers in the code is not recommended due to security and privacy concerns. Consider using generic placeholder values or fetching this data from a secure source. Suggested changes: - var name by remember { mutableStateOf("Pepito Andrés") }
- var surname by remember { mutableStateOf("Rincon Arismendy") }
- var citizenId by remember { mutableStateOf("1005634120") }
- var email by remember { mutableStateOf("p.rincon@uniandes.edu.co") }
- var phone by remember { mutableStateOf("p.rincon@uniandes.edu.co") }
+ var name by remember { mutableStateOf("") }
+ var surname by remember { mutableStateOf("") }
+ var citizenId by remember { mutableStateOf("") }
+ var email by remember { mutableStateOf("") }
+ var phone by remember { mutableStateOf("") }📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Column( | ||||||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||||||
| .fillMaxSize() | ||||||||||||||||||||||||||
| .padding(16.dp), | ||||||||||||||||||||||||||
| horizontalAlignment = Alignment.CenterHorizontally | ||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||
| // Greeting Text | ||||||||||||||||||||||||||
| Text(text = "¡Hi, Pepito!", fontSize = 28.sp, color = MaterialTheme.colorScheme.onSurface, style = MaterialTheme.typography.titleLarge) | ||||||||||||||||||||||||||
| Text( | ||||||||||||||||||||||||||
| text = "You can edit your personal information here.", | ||||||||||||||||||||||||||
| fontSize = 16.sp, | ||||||||||||||||||||||||||
| color = Color.Gray, | ||||||||||||||||||||||||||
| modifier = Modifier.padding(bottom = 16.dp) | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Profile Image | ||||||||||||||||||||||||||
| Image( | ||||||||||||||||||||||||||
| painter = painterResource(id = R.drawable.profile_image), // Replace with actual image | ||||||||||||||||||||||||||
| contentDescription = "Profile Image", | ||||||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||||||
| .size(120.dp) | ||||||||||||||||||||||||||
| .clip(CircleShape) | ||||||||||||||||||||||||||
| .background(MaterialTheme.colorScheme.primaryContainer) | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| Spacer(modifier = Modifier.height(32.dp)) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Text Fields for Profile Information | ||||||||||||||||||||||||||
| ProfileTextField(label = "Name", value = name, onValueChange = { name = it }) | ||||||||||||||||||||||||||
| ProfileTextField(label = "Surname", value = surname, onValueChange = { surname = it }) | ||||||||||||||||||||||||||
| ProfileTextField(label = "Citizen ID", value = citizenId, onValueChange = { citizenId = it }) | ||||||||||||||||||||||||||
| ProfileTextField(label = "Email", value = email, onValueChange = { email = it }) | ||||||||||||||||||||||||||
| ProfileTextField(label = "Phone", value = phone, onValueChange = { phone = it }) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| // Birthdate field with icon | ||||||||||||||||||||||||||
| TextField( | ||||||||||||||||||||||||||
| value = birthdate, | ||||||||||||||||||||||||||
| onValueChange = { birthdate = it }, | ||||||||||||||||||||||||||
| label = { Text("Birthdate") }, | ||||||||||||||||||||||||||
| trailingIcon = { | ||||||||||||||||||||||||||
| Icon( | ||||||||||||||||||||||||||
| imageVector = Icons.Outlined.DateRange, | ||||||||||||||||||||||||||
| contentDescription = "Calendar Icon" | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||
| singleLine = true, | ||||||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||||||
| .fillMaxWidth() | ||||||||||||||||||||||||||
| .padding(vertical = 8.dp), | ||||||||||||||||||||||||||
| placeholder = { Text("MM/DD/YYYY") } | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
|
Comment on lines
+68
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider using a DatePicker for birthdate input Using a Example implementation: // Import necessary libraries
import androidx.compose.material3.DatePickerDialog
import java.util.Calendar
// Inside your ProfileScreen composable
var isDatePickerVisible by remember { mutableStateOf(false) }
if (isDatePickerVisible) {
DatePickerDialog(
onDismissRequest = { isDatePickerVisible = false },
onDateChange = { selectedDate ->
birthdate = selectedDate // Format the date as needed
isDatePickerVisible = false
}
)
}
TextField(
value = birthdate,
onValueChange = { /* No-op since we're using a DatePicker */ },
label = { Text("Birthdate") },
trailingIcon = {
IconButton(onClick = { isDatePickerVisible = true }) {
Icon(
imageVector = Icons.Outlined.DateRange,
contentDescription = "Calendar Icon"
)
}
},
singleLine = true,
readOnly = true,
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp),
placeholder = { Text("MM/DD/YYYY") }
) |
||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| @Composable | ||||||||||||||||||||||||||
| fun ProfileTextField(label: String, value: String, onValueChange: (String) -> Unit) { | ||||||||||||||||||||||||||
| TextField( | ||||||||||||||||||||||||||
| value = value, | ||||||||||||||||||||||||||
| onValueChange = onValueChange, | ||||||||||||||||||||||||||
| label = { Text(label) }, | ||||||||||||||||||||||||||
| modifier = Modifier | ||||||||||||||||||||||||||
| .fillMaxWidth() | ||||||||||||||||||||||||||
| .padding(vertical = 8.dp), // Adds space between text fields | ||||||||||||||||||||||||||
| singleLine = true, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+86
to
+98
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Optimize To maintain consistent styling and theming across all text fields, consider customizing the Example modification: @Composable
fun ProfileTextField(label: String, value: String, onValueChange: (String) -> Unit) {
TextField(
value = value,
onValueChange = onValueChange,
label = { Text(label) },
modifier = Modifier
.fillMaxWidth()
.padding(vertical = 8.dp),
singleLine = true,
colors = TextFieldDefaults.textFieldColors(
containerColor = MaterialTheme.colorScheme.surface,
focusedIndicatorColor = MaterialTheme.colorScheme.primary,
unfocusedIndicatorColor = MaterialTheme.colorScheme.onSurfaceVariant
)
)
} |
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| @Preview(showBackground = true) | ||||||||||||||||||||||||||
| @Composable | ||||||||||||||||||||||||||
| fun PreviewProfileScreen() { | ||||||||||||||||||||||||||
| ProfileScreen() | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Inconsistency Found in Navigation Implementation.
The
NavBarcomponent does not include aNavigationBarItemfor the updatedProfileScreenat tab index3, and it's missing theOrdersScreenat tab index2. This mismatch can lead to navigation issues within the app.app/src/main/java/com/uniandes/ecobites/ui/components/NavBar.kt🔗 Analysis chain
Verify navigation logic for ProfileScreen.
The tab index for
ProfileScreenhas been changed from 2 to 3. This modification affects the app's navigation structure.Please confirm the following:
NavBarcomponent been updated to reflect this new tab order?To help verify the navigation logic, please run the following script:
Please review the script output to ensure that the navigation logic is consistent throughout the app.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 3802
Script:
Length of output: 3707