6177214e-ce7c-49e3-99de-ff9721b26f63 — Commit 2b0e5540
Changed files
comwell_key_app/assets/translations/da-DK.json | 6 +- comwell_key_app/assets/translations/en-US.json | 6 +- .../components/maps_bottom_modal.dart | 99 ++++++++++++++++------ .../pages/restaurant_facility_page.dart | 2 - 4 files changed, 84 insertions(+), 29 deletions(-)
Diff
diff --git a/comwell_key_app/assets/translations/da-DK.json b/comwell_key_app/assets/translations/da-DK.json
index 7c735669..b07eeaf5 100644
--- a/comwell_key_app/assets/translations/da-DK.json
+++ b/comwell_key_app/assets/translations/da-DK.json
@@ -258,5 +258,9 @@
"restaurant": "Restaurant",
"spa": "Spa",
"parking": "Parkering",
- "go_to_payment": "Gå til betaling"
+ "go_to_payment": "Gå til betaling",
+ "open_maps_error_title": "Kan ikke åbne kort",
+ "open_maps_error_subtitle": "Ingen kortprogram er tilgængeligt.",
+ "apple_maps": "Apple Kort",
+ "google_maps": "Google Kort"
}
\ No newline at end of file
diff --git a/comwell_key_app/assets/translations/en-US.json b/comwell_key_app/assets/translations/en-US.json
index e50f51e5..f9e09a20 100644
--- a/comwell_key_app/assets/translations/en-US.json
+++ b/comwell_key_app/assets/translations/en-US.json
@@ -257,5 +257,9 @@
"check_in_button_timer_minutes": "In {} minutes",
"check_in_button_timer_seconds": "In {} seconds",
"payment_cards_approve_conditions_title": "I accept ",
- "payment_cards_approve_conditions_subtitle": "terms and conditions"
+ "payment_cards_approve_conditions_subtitle": "terms and conditions",
+ "open_maps_error_title": "Cannot open maps",
+ "open_maps_error_subtitle": "No maps application is available.",
+ "apple_maps": "Apple Maps",
+ "google_maps": "Google Maps"
}
diff --git a/comwell_key_app/lib/hotel_information/components/maps_bottom_modal.dart b/comwell_key_app/lib/hotel_information/components/maps_bottom_modal.dart
index 44feb3b5..1e6ed585 100644
--- a/comwell_key_app/lib/hotel_information/components/maps_bottom_modal.dart
+++ b/comwell_key_app/lib/hotel_information/components/maps_bottom_modal.dart
@@ -1,3 +1,4 @@
+import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'dart:io' show Platform;
@@ -10,15 +11,64 @@ class MapsBottomModal extends StatelessWidget {
required this.address,
});
- static void show(BuildContext context, String address) {
- showModalBottomSheet<void>(
- context: context,
- builder: (BuildContext context) {
- return MapsBottomModal(
- address: address,
+ static Future<void> show(BuildContext context, String address) async {
+ final theme = Theme.of(context);
+
+ if (Platform.isAndroid) {
+ final url = Uri.parse('geo:0,0?q=$address');
+ if (await canLaunchUrl(url)) {
+ await launchUrl(url, mode: LaunchMode.externalApplication);
+ } else {
+ if (context.mounted) {
+ showDialog<void>(
+ context: context,
+ builder: (context) => AlertDialog(
+ title: Text('open_maps_error_title'.tr(), ),
+ content: Text('open_maps_error_subtitle'.tr()),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(context),
+ child: Text('OK', style: theme.textTheme.bodyMedium),
+ ),
+ ],
+ ),
+ );
+ }
+ }
+ return;
+ }
+
+ // For iOS, show the modal with options
+ if (context.mounted) {
+ await showModalBottomSheet<void>(
+ context: context,
+ builder: (BuildContext context) {
+ return MapsBottomModal(address: address);
+ },
+ );
+ }
+ }
+
+ Future<void> _launchMapsUrl(BuildContext context, Uri url) async {
+ if (await canLaunchUrl(url)) {
+ await launchUrl(url, mode: LaunchMode.externalApplication);
+ } else {
+ if (context.mounted) {
+ showDialog<void>(
+ context: context,
+ builder: (context) => AlertDialog(
+ title: Text('open_maps_error_title'.tr()),
+ content: Text('open_maps_error_subtitle'.tr()),
+ actions: [
+ TextButton(
+ onPressed: () => Navigator.pop(context),
+ child: Text('OK', style: Theme.of(context).textTheme.bodyMedium),
+ ),
+ ],
+ ),
);
- },
- );
+ }
+ }
}
@override
@@ -36,29 +86,28 @@ class MapsBottomModal extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
+ ListTile(
+ leading: const Icon(Icons.map_outlined),
+ title: Text('apple_maps'.tr(), style: theme.textTheme.bodyMedium),
+ onTap: () async {
+ Navigator.pop(context);
+ await _launchMapsUrl(
+ context,
+ Uri.parse('maps://?q=$address'),
+ );
+ },
+ ),
ListTile(
leading: const Icon(Icons.map),
- title: Text('Google Maps', style: theme.textTheme.bodyMedium),
+ title: Text('google_maps'.tr(), style: theme.textTheme.bodyMedium),
onTap: () async {
Navigator.pop(context);
- final googleMapsUrl = Uri.parse('https://www.google.com/maps/search/?api=1&query=$address');
- if (await canLaunchUrl(googleMapsUrl)) {
- await launchUrl(googleMapsUrl, mode: LaunchMode.externalApplication);
- }
+ await _launchMapsUrl(
+ context,
+ Uri.parse('https://www.google.com/maps/search/?api=1&query=$address'),
+ );
},
),
- if (Platform.isIOS)
- ListTile(
- leading: const Icon(Icons.map_outlined),
- title: Text('Apple Maps', style: theme.textTheme.bodyMedium),
- onTap: () async {
- Navigator.pop(context);
- final appleMapsUrl = Uri.parse('https://maps.apple.com/?q=$address');
- if (await canLaunchUrl(appleMapsUrl)) {
- await launchUrl(appleMapsUrl, mode: LaunchMode.externalApplication);
- }
- },
- ),
],
),
);
diff --git a/comwell_key_app/lib/hotel_information/pages/restaurant_facility_page.dart b/comwell_key_app/lib/hotel_information/pages/restaurant_facility_page.dart
index bfd09c69..11bbfa4d 100644
--- a/comwell_key_app/lib/hotel_information/pages/restaurant_facility_page.dart
+++ b/comwell_key_app/lib/hotel_information/pages/restaurant_facility_page.dart
@@ -18,9 +18,7 @@ class RestaurantFacilityPage extends StatelessWidget {
final Map<String, dynamic> restaurantData = restaurant.toJson();
final List<Widget> widgets = [];
-
restaurantData.forEach((key, value) {
-
switch (key) {
case 'title':
widgets.add(Text(