Reloadable configuration, FontService (WIP)

This commit is contained in:
2023-02-22 16:50:50 +01:00
parent d6022ee02c
commit 3db5945cfd
18 changed files with 166 additions and 41 deletions

View File

@@ -19,13 +19,14 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Controls.ItemsRepeater" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview5" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.0.0-preview4" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview4" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Svg.Skia" Version="11.0.0-preview5" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0-preview5" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="MvvmGen" Version="1.1.5" />
@@ -40,6 +41,7 @@
<ProjectReference Include="..\..\..\AppCommon\FileTime.App.Core.Abstraction\FileTime.App.Core.Abstraction.csproj" />
<ProjectReference Include="..\..\..\Providers\FileTime.Providers.Local.Abstractions\FileTime.Providers.Local.Abstractions.csproj" />
<ProjectReference Include="..\FileTime.GuiApp.Abstractions\FileTime.GuiApp.Abstractions.csproj" />
<ProjectReference Include="..\FileTime.GuiApp.Font.Abstractions\FileTime.GuiApp.Font.Abstractions.csproj" />
</ItemGroup>
</Project>

View File

@@ -9,7 +9,7 @@
</ResourceDictionary>
</Styles.Resources>
<FluentTheme Mode="Dark" />
<FluentTheme />
<Style Selector="TextBlock">
<Setter Property="Foreground" Value="{DynamicResource ForegroundBrush}" />

View File

@@ -3,4 +3,5 @@ namespace FileTime.GuiApp.ViewModels;
public interface IMainWindowViewModelBase
{
bool Loading { get; }
IObservable<string?> MainFont { get; }
}

View File

@@ -1,6 +1,9 @@
using System.Reactive.Subjects;
namespace FileTime.GuiApp.ViewModels;
public class MainWindowLoadingViewModel : IMainWindowViewModelBase
{
public bool Loading => true;
public IObservable<string?> MainFont { get; } = new BehaviorSubject<string?>("");
}

View File

@@ -9,6 +9,7 @@ using FileTime.Core.Timeline;
using FileTime.GuiApp.Services;
using FileTime.Providers.Local;
using InitableService;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using MvvmGen;
@@ -26,9 +27,11 @@ namespace FileTime.GuiApp.ViewModels;
[Inject(typeof(IItemPreviewService), PropertyAccessModifier = AccessModifier.Public)]
[Inject(typeof(IDialogService), PropertyAccessModifier = AccessModifier.Public)]
[Inject(typeof(ITimelessContentProvider), PropertyName = "_timelessContentProvider")]
[Inject(typeof(IFontService), "_fontService")]
public partial class MainWindowViewModel : IMainWindowViewModelBase
{
public bool Loading => false;
public IObservable<string?> MainFont => _fontService.MainFont;
public IGuiAppState AppState => _appState;
public string Title { get; private set; }

View File

@@ -20,9 +20,11 @@
Background="Transparent"
Closed="OnWindowClosed"
ExtendClientAreaToDecorationsHint="True"
FontFamily="{Binding MainFont^, Mode=OneWay}"
Icon="/Assets/filetime.ico"
InputElement.KeyDown="OnKeyDown"
KeyDown="OnKeyDown"
Opened="OnWindowOpened"
RequestedThemeVariant="Dark"
TransparencyLevelHint="Blur"
mc:Ignorable="d">
<Window.Resources>