From ea3354d6fb3ea1c0b4cbd1ed9c4a8597a07f3ee0 Mon Sep 17 00:00:00 2001 From: mostafametwally Date: Sat, 24 Feb 2024 21:24:02 +0100 Subject: [PATCH] added property Platform to sitestate to detect maui platform --- Oqtane.Client/UI/Head.razor | 8 ++++++++ Oqtane.Maui/Head.razor | 1 + Oqtane.Shared/Shared/SiteState.cs | 1 + 3 files changed, 10 insertions(+) diff --git a/Oqtane.Client/UI/Head.razor b/Oqtane.Client/UI/Head.razor index 7929e5067..95cd72ee0 100644 --- a/Oqtane.Client/UI/Head.razor +++ b/Oqtane.Client/UI/Head.razor @@ -22,6 +22,9 @@ [Parameter] public string RenderMode { get; set; } + [Parameter] + public string Platform { get; set; } + [Parameter] public string Runtime { get; set; } @@ -30,6 +33,11 @@ ((INotifyPropertyChanged)SiteState.Properties).PropertyChanged += PropertyChanged; } + protected override async Task OnParametersSetAsync() + { + SiteState.Platform = Platform; + } + private void PropertyChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) diff --git a/Oqtane.Maui/Head.razor b/Oqtane.Maui/Head.razor index 43c73f479..a88e76d62 100644 --- a/Oqtane.Maui/Head.razor +++ b/Oqtane.Maui/Head.razor @@ -11,6 +11,7 @@ Parameters = new Dictionary(); Parameters.Add(new KeyValuePair("RenderMode", RenderModes.Interactive)); Parameters.Add(new KeyValuePair("Runtime", Runtimes.Hybrid)); + Parameters.Add(new KeyValuePair("Platform", DeviceInfo.Current.Platform.ToString())); } } diff --git a/Oqtane.Shared/Shared/SiteState.cs b/Oqtane.Shared/Shared/SiteState.cs index 3a689e6cc..a342a5e3f 100644 --- a/Oqtane.Shared/Shared/SiteState.cs +++ b/Oqtane.Shared/Shared/SiteState.cs @@ -13,6 +13,7 @@ public class SiteState public string AuthorizationToken { get; set; } // passed from server for use in service calls on client public string RemoteIPAddress { get; set; } // passed from server as cannot be reliably retrieved on client public bool IsPrerendering { get; set; } + public string Platform { get; set; } //updated by Maui to retrieve platform in client private dynamic _properties; public dynamic Properties => _properties ?? (_properties = new PropertyDictionary());