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

Tml 48 #83

Closed
wants to merge 25 commits into from
Closed

Tml 48 #83

wants to merge 25 commits into from

Conversation

YuuDaRealest
Copy link
Contributor

@YuuDaRealest YuuDaRealest commented May 28, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a first transition screen to guide new users through onboarding or direct them to a waiting screen.
    • Added a login screen with form validation and input fields for username and password.
    • Implemented an onboarding screen and a pre-authentication onboarding widget.
    • Created a waiting screen with multiple splash pages and navigation buttons.
    • Added a waiting page widget for customizable waiting pages.
  • Dependency Updates

    • Added shared_preferences version 2.2.3 to the project.
  • Refactor

    • Updated import paths for various files to align with the new project structure.

Copy link
Contributor

coderabbitai bot commented May 28, 2024

Walkthrough

The recent changes in the mobile app project introduce several new features and updates, including the implementation of Domain-Driven Design (DDD) principles, updated import paths for better organization, and new UI elements such as the First Transition Screen, OnBoarding Screen, and Waiting Screen. Additionally, a new Login Screen and pre-authentication onboarding widget are added to enhance the user experience during the initial app setup and login process. The pubspec.yaml file now includes a dependency on shared_preferences.

Changes

File Path Change Summary
apps/mobile/READ_DDD.md Introduces Domain-Driven Design (DDD) concepts and benefits.
apps/mobile/lib/contexts/identiy_access/users/domain/entities/account.dart Updated import path for auth_value_objects.
apps/mobile/lib/contexts/identiy_access/users/infra/account_dto.dart Updated import paths for auth_value_objects and account.
apps/mobile/lib/contexts/identiy_access/users/infra/account_entity.dart Updated import paths for auth_value_objects and account.
apps/mobile/lib/contexts/identiy_access/users/presentation/pages/first_transition_screen.dart Introduces FirstTransitionScreen widget to manage initial app transition.
apps/mobile/lib/contexts/identiy_access/users/presentation/pages/on_boarding_screen.dart Introduces OnBoardingScreen widget for user onboarding.
apps/mobile/lib/contexts/identiy_access/users/presentation/pages/waiting_screen.dart Introduces WaitingScreen widget for displaying splash pages.
apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/waiting_page_widget.dart Introduces WaitingPageWidget for customizable waiting pages.
apps/mobile/lib/main.dart Updated home screen to use FirstTransitionScreen and removed old counter logic.
apps/mobile/pubspec.yaml Added shared_preferences: ^2.2.3 dependency.
apps/mobile/lib/contexts/identiy_access/users/presentation/pages/login_screen.dart Introduces LoginScreen widget with form validation and login logic.
apps/mobile/lib/contexts/identiy_access/users/presentation/pages/on_boarding_pre_authen_screen.dart Introduces OnBoardingPreAuthenScreen widget for pre-authentication onboarding.
apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/on_boarding_pre_authen_widget.dart Introduces OnBoardingPreAuthenWidget for pre-authentication onboarding UI.
apps/mobile/lib/features/authentication/presentation/auth/login/login_screen.dart Commented out import statements and code related to unused packages.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant App
    participant SharedPreferences

    User->>App: Launch App
    App->>SharedPreferences: Check if first time user
    SharedPreferences-->>App: Returns isFirstTime
    alt isFirstTime
        App->>User: Show OnBoardingScreen
    else
        App->>User: Show WaitingScreen
    end
    User->>App: Complete Onboarding/Login
    App->>User: Navigate to Main Screen
Loading

Poem

In the world of apps, a change so grand,
New screens and paths, all carefully planned.
Onboarding, waiting, a login so neat,
With shared preferences, the cycle's complete.
🐇 CodeRabbit cheers, with joy in the air,
For the app's new journey, beyond compare! 🌟


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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.

Copy link
Contributor

@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: 0

Outside diff range and nitpick comments (1)
apps/mobile/READ_DDD.md (1)

32-36: Consider adding commas and revising sentences for clarity:

  • Line 32: After "key", add a comma.
  • Line 34: After "software", add a comma.
  • Line 36: Simplify "in order to get there fastest and safest" to "to get there faster and safer".
  • Line 45: After "team", add a comma.
  • Line 70: After "Context", add a comma.

Also applies to: 45-45, 70-70

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 5b3ed55 and 441630b.
Files selected for processing (4)
  • apps/mobile/READ_DDD.md (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/domain/entities/account.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/infra/account_dto.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/infra/account_entity.dart (1 hunks)
Additional Context Used
LanguageTool (6)
apps/mobile/READ_DDD.md (6)

Near line 32: Consider adding a comma here.
Context: ...• Centralizing knowledge is key because with that the business is capable of ensuring tha...
Rule ID: FOR_THAT_COMMA


Near line 34: Possible missing comma found.
Context: ...d the software. That doesn’t mean maybe some few translations. It means zero transla...
Rule ID: AI_HYDRA_LEO_MISSING_COMMA


Near line 36: Consider a shorter alternative to avoid wordiness.
Context: ...at existing software assets to leverage in order to get there fastest and safest, and who m...
Rule ID: IN_ORDER_TO_PREMIUM


Near line 36: Possible missing comma found.
Context: ...olved. Tactical design helps us craft a single elegant model of a solution using time-...
Rule ID: AI_HYDRA_LEO_MISSING_COMMA


Near line 45: Possible missing comma found.
Context: ... role on the team, since you are on the team you use the Ubiquitous Language of the ...
Rule ID: AI_HYDRA_LEO_MISSING_COMMA


Near line 70: Possible missing comma found.
Context: ...king on the project that develops in an isolated Bounded Context. • On a single project ...
Rule ID: AI_HYDRA_LEO_MISSING_COMMA

Markdownlint (2)
apps/mobile/READ_DDD.md (2)

75: Expected: 1; Actual: 2
Multiple consecutive blank lines


40: null
Emphasis used instead of a heading

Additional comments not posted (7)
apps/mobile/lib/contexts/identiy_access/users/domain/entities/account.dart (2)

5-5: The updated import path aligns with the new project structure. Good job on maintaining consistency.


Line range hint 9-27: The Account class implementation is clean and adheres to domain-driven design principles. The use of freezed for immutability and pattern matching is appropriate.

apps/mobile/lib/contexts/identiy_access/users/infra/account_entity.dart (2)

3-4: The updated import paths are correct and reflect the new project structure. This ensures consistency across the codebase.


Line range hint 10-28: The AccountEntity class is well-implemented, providing clear methods for converting between the domain model and the database model. The use of Hive for local storage is appropriate.

apps/mobile/lib/contexts/identiy_access/users/infra/account_dto.dart (2)

3-4: The updated import paths are correct and reflect the new project structure. This ensures consistency across the codebase.


Line range hint 12-34: The AccountDto class is correctly implemented, providing essential methods for data transfer between the domain model and data transfer objects. The JSON serialization method is also correctly implemented.

apps/mobile/READ_DDD.md (1)

1-74: The content of READ_DDD.md is well-structured and provides a comprehensive introduction to Domain-Driven Design. It effectively communicates key concepts and practices.

Copy link
Contributor

@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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 441630b and d668d5a.

Files selected for processing (6)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/pages/first_transition_screen.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/pages/on_boarding_screen.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/pages/waiting_screen.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/waiting_page_widget.dart (1 hunks)
  • apps/mobile/lib/main.dart (2 hunks)
  • apps/mobile/pubspec.yaml (1 hunks)
Files skipped from review due to trivial changes (1)
  • apps/mobile/pubspec.yaml
Additional comments not posted (3)
apps/mobile/lib/contexts/identiy_access/users/presentation/pages/first_transition_screen.dart (1)

35-35: Recursive call to OnBoardingScreen within itself can lead to an infinite loop.

- return OnBoardingScreen();
+ // Correct widget or action should be here

Likely invalid or redundant comment.

apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/waiting_page_widget.dart (1)

3-56: The implementation of the WaitingPageWidget is clean and follows good practices.

apps/mobile/lib/contexts/identiy_access/users/presentation/pages/waiting_screen.dart (1)

3-87: The implementation of the WaitingScreen is clean and follows good practices.

tooltip: 'Increment',
child: const Icon(Icons.add),
),
home: const FirstTransitionScrene(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in the widget name should be corrected to match the intended class name.

- home: const FirstTransitionScrene(),
+ home: const FirstTransitionScreen(),
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.

Suggested change
home: const FirstTransitionScrene(),
home: const FirstTransitionScreen(),

@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:techmely_app/contexts/identiy_access/users/presentation/pages/first_transition_screen.dart';
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo in the class name and import path.

- import 'package:techmely_app/contexts/identiy_access/users/presentation/pages/first_transition_screen.dart';
+ import 'package:techmely_app/contexts/identity_access/users/presentation/pages/first_transition_screen.dart';
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.

Suggested change
import 'package:techmely_app/contexts/identiy_access/users/presentation/pages/first_transition_screen.dart';
import 'package:techmely_app/contexts/identity_access/users/presentation/pages/first_transition_screen.dart';

if (isFirstTime) {
return WaitingScreen();
} else {
return OnBoardingScreen();
Copy link
Contributor

Choose a reason for hiding this comment

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

Recursive call to OnBoardingScreen within itself can lead to an infinite loop.

- return OnBoardingScreen();
+ // Correct widget or action should be here

Committable suggestion was skipped due to low confidence.

Copy link
Contributor

@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: 3

Outside diff range and nitpick comments (2)
apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/on_boarding_pre_authen_widget.dart (1)

14-41: The build method is well-constructed with clear navigation logic. Consider adding a comment above the navigation logic to explain its purpose for better code readability.

apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/waiting_page_widget.dart (1)

5-21: Ensure proper documentation for the WaitingPageWidget constructor.

It's good practice to add documentation comments for public classes and their constructors, especially when they are as configurable as WaitingPageWidget. This helps other developers understand the purpose of the widget and how to use it effectively.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d668d5a and 7c6cfc0.

Files selected for processing (6)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/pages/login_screen.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/pages/on_boarding_pre_authen_screen.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/pages/waiting_screen.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/on_boarding_pre_authen_widget.dart (1 hunks)
  • apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/waiting_page_widget.dart (1 hunks)
  • apps/mobile/lib/features/authentication/presentation/auth/login/login_screen.dart (1 hunks)
Files skipped from review due to trivial changes (1)
  • apps/mobile/lib/features/authentication/presentation/auth/login/login_screen.dart
Additional comments not posted (6)
apps/mobile/lib/contexts/identiy_access/users/presentation/pages/on_boarding_pre_authen_screen.dart (3)

6-6: Constructor correctly utilizes super.key, aligning with Flutter best practices for widget identification and reusability.


13-15: initState method correctly calls super.initState(), ensuring proper widget state initialization.


18-20: The build method is straightforward and correctly returns an instance of OnBoardingPreAuthenWidget.

apps/mobile/lib/contexts/identiy_access/users/presentation/widgets/on_boarding_pre_authen_widget.dart (1)

6-6: Constructor correctly utilizes super.key, aligning with Flutter best practices.

apps/mobile/lib/contexts/identiy_access/users/presentation/pages/waiting_screen.dart (1)

6-6: Constructor correctly utilizes super.key, aligning with Flutter best practices.

apps/mobile/lib/contexts/identiy_access/users/presentation/pages/login_screen.dart (1)

21-62: The build method is well-constructed with a clear layout and validation logic for the form fields. Good use of FormState for managing form validation.

Comment on lines +30 to +77
return Container(
color: Colors.blue, // Màu nền tùy chỉnh
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(widget.icon, size: 100, color: Colors.white),
SizedBox(height: 20),
Text(
widget.text,
style: TextStyle(fontSize: 24, color: Colors.white),
textAlign: TextAlign.center,
),
SizedBox(height: 40),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (widget.showBackButton)
ElevatedButton(
onPressed: () => widget.pageController.previousPage(
duration: Duration(milliseconds: 500),
curve: Curves.ease,
),
child: Text('Quay lại'),
),
if (widget.showNextButton)
ElevatedButton(
onPressed: () => widget.pageController.nextPage(
duration: Duration(milliseconds: 500),
curve: Curves.ease,
),
child: Text('Tiếp theo'),
),
if (widget.showFinalButton)
ElevatedButton(
onPressed: () => (Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => OnBoardingPreAuthenWidget(),
),
)),
child: Text('Skip'),
),
],
),
],
),
),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Review the widget build method for potential improvements.

The build method is well-structured, but there are a couple of areas that could be improved for better performance and readability:

  1. Color and TextStyle Definitions: Consider defining the color and text styles outside the build method or in a theme to avoid recreating these objects on every build.
  2. Button Creation: The button creation code is repetitive. You could create a helper method to generate buttons to reduce redundancy and improve maintainability.
+ Color backgroundColor = Colors.blue;
+ TextStyle textStyle = TextStyle(fontSize: 24, color: Colors.white);

- color: Colors.blue,
+ color: backgroundColor,

- style: TextStyle(fontSize: 24, color: Colors.white),
+ style: textStyle,

Additionally, consider extracting the button logic into a separate method:

+ Widget _buildButton(String text, VoidCallback onPressed) {
+   return ElevatedButton(
+     onPressed: onPressed,
+     child: Text(text),
+   );
+ }

- ElevatedButton(
-   onPressed: () => widget.pageController.previousPage(
-     duration: Duration(milliseconds: 500),
-     curve: Curves.ease,
-   ),
-   child: Text('Quay lại'),
- ),
+ _buildButton('Quay lại', () => widget.pageController.previousPage(
+   duration: Duration(milliseconds: 500),
+   curve: Curves.ease,
+ )),

Comment on lines +16 to +54
Widget build(BuildContext context) {
final PageController _pageController = PageController();
return Scaffold(
body: PageView(
controller: _pageController,
onPageChanged: (int page) {
setState(() {
_currentPage = page;
});
},
children: [
WaitingPageWidget(
text: 'Chào mừng đến với ứng dụng của chúng tôi!',
icon: Icons.emoji_emotions,
showNextButton: true,
showBackButton: false,
showFinalButton: false,
pageController: _pageController,
),
WaitingPageWidget(
text: 'Khám phá các tính năng tuyệt vời!',
icon: Icons.explore,
showNextButton: true,
showBackButton: true,
showFinalButton: false,
pageController: _pageController,
),
WaitingPageWidget(
text: 'Bắt đầu hành trình của bạn ngay bây giờ!',
icon: Icons.rocket_launch,
showNextButton: false,
showBackButton: true,
showFinalButton: true,
pageController: _pageController,
),
],
),
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The build method effectively uses a PageView for navigation. However, consider using a single instance of PageController initialized in the constructor or as a final variable to avoid potential issues with multiple instances.

Comment on lines +13 to +19
void _login() {
if (_formKey.currentState?.validate() ?? false) {
String username = _usernameController.text;
String password = _passwordController.text;
print('Username: $username, Password: $password');
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The _login method logs sensitive data (username and password) directly to the console, which is a security risk. Please remove or modify the logging statement to avoid exposing sensitive information.

  • apps/mobile/lib/contexts/identiy_access/users/presentation/pages/login_screen.dart line 17
Analysis chain

The _login method correctly handles form validation and data extraction. Ensure sensitive data like passwords are handled securely in production environments.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that sensitive data handling in the `_login` method adheres to security best practices.

# Test: Search for logging or improper handling of sensitive data. Expect: No direct logging of sensitive data.
rg --type dart 'print' apps/mobile/lib/contexts/identiy_access/users/presentation/pages/login_screen.dart

Length of output: 162

@harrytran998 harrytran998 deleted the TML-48 branch July 9, 2024 07:13
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