diff --git a/.github/workflows/api_unittest.yml b/.github/workflows/api_unittest.yml new file mode 100644 index 0000000..10cce38 --- /dev/null +++ b/.github/workflows/api_unittest.yml @@ -0,0 +1,31 @@ +name: API Unittest + +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET10 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + + - name: Restore workloads + run: dotnet workload restore ./Test.RelativeControl/Test.RelativeControl.csproj + + - name: Restore dependencies + run: dotnet restore ./Test.RelativeControl/Test.RelativeControl.csproj + + - name: Build + run: dotnet build --no-restore --configuration Release ./Test.RelativeControl/Test.RelativeControl.csproj + + - name: Run tests + run: dotnet run --project ./Test.RelativeControl/Test.RelativeControl.csproj \ No newline at end of file diff --git a/.github/workflows/headless_unittest.yml b/.github/workflows/headless_unittest.yml new file mode 100644 index 0000000..5f5735b --- /dev/null +++ b/.github/workflows/headless_unittest.yml @@ -0,0 +1,33 @@ +# 工作流的名称 +name: Headless Unittest + +# 触发工作流的事件:当代码推送到 main 分支或发起 pull request 时运行 +on: + pull_request: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup .NET10 + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + + - name: Restore workloads + run: dotnet workload restore ./HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj + + - name: Restore dependencies + run: dotnet restore ./HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj + + - name: Build + run: dotnet build --no-restore --configuration Release ./HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj + + - name: Run tests + run: dotnet run --project ./HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj \ No newline at end of file diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Demo.RelativeControl.Android.csproj b/Demo.RelativeControl/Demo.RelativeControl.Android/Demo.RelativeControl.Android.csproj deleted file mode 100644 index 473d3a9..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Demo.RelativeControl.Android.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - Exe - net9.0-android - 21 - enable - com.CompanyName.Demo.RelativeControl - 1 - 1.0 - apk - false - - - - - Resources\drawable\Icon.png - - - - - - - - - - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Icon.png b/Demo.RelativeControl/Demo.RelativeControl.Android/Icon.png deleted file mode 100644 index 41a2a61..0000000 Binary files a/Demo.RelativeControl/Demo.RelativeControl.Android/Icon.png and /dev/null differ diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/MainActivity.cs b/Demo.RelativeControl/Demo.RelativeControl.Android/MainActivity.cs deleted file mode 100644 index dc5fb7a..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/MainActivity.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Android.App; -using Android.Content.PM; -using Avalonia; -using Avalonia.Android; -using Avalonia.ReactiveUI; - -namespace Demo.RelativeControl.Android; - -[Activity( - Label = "Demo.RelativeControl.Android", - Theme = "@style/MyTheme.NoActionBar", - Icon = "@drawable/icon", - MainLauncher = true, - ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)] -public class MainActivity : AvaloniaMainActivity { - protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) { - return base.CustomizeAppBuilder(builder).WithInterFont().UseReactiveUI(); - } -} \ No newline at end of file diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Properties/AndroidManifest.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Properties/AndroidManifest.xml deleted file mode 100644 index f6039c3..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Properties/AndroidManifest.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/AboutResources.txt b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/AboutResources.txt deleted file mode 100644 index c2bca97..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/AboutResources.txt +++ /dev/null @@ -1,44 +0,0 @@ -Images, layout descriptions, binary blobs and string dictionaries can be included -in your application as resource files. Various Android APIs are designed to -operate on the resource IDs instead of dealing with images, strings or binary blobs -directly. - -For example, a sample Android app that contains a user interface layout (main.axml), -an internationalization string table (strings.xml) and some icons (drawable-XXX/icon.png) -would keep its resources in the "Resources" directory of the application: - -Resources/ - drawable/ - icon.png - - layout/ - main.axml - - values/ - strings.xml - -In order to get the build system to recognize Android resources, set the build action to -"AndroidResource". The native Android APIs do not operate directly with filenames, but -instead operate on resource IDs. When you compile an Android application that uses resources, -the build system will package the resources for distribution and generate a class called "R" -(this is an Android convention) that contains the tokens for each one of the resources -included. For example, for the above Resources layout, this is what the R class would expose: - -public class R { - public class drawable { - public const int icon = 0x123; - } - - public class layout { - public const int main = 0x456; - } - - public class strings { - public const int first_string = 0xabc; - public const int second_string = 0xbcd; - } -} - -You would then use R.drawable.icon to reference the drawable/icon.png file, or R.layout.main -to reference the layout/main.axml file, or R.strings.first_string to reference the first -string in the dictionary file values/strings.xml. \ No newline at end of file diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-night-v31/avalonia_anim.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-night-v31/avalonia_anim.xml deleted file mode 100644 index fb8ed42..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-night-v31/avalonia_anim.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-v31/avalonia_anim.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-v31/avalonia_anim.xml deleted file mode 100644 index 149badf..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable-v31/avalonia_anim.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable/splash_screen.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable/splash_screen.xml deleted file mode 100644 index fcceec6..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/drawable/splash_screen.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-night/colors.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-night/colors.xml deleted file mode 100644 index 3c9f0b1..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-night/colors.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #212121 - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-v31/styles.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-v31/styles.xml deleted file mode 100644 index a93e7c4..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values-v31/styles.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/colors.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/colors.xml deleted file mode 100644 index 53097af..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/colors.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #FFFFFF - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/styles.xml b/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/styles.xml deleted file mode 100644 index 2deaa4c..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Android/Resources/values/styles.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/Demo.RelativeControl.Browser.csproj b/Demo.RelativeControl/Demo.RelativeControl.Browser/Demo.RelativeControl.Browser.csproj deleted file mode 100644 index 8926bb4..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Browser/Demo.RelativeControl.Browser.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - net9.0-browser - Exe - true - - - - - - - - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/Program.cs b/Demo.RelativeControl/Demo.RelativeControl.Browser/Program.cs deleted file mode 100644 index 4aa5937..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Browser/Program.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Runtime.Versioning; -using System.Threading.Tasks; -using Avalonia; -using Avalonia.Browser; -using Avalonia.ReactiveUI; -using Demo.RelativeControl; - -[assembly: SupportedOSPlatform("browser")] - -internal sealed partial class Program { - private static Task Main(string[] args) => - BuildAvaloniaApp().WithInterFont().UseReactiveUI().StartBrowserAppAsync("out"); - - public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure(); -} \ No newline at end of file diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/AssemblyInfo.cs b/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/AssemblyInfo.cs deleted file mode 100644 index f31aed8..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/AssemblyInfo.cs +++ /dev/null @@ -1 +0,0 @@ -[assembly: System.Runtime.Versioning.SupportedOSPlatform("browser")] \ No newline at end of file diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/launchSettings.json b/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/launchSettings.json deleted file mode 100644 index 8593603..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Browser/Properties/launchSettings.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "profiles": { - "Demo.RelativeControl.Browser": { - "commandName": "Project", - "launchBrowser": true, - "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" - }, - "applicationUrl": "https://localhost:7169;http://localhost:5235", - "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}" - } - } -} diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/runtimeconfig.template.json b/Demo.RelativeControl/Demo.RelativeControl.Browser/runtimeconfig.template.json deleted file mode 100644 index 0d03d03..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Browser/runtimeconfig.template.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "wasmHostProperties": { - "perHostConfig": [ - { - "name": "browser", - "host": "browser" - } - ] - } -} \ No newline at end of file diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/app.css b/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/app.css deleted file mode 100644 index f79185c..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/app.css +++ /dev/null @@ -1,58 +0,0 @@ -/* HTML styles for the splash screen */ -.avalonia-splash { - position: absolute; - height: 100%; - width: 100%; - background: white; - font-family: 'Outfit', sans-serif; - justify-content: center; - align-items: center; - display: flex; - pointer-events: none; -} - -/* Light theme styles */ -@media (prefers-color-scheme: light) { - .avalonia-splash { - background: white; - } - - .avalonia-splash h2 { - color: #1b2a4e; - } - - .avalonia-splash a { - color: #0D6EFD; - } -} - -@media (prefers-color-scheme: dark) { - .avalonia-splash { - background: #1b2a4e; - } - - .avalonia-splash h2 { - color: white; - } - - .avalonia-splash a { - color: white; - } -} - -.avalonia-splash h2 { - font-weight: 400; - font-size: 1.5rem; -} - -.avalonia-splash a { - text-decoration: none; - font-size: 2.5rem; - display: block; -} - -.avalonia-splash.splash-close { - transition: opacity 200ms, display 200ms; - display: none; - opacity: 0; -} diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/favicon.ico b/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/favicon.ico deleted file mode 100644 index da8d49f..0000000 Binary files a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/favicon.ico and /dev/null differ diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/index.html b/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/index.html deleted file mode 100644 index 4250d06..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/index.html +++ /dev/null @@ -1,47 +0,0 @@ - - - - - Demo.RelativeControl.Browser - - - - - - -
-
-

- Powered by - - - - - - - - - - - - - - -

-
-
- - - - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/main.js b/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/main.js deleted file mode 100644 index 4d5852e..0000000 --- a/Demo.RelativeControl/Demo.RelativeControl.Browser/wwwroot/main.js +++ /dev/null @@ -1,13 +0,0 @@ -import {dotnet} from './_framework/dotnet.js' - -const is_browser = typeof window != "undefined"; -if (!is_browser) throw new Error(`Expected to be running in a browser`); - -const dotnetRuntime = await dotnet - .withDiagnosticTracing(false) - .withApplicationArgumentsFromQuery() - .create(); - -const config = dotnetRuntime.getConfig(); - -await dotnetRuntime.runMain(config.mainAssemblyName, [globalThis.location.href]); diff --git a/Demo.RelativeControl/Demo.RelativeControl.Desktop/Demo.RelativeControl.Desktop.csproj b/Demo.RelativeControl/Demo.RelativeControl.Desktop/Demo.RelativeControl.Desktop.csproj index a737814..2cc1f7a 100644 --- a/Demo.RelativeControl/Demo.RelativeControl.Desktop/Demo.RelativeControl.Desktop.csproj +++ b/Demo.RelativeControl/Demo.RelativeControl.Desktop/Demo.RelativeControl.Desktop.csproj @@ -3,7 +3,7 @@ WinExe - net9.0 + net10.0 enable true @@ -13,9 +13,8 @@ - + - diff --git a/Demo.RelativeControl/Demo.RelativeControl.Desktop/Program.cs b/Demo.RelativeControl/Demo.RelativeControl.Desktop/Program.cs index 095d31b..40801a6 100644 --- a/Demo.RelativeControl/Demo.RelativeControl.Desktop/Program.cs +++ b/Demo.RelativeControl/Demo.RelativeControl.Desktop/Program.cs @@ -1,6 +1,5 @@ using System; using Avalonia; -using Avalonia.ReactiveUI; namespace Demo.RelativeControl.Desktop; @@ -8,9 +7,10 @@ sealed 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) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); + [STAThread] + public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args); // Avalonia configuration, don't remove; also used by visual designer. public static AppBuilder BuildAvaloniaApp() => - AppBuilder.Configure().UsePlatformDetect().WithInterFont().UseReactiveUI().LogToTrace(); + AppBuilder.Configure().UsePlatformDetect().WithInterFont().LogToTrace(); } \ No newline at end of file diff --git a/Demo.RelativeControl/Demo.RelativeControl.iOS/AppDelegate.cs b/Demo.RelativeControl/Demo.RelativeControl.iOS/AppDelegate.cs index 1d2403b..d21f9ed 100644 --- a/Demo.RelativeControl/Demo.RelativeControl.iOS/AppDelegate.cs +++ b/Demo.RelativeControl/Demo.RelativeControl.iOS/AppDelegate.cs @@ -1,10 +1,6 @@ using Foundation; -using UIKit; using Avalonia; -using Avalonia.Controls; using Avalonia.iOS; -using Avalonia.Media; -using Avalonia.ReactiveUI; namespace Demo.RelativeControl.iOS; @@ -17,6 +13,6 @@ public partial class AppDelegate : AvaloniaAppDelegate #pragma warning restore CA1711 // Identifiers should not have incorrect suffix { protected override AppBuilder CustomizeAppBuilder(AppBuilder builder) { - return base.CustomizeAppBuilder(builder).WithInterFont().UseReactiveUI(); + return base.CustomizeAppBuilder(builder).WithInterFont(); } } \ No newline at end of file diff --git a/Demo.RelativeControl/Demo.RelativeControl.iOS/Demo.RelativeControl.iOS.csproj b/Demo.RelativeControl/Demo.RelativeControl.iOS/Demo.RelativeControl.iOS.csproj index 20fb5ea..a36a528 100644 --- a/Demo.RelativeControl/Demo.RelativeControl.iOS/Demo.RelativeControl.iOS.csproj +++ b/Demo.RelativeControl/Demo.RelativeControl.iOS/Demo.RelativeControl.iOS.csproj @@ -1,13 +1,13 @@  Exe - net9.0-ios + net10.0-ios 13.0 enable - + diff --git a/Demo.RelativeControl/Demo.RelativeControl/Demo.RelativeControl.csproj b/Demo.RelativeControl/Demo.RelativeControl/Demo.RelativeControl.csproj index bfe8e81..e83f5a0 100644 --- a/Demo.RelativeControl/Demo.RelativeControl/Demo.RelativeControl.csproj +++ b/Demo.RelativeControl/Demo.RelativeControl/Demo.RelativeControl.csproj @@ -1,18 +1,15 @@  - net9.0 + net10.0 enable latest true - + - - - - - - + + + diff --git a/Demo.RelativeControl/Demo.RelativeControl/MainWindow.axaml b/Demo.RelativeControl/Demo.RelativeControl/MainWindow.axaml index 9bd6d1c..33f6c35 100644 --- a/Demo.RelativeControl/Demo.RelativeControl/MainWindow.axaml +++ b/Demo.RelativeControl/Demo.RelativeControl/MainWindow.axaml @@ -28,7 +28,7 @@ diff --git a/HeadlessTest.RelativeControl/AbsoluteUnitTest.cs b/HeadlessTest.RelativeControl/AbsoluteUnitTest.cs index dd8c48d..9e15561 100644 --- a/HeadlessTest.RelativeControl/AbsoluteUnitTest.cs +++ b/HeadlessTest.RelativeControl/AbsoluteUnitTest.cs @@ -1,7 +1,5 @@ using Avalonia.Controls; -using Avalonia.Controls.Templates; using Avalonia.Headless.XUnit; -using Avalonia.VisualTree; using RelativeControl.Avalonia; namespace HeadlessTest.RelativeControl; diff --git a/HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj b/HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj index 4d71747..8a85db7 100644 --- a/HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj +++ b/HeadlessTest.RelativeControl/HeadlessTest.RelativeControl.csproj @@ -1,6 +1,7 @@  + Exe net9.0 enable enable @@ -8,20 +9,16 @@ - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/README.md b/README.md index 4e39f23..b943f54 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,6 @@ This provides some relative units and features for [Avalonia](https://github.com [More Info](API%20References.md) -## New Features in 1.3.x -- Now support using relatives in style setters. -```xaml - -``` -- Now you can use a visual anchor to provide relative feature for objects which is non-visual but have layout properties. - - ## Get Started ### Add NuGet package: @@ -97,7 +87,7 @@ Other properties using `RelativeThickness`: ### Bind any property ```xaml - + ``` > This will set the `PROPERTY`'s value to 50% of `SOURCE_PROPERTY`'s value. @@ -154,115 +144,4 @@ public static readonly AttachedProperty> XXXProperty = em: The control's FontSize vw: Window's width vh: Window's height - %: Represents percentage. Only used for custom bindings. - -## Minimum Available Version of an API - -### 0.0.5 - -- Width -- Height -- MinWidth -- MinHeight -- MaxWidth -- MaxHeight -- BorderThickness -- CornerRadius - -### 0.1.0 - -- Margin -- Padding - -### 1.0.0-alpha - -- RelativeBinding - -> You can bind any property! *[How to bind a custom property?](#bind-any-property)* - -### 1.0.0-beta - -- SetOneTimeWidth -- SetOneTimeHeight -- RelativeBindOneTime - -> These will update only once when the control is attached to visual tree! - -## Breaking Changes - -### 0.2.1: - -Relative units are using percentages (Excepts `em`). To make it more like *css*. - -```diff --