Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aritchie committed Dec 16, 2024
1 parent 0d35152 commit 1f679d6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 39 deletions.
2 changes: 1 addition & 1 deletion ProjectTemplates/ShinyApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public partial class App : Application
{
#if (shinyframework || prism)
#if (prism)
public App()
{
this.InitializeComponent();
Expand Down
27 changes: 1 addition & 26 deletions ProjectTemplates/ShinyApp/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,5 @@
namespace ShinyApp;

#if shinyframework
//[Shiny.Stores.ObjectStoreBinder("secure")] // defaults to standard platform preferences
// any public get/set values marked with [Reactive] will automatically be saved to the configured store
public class AppSettings : ReactiveObject, IShinyStartupTask
{
[Reactive] public AppTheme CurrentTheme { get; set; } = AppTheme.Unspecified;


public void Start()
{
if (Application.Current != null)
{
Observable
.Interval(TimeSpan.FromSeconds(1))
.Where(_ => Application.Current != null)
.Take(1)
.Subscribe(_ => Application.Current!.UserAppTheme = this.CurrentTheme);
}
this.WhenAnyValue(x => x.CurrentTheme)
.Skip(1)
.Subscribe(x => Application.Current!.UserAppTheme = x);
}
}
#else
//[Shiny.Stores.ObjectStoreBinder("secure")] // defaults to standard platform preferences
// any public get/set values that notify will automatically be saved to the configured store
public class AppSettings : NotifyPropertyChanged, IShinyStartupTask
Expand All @@ -42,5 +18,4 @@ public void Start()
.Skip(1)
.Subscribe(x => Application.Current!.UserAppTheme = x);
}
}
#endif
}
14 changes: 7 additions & 7 deletions ProjectTemplates/ShinyApp/GlobalUsings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@
global using System.Reactive.Linq;
global using System.Reactive.Threading.Tasks;
global using Microsoft.Extensions.Logging;
#if (useconfig)
#if useconfig
global using Microsoft.Extensions.Configuration;
#endif
#if (localization)
#if localization
global using Microsoft.Extensions.Localization;
#endif
#if shinyframework || reactiveui
#if reactiveui
global using ReactiveUI;
global using ReactiveUI.Fody.Helpers;
#endif
#if shinyframework || prism
#if prism
global using Prism.AppModel;
global using Prism.Navigation;
global using Prism.Services;
#endif
#if shinyframework || localization
#if localization
global using Microsoft.Extensions.Localization;
#endif
#if shinyframework || communitytoolkit
#if communitytoolkit
global using CommunityToolkit.Maui;
#endif
#if usecsharpmarkup
global using CommunityToolkit.Maui.Markup;
#endif
#if (ctmvvm)
#if ctmvvm
global using CommunityToolkit.Mvvm.ComponentModel;
global using CommunityToolkit.Mvvm.Input;
#endif
2 changes: 1 addition & 1 deletion ProjectTemplates/ShinyApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

public partial class MainPage : ContentPage
{
#if (shinyframework || prism)
#if (prism)
public MainPage()
{
this.InitializeComponent();
Expand Down
6 changes: 2 additions & 4 deletions ProjectTemplates/ShinyApp/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,10 +251,8 @@ public static MauiApp CreateMauiApp()
#endif
//+:cnd:noEmit
#endif
#if (!shinyframework)
builder.Services.AddConnectivity();
builder.Services.AddBattery();
#endif
#if shinymediator
builder.Services.AddShinyMediator(x => x
.AddMemoryCaching()
Expand All @@ -270,10 +268,10 @@ public static MauiApp CreateMauiApp()
pipeline.AddTimeout(TimeSpan.FromSeconds(5));
})
)
#if shinyframework
.UseMaui()
#if prism
.AddPrismSupport()
#endif
.UseMaui()
#if useblazor
.UseBlazor()
#endif
Expand Down

0 comments on commit 1f679d6

Please sign in to comment.