-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jorge Andrés Díaz
authored and
Jorge Andrés Díaz
committed
Feb 9, 2024
1 parent
496c99e
commit a669bba
Showing
15 changed files
with
426 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"@@locale": "en_US", | ||
|
||
"app_name": "Solar Energy Prediction", | ||
|
||
"app_requires_location_services_and_permission_title": "This app requires GPS enabled and location permission granted", | ||
"request_gps_services_button": "Request GPS services" | ||
|
||
"request_gps_services_button": "Request GPS services", | ||
"locating_user_on_map_text": "Locating user on map...", | ||
"user_location_is_unknown_text": "User location is unknown!" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:google_maps_flutter/google_maps_flutter.dart'; | ||
|
||
extension LocationExtension on LatLng { | ||
bool isDefaultPoint() { | ||
return longitude == 0 && latitude == 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class AppColors { | ||
static const purpleMedium = Color(0xFF8A05BE); | ||
static const caribbeanGreen = Color(0xFF00D180); | ||
static const pinkSalmon = Color(0xFFFF99AA); | ||
static const grayEmperor = Color(0xFF524F52); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
const mapTheme = [ | ||
{ | ||
"featureType": "all", | ||
"elementType": "geometry.fill", | ||
"stylers": [ | ||
{"weight": "2.00"} | ||
] | ||
}, | ||
{ | ||
"featureType": "all", | ||
"elementType": "geometry.stroke", | ||
"stylers": [ | ||
{"color": "#9c9c9c"} | ||
] | ||
}, | ||
{ | ||
"featureType": "all", | ||
"elementType": "labels.text", | ||
"stylers": [ | ||
{"visibility": "on"} | ||
] | ||
}, | ||
{ | ||
"featureType": "landscape", | ||
"elementType": "all", | ||
"stylers": [ | ||
{"color": "#f2f2f2"} | ||
] | ||
}, | ||
{ | ||
"featureType": "landscape", | ||
"elementType": "geometry.fill", | ||
"stylers": [ | ||
{"color": "#ffffff"} | ||
] | ||
}, | ||
{ | ||
"featureType": "landscape.man_made", | ||
"elementType": "geometry.fill", | ||
"stylers": [ | ||
{"color": "#ffffff"} | ||
] | ||
}, | ||
{ | ||
"featureType": "poi", | ||
"elementType": "all", | ||
"stylers": [ | ||
{"visibility": "off"} | ||
] | ||
}, | ||
{ | ||
"featureType": "road", | ||
"elementType": "all", | ||
"stylers": [ | ||
{"saturation": -100}, | ||
{"lightness": 45} | ||
] | ||
}, | ||
{ | ||
"featureType": "road", | ||
"elementType": "geometry.fill", | ||
"stylers": [ | ||
{"color": "#eeeeee"} | ||
] | ||
}, | ||
{ | ||
"featureType": "road", | ||
"elementType": "labels.text.fill", | ||
"stylers": [ | ||
{"color": "#7b7b7b"} | ||
] | ||
}, | ||
{ | ||
"featureType": "road", | ||
"elementType": "labels.text.stroke", | ||
"stylers": [ | ||
{"color": "#ffffff"} | ||
] | ||
}, | ||
{ | ||
"featureType": "road.highway", | ||
"elementType": "all", | ||
"stylers": [ | ||
{"visibility": "simplified"} | ||
] | ||
}, | ||
{ | ||
"featureType": "road.arterial", | ||
"elementType": "labels.icon", | ||
"stylers": [ | ||
{"visibility": "off"} | ||
] | ||
}, | ||
{ | ||
"featureType": "transit", | ||
"elementType": "all", | ||
"stylers": [ | ||
{"visibility": "off"} | ||
] | ||
}, | ||
{ | ||
"featureType": "water", | ||
"elementType": "all", | ||
"stylers": [ | ||
{"color": "#46bcec"}, | ||
{"visibility": "on"} | ||
] | ||
}, | ||
{ | ||
"featureType": "water", | ||
"elementType": "geometry.fill", | ||
"stylers": [ | ||
{"color": "#c8d7d4"} | ||
] | ||
}, | ||
{ | ||
"featureType": "water", | ||
"elementType": "labels.text.fill", | ||
"stylers": [ | ||
{"color": "#070707"} | ||
] | ||
}, | ||
{ | ||
"featureType": "water", | ||
"elementType": "labels.text.stroke", | ||
"stylers": [ | ||
{"color": "#ffffff"} | ||
] | ||
} | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
lib/features/map/presentation/view_models/map_view_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:flutter/cupertino.dart'; | ||
import 'package:google_maps_flutter/google_maps_flutter.dart'; | ||
import 'package:location/location.dart'; | ||
import 'package:solar_energy_prediction/core/config/l10n/l10n.dart'; | ||
import 'package:solar_energy_prediction/core/extensions/location_extensions.dart'; | ||
import 'package:solar_energy_prediction/core/notifier_helpers/snackbar_status_notifier.dart'; | ||
import 'package:solar_energy_prediction/core/theme/map_theme.dart'; | ||
|
||
class MapViewModel extends ChangeNotifier with SnackbarStatusMixin { | ||
final Location _location; | ||
|
||
Location get location => _location; | ||
|
||
LatLng _lastKnownLocation; | ||
|
||
LatLng get lastKnownLocation => _lastKnownLocation; | ||
|
||
GoogleMapController? _mapController; | ||
|
||
GoogleMapController? get mapController => _mapController; | ||
|
||
MapViewModel({ | ||
required Location location, | ||
}) : _location = location, | ||
_lastKnownLocation = const LatLng(0, 0); | ||
|
||
Future<void> updateLastKnownLocation() async { | ||
final currentLocation = await location.getLocation(); | ||
_lastKnownLocation = LatLng(currentLocation.latitude ?? 0, currentLocation.longitude ?? 0); | ||
notifyListeners(); | ||
} | ||
|
||
void onMapInitialized(GoogleMapController mapController) { | ||
_mapController = mapController; | ||
_mapController?.setMapStyle(jsonEncode(mapTheme)); | ||
} | ||
|
||
void locateUserOnMap() { | ||
if (_lastKnownLocation.isDefaultPoint()) { | ||
snackBarStatus.postError(S.current.user_location_is_unknown_text); | ||
} else { | ||
final cameraUpdate = CameraUpdate.newLatLng(_lastKnownLocation); | ||
_mapController?.animateCamera(cameraUpdate); | ||
} | ||
} | ||
} |
Oops, something went wrong.