From aab2c43b249392421ad63fba5f0277e2523f6f69 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 11 Jan 2025 16:03:27 +0545 Subject: [PATCH] Dashboard update --- Helpers/GeolocationHelper.cs | 32 ++++++++ Views/DashboardPage.xaml | 138 +++++++++++++++++++++++++++++++++++ Views/DashboardPage.xaml.cs | 26 +++++++ 3 files changed, 196 insertions(+) create mode 100644 Helpers/GeolocationHelper.cs create mode 100644 Views/DashboardPage.xaml create mode 100644 Views/DashboardPage.xaml.cs 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 @@ + + + + +