Skip to content

Commit

Permalink
Avalonia: Profile dialog, embed localization and use FluentAvaloniaUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Guerra24 committed Apr 3, 2022
1 parent e8ff194 commit 9def441
Show file tree
Hide file tree
Showing 40 changed files with 372 additions and 427 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/build-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
env:
DOTNET_NOLOGO: true
run: |
dotnet publish LRReader.Avalonia\LRReader.Avalonia.csproj -nologo -v:minimal /p:Configuration=Release /p:PublishProfile=linux-x64
dotnet publish LRReader.Avalonia.Desktop\LRReader.Avalonia.Desktop.csproj -nologo -v:minimal /p:Configuration=Release /p:PublishProfile=linux-x64
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: LRReader.Avalonia.Linux-X64
path: LRReader.Avalonia/publish/linux-x64
name: LRReader.Avalonia.Desktop.Linux-X64
path: LRReader.Avalonia.Desktop/publish/linux-x64
buildAvaloniaMacOSX64:
name: Build Avalonia macOS X64
runs-on: windows-2022
Expand All @@ -34,12 +34,12 @@ jobs:
env:
DOTNET_NOLOGO: true
run: |
dotnet publish LRReader.Avalonia\LRReader.Avalonia.csproj -nologo -v:minimal /p:Configuration=Release /p:PublishProfile=macos-x64
dotnet publish LRReader.Avalonia.Desktop\LRReader.Avalonia.Desktop.csproj -nologo -v:minimal /p:Configuration=Release /p:PublishProfile=macos-x64
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: LRReader.Avalonia.macOS-X64
path: LRReader.Avalonia/publish/macos-x64
name: LRReader.Avalonia.Desktop.macOS-X64
path: LRReader.Avalonia.Desktop/publish/macos-x64
buildAvaloniaWinX64:
name: Build Avalonia Windows X64
runs-on: windows-2022
Expand All @@ -52,12 +52,12 @@ jobs:
env:
DOTNET_NOLOGO: true
run: |
dotnet publish LRReader.Avalonia\LRReader.Avalonia.csproj -nologo -v:minimal /p:Configuration=Release /p:PublishProfile=win-x64
dotnet publish LRReader.Avalonia.Desktop\LRReader.Avalonia.Desktop.csproj -nologo -v:minimal /p:Configuration=Release /p:PublishProfile=win-x64
- name: Upload Artifacts
uses: actions/upload-artifact@v2
with:
name: LRReader.Avalonia.Win-X64
path: LRReader.Avalonia/publish/win-x64
name: LRReader.Avalonia.Desktop.Win-X64
path: LRReader.Avalonia.Desktop/publish/win-x64
buildUWP:
name: Build UWP
runs-on: windows-2022
Expand Down
19 changes: 19 additions & 0 deletions LRReader.Avalonia.Desktop/LRReader.Avalonia.Desktop.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ApplicationIcon>logo.ico</ApplicationIcon>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>
<ItemGroup>
<Content Include="logo.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="0.10.13" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LRReader.Avalonia\LRReader.Avalonia.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using Avalonia;

namespace LRReader.Avalonia
namespace LRReader.Avalonia.Desktop
{
class Program
static class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
Init.EarlyInit();
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion LRReader.Avalonia/App.axaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:LRReader.Shared.ViewModels"
xmlns:sty="using:FluentAvalonia.Styling"
x:Class="LRReader.Avalonia.App">
<Application.Styles>
<FluentTheme Mode="Dark"/>
<sty:FluentAvaloniaTheme />
<StyleInclude Source="avares://Aura.UI.FluentTheme/AuraUI.xaml"/>
<StyleInclude Source="/Resources/ThemeDictionary.axaml"/>
<StyleInclude Source="/Resources/AvaloniaTemplates.axaml"/>
Expand Down
4 changes: 4 additions & 0 deletions LRReader.Avalonia/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public override void OnFrameworkInitializationCompleted()
{
desktop.MainWindow = new MainWindow();
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleView)
{
singleView.MainView = new MainView();
}

base.OnFrameworkInitializationCompleted();
}
Expand Down
15 changes: 4 additions & 11 deletions LRReader.Avalonia/LRReader.Avalonia.csproj
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<StartupObject>LRReader.Avalonia.Program</StartupObject>
<ApplicationIcon>logo.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aura.UI" Version="0.1.4.2" />
<PackageReference Include="Aura.UI.FluentTheme" Version="0.1.4.2" />
<PackageReference Include="Avalonia" Version="0.10.13" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.13" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.13" />
<PackageReference Include="Microsoft.Toolkit.Mvvm" Version="7.1.2" />
<PackageReference Include="FluentAvaloniaUI" Version="1.3.2" />
<PackageReference Include="XamlNameReferenceGenerator" Version="1.3.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LRReader.Shared\LRReader.Shared.csproj" />
Expand All @@ -21,11 +19,6 @@
<AvaloniaResource Include="Assets\**" />
</ItemGroup>
<ItemGroup>
<Content Include="..\LRReader.UWP\Strings\**" LinkBase="Strings">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<EmbeddedResource Include="..\LRReader.UWP\Strings\**" LinkBase="Strings" />
</ItemGroup>
<ItemGroup>
<Content Include="logo.ico" />
</ItemGroup>
</Project>
</Project>
14 changes: 7 additions & 7 deletions LRReader.Avalonia/ResourceLoader.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Xml;
Expand All @@ -15,11 +14,12 @@ class ResourceLoader

public ResourceLoader(string file)
{
var path = AppContext.BaseDirectory;
var langFile = $"{path}/Strings/en/{file}.resw";
if (File.Exists(langFile))
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream($"LRReader.Avalonia.Strings.en.{file}.resw");
if (stream == null)
return;
using (stream)
{
var xml = new XmlTextReader(langFile);
var xml = new XmlTextReader(stream);
while (xml.Read())
{
switch (xml.NodeType)
Expand All @@ -30,7 +30,7 @@ public ResourceLoader(string file)
var key = xml.GetAttribute("name");
xml.Read();
xml.Read();
Lang.Add(key.Replace('.', '/'), xml.ReadString());
Lang.Add(key!.Replace('.', '/'), xml.ReadString());
}
break;
}
Expand Down Expand Up @@ -61,7 +61,7 @@ public static ResourceLoader GetForCurrentView(string file)

public sealed class LocalizedString : MarkupExtension
{
public string Key { get; set; }
public string Key { get; set; } = null!;

public override object ProvideValue(IServiceProvider serviceProvider)
{
Expand Down
Loading

0 comments on commit 9def441

Please sign in to comment.