Skip to content

Conversation

@ma-r-s
Copy link
Collaborator

@ma-r-s ma-r-s commented Oct 3, 2024

Summary by CodeRabbit

  • New Features

    • Enhanced the Profile Screen with a comprehensive user interface, including input fields for user attributes and a profile picture placeholder.
    • Introduced new composables: ProfileTextField for consistent styling of text fields and PreviewProfileScreen for UI previews.
  • Bug Fixes

    • Adjusted tab selection logic to correctly display the Profile Screen.
  • Chores

    • Cleaned up import statements in MainActivity and NavigationHost files.

@coderabbitai
Copy link

coderabbitai bot commented Oct 3, 2024

📝 Walkthrough

Walkthrough

The changes in this pull request primarily involve modifications to the MainActivity.kt, NavigationHost.kt, and ProfileScreen.kt files within the com.uniandes.ecobites package. Key adjustments include the repositioning of imports, a change in tab index for the ProfileScreen, and the enhancement of the ProfileScreen composable to include a more comprehensive user profile interface. New state variables and UI elements have been introduced to improve user interaction and display.

Changes

File Path Change Summary
app/src/main/java/com/uniandes/ecobites/MainActivity.kt Adjusted import statements, removed unused imports, and changed ProfileScreen tab index from 2 to 3.
app/src/main/java/com/uniandes/ecobites/ui/navigation/NavigationHost.kt Added import for ProfileScreen, allowing its use in the NavigationHost function.
app/src/main/java/com/uniandes/ecobites/ui/screens/ProfileScreen.kt Expanded ProfileScreen UI with new state variables and layout; added ProfileTextField and PreviewProfileScreen methods.

Possibly related PRs

  • Views cart login register #15: The changes in MainActivity.kt regarding the ProfileScreen tab index adjustment relate to the modifications in NavigationHost.kt, where the ProfileScreen import was reintroduced, indicating a connection in how screens are navigated based on tab selections.
  • Closes #22 #23: The updates in MainActivity.kt and LoginScreen.kt regarding the login mechanism and state management may relate to the overall navigation and user flow, which could be impacted by the changes in the NavigationHost.kt file, although the direct connection is less clear.

Suggested reviewers

  • LuimarcoCarrascalDiaz

Poem

🐰 In the meadow where screens do play,
A profile blooms in a brand new way.
With fields to fill and tabs to show,
Our app's a garden, watch it grow!
So hop along, dear friends, let's cheer,
For changes bright and updates near! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@ma-r-s ma-r-s self-assigned this Oct 3, 2024
@ma-r-s ma-r-s merged commit fe5188a into main Oct 3, 2024
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Outside diff range and nitpick comments (2)
app/src/main/java/com/uniandes/ecobites/MainActivity.kt (1)

Line range hint 1-77: Summary of changes and request for additional context.

The changes in this PR appear to focus on two main areas:

  1. Reorganization of import statements
  2. Modification of the tab index for the ProfileScreen

While these changes seem minor, they could have a significant impact on the app's navigation and user experience.

To ensure a comprehensive review:

  1. Could you provide more context about the issue this PR is addressing (referenced as #10 in the PR title)?
  2. Have you considered the impact of these changes on the overall user flow and experience?
  3. Are there any related changes in other files that we should be aware of?

This additional information will help in evaluating the full scope and implications of these modifications.

app/src/main/java/com/uniandes/ecobites/ui/screens/ProfileScreen.kt (1)

39-39: Review greeting text punctuation for consistency

The greeting text "¡Hi, Pepito!" uses an inverted exclamation mark, which is typical in Spanish. If the greeting is in English, consider removing the inverted exclamation mark for consistency. Alternatively, if the app supports localization, you might want to fully translate the greeting to Spanish.

Suggested change:

- Text(text = "¡Hi, Pepito!", fontSize = 28.sp, color = MaterialTheme.colorScheme.onSurface, style = MaterialTheme.typography.titleLarge)
+ Text(text = "Hi, Pepito!", fontSize = 28.sp, color = MaterialTheme.colorScheme.onSurface, style = MaterialTheme.typography.titleLarge)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 0bff5d1 and ab0b504.

⛔ Files ignored due to path filters (1)
  • app/src/main/res/drawable/profile_image.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • app/src/main/java/com/uniandes/ecobites/MainActivity.kt (2 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/navigation/NavigationHost.kt (1 hunks)
  • app/src/main/java/com/uniandes/ecobites/ui/screens/ProfileScreen.kt (1 hunks)
🔇 Additional comments (2)
app/src/main/java/com/uniandes/ecobites/ui/navigation/NavigationHost.kt (1)

Line range hint 9-18: Verify if this change fully addresses issue #10.

The addition of the ProfileScreen import and its usage in the NavigationHost function appear correct. However, to ensure this change fully addresses issue #10, please confirm:

  1. Was the missing import the only problem mentioned in issue #10?
  2. Are there any other files or components that needed modification to fully resolve the issue?

To help verify the completeness of this fix, you can run the following script:

This script will help identify any remaining TODO comments, references to the issue, or other usages of ProfileScreen that might need attention.

✅ Verification successful

Issue #10 Fully Addressed

The addition of ProfileScreen in the NavigationHost function has been successfully verified. No remaining references to issue #10 were found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining TODO comments or references to issue #10

# Search for TODO comments or references to issue #10
echo "Searching for TODO comments or references to issue #10:"
rg --type kotlin "TODO|issue #10|#10"

# Check if ProfileScreen is used in other files
echo "Checking usage of ProfileScreen in other files:"
rg --type kotlin "ProfileScreen"

Length of output: 1800

app/src/main/java/com/uniandes/ecobites/MainActivity.kt (1)

11-11: LGTM: Import statement reorganized.

The import statement for ProfileScreen has been repositioned. This change, along with the removal of unused imports mentioned in the summary, contributes to better code organization.

To ensure all necessary imports are present, please run the following script:

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

Comment on lines +68 to +82
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") }
)
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") }
)

Comment on lines +86 to +98
@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,

)
}
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
        )
    )
}

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") }

Comment on lines +25 to +30
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") }
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") }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants