Skip to content

Feature/home-screen-#27#29

Merged
abelarismendy merged 6 commits intomainfrom
feature/home-screen-#27
Sep 29, 2024
Merged

Feature/home-screen-#27#29
abelarismendy merged 6 commits intomainfrom
feature/home-screen-#27

Conversation

@abelarismendy
Copy link
Copy Markdown
Contributor

@abelarismendy abelarismendy commented Sep 29, 2024

closes #27

Summary by CodeRabbit

  • New Features

    • Introduced a new HomeBloc for managing home feature state.
    • Added event handling for tab changes and search queries.
    • Implemented a modular HomeScreen with enhanced UI components, including a search bar and carousel.
    • Added support for assets in the assets/carousel/ directory.
  • Bug Fixes

    • Commented out steps in the GitHub Actions workflow for building APKs and app bundles to prevent execution errors.
  • Refactor

    • Refactored HomeScreen to improve state management and responsiveness.

@abelarismendy abelarismendy self-assigned this Sep 29, 2024
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Sep 29, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough
📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request introduce a new state management structure for the home feature of a Flutter application using the Bloc pattern. This includes the addition of a HomeBloc, related events, and states, as well as a refactored HomeScreen to utilize these new components. Additionally, modifications to the GitHub Actions workflow and the pubspec.yaml file for asset management are included.

Changes

File Path Change Summary
.github/workflows/dart.yml Commented out steps for building APK and app bundle in the GitHub Actions workflow.
lib/features/home/presentation/bloc/home_bloc.dart Added HomeBloc class to manage home feature state with events for tab and search query changes.
lib/features/home/presentation/bloc/home_event.dart Introduced HomeEvent class with TabChanged and SearchQueryChanged events for user interactions.
lib/features/home/presentation/bloc/home_state.dart Created HomeState class with properties for selected tab index and search query, including HomeInitial.
lib/features/home/presentation/screens/home_screen.dart Refactored HomeScreen to use HomeBloc, added HomeScreenContent widget, and updated UI components.
pubspec.yaml Added asset path for assets/carousel/ to include additional resources.

Assessment against linked issues

Objective Addressed Explanation
Implement home screen feature (Issue #27)

Possibly related PRs

Suggested labels

enhancement, bug

Suggested reviewers

  • RaulRinconX

Poem

🐰 In the garden where ideas bloom,
A new screen emerges, dispelling the gloom.
With tabs that change and queries that flow,
The home feature shines, ready to grow!
Hops of joy in every line,
Fluttering forward, all will be fine! 🌼


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.

@abelarismendy abelarismendy added the enhancement New feature or request label Sep 29, 2024
@abelarismendy abelarismendy added this to the Sprint 2 milestone Sep 29, 2024
Copy link
Copy Markdown

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

🧹 Outside diff range and nitpick comments (6)
lib/features/home/presentation/bloc/home_event.dart (1)

1-24: Overall implementation looks great, with a minor suggestion.

The home_event.dart file is well-structured and implements the necessary event classes for the home feature using the BLoC pattern. The classes HomeEvent, TabChanged, and SearchQueryChanged are all correctly implemented, following Dart and Flutter best practices.

These events align well with the objectives of implementing a home screen feature, handling tab changes and search query updates.

Consider adding a brief documentation comment for each class to improve code readability and maintainability. For example:

/// Base class for all home-related events.
abstract class HomeEvent extends Equatable {
  // ...
}

/// Event emitted when a tab is changed.
class TabChanged extends HomeEvent {
  // ...
}

/// Event emitted when the search query is updated.
class SearchQueryChanged extends HomeEvent {
  // ...
}
lib/features/home/presentation/bloc/home_state.dart (1)

21-25: Props override is correct, but HomeInitial class might be unnecessary.

The props getter is correctly overridden, ensuring that Equatable works as expected for state comparison.

However, the HomeInitial class seems unnecessary:

  • It doesn't add any functionality or properties to HomeState.
  • The initial state can be represented by the default HomeState constructor.

Consider removing the HomeInitial class and using HomeState() directly for the initial state in your bloc. This would simplify the code without losing any functionality. If you need to distinguish the initial state, you could add a boolean flag to HomeState instead.

-class HomeInitial extends HomeState {}

If you decide to keep HomeInitial, please add a comment explaining its purpose and how it differs from the default HomeState.

lib/features/home/presentation/bloc/home_bloc.dart (3)

7-11: LGTM: HomeBloc class declaration and constructor are well-implemented.

The HomeBloc class is correctly set up, extending Bloc<HomeEvent, HomeState> and initializing with the HomeInitial state. Event handlers are properly registered in the constructor.

Consider adding a newline before the class declaration to improve readability:

 part 'home_state.dart';
+
 class HomeBloc extends Bloc<HomeEvent, HomeState> {
   HomeBloc() : super(HomeInitial()) {
     on<TabChanged>(_onTabChanged);
     on<SearchQueryChanged>(_onSearchQueryChanged);
   }

13-22: LGTM: Event handlers are correctly implemented.

The event handlers _onTabChanged and _onSearchQueryChanged are well-implemented, following the correct pattern for updating state in a Bloc. The use of copyWith method suggests good immutability practices in the HomeState class.

For consistency, consider using the same formatting for both event handlers:

 void _onTabChanged(TabChanged event, Emitter<HomeState> emit) {
   emit(state.copyWith(selectedTabIndex: event.index));
 }

-void _onSearchQueryChanged(
-  SearchQueryChanged event,
-  Emitter<HomeState> emit,
-) {
+void _onSearchQueryChanged(SearchQueryChanged event, Emitter<HomeState> emit) {
   emit(state.copyWith(searchQuery: event.query));
 }

1-23: Overall implementation looks good, but consider adding more functionality.

The HomeBloc class is well-implemented, following Flutter Bloc best practices. It correctly handles tab changes and search query updates. However, based on the PR objectives and the provided mockup, there might be some missing functionality:

  1. The bloc doesn't seem to handle loading or displaying the content for each tab.
  2. There's no logic for handling the "See all" functionality shown in the mockup.
  3. The bloc doesn't manage the state for the featured content section.

Consider extending the HomeBloc to include these additional features:

  1. Add events and state updates for loading and storing content for each tab.
  2. Implement logic for the "See all" functionality, possibly by adding a new event and updating the state accordingly.
  3. Include state management for the featured content section, potentially by adding a featuredContent field to the state and corresponding events to update it.

These additions would make the HomeBloc more comprehensive and align it better with the objectives outlined in the PR and the provided mockup.

lib/features/home/presentation/screens/home_screen.dart (1)

71-71: Consider externalizing hard-coded strings for localization

The address 'Calle 13 #12-34' is hard-coded in the Text widget. To facilitate future localization and make it easier to maintain, consider using the Flutter intl package or a similar solution to manage strings.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 5da2899 and 69a4030.

⛔ Files ignored due to path filters (2)
  • assets/carousel/50off.jpeg is excluded by !**/*.jpeg
  • assets/carousel/free-delivery.jpeg is excluded by !**/*.jpeg
📒 Files selected for processing (6)
  • .github/workflows/dart.yml (1 hunks)
  • lib/features/home/presentation/bloc/home_bloc.dart (1 hunks)
  • lib/features/home/presentation/bloc/home_event.dart (1 hunks)
  • lib/features/home/presentation/bloc/home_state.dart (1 hunks)
  • lib/features/home/presentation/screens/home_screen.dart (1 hunks)
  • pubspec.yaml (1 hunks)
🔇 Additional comments (11)
lib/features/home/presentation/bloc/home_event.dart (3)

3-8: LGTM: Well-structured base event class.

The HomeEvent class is well-implemented:

  • Extends Equatable for proper value equality.
  • Uses a const constructor for immutability.
  • Correctly overrides the props getter with an empty list for the base class.
  • Follows Dart and Flutter naming conventions.

This provides a solid foundation for specific event classes to build upon.


10-16: LGTM: Well-implemented tab change event.

The TabChanged class is correctly implemented:

  • Extends HomeEvent as expected.
  • Uses a final property for immutability.
  • Properly overrides the props getter to include the index for equality comparison.
  • Follows Dart and Flutter naming conventions.

This class will effectively handle tab change events in the home feature.


18-24: LGTM: Well-implemented search query change event.

The SearchQueryChanged class is correctly implemented:

  • Extends HomeEvent as expected.
  • Uses a final property for immutability.
  • Properly overrides the props getter to include the query for equality comparison.
  • Follows Dart and Flutter naming conventions.

This class will effectively handle search query change events in the home feature.

lib/features/home/presentation/bloc/home_state.dart (3)

3-9: LGTM: HomeState class structure is well-defined.

The HomeState class is well-structured:

  • It extends Equatable for efficient state comparison.
  • The properties selectedTabIndex and searchQuery align with the expected home screen functionality.
  • Default values in the constructor provide a good initial state.

This structure should effectively manage the state for the home screen.


11-19: LGTM: copyWith method is correctly implemented.

The copyWith method is well-implemented:

  • It allows for creating a new HomeState with optional updates.
  • The use of the null-aware operator (??) ensures that only specified fields are updated.
  • This implementation adheres to the immutability principle, which is crucial for proper state management in Flutter/Bloc architecture.

The method correctly handles partial updates, maintaining the integrity of the state object.


1-2: Verify the file structure and imports.

The file is structured as a part of 'home_bloc.dart', which is a good practice for organizing related bloc files. However, ensure that all necessary imports (e.g., 'package:equatable/equatable.dart') are present in the main 'home_bloc.dart' file to avoid any potential issues.

✅ Verification successful

Imports are correctly set up.

The main bloc file includes all necessary imports:

  • package:equatable/equatable.dart
  • package:flutter_bloc/flutter_bloc.dart

No additional imports are required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify imports in the main bloc file
# Expected result: Should find import statements for Equatable and other necessary packages

rg --type dart "^import" lib/features/home/presentation/bloc/home_bloc.dart

Length of output: 169

lib/features/home/presentation/bloc/home_bloc.dart (1)

1-5: LGTM: Imports and part declarations are appropriate.

The imports and part declarations are correctly set up for implementing a Bloc pattern. Separating events and states into different files is a good practice for code organization.

.github/workflows/dart.yml (1)

36-39: Clarify the intention behind commenting out build steps

The build and bundle steps in the GitHub Actions workflow have been commented out. This change has significant implications:

  1. The workflow will no longer produce APK or app bundle artifacts.
  2. It may hinder automatic builds and deployments.
  3. Testing the app on different devices or distributing it could become more challenging.

These changes don't seem to align directly with the PR objective of implementing a home screen feature.

Could you please clarify:

  1. Is this change intentional?
  2. If so, what's the reasoning behind disabling these build steps?
  3. Are there alternative methods in place for building and testing the app?

To help verify the impact, you can run the following script:

This script will help identify if there are alternative build processes in place that might justify commenting out these steps.

pubspec.yaml (1)

59-59: LGTM! Verify the new asset directory.

The addition of the assets/carousel/ path is appropriate for including carousel assets, which aligns with implementing the new home screen feature as per the PR objectives.

Let's verify that the directory exists and contains assets:

This script will help ensure that the necessary assets for the carousel feature are present in the project.

✅ Verification successful

Verified: The assets/carousel/ directory exists and contains the required assets.

The addition of the assets/carousel/ path is correctly implemented, and the directory includes the necessary asset files for the carousel feature.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of the carousel assets directory and its contents.

# Test 1: Check if the directory exists
if [ -d "assets/carousel" ]; then
    echo "The assets/carousel directory exists."
else
    echo "Error: The assets/carousel directory does not exist."
    exit 1
fi

# Test 2: Check if the directory contains files
file_count=$(find assets/carousel -type f | wc -l)
if [ "$file_count" -gt 0 ]; then
    echo "The assets/carousel directory contains $file_count file(s)."
else
    echo "Warning: The assets/carousel directory is empty."
fi

# Test 3: List the files in the directory (if any)
echo "Files in assets/carousel:"
ls -1 assets/carousel

Length of output: 411

lib/features/home/presentation/screens/home_screen.dart (2)

36-40: Event handling for tab selection is correctly implemented

The _handleTabSelection method correctly checks if the tab index is changing and dispatches the TabChanged event to the HomeBloc. This ensures that the state stays in sync with the UI.


188-202: The _buildTab method is well-structured and effective

The _buildTab method cleanly constructs each tab with appropriate icons and labels, and visually indicates the selected tab using the fill property.

Comment thread lib/features/home/presentation/screens/home_screen.dart
Comment thread lib/features/home/presentation/screens/home_screen.dart Outdated
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@abelarismendy abelarismendy changed the title Feature/home screen #27 Feature/home-screen #27 Sep 29, 2024
@abelarismendy abelarismendy changed the title Feature/home-screen #27 Feature/home-screen-#27 Sep 29, 2024
@abelarismendy abelarismendy merged commit 5e386bd into main Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: DONE

Development

Successfully merging this pull request may close these issues.

feature/home-screen

2 participants