Skip to content
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

[SCRUM-6] Implement profile page ui #2

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

[SCRUM-6] Implement profile page ui #2

wants to merge 3 commits into from

Conversation

Marwanyx
Copy link
Collaborator

@Marwanyx Marwanyx commented Feb 1, 2025

made a boilerplate profile page, few buttons, edit profile, possible settings button.
made an empty home page for debugging/navigation between pages

@Marwanyx Marwanyx changed the title completed changes to profile page [SCRUM-6] Implement profile page ui Feb 1, 2025
Copy link
Collaborator

@V-X-L-U V-X-L-U left a comment

Choose a reason for hiding this comment

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

Overall, really well done. The major comment would be on code style but you seemed to have a made a lot of progress with understanding and using Flutter, particularly with the variety of widgets you were able to find and use.


@override
Widget build(BuildContext context) {
return Scaffold(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally, it is always preferable to use SafeArea widget. For our purposes, we will use it for all our pages so that we don't get unexpected parts of our page being blocked by notches and whatnot.


@override
Widget build(BuildContext context) {
return SafeArea(
Copy link
Collaborator

Choose a reason for hiding this comment

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

One fine detail is that SafeArea is typically placed inside the Scaffold. See Flutter docs on this

final String firstName = firstNameController.text.trim();
final String lastName = lastNameController.text.trim();

if (firstName.isEmpty || lastName.isEmpty) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, not sure if this is the best way to show the error -- especially b/c the SnackBar appears behind the dialog (greyed out).

You should look into error messages built into Form. You might want to talk to Ziad about this -- I think he used it in his implementation.

context.go('/home');
},
),
title: Text('Profile'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Flutter code by default is deeply nested and is often hard to read. We mitigate this by using widget builder functions (like you with your _buildXXX functions). For simpler sub-widgets, we typically just have a final XXX = ... where XXX is a variable name describing a sub-widget and ... is the widget definition. You should apply this pattern the sub-widgets you marked with comments such as // Profile Picture, or // User Name.

My general rule-of-thumb is to decompose a single page into sub-widgets and to define either _buildXXX or final XXX sub-widgets. After this, in the build method return statement, I compose all the sub-widgets using layout widgets like Scaffold/Column/Row/Container/Stack/ListView and many more. The idea is to separate sub-widget definition from the code that lays out all the sub-widgets into the final page.

);
}

void _showEditProfileDialog(BuildContext context) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment to the effect of code nesting.

You should identify the sub-widgets and use helper build functions or final variables to help reduce nesting in the code.

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.

2 participants