feature/internationale #46
@@ -74,8 +74,11 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
void _initToken() {
|
void _initToken() {
|
||||||
mapboxAccessToken = dotenv.env['MAPBOX_ACCESS_TOKEN'] ?? '';
|
mapboxAccessToken = dotenv.env['MAPBOX_ACCESS_TOKEN'] ?? '';
|
||||||
if (mapboxAccessToken.isEmpty) {
|
if (mapboxAccessToken.isEmpty) {
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"Mapbox Access Token is not available.");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.map_token ??
|
||||||
|
"Map Access Token is not available.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +132,11 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
try {
|
try {
|
||||||
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||||
if (!serviceEnabled) {
|
if (!serviceEnabled) {
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"Location services are disabled.");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.geo_disabled ??
|
||||||
|
"Location services are disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,14 +147,18 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
showAlertDialog(
|
showAlertDialog(
|
||||||
context,
|
context,
|
||||||
AppLocalizations.of(context)?.error ?? "Error",
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
"Location permissions are denied.");
|
AppLocalizations.of(context)?.permission_denied ??
|
||||||
|
"Location permissions are denied.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (permission == LocationPermission.deniedForever) {
|
if (permission == LocationPermission.deniedForever) {
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"Location permissions are permanently denied. Enable them in settings.");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.enable_permission ??
|
||||||
|
"Location permissions are permanently denied. Enable them in settings.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const LocationSettings locationSettings = LocationSettings(
|
const LocationSettings locationSettings = LocationSettings(
|
||||||
@@ -164,7 +174,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
showAlertDialog(
|
showAlertDialog(
|
||||||
context,
|
context,
|
||||||
AppLocalizations.of(context)?.error ?? "Error",
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
"No last known position available..");
|
AppLocalizations.of(context)?.no_last_position ??
|
||||||
|
"No last known position available..");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle other errors
|
// Handle other errors
|
||||||
@@ -173,7 +184,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
showAlertDialog(
|
showAlertDialog(
|
||||||
context,
|
context,
|
||||||
AppLocalizations.of(context)?.error ?? "Error",
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
"No last known position available");
|
AppLocalizations.of(context)?.no_last_position ??
|
||||||
|
"No last known position available");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (position != null) {
|
if (position != null) {
|
||||||
@@ -185,8 +197,11 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
_initToken();
|
_initToken();
|
||||||
_getEventInfo();
|
_getEventInfo();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"Failed to get user location: $e");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.failed_location ??
|
||||||
|
"Failed to get user location");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,8 +221,11 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
}).toList();
|
}).toList();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"Failed to fetch the route: ${response.statusCode}");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.failed_fetch ??
|
||||||
|
"Failed to fetch the route");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,16 +258,23 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
showAlertDialog(
|
showAlertDialog(
|
||||||
context,
|
context,
|
||||||
AppLocalizations.of(context)?.error ?? "Error",
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
"Error: Invalid coordinates, cannot add symbol.");
|
AppLocalizations.of(context)?.invalid_coordinates_symbol ??
|
||||||
|
"Error: Invalid coordinates, cannot add symbol.");
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// Handle any exception that occurs when adding the symbol
|
// Handle any exception that occurs when adding the symbol
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"Error when adding symbol.");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.error_symbol ??
|
||||||
|
"Error when adding symbol.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"Error when adding symbol.");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.error_symbol ??
|
||||||
|
"Error when adding symbol.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,8 +285,11 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
currentRouteLine = null;
|
currentRouteLine = null;
|
||||||
}
|
}
|
||||||
if (!isUserPositionInitialized) {
|
if (!isUserPositionInitialized) {
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"User position is not yet initialized. Try again.");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.position_not_init ??
|
||||||
|
"User position is not yet initialized. Try again.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,8 +328,11 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
_zoomToFitRoute(routeCoordinates);
|
_zoomToFitRoute(routeCoordinates);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showAlertDialog(context, AppLocalizations.of(context)?.error ?? "Error",
|
showAlertDialog(
|
||||||
"Invalid coordinates or user position.");
|
context,
|
||||||
|
AppLocalizations.of(context)?.error ?? "Error",
|
||||||
|
AppLocalizations.of(context)?.invalid_coordinates ??
|
||||||
|
"Invalid coordinates or user position.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,7 +386,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
children: [
|
children: [
|
||||||
Icon(Icons.directions_walk, color: Colors.blue),
|
Icon(Icons.directions_walk, color: Colors.blue),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text('Walking'),
|
Text(AppLocalizations.of(context)?.walking ?? 'Walking'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -365,7 +396,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
children: [
|
children: [
|
||||||
Icon(Icons.directions_bike, color: Colors.green),
|
Icon(Icons.directions_bike, color: Colors.green),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text('Cycling'),
|
Text(AppLocalizations.of(context)?.cycling ?? 'Cycling'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -375,7 +406,7 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
children: [
|
children: [
|
||||||
Icon(Icons.directions_car, color: Colors.red),
|
Icon(Icons.directions_car, color: Colors.red),
|
||||||
SizedBox(width: 8),
|
SizedBox(width: 8),
|
||||||
Text('Driving'),
|
Text(AppLocalizations.of(context)?.driving ?? 'Driving'),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -410,7 +441,8 @@ class _MapboxPagesState extends State<MapboxPages> with ShowAlertDialog {
|
|||||||
child: FloatingActionButton(
|
child: FloatingActionButton(
|
||||||
onPressed: _drawRouteAndMarkers,
|
onPressed: _drawRouteAndMarkers,
|
||||||
child: Icon(Icons.directions),
|
child: Icon(Icons.directions),
|
||||||
tooltip: 'Get Directions and Markers',
|
tooltip: AppLocalizations.of(context)?.get_direction ??
|
||||||
|
'Get Directions and Markers',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
Reference in New Issue
Block a user