From 09ecd24355045b8d59e9c12a2cc51a48764d170c Mon Sep 17 00:00:00 2001 From: syneffort Date: Wed, 21 Feb 2024 10:12:41 +0900 Subject: [PATCH] flyout --- MyFirstMauiApp/FlyoutTabSearch/App.xaml | 14 + MyFirstMauiApp/FlyoutTabSearch/App.xaml.cs | 12 + MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml | 33 ++ .../FlyoutTabSearch/AppShell.xaml.cs | 10 + .../FlyoutTabSearch/Data/ILatLongService.cs | 13 + .../FlyoutTabSearch/Data/LatLongService.cs | 27 ++ .../Data/MoonPhaseCalculator.cs | 52 +++ .../FlyoutTabSearch/Data/SunriseService.cs | 46 ++ .../FlyoutTabSearch/FlyoutTabSearch.csproj | 75 ++++ MyFirstMauiApp/FlyoutTabSearch/MainPage.xaml | 41 ++ .../FlyoutTabSearch/MainPage.xaml.cs | 25 ++ MyFirstMauiApp/FlyoutTabSearch/MauiProgram.cs | 25 ++ .../FlyoutTabSearch/Pages/AboutPage.xaml | 12 + .../FlyoutTabSearch/Pages/AboutPage.xaml.cs | 9 + .../FlyoutTabSearch/Pages/MoonPhasePage.xaml | 41 ++ .../Pages/MoonPhasePage.xaml.cs | 46 ++ .../FlyoutTabSearch/Pages/SunrisePage.xaml | 42 ++ .../FlyoutTabSearch/Pages/SunrisePage.xaml.cs | 44 ++ .../Platforms/Android/AndroidManifest.xml | 6 + .../Platforms/Android/MainActivity.cs | 11 + .../Platforms/Android/MainApplication.cs | 16 + .../Android/Resources/values/colors.xml | 6 + .../Platforms/MacCatalyst/AppDelegate.cs | 10 + .../Platforms/MacCatalyst/Info.plist | 30 ++ .../Platforms/MacCatalyst/Program.cs | 16 + .../FlyoutTabSearch/Platforms/Tizen/Main.cs | 17 + .../Platforms/Tizen/tizen-manifest.xml | 15 + .../Platforms/Windows/App.xaml | 8 + .../Platforms/Windows/App.xaml.cs | 25 ++ .../Platforms/Windows/Package.appxmanifest | 46 ++ .../Platforms/Windows/app.manifest | 15 + .../Platforms/iOS/AppDelegate.cs | 10 + .../FlyoutTabSearch/Platforms/iOS/Info.plist | 32 ++ .../FlyoutTabSearch/Platforms/iOS/Program.cs | 16 + .../Properties/launchSettings.json | 8 + .../Resources/AppIcon/appicon.svg | 4 + .../Resources/AppIcon/appiconfg.svg | 8 + .../Resources/Fonts/OpenSans-Regular.ttf | Bin 0 -> 107168 bytes .../Resources/Fonts/OpenSans-Semibold.ttf | Bin 0 -> 111060 bytes .../Resources/Images/comet.png | Bin 0 -> 4160 bytes .../Resources/Images/dotnet_bot.svg | 93 ++++ .../FlyoutTabSearch/Resources/Images/moon.png | Bin 0 -> 2348 bytes .../Resources/Images/question.png | Bin 0 -> 2881 bytes .../Resources/Images/starfield.png | Bin 0 -> 48376 bytes .../FlyoutTabSearch/Resources/Images/sun.png | Bin 0 -> 2445 bytes .../Resources/Raw/AboutAssets.txt | 15 + .../Resources/Splash/splash.svg | 8 + .../Resources/Styles/Colors.xaml | 44 ++ .../Resources/Styles/Styles.xaml | 405 ++++++++++++++++++ MyFirstMauiApp/MyFirstMauiApp.sln | 10 +- 50 files changed, 1440 insertions(+), 1 deletion(-) create mode 100644 MyFirstMauiApp/FlyoutTabSearch/App.xaml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/App.xaml.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/AppShell.xaml.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Data/ILatLongService.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Data/LatLongService.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Data/MoonPhaseCalculator.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Data/SunriseService.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/FlyoutTabSearch.csproj create mode 100644 MyFirstMauiApp/FlyoutTabSearch/MainPage.xaml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/MainPage.xaml.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/MauiProgram.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Pages/AboutPage.xaml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Pages/AboutPage.xaml.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Pages/MoonPhasePage.xaml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Pages/MoonPhasePage.xaml.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Pages/SunrisePage.xaml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Pages/SunrisePage.xaml.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Android/AndroidManifest.xml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Android/MainActivity.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Android/MainApplication.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Android/Resources/values/colors.xml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/MacCatalyst/AppDelegate.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/MacCatalyst/Info.plist create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/MacCatalyst/Program.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Tizen/Main.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Tizen/tizen-manifest.xml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Windows/App.xaml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Windows/App.xaml.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Windows/Package.appxmanifest create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/Windows/app.manifest create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/iOS/AppDelegate.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/iOS/Info.plist create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Platforms/iOS/Program.cs create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Properties/launchSettings.json create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/AppIcon/appicon.svg create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/AppIcon/appiconfg.svg create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Fonts/OpenSans-Regular.ttf create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Fonts/OpenSans-Semibold.ttf create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Images/comet.png create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Images/dotnet_bot.svg create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Images/moon.png create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Images/question.png create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Images/starfield.png create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Images/sun.png create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Raw/AboutAssets.txt create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Splash/splash.svg create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Styles/Colors.xaml create mode 100644 MyFirstMauiApp/FlyoutTabSearch/Resources/Styles/Styles.xaml 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 @@ + + + + + + + + +