diff --git a/Helpers/GeolocationHelper.cs b/Helpers/GeolocationHelper.cs new file mode 100644 index 0000000..7117e1f --- /dev/null +++ b/Helpers/GeolocationHelper.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Justice.Helpers +{ + public class GeolocationHelper + { + public static async Task<(double Latitude, double Longitude)> GetCurrentLocationAsync() + { + var location = await Geolocation.Default.GetLocationAsync(); + if (location != null) + { + return (location.Latitude, location.Longitude); + } + throw new Exception("Unable to fetch location"); + } + + public static async Task GetReadableAddressAsync(double latitude, double longitude) + { + var placemarks = await Geocoding.Default.GetPlacemarksAsync(latitude, longitude); + var placemark = placemarks.FirstOrDefault(); + if ( placemark !=null) + { + return $"{placemark.SubLocality}, {placemark.Thoroughfare}, {placemark.Locality}, {placemark.CountryName}"; + } + return "Address Not Found"; + } + } +} diff --git a/Views/DashboardPage.xaml b/Views/DashboardPage.xaml new file mode 100644 index 0000000..6f35974 --- /dev/null +++ b/Views/DashboardPage.xaml @@ -0,0 +1,138 @@ + + + + +