diff --git a/App.xaml.cs b/App.xaml.cs index 33ae922..147c72f 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -1,5 +1,9 @@ namespace Neighbourhood.omg.lol { public partial class App : Application { + + public static string Name { get; set; } + public static string Version { get; set; } + public App(NavigatorService navigatorService) { InitializeComponent(); diff --git a/Components/Layout/AvatarMenu.razor b/Components/Layout/AvatarMenu.razor index c90ce6e..ae358b2 100644 --- a/Components/Layout/AvatarMenu.razor +++ b/Components/Layout/AvatarMenu.razor @@ -1,5 +1,4 @@ -@using System.Reflection -@inject CustomAuthenticationStateProvider AuthStateProvider; +@inject CustomAuthenticationStateProvider AuthStateProvider; @inject State State; @@ -45,7 +44,7 @@ - @assembly.Name - @assembly.Version?.ToString() + @App.Name - @App.Version @@ -81,7 +80,6 @@ @code { - AssemblyName assembly = Assembly.GetExecutingAssembly().GetName(); public void changeAddress(AddressResponseData address) { State.SelectedAddress = address; } diff --git a/LoginWebViewPage.xaml.cs b/LoginWebViewPage.xaml.cs index 62e3cb0..7cec6ca 100644 --- a/LoginWebViewPage.xaml.cs +++ b/LoginWebViewPage.xaml.cs @@ -33,6 +33,7 @@ public partial class LoginWebViewPage : ContentPage if ( client_id != null && client_secret != null && redirect_uri != null) { + //this.loginwebview.UserAgent = new System.Net.Http.Headers.ProductInfoHeaderValue(App.Name, App.Version).ToString(); this.loginwebview.Source = $"https://home.omg.lol/oauth/authorize?client_id={client_id}&scope=everything&redirect_uri={redirect_uri}&response_type=code"; } } diff --git a/MauiProgram.cs b/MauiProgram.cs index 3f05c8f..5202399 100644 --- a/MauiProgram.cs +++ b/MauiProgram.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Components.Authorization; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Neighbourhood.omg.lol.Models; +using System.Reflection; namespace Neighbourhood.omg.lol { public static class MauiProgram { @@ -22,8 +23,16 @@ namespace Neighbourhood.omg.lol { builder.Services.AddSingleton(); builder.Services.AddSingleton(); - ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); - builder.Services.AddSingleton(configurationBuilder.AddUserSecrets().Build()); + //ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); + //builder.Services.AddSingleton(configurationBuilder.AddUserSecrets().Build()); + var assembly = Assembly.GetExecutingAssembly(); + var details = assembly.GetName(); + App.Name = details.Name!; + App.Version = details.Version!.ToString(); + var appSettings = $"{App.Name}.appsettings.json"; + using var stream = assembly.GetManifestResourceStream(appSettings); + var config = new ConfigurationBuilder().AddJsonStream(stream).Build(); + builder.Configuration.AddConfiguration(config); builder.Services.AddAuthorizationCore(); builder.Services.AddScoped(); diff --git a/Neighbourhood.omg.lol.csproj b/Neighbourhood.omg.lol.csproj index ddb8e87..b24724a 100644 --- a/Neighbourhood.omg.lol.csproj +++ b/Neighbourhood.omg.lol.csproj @@ -90,6 +90,10 @@ + + + + @@ -195,6 +199,10 @@ + + + + diff --git a/RestService.cs b/RestService.cs index c83b9ea..540bfb6 100644 --- a/RestService.cs +++ b/RestService.cs @@ -19,8 +19,7 @@ namespace Neighbourhood.omg.lol { public RestService(string? token = null) { _client = new HttpClient(); _client.BaseAddress = new Uri(BaseUrl); - AssemblyName name = Assembly.GetExecutingAssembly().GetName(); - _client.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue(name.Name ?? "Neighbourhood.omg.lol", name.Version?.ToString())); + _client.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue(App.Name, App.Version)); _serializerOptions = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.SnakeCaseLower, WriteIndented = true diff --git a/appsettings.json b/appsettings.json new file mode 100644 index 0000000..7062483 --- /dev/null +++ b/appsettings.json @@ -0,0 +1,5 @@ +{ + "client_id": "08656a9ade42b8ff16b868c4bb33379e", + "client_secret": "529e47904ca8900a4fb187ecee2f6221", + "redirect_uri": "https://auth.neighbourhood.omg.lol/" +} diff --git a/wwwroot/css/style.css b/wwwroot/css/style.css index 7bcd59b..1256de8 100644 --- a/wwwroot/css/style.css +++ b/wwwroot/css/style.css @@ -461,7 +461,7 @@ article { overflow-wrap: anywhere; } -nav label { +nav label:is(.checkbox, .radio, .switch) { white-space: break-spaces; flex: 1 1 100%; } \ No newline at end of file