diff --git a/MyFirstMauiApp/FlyoutTabSearch/App.xaml b/MyFirstMauiApp/FlyoutTabSearch/App.xaml new file mode 100644 index 0000000..860ba3a --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + + diff --git a/MyFirstMauiApp/FlyoutTabSearch/App.xaml.cs b/MyFirstMauiApp/FlyoutTabSearch/App.xaml.cs new file mode 100644 index 0000000..24d9746 --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/App.xaml.cs @@ -0,0 +1,12 @@ +namespace FlyoutTabSearch +{ + public partial class App : Application + { + public App() + { + InitializeComponent(); + + MainPage = new AppShell(); + } + } +} diff --git a/MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml b/MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml new file mode 100644 index 0000000..bb1c393 --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml @@ -0,0 +1,33 @@ + + + + + + + moon.png + + + + + + + + + + + + + + + + + + + diff --git a/MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml.cs b/MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml.cs new file mode 100644 index 0000000..2c8195c --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml.cs @@ -0,0 +1,10 @@ +namespace FlyoutTabSearch +{ + public partial class AppShell : Shell + { + public AppShell() + { + InitializeComponent(); + } + } +} diff --git a/MyFirstMauiApp/FlyoutTabSearch/Data/ILatLongService.cs b/MyFirstMauiApp/FlyoutTabSearch/Data/ILatLongService.cs new file mode 100644 index 0000000..059fe79 --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/Data/ILatLongService.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlyoutTabSearch.Data +{ + public interface ILatLongService + { + Task<(double Latitude, double Longitude)> GetLatLong(); + } +} diff --git a/MyFirstMauiApp/FlyoutTabSearch/Data/LatLongService.cs b/MyFirstMauiApp/FlyoutTabSearch/Data/LatLongService.cs new file mode 100644 index 0000000..bb99327 --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/Data/LatLongService.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlyoutTabSearch.Data +{ + public class LatLongService : ILatLongService + { + public async Task<(double Latitude, double Longitude)> GetLatLong() + { + var latLoc = 0.0; + var longLoc = 0.0; + + var status = await Permissions.RequestAsync(); + if (status == PermissionStatus.Granted) + { + var request = new GeolocationRequest(GeolocationAccuracy.Default, TimeSpan.FromSeconds(10)); + var location = await Geolocation.GetLocationAsync(request); + latLoc = location.Latitude; + longLoc = location.Longitude; + } + return (latLoc, longLoc); + } + } +} diff --git a/MyFirstMauiApp/FlyoutTabSearch/Data/MoonPhaseCalculator.cs b/MyFirstMauiApp/FlyoutTabSearch/Data/MoonPhaseCalculator.cs new file mode 100644 index 0000000..a3371cd --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/Data/MoonPhaseCalculator.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlyoutTabSearch.Data +{ + public class MoonPhaseCalculator + { + public enum Phase + { + New, + WaxingCrescent, + FirstQuarter, + WaxingGibbous, + Full, + WaningGibbous, + LastQuarter, + WaningCrescent, + } + + static double synodicLength = 29.530588853; //length in days of a complete moon cycle + static DateTime referenceNewMoonDate = new DateTime(2017, 11, 18); + + public static Phase GetPhase(DateTime date) + { + return GetPhase(GetAge(date)); + } + + static double GetAge(DateTime date) + { + double days = (date - referenceNewMoonDate).TotalDays; + + return days % synodicLength; + } + + static Phase GetPhase(double age) + { + if (age < 1) return Phase.New; + if (age < 7) return Phase.WaxingCrescent; + if (age < 8) return Phase.FirstQuarter; + if (age < 14) return Phase.WaxingGibbous; + if (age < 15) return Phase.Full; + if (age < 22) return Phase.WaningGibbous; + if (age < 23) return Phase.LastQuarter; + if (age < 29) return Phase.WaningCrescent; + + return Phase.New; + } + } +} diff --git a/MyFirstMauiApp/FlyoutTabSearch/Data/SunriseService.cs b/MyFirstMauiApp/FlyoutTabSearch/Data/SunriseService.cs new file mode 100644 index 0000000..432a544 --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/Data/SunriseService.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Threading.Tasks; + +namespace FlyoutTabSearch.Data +{ + public class SunriseService + { + const string SunriseSunsetServiceUrl = "https://api.sunrise-sunset.org"; + + public async Task<(DateTime Sunrise, DateTime Sunset)> GetSunriseSunsetTimes(double latitude, double longitude) + { + var query = $"{SunriseSunsetServiceUrl}/json?lat={latitude}&lng={longitude}&date=today"; + + var client = new HttpClient(); + client.DefaultRequestHeaders.Add("Accept", "application/json"); + var json = await client.GetStringAsync(query); + + var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; + var data = JsonSerializer.Deserialize(json, options); + + return (DateTime.Parse(data.Results.Sunrise), DateTime.Parse(data.Results.Sunset)); + } + + class SunriseSunsetData + { +#pragma warning disable 0649 + // Field is only set via JSON deserialization, so disable warning that the field is never set. + //public SunriseSunsetResults Results; + public SunriseSunsetResults Results { get; set; } +#pragma warning restore 0649 + } + + class SunriseSunsetResults + { +#pragma warning disable 0649 + // Fields are only set via JSON deserialization, so disable warning that the fields are never set. + public string Sunrise { get; set; } + public string Sunset { get; set; } +#pragma warning restore 0649 + } + } +} diff --git a/MyFirstMauiApp/FlyoutTabSearch/FlyoutTabSearch.csproj b/MyFirstMauiApp/FlyoutTabSearch/FlyoutTabSearch.csproj new file mode 100644 index 0000000..5b2bff4 --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/FlyoutTabSearch.csproj @@ -0,0 +1,75 @@ + + + + net7.0-android;net7.0-ios;net7.0-maccatalyst + $(TargetFrameworks);net7.0-windows10.0.19041.0 + + + Exe + FlyoutTabSearch + true + true + enable + + + FlyoutTabSearch + + + com.companyname.flyouttabsearch + de294658-0b5e-4eb1-af79-f5fd62d4c454 + + + 1.0 + 1 + + 11.0 + 13.1 + 21.0 + 10.0.17763.0 + 10.0.17763.0 + 6.5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + MSBuild:Compile + + + MSBuild:Compile + + + MSBuild:Compile + + + + diff --git a/MyFirstMauiApp/FlyoutTabSearch/MainPage.xaml b/MyFirstMauiApp/FlyoutTabSearch/MainPage.xaml new file mode 100644 index 0000000..0ce36b7 --- /dev/null +++ b/MyFirstMauiApp/FlyoutTabSearch/MainPage.xaml @@ -0,0 +1,41 @@ + + + + + + + + +