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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions mobile-v3/assets/icons/location.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 43 additions & 0 deletions mobile-v3/lib/src/app/map/pages/map_search_error_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class MapSearchErrorPage extends StatelessWidget {
const MapSearchErrorPage({super.key});

@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
double maxWidth = constraints.maxWidth;
double maxHeight = constraints.maxHeight;

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,
),
),
],
);
Comment on lines +14 to +39
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.

},
);
}
}
Loading