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

Add MapSearchErrorPage with location icon for no results found #2320

Merged
merged 1 commit into from
Dec 10, 2024

Conversation

Mozart299
Copy link
Contributor

@Mozart299 Mozart299 commented Dec 10, 2024

Summary of Changes (What does this PR do?)

  • Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Status of maturity (all need to be checked before merging):

  • I've tested this locally
  • I consider this code done
  • This change ready to hit production in its current state
  • The title of the PR states what changed and the related issues number (used for the release note).
  • I've included issue number in the "Closes #ISSUE-NUMBER" part of the "What are the relevant tickets?" section to link the issue.
  • I've updated corresponding documentation for the changes in this PR.
  • I have written unit and/or e2e tests for my change(s).

How should this be manually tested?

  • Please include the steps to be done inorder to setup and test this PR.

What are the relevant tickets?

Screenshots (optional)

Summary by CodeRabbit

  • New Features
    • Introduced a new error page for map searches that displays a message when no results are found.
    • Enhanced user experience with responsive design elements and clear messaging.

Copy link

coderabbitai bot commented Dec 10, 2024

📝 Walkthrough

Walkthrough

A new file named map_search_error_page.dart has been added to the project, introducing the MapSearchErrorPage class. This class extends StatelessWidget and serves as a user interface for displaying an error message when no search results are available on a map. The layout is responsive, utilizing a LayoutBuilder to adapt to various screen sizes, and includes a central column with an SVG icon and two messages guiding the user.

Changes

File Path Change Summary
mobile-v3/lib/src/app/map/pages/map_search_error_page.dart Added MapSearchErrorPage class with responsive UI for error display when no search results are found.

Poem

In the code, a new page does bloom,
For errors in searching, it clears the gloom.
With icons and messages, so bright and clear,
Guiding lost users, instilling cheer!
A layout that flexes, for screens big and small,
A friendly reminder, it welcomes us all! 🌟


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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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 or @coderabbitai title 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.

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: 1

🧹 Outside diff range and nitpick comments (2)
mobile-v3/lib/src/app/map/pages/map_search_error_page.dart (2)

8-13: Consider adding documentation and improving responsiveness.

While the LayoutBuilder approach is good, consider:

  1. Adding documentation to explain the responsive calculations
  2. Adding min/max bounds for the relative sizes to ensure readability on extreme screen sizes
+ /// Builds a responsive error page that adapts to different screen sizes.
+ /// Uses relative sizing with minimum and maximum bounds for better readability.
  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
      builder: (context, constraints) {
        double maxWidth = constraints.maxWidth;
        double maxHeight = constraints.maxHeight;
+       // Ensure minimum spacing on very small screens
+       final minSpacing = maxHeight * 0.02.clamp(10.0, 20.0);

4-43: Consider implementing a more scalable error page pattern.

Since this is an error page component, consider creating a reusable base error page widget that can be extended for different error scenarios. This would promote consistency across the app and reduce code duplication for future error pages.

Example approach:

abstract class BaseErrorPage extends StatelessWidget {
  final String icon;
  final String primaryMessage;
  final String secondaryMessage;
  
  const BaseErrorPage({
    required this.icon,
    required this.primaryMessage,
    required this.secondaryMessage,
    super.key,
  });
  
  // Common layout logic here
}

class MapSearchErrorPage extends BaseErrorPage {
  const MapSearchErrorPage({super.key}) : super(
    icon: AssetPaths.locationIcon,
    primaryMessage: AppLocalizations.of(context).noResultsFound,
    secondaryMessage: AppLocalizations.of(context).tryDifferentLocation,
  );
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6e7d5da and 8219db9.

⛔ Files ignored due to path filters (1)
  • mobile-v3/assets/icons/location.svg is excluded by !**/*.svg
📒 Files selected for processing (1)
  • mobile-v3/lib/src/app/map/pages/map_search_error_page.dart (1 hunks)
🔇 Additional comments (3)
mobile-v3/lib/src/app/map/pages/map_search_error_page.dart (3)

1-2: LGTM! Clean and necessary imports.

The imports are minimal and directly related to the widget's functionality.


4-5: Well-structured widget declaration!

Good choice using StatelessWidget as this is a pure presentational component.


17-21: Verify the SVG asset existence.

Ensure the location.svg asset is properly included in the pubspec.yaml assets section.

✅ Verification successful

The previous attempt didn't find the files because we might be in a different directory structure. Let's locate the correct paths first before verifying the asset existence and pubspec.yaml configuration.


The output shows that the location.svg file exists in the correct path (mobile-v3/assets/icons/location.svg). Let's verify its configuration in pubspec.yaml to ensure it's properly declared.


SVG asset verification completed successfully

The location.svg file exists at the correct path and is properly configured in pubspec.yaml under the assets section. The directory 'assets/icons/' is included in the Flutter assets configuration, which makes all SVG files in this directory accessible to the application.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if the SVG asset exists and is referenced in pubspec.yaml
if [ -f "assets/icons/location.svg" ]; then
    echo "SVG file exists"
else
    echo "SVG file missing"
fi

grep -A 5 "flutter:" pubspec.yaml | grep -A 5 "assets:"

Length of output: 181


Script:

#!/bin/bash
# Let's first find the pubspec.yaml file location
fd pubspec.yaml

# Then let's search for SVG files in the repository
fd -e svg

# Let's also check the mobile-v3 directory structure
ls -la mobile-v3

Length of output: 12557


Script:

#!/bin/bash
# Let's check the pubspec.yaml for asset configuration
cat mobile-v3/pubspec.yaml | grep -A 10 "flutter:" | grep -A 10 "assets:"

# Verify the specific SVG file exists
ls -la mobile-v3/assets/icons/location.svg

Length of output: 256

Comment on lines +14 to +39
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
'assets/icons/location.svg',
width: maxWidth * 0.5,
height: maxWidth * 0.5,
),
SizedBox(height: maxHeight * 0.05),
Text(
"No results found",
style: Theme.of(context).textTheme.headlineLarge!.copyWith(
fontSize: maxWidth * 0.06,
fontWeight: FontWeight.bold,
),
),
SizedBox(height: maxHeight * 0.02),
Text(
"Please try again with a different location name",
textAlign: TextAlign.center,
style: TextStyle(
fontSize: maxWidth * 0.04,
),
),
],
);
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Several improvements recommended for maintainability and robustness.

While the layout structure is good, consider the following improvements:

  1. Externalize strings for localization:
+ import 'package:flutter_gen/gen_l10n/app_localizations.dart';

  Text(
-   "No results found",
+   AppLocalizations.of(context).noResultsFound,
  ),
  1. Move asset path to constants:
+ // In constants.dart
+ class AssetPaths {
+   static const locationIcon = 'assets/icons/location.svg';
+ }

  SvgPicture.asset(
-   'assets/icons/location.svg',
+   AssetPaths.locationIcon,
  ),
  1. Add error handling for SVG loading:
  SvgPicture.asset(
    AssetPaths.locationIcon,
    width: maxWidth * 0.5,
    height: maxWidth * 0.5,
+   placeholderBuilder: (context) => const Icon(Icons.location_on),
  ),

Committable suggestion skipped: line range outside the PR's diff.

@Baalmart Baalmart merged commit 1f52223 into staging Dec 10, 2024
31 checks passed
@Baalmart Baalmart deleted the map-search-error-state-screen branch December 10, 2024 18:45
@Baalmart Baalmart mentioned this pull request Dec 10, 2024
8 tasks
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