Skip to content
Merged
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
17 changes: 2 additions & 15 deletions app/src/main/java/com/uniandes/ecobites/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,14 @@ package com.uniandes.ecobites
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
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.material3.Button
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.PasswordVisualTransformation
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.uniandes.ecobites.ui.screens.ProfileScreen
import com.uniandes.ecobites.ui.screens.CartScreen
import com.uniandes.ecobites.ui.screens.home.HomeScreen
import com.uniandes.ecobites.ui.screens.ProfileScreen
import com.uniandes.ecobites.ui.theme.AppTheme
import com.uniandes.ecobites.ui.components.NavBar
import com.uniandes.ecobites.ui.SplashScreen
Expand Down Expand Up @@ -87,7 +74,7 @@ fun MainContent() {
when (selectedTab) {
0 -> HomeScreen()
1 -> CartScreen()
2 -> ProfileScreen()
3 -> ProfileScreen()
Copy link

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 NavBar component does not include a NavigationBarItem for the updated ProfileScreen at tab index 3, and it's missing the OrdersScreen at tab index 2. This mismatch can lead to navigation issues within the app.

  • Files Affected:
    • app/src/main/java/com/uniandes/ecobites/ui/components/NavBar.kt
🔗 Analysis chain

Verify navigation logic for ProfileScreen.

The tab index for ProfileScreen has been changed from 2 to 3. This modification affects the app's navigation structure.

Please confirm the following:

  1. Is this change intentional and does it align with the issue mentioned in "Closes feature/vista profile #10"?
  2. Has the NavBar component been updated to reflect this new tab order?
  3. Are there any other parts of the app that need to be updated due to this change?

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:

#!/bin/bash
# Description: Verify navigation logic consistency across the app

# Test: Check NavBar implementation for consistency with new tab order
rg --type kotlin 'NavBar\s*\(' -A 10 app/src/main/java/com/uniandes/ecobites

# Test: Look for other occurrences of tab indices that might need updating
rg --type kotlin '\bwhen\s*\(.+\)\s*\{' -A 10 app/src/main

Length of output: 3802


Script:

#!/bin/bash
# Description: Verify navigation logic consistency across the app

# Test: Check NavBar implementation for consistency with new tab order
rg --type kotlin 'NavBar\s*\(' -A 10 app/src/main/java/com/uniandes/ecobites

# Test: Look for other occurrences of tab indices that might need updating
rg --type kotlin '\bwhen\s*\(.+\)\s*\{' -A 10 app/src/main

Length of output: 3707

}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.uniandes.ecobites.ui.navigation

import androidx.compose.runtime.Composable
import com.uniandes.ecobites.ui.screens.ProfileScreen
import com.uniandes.ecobites.ui.screens.CartScreen
import com.uniandes.ecobites.ui.screens.home.HomeScreen
import com.uniandes.ecobites.ui.screens.OrdersScreen
import com.uniandes.ecobites.ui.screens.ProfileScreen

@Composable
fun NavigationHost(selectedTab: Int) {
Expand Down
101 changes: 98 additions & 3 deletions app/src/main/java/com/uniandes/ecobites/ui/screens/ProfileScreen.kt
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") }
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct the initial value of 'phone'; currently set to an email address

The phone variable is initialized with an email address instead of a phone number. This may cause confusion or errors in the user interface.

Suggested fix:

- var phone by remember { mutableStateOf("p.rincon@uniandes.edu.co") }
+ var phone by remember { mutableStateOf("123-456-7890") }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
var phone by remember { mutableStateOf("p.rincon@uniandes.edu.co") }
var phone by remember { mutableStateOf("123-456-7890") }

var birthdate by remember { mutableStateOf("08/17/2023") }
Comment on lines +25 to +30
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

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

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
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 birthdate by remember { mutableStateOf("08/17/2023") }
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("") }
var birthdate by remember { mutableStateOf("08/17/2023") }


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
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider using a DatePicker for birthdate input

Using a DatePicker instead of a plain TextField can enhance user experience by providing an intuitive interface for date selection, reducing input errors, and ensuring consistent date formatting.

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
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Optimize ProfileTextField by customizing TextField styling

To maintain consistent styling and theming across all text fields, consider customizing the TextField within your ProfileTextField composable using TextFieldDefaults. This approach centralizes styling and makes future adjustments easier.

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()
}
Binary file added app/src/main/res/drawable/profile_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.