Skip to content

Commit

Permalink
Adding user dialogs & debug rainbows - cleaning up mauiprogram.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Apr 1, 2024
1 parent 9b67b77 commit 0e69a98
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 59 deletions.
12 changes: 12 additions & 0 deletions ProjectTemplates/ShinyApp/.template.config/ide.host.json
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,18 @@
"text": "Add Screen Recording (Plugin.Maui.ScreenRecording)"
},
"isVisible": true
},{
"id": "userdialogs",
"name":{
"text": "Add ACR User Dialogs (Acr.UserDialogs)"
},
"isVisible": true
},{
"id": "debugrainbows",
"name":{
"text": "Add Debug Rainbows (Plugin.Maui.DebugRainbows)"
},
"isVisible": true
},{
"id": "ffimageloading",
"name":{
Expand Down
14 changes: 14 additions & 0 deletions ProjectTemplates/ShinyApp/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,20 @@
"description": "Add SkiaSharp Extended (Lottie) - Documentation: https://github.com/mono/SkiaSharp.Extended",
"displayName": "Add SkiaSharp Extended (Lottie)"
},
"userdialogs": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Add ACR User Dialogs - Documentation: https://github.com/aritchie/userdialogs",
"displayName": "Add ACR User Dialogs"
},
"debugrainbows": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Add Debug Rainbows - Documentation: https://github.com/sthewissen/Plugin.Maui.DebugRainbows",
"displayName": "Add Debug Rainbows"
},
"ffimageloading":{
"type": "parameter",
"datatype": "bool",
Expand Down
16 changes: 16 additions & 0 deletions ProjectTemplates/ShinyApp/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,4 +320,20 @@ A set of 70+ free and open source native Blazor UI controls
* [Documentation](https://blazor.radzen.com/)]
* [GitHub](https://github.com/radzenhq/radzen-blazor)

<!--#endif-->
<!--#if (userdialogs)-->
## ACR User Dialogs

_A cross platform library that allows you to call for standard user dialogs from a shared/portable library that supports Android & iOS by Allan Ritchie_

* [GitHub](https://github.com/aritchie/userdialogs)

<!--#endif-->
<!--#if (debugrainbow)-->
## Debug Rainbow

_Have you ever had a piece of XAML code that didn't produce the layout you expected? Did you change the background colors on certain elements to get an idea of where they are positioned? Admit it, you have and pretty much all of us have at some point. Either way, this is the package for you! It adds some nice colorful debug modes to your ContentPages or specific visual elements that let you immediately see where all of your elements are located! by Steven Thewissen_

[GitHub](https://github.com/sthewissen/Plugin.Maui.DebugRainbows)

<!--#endif-->
118 changes: 66 additions & 52 deletions ProjectTemplates/ShinyApp/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,15 @@
#if inappbilling
using Plugin.InAppBilling;
#endif
#if storereview
using Plugin.StoreReview;
#if debugrainbows
using Plugin.Maui.DebugRainbows;
#endif
#if barcodes
using ZXing.Net.Maui.Controls;
#endif
#if calendar
using Plugin.Maui.CalendarStore;
#endif
#if audio
using Plugin.Maui.Audio;
#endif
#if screenrecord
using Plugin.Maui.ScreenRecording;
#endif
#if fingerprint
using Plugin.Fingerprint;
#endif
#if usehttp
using Refit;
#endif
#if screenrecord
using Plugin.Maui.Audio;
#endif
#if sharpnadocv
using Sharpnado.CollectionView;
#endif
Expand Down Expand Up @@ -68,9 +56,6 @@ public static MauiApp CreateMauiApp() => MauiApp
.UseUraniumUIMaterial()
.UseUraniumUIBlurs()
#endif
#if screenrecord
.UseScreenRecording()
#endif
#if shinyframework || communitytoolkit
.UseMauiCommunityToolkit()
#endif
Expand All @@ -86,6 +71,15 @@ public static MauiApp CreateMauiApp() => MauiApp
#if sharpnadocv
.UseSharpnadoCollectionView(false)
#endif
#if (userdialogs)
.ConfigureLifecycleEvents(events =>
{
//-:cnd:noEmit
#if ANDROID
events.AddAndroid(android => android.OnApplicationCreate(app => Acr.UserDialogs.UserDialogs.Init(app)));
#endif
//+:cnd:noEmit
})
#if ffimageloading
.UseFFImageLoading()
#endif
Expand Down Expand Up @@ -146,6 +140,24 @@ public static MauiApp CreateMauiApp() => MauiApp
// .AddAppAction("battery_info", "Battery Info")
.OnAppAction(y => Shiny.Hosting.Host.GetService<ShinyApp.Delegates.AppActionDelegate>().Handle(y))
)
#endif
#if debugrainbows
//-:cnd:noEmit
#if DEBUG
.UseDebugRainbows(
// new DebugRainbowOptions{
// ShowRainbows = true,
// ShowGrid = true,
// HorizontalItemSize = 20,
// VerticalItemSize = 20,
// MajorGridLineInterval = 4,
// MajorGridLines = new GridLineOptions { Color = Color.FromRgb(255, 0, 0), Opacity = 1, Width = 4 },
// MinorGridLines = new GridLineOptions { Color = Color.FromRgb(255, 0, 0), Opacity = 1, Width = 1 },
// GridOrigin = DebugGridOrigin.TopLeft,
// }
)
#endif
//+:cnd:noEmit
#endif
.ConfigureFonts(fonts =>
{
Expand Down Expand Up @@ -190,15 +202,6 @@ static MauiAppBuilder RegisterInfrastructure(this MauiAppBuilder builder)
#endif
//+:cnd:noEmit
var s = builder.Services;
#if (audio)
s.AddSingleton(AudioManager.Current);
#endif
#if (calendar)
s.AddSingleton(CalendarStore.Default);
#endif
#if (screenrecord)
s.AddSingleton(ScreenRecording.Default);
#endif
#if appaction
s.AddSingleton<ShinyApp.Delegates.AppActionDelegate>();
#endif
Expand Down Expand Up @@ -236,23 +239,6 @@ static MauiAppBuilder RegisterInfrastructure(this MauiAppBuilder builder)
#if essentialsfilepicker
s.AddSingleton(FilePicker.Default);
#endif
#if inappbilling
s.AddSingleton(CrossInAppBilling.Current);
#endif
#if storereview
s.AddSingleton(CrossStoreReview.Current);
#endif
#if fingerprint
s.AddSingleton(sp =>
{
//-:cnd:noEmit
#if ANDROID
CrossFingerprint.SetCurrentActivityResolver(() => sp.GetRequiredService<AndroidPlatform>().CurrentActivity);
#endif
//+:cnd:noEmit
return CrossFingerprint.Current;
});
#endif
#if startup
s.AddShinyService<AppStartup>();
#endif
Expand Down Expand Up @@ -294,9 +280,6 @@ static MauiAppBuilder RegisterInfrastructure(this MauiAppBuilder builder)
#if notifications
s.AddNotifications<ShinyApp.Delegates.MyLocalNotificationDelegate>();
#endif
#if speechrecognition
s.AddSpeechRecognition();
#endif
#if usepushnative
s.AddPush<ShinyApp.Delegates.MyPushDelegate>();
#endif
Expand All @@ -310,12 +293,43 @@ static MauiAppBuilder RegisterInfrastructure(this MauiAppBuilder builder)
#if usepushfirebase
s.AddPushFirebaseMessaging<ShinyApp.Delegates.MyPushDelegate>();
#endif
#if health
#if speechrecognition
s.AddSingleton(CommunityToolkit.Maui.Media.SpeechToText.Default);
#endif
#if (audio)
#if screenrecord
builder.UseScreenRecording();
s.AddSingleton(AudioManager.Current);
#endif
#if (calendar)
s.AddSingleton(Plugin.Maui.CalendarStore.CalendarStore.Default);
#endif
#if (screenrecord)
s.AddSingleton(Plugin.Maui.ScreenRecording.ScreenRecording.Default);
#endif
#if inappbilling
s.AddSingleton(Plugin.InAppBilling.CrossInAppBilling.Current);
#endif
#if storereview
s.AddSingleton(Plugin.StoreReview.CrossStoreReview.Current);
#endif
#if fingerprint
s.AddSingleton(sp =>
{
//-:cnd:noEmit
#if !MACCATALYST
s.AddHealthIntegration();
#if ANDROID
Plugin.Fingerprint.CrossFingerprint.SetCurrentActivityResolver(() => sp.GetRequiredService<AndroidPlatform>().CurrentActivity);
#endif
//+:cnd:noEmit
return Plugin.Fingerprint.CrossFingerprint.Current;
});
#endif
#if userdialogs
s.AddSingleton(sp =>
{
Acr.UserDialogs.UserDialogs.Init(() => sp.GetRequiredService<AndroidPlatform>().CurrentActivity);
return Acr.UserDialogs.UserDialogs.Instance;
});
#endif
#if shinyframework
s.AddDataAnnotationValidation();
Expand Down
18 changes: 12 additions & 6 deletions ProjectTemplates/ShinyApp/ShinyApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,15 @@
<PackageReference Include="Onion.Maui.GoogleMaps" Version="5.0.1" />
<!--#endif-->
<!--#if (shinyframework)-->
<PackageReference Include="Prism.DryIoc.Maui" Version="9.0.436-pre" />
<PackageReference Include="Prism.DryIoc.Maui" Version="9.0.401-pre" />
<PackageReference Include="ReactiveUI.Fody" Version="19.5.41" />
<PackageReference Include="Shiny.Framework" Version="4.1.0" />
<!--#else-->
<PackageReference Include="Shiny.Core" Version="$(ShinyVersion)" />
<PackageReference Include="Shiny.Hosting.Maui" Version="$(ShinyVersion)" />
<!--#endif-->
<!--#if (localization)-->
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.3" />
<!--#endif-->
<!--#if (usemsal)-->
<PackageReference Include="Microsoft.Identity.Client" Version="4.59.0" />
Expand Down Expand Up @@ -252,9 +252,9 @@
<PackageReference Include="Sharpnado.CollectionView.Maui" Version="3.1.2" />
<!--#endif-->
<!--#if (uraniumui)-->
<PackageReference Include="UraniumUI.Material" Version="2.8.0" />
<PackageReference Include="UraniumUI.Icons.MaterialIcons" Version="2.8.0" />
<PackageReference Include="UraniumUI.Blurs" Version="2.8.0" />
<PackageReference Include="UraniumUI.Material" Version="2.8.1" />
<PackageReference Include="UraniumUI.Icons.MaterialIcons" Version="2.8.1" />
<PackageReference Include="UraniumUI.Blurs" Version="2.8.1" />
<!--#endif-->
<!--#if (screenrecord)-->
<PackageReference Include="Plugin.Maui.ScreenRecording" Version="1.0.0-preview2" />
Expand All @@ -265,6 +265,12 @@
<!--#if (skiaextended)-->
<PackageReference Include="SkiaSharp.Extended.UI.Maui" Version="2.0.0-preview.92" />
<!--#endif-->
<!--#if (userdialogs)-->
<PackageReference Include="Acr.UserDialogs" Version="9.0.0" />
<!--#endif-->
<!--#if (debugrainbows)-->
<PackageReference Include="Plugin.Maui.DebugRainbows" Version="1.2.0" Condition="'$(Configuration)' == 'Debug'" />
<!--#endif-->
<!--#if (ffimageloading)-->
<PackageReference Include="FFImageLoading.Maui" Version="1.1.0" />
<!--#endif-->
Expand All @@ -276,7 +282,7 @@
<!--#endif-->
<!--#if (useblazor && radzen)-->
<PackageReference Include="Radzen.Blazor" Version="4.29.1" />
<!--#endif-->
<!--#endif-->
</ItemGroup>

<!--#if (flipper)-->
Expand Down
2 changes: 1 addition & 1 deletion Template.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Shiny.NET Templates - One stop shop to setup almost everything you can imagine within your .NET MAUI application</Description>
<PackageType>Template</PackageType>
<PackageVersion>2.4.3</PackageVersion>
<PackageVersion>2.4.4</PackageVersion>
<PackageId>Shiny.Templates</PackageId>
<Title>Shiny Templates</Title>
<Authors>Allan Ritchie</Authors>
Expand Down

0 comments on commit 0e69a98

Please sign in to comment.