diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7b363cb..bcc040c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Setup dotnet uses: actions/setup-dotnet@v5 @@ -32,7 +32,7 @@ jobs: run: touch $OUTPUT_PATH/.nojekyll - name: Commit wwwroot to GitHub Pages - uses: JamesIves/github-pages-deploy-action@v4.5.0 + uses: JamesIves/github-pages-deploy-action@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: gh-pages diff --git a/.github/workflows/pack-nightly.yml b/.github/workflows/pack-nightly.yml index 2e82c13..40a9554 100644 --- a/.github/workflows/pack-nightly.yml +++ b/.github/workflows/pack-nightly.yml @@ -31,7 +31,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Get Version run: | @@ -62,7 +62,7 @@ jobs: run: dotnet nuget push "nugets/*.nupkg" --api-key ${{ secrets.IRIHI_NUGET_API_KEY }} --source irihi.tech --skip-duplicate - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: nugets path: nugets diff --git a/.github/workflows/pack.yml b/.github/workflows/pack.yml index 4d8d8f2..d68411c 100644 --- a/.github/workflows/pack.yml +++ b/.github/workflows/pack.yml @@ -47,7 +47,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Pack 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 - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: nugets path: nugets diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ee4062e..51e3b14 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -75,11 +75,11 @@ jobs: runs-on: windows-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - 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 - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: Semi.Avalonia.Demo.Desktop.win-x64 path: | @@ -91,13 +91,13 @@ jobs: runs-on: windows-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Enable Native AOT in .csproj run: sed -i 's##true#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj - name: Publish win-x64 AOT run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r win-x64 -c Release -o publish - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: Semi.Avalonia.Demo.Desktop.win-x64.NativeAOT path: | @@ -109,11 +109,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - 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 - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: Semi.Avalonia.Demo.Desktop.linux-x64 path: | @@ -125,13 +125,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Enable Native AOT in .csproj run: sed -i 's##true#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj - name: Publish linux-x64 AOT run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r linux-x64 -c Release -o publish - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: Semi.Avalonia.Demo.Desktop.linux-x64.NativeAOT path: | @@ -143,11 +143,11 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - 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 - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: Semi.Avalonia.Demo.Drm.linux-x64 path: | @@ -159,13 +159,13 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Enable Native AOT in .csproj run: sed -i 's##true#' demo/Semi.Avalonia.Demo.Drm/Semi.Avalonia.Demo.Drm.csproj - name: Publish linux-x64 AOT run: dotnet publish demo/Semi.Avalonia.Demo.Drm -r linux-x64 -c Release -o publish - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: Semi.Avalonia.Demo.Drm.linux-x64.NativeAOT path: | @@ -177,11 +177,11 @@ jobs: runs-on: macos-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - 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 - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: Semi.Avalonia.Demo.Desktop.osx-arm64 path: | @@ -193,13 +193,13 @@ jobs: runs-on: macos-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Enable Native AOT in .csproj run: sed -i '' 's##true#' demo/Semi.Avalonia.Demo.Desktop/Semi.Avalonia.Demo.Desktop.csproj - name: Publish osx-arm64 AOT run: dotnet publish demo/Semi.Avalonia.Demo.Desktop -r osx-arm64 -c Release -o publish - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: Semi.Avalonia.Demo.Desktop.osx-arm64.NativeAOT path: | @@ -211,7 +211,7 @@ jobs: runs-on: windows-latest steps: - name: Checkout - uses: actions/checkout@v5 + uses: actions/checkout@v6 - name: Install Android workload run: dotnet workload install android - name: Restore Dependencies @@ -219,7 +219,7 @@ jobs: - 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 - name: Upload a Build Artifact - uses: actions/upload-artifact@v4.6.2 + uses: actions/upload-artifact@v7 with: name: android-arm64 path: publish/*Signed.apk diff --git a/.github/workflows/release-tag.yml b/.github/workflows/release-tag.yml index 36c5a97..83c0466 100644 --- a/.github/workflows/release-tag.yml +++ b/.github/workflows/release-tag.yml @@ -41,7 +41,7 @@ jobs: needs: [ nuget,publish ] runs-on: ubuntu-latest steps: - - uses: actions/download-artifact@v4.3.0 + - uses: actions/download-artifact@v8 - name: Display structure of downloaded files run: ls -R @@ -62,7 +62,7 @@ jobs: run: ls -R - 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' with: generate_release_notes: true diff --git a/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj b/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj index 2b85fe5..aec0255 100644 --- a/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj +++ b/demo/Semi.Avalonia.Demo/Semi.Avalonia.Demo.csproj @@ -14,7 +14,7 @@ - + None All diff --git a/src/Semi.Avalonia.ColorPicker/ColorPickerSemiTheme.axaml b/src/Semi.Avalonia.ColorPicker/ColorPickerSemiTheme.axaml index 42887da..f4c3ed7 100644 --- a/src/Semi.Avalonia.ColorPicker/ColorPickerSemiTheme.axaml +++ b/src/Semi.Avalonia.ColorPicker/ColorPickerSemiTheme.axaml @@ -6,6 +6,7 @@ + diff --git a/src/Semi.Avalonia.DataGrid/DataGridSemiTheme.axaml b/src/Semi.Avalonia.DataGrid/DataGridSemiTheme.axaml index dffe25f..cfbd6ed 100644 --- a/src/Semi.Avalonia.DataGrid/DataGridSemiTheme.axaml +++ b/src/Semi.Avalonia.DataGrid/DataGridSemiTheme.axaml @@ -6,6 +6,7 @@ + diff --git a/src/Semi.Avalonia/Index.axaml b/src/Semi.Avalonia/Index.axaml index a9ada0b..7a600df 100644 --- a/src/Semi.Avalonia/Index.axaml +++ b/src/Semi.Avalonia/Index.axaml @@ -4,17 +4,18 @@ - - - - - - + + + + + + + - + diff --git a/src/Semi.Avalonia/Properties/AssemblyInfo.cs b/src/Semi.Avalonia/Properties/AssemblyInfo.cs index 71b358a..67efa50 100644 --- a/src/Semi.Avalonia/Properties/AssemblyInfo.cs +++ b/src/Semi.Avalonia/Properties/AssemblyInfo.cs @@ -2,4 +2,6 @@ [assembly: XmlnsPrefix("https://irihi.tech/semi", "semi")] [assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia")] -[assembly: XmlnsDefinition("https://irihi.tech/semi", "Semi.Avalonia.Converters")] \ No newline at end of file +[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")] diff --git a/src/Semi.Avalonia/Schemes/AquaticScheme.axaml b/src/Semi.Avalonia/Schemes/AquaticScheme.axaml deleted file mode 100644 index 251c757..0000000 --- a/src/Semi.Avalonia/Schemes/AquaticScheme.axaml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Semi.Avalonia/Schemes/DarkScheme.axaml b/src/Semi.Avalonia/Schemes/DarkScheme.axaml deleted file mode 100644 index 9269f84..0000000 --- a/src/Semi.Avalonia/Schemes/DarkScheme.axaml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Semi.Avalonia/Schemes/DesertScheme.axaml b/src/Semi.Avalonia/Schemes/DesertScheme.axaml deleted file mode 100644 index 90d53b7..0000000 --- a/src/Semi.Avalonia/Schemes/DesertScheme.axaml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Semi.Avalonia/Schemes/DuskScheme.axaml b/src/Semi.Avalonia/Schemes/DuskScheme.axaml deleted file mode 100644 index ba61cd2..0000000 --- a/src/Semi.Avalonia/Schemes/DuskScheme.axaml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Semi.Avalonia/Schemes/LightScheme.axaml b/src/Semi.Avalonia/Schemes/LightScheme.axaml deleted file mode 100644 index 0788b04..0000000 --- a/src/Semi.Avalonia/Schemes/LightScheme.axaml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Semi.Avalonia/Schemes/NightSkyScheme.axaml b/src/Semi.Avalonia/Schemes/NightSkyScheme.axaml deleted file mode 100644 index 74d6e92..0000000 --- a/src/Semi.Avalonia/Schemes/NightSkyScheme.axaml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/Semi.Avalonia/SemiTheme.axaml b/src/Semi.Avalonia/SemiTheme.axaml index 3b63207..69cc688 100644 --- a/src/Semi.Avalonia/SemiTheme.axaml +++ b/src/Semi.Avalonia/SemiTheme.axaml @@ -5,19 +5,20 @@ - - - - - - + + + + + + + - + - + diff --git a/src/Semi.Avalonia/SemiTheme.axaml.cs b/src/Semi.Avalonia/SemiTheme.axaml.cs index 8b3e148..cff06ca 100644 --- a/src/Semi.Avalonia/SemiTheme.axaml.cs +++ b/src/Semi.Avalonia/SemiTheme.axaml.cs @@ -3,6 +3,7 @@ using System.Globalization; using Avalonia; using Avalonia.Controls; using Avalonia.Styling; +using Irihi.Avalonia.Shared.Helpers; using Semi.Avalonia.Locale; namespace Semi.Avalonia; @@ -36,43 +37,27 @@ public class SemiTheme : Styles private static readonly ResourceDictionary DefaultResource = new zh_cn(); - private CultureInfo? _locale; - public CultureInfo? Locale { - get => _locale; + get; set { try { if (TryGetLocaleResource(value, out var resource) && resource is not null) { - _locale = value; - if (Resources is ResourceDictionary rd) - { - rd.SetItems(resource); - } - else - { - foreach (var kv in resource) Resources[kv.Key] = kv.Value; - } + field = value; + Resources.BulkSetResources(resource); } else { - _locale = new CultureInfo("zh-CN"); - if (Resources is ResourceDictionary rd) - { - rd.SetItems(DefaultResource); - } - else - { - foreach (var kv in DefaultResource) Resources[kv.Key] = kv.Value; - } + field = new CultureInfo("zh-CN"); + Resources.BulkSetResources(DefaultResource); } } catch { - _locale = CultureInfo.InvariantCulture; + field = CultureInfo.InvariantCulture; } } } @@ -105,28 +90,13 @@ public class SemiTheme : Styles { if (culture is null) return; if (!LocaleToResource.TryGetValue(culture, out var resources)) return; - - if (application.Resources is ResourceDictionary rd) - { - rd.SetItems(resources); - } - else - { - foreach (var kv in resources) application.Resources[kv.Key] = kv.Value; - } + application.Resources.BulkSetResources(resources); } public static void OverrideLocaleResources(StyledElement element, CultureInfo? culture) { if (culture is null) return; if (!LocaleToResource.TryGetValue(culture, out var resources)) return; - if (element.Resources is ResourceDictionary rd) - { - rd.SetItems(resources); - } - else - { - foreach (var kv in resources) element.Resources[kv.Key] = kv.Value; - } + element.Resources.BulkSetResources(resources); } } \ No newline at end of file diff --git a/src/Semi.Avalonia/Tokens/_index.axaml b/src/Semi.Avalonia/Tokens/_index.axaml new file mode 100644 index 0000000..44d8685 --- /dev/null +++ b/src/Semi.Avalonia/Tokens/_index.axaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + \ No newline at end of file