mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-15 21:56:36 +08:00
Adjust Resource Structure (#771)
* chore: update GitHub Actions to use latest versions of actions. * feat: update theme resource structure and remove Schemes. * refactor: simplify locale resource handling and remove redundant code. * feat: add Light theme resource to ColorPicker and DataGrid semi themes. * feat: replace SetResources with BulkSetResources.
This commit is contained in:
4
.github/workflows/deploy.yml
vendored
4
.github/workflows/deploy.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Setup dotnet
|
- name: Setup dotnet
|
||||||
uses: actions/setup-dotnet@v5
|
uses: actions/setup-dotnet@v5
|
||||||
@@ -32,7 +32,7 @@ jobs:
|
|||||||
run: touch $OUTPUT_PATH/.nojekyll
|
run: touch $OUTPUT_PATH/.nojekyll
|
||||||
|
|
||||||
- name: Commit wwwroot to GitHub Pages
|
- name: Commit wwwroot to GitHub Pages
|
||||||
uses: JamesIves/github-pages-deploy-action@v4.5.0
|
uses: JamesIves/github-pages-deploy-action@v4
|
||||||
with:
|
with:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
branch: gh-pages
|
branch: gh-pages
|
||||||
|
|||||||
4
.github/workflows/pack-nightly.yml
vendored
4
.github/workflows/pack-nightly.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Get Version
|
- name: Get Version
|
||||||
run: |
|
run: |
|
||||||
@@ -62,7 +62,7 @@ jobs:
|
|||||||
run: dotnet nuget push "nugets/*.nupkg" --api-key ${{ secrets.IRIHI_NUGET_API_KEY }} --source irihi.tech --skip-duplicate
|
run: dotnet nuget push "nugets/*.nupkg" --api-key ${{ secrets.IRIHI_NUGET_API_KEY }} --source irihi.tech --skip-duplicate
|
||||||
|
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: nugets
|
name: nugets
|
||||||
path: nugets
|
path: nugets
|
||||||
|
|||||||
4
.github/workflows/pack.yml
vendored
4
.github/workflows/pack.yml
vendored
@@ -47,7 +47,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Pack Semi.Avalonia
|
- name: Pack Semi.Avalonia
|
||||||
if: ${{ inputs.Semi_Avalonia }}
|
if: ${{ inputs.Semi_Avalonia }}
|
||||||
@@ -70,7 +70,7 @@ jobs:
|
|||||||
run: dotnet nuget push "nugets/*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
|
run: dotnet nuget push "nugets/*.nupkg" --api-key ${{ secrets.NUGET_ORG_API_KEY }} --source https://api.nuget.org/v3/index.json --skip-duplicate
|
||||||
|
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: nugets
|
name: nugets
|
||||||
path: nugets
|
path: nugets
|
||||||
|
|||||||
36
.github/workflows/publish.yml
vendored
36
.github/workflows/publish.yml
vendored
@@ -75,11 +75,11 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Publish win-x64
|
- name: Publish win-x64
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r win-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r win-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Semi.Avalonia.Demo.Desktop.win-x64
|
name: Semi.Avalonia.Demo.Desktop.win-x64
|
||||||
path: |
|
path: |
|
||||||
@@ -91,13 +91,13 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Enable Native AOT in .csproj
|
- name: Enable Native AOT in .csproj
|
||||||
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
||||||
- name: Publish win-x64 AOT
|
- name: Publish win-x64 AOT
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r win-x64 -c Release -o publish
|
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r win-x64 -c Release -o publish
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Semi.Avalonia.Demo.Desktop.win-x64.NativeAOT
|
name: Semi.Avalonia.Demo.Desktop.win-x64.NativeAOT
|
||||||
path: |
|
path: |
|
||||||
@@ -109,11 +109,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Publish linux-x64
|
- name: Publish linux-x64
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r linux-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r linux-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Semi.Avalonia.Demo.Desktop.linux-x64
|
name: Semi.Avalonia.Demo.Desktop.linux-x64
|
||||||
path: |
|
path: |
|
||||||
@@ -125,13 +125,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Enable Native AOT in .csproj
|
- name: Enable Native AOT in .csproj
|
||||||
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
||||||
- name: Publish linux-x64 AOT
|
- name: Publish linux-x64 AOT
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r linux-x64 -c Release -o publish
|
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r linux-x64 -c Release -o publish
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Semi.Avalonia.Demo.Desktop.linux-x64.NativeAOT
|
name: Semi.Avalonia.Demo.Desktop.linux-x64.NativeAOT
|
||||||
path: |
|
path: |
|
||||||
@@ -143,11 +143,11 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Publish linux-x64 DRM
|
- name: Publish linux-x64 DRM
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Drm -r linux-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
run: dotnet publish demo/Semi.Avalonia.Demo.Drm -r linux-x64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Semi.Avalonia.Demo.Drm.linux-x64
|
name: Semi.Avalonia.Demo.Drm.linux-x64
|
||||||
path: |
|
path: |
|
||||||
@@ -159,13 +159,13 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Enable Native AOT in .csproj
|
- name: Enable Native AOT in .csproj
|
||||||
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Drm/Semi.Avalonia.Demo.Drm.csproj
|
run: sed -i 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Drm/Semi.Avalonia.Demo.Drm.csproj
|
||||||
- name: Publish linux-x64 AOT
|
- name: Publish linux-x64 AOT
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Drm -r linux-x64 -c Release -o publish
|
run: dotnet publish demo/Semi.Avalonia.Demo.Drm -r linux-x64 -c Release -o publish
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Semi.Avalonia.Demo.Drm.linux-x64.NativeAOT
|
name: Semi.Avalonia.Demo.Drm.linux-x64.NativeAOT
|
||||||
path: |
|
path: |
|
||||||
@@ -177,11 +177,11 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Publish osx-arm64
|
- name: Publish osx-arm64
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r osx-arm64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r osx-arm64 -c Release -o publish --sc /p:PublishSingleFile=true /p:IncludeNativeLibrariesForSelfExtract=true
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Semi.Avalonia.Demo.Desktop.osx-arm64
|
name: Semi.Avalonia.Demo.Desktop.osx-arm64
|
||||||
path: |
|
path: |
|
||||||
@@ -193,13 +193,13 @@ jobs:
|
|||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Enable Native AOT in .csproj
|
- name: Enable Native AOT in .csproj
|
||||||
run: sed -i '' 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
run: sed -i '' 's#<!--<PublishAot>true</PublishAot>-->#<PublishAot>true</PublishAot>#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj
|
||||||
- name: Publish osx-arm64 AOT
|
- name: Publish osx-arm64 AOT
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r osx-arm64 -c Release -o publish
|
run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r osx-arm64 -c Release -o publish
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: Semi.Avalonia.Demo.Desktop.osx-arm64.NativeAOT
|
name: Semi.Avalonia.Demo.Desktop.osx-arm64.NativeAOT
|
||||||
path: |
|
path: |
|
||||||
@@ -211,7 +211,7 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v6
|
||||||
- name: Install Android workload
|
- name: Install Android workload
|
||||||
run: dotnet workload install android
|
run: dotnet workload install android
|
||||||
- name: Restore Dependencies
|
- name: Restore Dependencies
|
||||||
@@ -219,7 +219,7 @@ jobs:
|
|||||||
- name: Publish Android
|
- name: Publish Android
|
||||||
run: dotnet publish demo/Semi.Avalonia.Demo.Android -c Release -f net10.0-android --no-restore -o publish /p:RuntimeIdentifier=android-arm64
|
run: dotnet publish demo/Semi.Avalonia.Demo.Android -c Release -f net10.0-android --no-restore -o publish /p:RuntimeIdentifier=android-arm64
|
||||||
- name: Upload a Build Artifact
|
- name: Upload a Build Artifact
|
||||||
uses: actions/upload-artifact@v4.6.2
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: android-arm64
|
name: android-arm64
|
||||||
path: publish/*Signed.apk
|
path: publish/*Signed.apk
|
||||||
|
|||||||
4
.github/workflows/release-tag.yml
vendored
4
.github/workflows/release-tag.yml
vendored
@@ -41,7 +41,7 @@ jobs:
|
|||||||
needs: [ nuget,publish ]
|
needs: [ nuget,publish ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/download-artifact@v4.3.0
|
- uses: actions/download-artifact@v8
|
||||||
|
|
||||||
- name: Display structure of downloaded files
|
- name: Display structure of downloaded files
|
||||||
run: ls -R
|
run: ls -R
|
||||||
@@ -62,7 +62,7 @@ jobs:
|
|||||||
run: ls -R
|
run: ls -R
|
||||||
|
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: softprops/action-gh-release@v2.3.2
|
uses: softprops/action-gh-release@v3
|
||||||
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
|
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch'
|
||||||
with:
|
with:
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<PackageReference Include="Avalonia"/>
|
<PackageReference Include="Avalonia"/>
|
||||||
<PackageReference Include="Avalonia.Controls.ColorPicker"/>
|
<PackageReference Include="Avalonia.Controls.ColorPicker"/>
|
||||||
<PackageReference Include="Avalonia.Controls.DataGrid"/>
|
<PackageReference Include="Avalonia.Controls.DataGrid"/>
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove AvaloniaUI.DiagnosticsSupport package from build output in Release configuration.-->
|
||||||
<PackageReference Include="AvaloniaUI.DiagnosticsSupport">
|
<PackageReference Include="AvaloniaUI.DiagnosticsSupport">
|
||||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceInclude x:Key="Default" Source="Light.axaml" />
|
<ResourceInclude x:Key="Default" Source="Light.axaml" />
|
||||||
|
<ResourceInclude x:Key="Light" Source="Light.axaml" />
|
||||||
<ResourceInclude x:Key="Dark" Source="Dark.axaml" />
|
<ResourceInclude x:Key="Dark" Source="Dark.axaml" />
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceInclude x:Key="Default" Source="Light.axaml" />
|
<ResourceInclude x:Key="Default" Source="Light.axaml" />
|
||||||
|
<ResourceInclude x:Key="Light" Source="Light.axaml" />
|
||||||
<ResourceInclude x:Key="Dark" Source="Dark.axaml" />
|
<ResourceInclude x:Key="Dark" Source="Dark.axaml" />
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
|||||||
@@ -4,17 +4,18 @@
|
|||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceInclude x:Key="Default" Source="/Schemes/LightScheme.axaml" />
|
<ResourceInclude x:Key="Default" Source="/Themes/Light/_index.axaml" />
|
||||||
<ResourceInclude x:Key="Dark" Source="/Schemes/DarkScheme.axaml" />
|
<ResourceInclude x:Key="Light" Source="/Themes/Light/_index.axaml" />
|
||||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="/Schemes/AquaticScheme.axaml" />
|
<ResourceInclude x:Key="Dark" Source="/Themes/Dark/_index.axaml" />
|
||||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="/Schemes/DesertScheme.axaml" />
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="/Themes/HighContrast/_index.axaml" />
|
||||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="/Schemes/DuskScheme.axaml" />
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="/Themes/HighContrast/_index.axaml" />
|
||||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="/Schemes/NightSkyScheme.axaml" />
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="/Themes/HighContrast/_index.axaml" />
|
||||||
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="/Themes/HighContrast/_index.axaml" />
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceInclude Source="/Controls/_index.axaml" />
|
<ResourceInclude Source="/Controls/_index.axaml" />
|
||||||
<ResourceInclude Source="/Themes/Shared/_index.axaml" />
|
<ResourceInclude Source="/Themes/Shared/_index.axaml" />
|
||||||
<ResourceInclude Source="/Tokens/Variables.axaml" />
|
<ResourceInclude Source="/Tokens/_index.axaml" />
|
||||||
<ResourceInclude Source="/Locale/zh-cn.axaml" />
|
<ResourceInclude Source="/Locale/zh-cn.axaml" />
|
||||||
<semi:Icons />
|
<semi:Icons />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|||||||
@@ -2,4 +2,6 @@
|
|||||||
|
|
||||||
[assembly: XmlnsPrefix("https://irihi.tech/semi", "semi")]
|
[assembly: XmlnsPrefix("https://irihi.tech/semi", "semi")]
|
||||||
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia")]
|
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia")]
|
||||||
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Converters")]
|
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Converters")]
|
||||||
|
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Tokens")]
|
||||||
|
[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Tokens.Palette")]
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceInclude Source="/Tokens/HighContrast/Aquatic.axaml" />
|
|
||||||
<ResourceInclude Source="/Themes/HighContrast/_index.axaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceInclude Source="/Tokens/Palette/Dark.axaml" />
|
|
||||||
<ResourceInclude Source="/Themes/Dark/_index.axaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceInclude Source="/Tokens/HighContrast/Desert.axaml" />
|
|
||||||
<ResourceInclude Source="/Themes/HighContrast/_index.axaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceInclude Source="/Tokens/HighContrast/Dusk.axaml" />
|
|
||||||
<ResourceInclude Source="/Themes/HighContrast/_index.axaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceInclude Source="/Tokens/Palette/Light.axaml" />
|
|
||||||
<ResourceInclude Source="/Themes/Light/_index.axaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceInclude Source="/Tokens/HighContrast/NightSky.axaml" />
|
|
||||||
<ResourceInclude Source="/Themes/HighContrast/_index.axaml" />
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@@ -5,19 +5,20 @@
|
|||||||
<Styles.Resources>
|
<Styles.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
<ResourceDictionary.ThemeDictionaries>
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceInclude x:Key="Default" Source="/Schemes/LightScheme.axaml" />
|
<ResourceInclude x:Key="Default" Source="/Themes/Light/_index.axaml" />
|
||||||
<ResourceInclude x:Key="Dark" Source="/Schemes/DarkScheme.axaml" />
|
<ResourceInclude x:Key="Light" Source="/Themes/Light/_index.axaml" />
|
||||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="/Schemes/AquaticScheme.axaml" />
|
<ResourceInclude x:Key="Dark" Source="/Themes/Dark/_index.axaml" />
|
||||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="/Schemes/DesertScheme.axaml" />
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="/Themes/HighContrast/_index.axaml" />
|
||||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="/Schemes/DuskScheme.axaml" />
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="/Themes/HighContrast/_index.axaml" />
|
||||||
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="/Schemes/NightSkyScheme.axaml" />
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="/Themes/HighContrast/_index.axaml" />
|
||||||
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="/Themes/HighContrast/_index.axaml" />
|
||||||
</ResourceDictionary.ThemeDictionaries>
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceInclude Source="/Controls/_index.axaml" />
|
<ResourceInclude Source="/Controls/_index.axaml" />
|
||||||
<ResourceInclude Source="/Themes/Shared/_index.axaml" />
|
<ResourceInclude Source="/Themes/Shared/_index.axaml" />
|
||||||
<ResourceInclude Source="/Tokens/Variables.axaml" />
|
<ResourceInclude Source="/Tokens/_index.axaml" />
|
||||||
<ResourceInclude Source="/Locale/zh-cn.axaml" />
|
<ResourceInclude Source="/Locale/zh-cn.axaml" />
|
||||||
<ResourceInclude Source="/Icons/_index.axaml" />
|
<semi:Icons />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</Styles.Resources>
|
</Styles.Resources>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Globalization;
|
|||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Styling;
|
using Avalonia.Styling;
|
||||||
|
using Irihi.Avalonia.Shared.Helpers;
|
||||||
using Semi.Avalonia.Locale;
|
using Semi.Avalonia.Locale;
|
||||||
|
|
||||||
namespace Semi.Avalonia;
|
namespace Semi.Avalonia;
|
||||||
@@ -36,43 +37,27 @@ public class SemiTheme : Styles
|
|||||||
|
|
||||||
private static readonly ResourceDictionary DefaultResource = new zh_cn();
|
private static readonly ResourceDictionary DefaultResource = new zh_cn();
|
||||||
|
|
||||||
private CultureInfo? _locale;
|
|
||||||
|
|
||||||
public CultureInfo? Locale
|
public CultureInfo? Locale
|
||||||
{
|
{
|
||||||
get => _locale;
|
get;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (TryGetLocaleResource(value, out var resource) && resource is not null)
|
if (TryGetLocaleResource(value, out var resource) && resource is not null)
|
||||||
{
|
{
|
||||||
_locale = value;
|
field = value;
|
||||||
if (Resources is ResourceDictionary rd)
|
Resources.BulkSetResources(resource);
|
||||||
{
|
|
||||||
rd.SetItems(resource);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var kv in resource) Resources[kv.Key] = kv.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_locale = new CultureInfo("zh-CN");
|
field = new CultureInfo("zh-CN");
|
||||||
if (Resources is ResourceDictionary rd)
|
Resources.BulkSetResources(DefaultResource);
|
||||||
{
|
|
||||||
rd.SetItems(DefaultResource);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var kv in DefaultResource) Resources[kv.Key] = kv.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
_locale = CultureInfo.InvariantCulture;
|
field = CultureInfo.InvariantCulture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -105,28 +90,13 @@ public class SemiTheme : Styles
|
|||||||
{
|
{
|
||||||
if (culture is null) return;
|
if (culture is null) return;
|
||||||
if (!LocaleToResource.TryGetValue(culture, out var resources)) return;
|
if (!LocaleToResource.TryGetValue(culture, out var resources)) return;
|
||||||
|
application.Resources.BulkSetResources(resources);
|
||||||
if (application.Resources is ResourceDictionary rd)
|
|
||||||
{
|
|
||||||
rd.SetItems(resources);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var kv in resources) application.Resources[kv.Key] = kv.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void OverrideLocaleResources(StyledElement element, CultureInfo? culture)
|
public static void OverrideLocaleResources(StyledElement element, CultureInfo? culture)
|
||||||
{
|
{
|
||||||
if (culture is null) return;
|
if (culture is null) return;
|
||||||
if (!LocaleToResource.TryGetValue(culture, out var resources)) return;
|
if (!LocaleToResource.TryGetValue(culture, out var resources)) return;
|
||||||
if (element.Resources is ResourceDictionary rd)
|
element.Resources.BulkSetResources(resources);
|
||||||
{
|
|
||||||
rd.SetItems(resources);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (var kv in resources) element.Resources[kv.Key] = kv.Value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
16
src/Semi.Avalonia/Tokens/_index.axaml
Normal file
16
src/Semi.Avalonia/Tokens/_index.axaml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:semi="https://irihi.tech/semi">
|
||||||
|
<ResourceDictionary.ThemeDictionaries>
|
||||||
|
<semi:Light x:Key="Default" />
|
||||||
|
<semi:Light x:Key="Light" />
|
||||||
|
<semi:Dark x:Key="Dark" />
|
||||||
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Aquatic}" Source="HighContrast/Aquatic.axaml" />
|
||||||
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Desert}" Source="HighContrast/Desert.axaml" />
|
||||||
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.Dusk}" Source="HighContrast/Dusk.axaml" />
|
||||||
|
<ResourceInclude x:Key="{x:Static semi:SemiTheme.NightSky}" Source="HighContrast/NightSky.axaml" />
|
||||||
|
</ResourceDictionary.ThemeDictionaries>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<semi:Variables />
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
Reference in New Issue
Block a user