Skip to content

Commit

Permalink
fix issue AvaloniaUI#240
Browse files Browse the repository at this point in the history
  • Loading branch information
FroggieFrog committed May 7, 2024
1 parent c9fa33d commit 301b5fc
Show file tree
Hide file tree
Showing 46 changed files with 274 additions and 220 deletions.
22 changes: 11 additions & 11 deletions templates/csharp/xplat/.template.config/template.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"name": "Avalonia Cross Platform Application",
"preferNameDirectory": true,
"shortName": "avalonia.xplat",
"sourceName": "AvaloniaTest",
"sourceName": "AvaloniaTest.1", //based on: https://github.com/dotnet/templating/issues/1920#issuecomment-901954876
"defaultName": "AvaloniaApplication",
"tags": {
"language": "C#",
Expand Down Expand Up @@ -74,8 +74,8 @@
{
"condition": "(RemoveViewLocator)",
"exclude": [
"AvaloniaTest/App.axaml",
"AvaloniaTest/ViewLocator.cs"
"AvaloniaTest.1/App.axaml",
"AvaloniaTest.1/ViewLocator.cs"
],
"rename": {
"App.RemoveViewLocator.axaml": "App.axaml"
Expand All @@ -84,25 +84,25 @@
{
"condition": "(!RemoveViewLocator)",
"exclude": [
"AvaloniaTest/App.RemoveViewLocator.axaml"
"AvaloniaTest.1/App.RemoveViewLocator.axaml"
]
}
]
}
],
"primaryOutputs": [
{ "path": "AvaloniaTest/AvaloniaTest.csproj" },
{ "path": "AvaloniaTest.Android/AvaloniaTest.Android.csproj" },
{ "path": "AvaloniaTest.Desktop/AvaloniaTest.Desktop.csproj" },
{ "path": "AvaloniaTest.iOS/AvaloniaTest.iOS.csproj" },
{ "path": "AvaloniaTest.Browser/AvaloniaTest.Browser.csproj" },
{ "path": "AvaloniaTest.1/AvaloniaTest.1.csproj" },
{ "path": "AvaloniaTest.1.Android/AvaloniaTest.1.Android.csproj" },
{ "path": "AvaloniaTest.1.Desktop/AvaloniaTest.1.Desktop.csproj" },
{ "path": "AvaloniaTest.1.iOS/AvaloniaTest.1.iOS.csproj" },
{ "path": "AvaloniaTest.1.Browser/AvaloniaTest.1.Browser.csproj" },
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"path": "AvaloniaTest/ViewModels/MainViewModel.cs"
"path": "AvaloniaTest.1/ViewModels/MainViewModel.cs"
},
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"path": "AvaloniaTest/Views/MainView.axaml"
"path": "AvaloniaTest.1/Views/MainView.axaml"
}
],
"postActions": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>FrameworkParameter-android</TargetFramework>
<SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
<ApplicationId>com.CompanyName.AvaloniaTest</ApplicationId>
<ApplicationId>com.CompanyName.AvaloniaTest._1</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<AndroidPackageFormat>apk</AndroidPackageFormat>
Expand All @@ -23,6 +23,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest\AvaloniaTest.csproj" />
<ProjectReference Include="..\AvaloniaTest.1\AvaloniaTest.1.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
using Android.Content.PM;
using Avalonia;
using Avalonia.Android;
#if (ReactiveUIToolkitChosen)
using Avalonia.ReactiveUI;
#endif

namespace AvaloniaTest.Android;
namespace AvaloniaTest._1.Android;

[Activity(
Label = "AvaloniaTest.Android",
Label = "AvaloniaTest._1.Android",
Theme = "@style/MyTheme.NoActionBar",
Icon = "@drawable/icon",
MainLauncher = true,
Expand All @@ -17,7 +19,11 @@ public class MainActivity : AvaloniaMainActivity<App>
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
return base.CustomizeAppBuilder(builder)
#if (CommunityToolkitChosen)
.WithInterFont();
#else
.WithInterFont()
.UseReactiveUI();
#endif
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="AvaloniaTest" android:icon="@drawable/Icon" />
<application android:label="AvaloniaTest.1" android:icon="@drawable/Icon" />
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest\AvaloniaTest.csproj" />
<ProjectReference Include="..\AvaloniaTest.1\AvaloniaTest.1.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,20 @@
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Browser;
#if (ReactiveUIToolkitChosen)
using Avalonia.ReactiveUI;
using AvaloniaTest;
#endif
using AvaloniaTest._1;

[assembly: SupportedOSPlatform("browser")]

internal sealed partial class Program
{
private static Task Main(string[] args) => BuildAvaloniaApp()
.WithInterFont()
#if (ReactiveUIToolkitChosen)
.UseReactiveUI()
#endif
.StartBrowserAppAsync("out");

public static AppBuilder BuildAvaloniaApp()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"profiles": {
"AvaloniaTest.Browser": {
"AvaloniaTest.1.Browser": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<title>AvaloniaTest.Browser</title>
<title>AvaloniaTest.1.Browser</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with FrameworkParameter-windows TFM, one for MacOS with FrameworkParameter-macos and one with FrameworkParameter TFM for Linux.-->
<TargetFramework>FrameworkParameter</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>

<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest\AvaloniaTest.csproj" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<!--If you are willing to use Windows/MacOS native APIs you will need to create 3 projects.
One for Windows with FrameworkParameter-windows TFM, one for MacOS with FrameworkParameter-macos and one with FrameworkParameter TFM for Linux.-->
<TargetFramework>FrameworkParameter</TargetFramework>
<Nullable>enable</Nullable>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
</PropertyGroup>

<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest.1\AvaloniaTest.1.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
using System;
using Avalonia;
using Avalonia.ReactiveUI;

namespace AvaloniaTest.Desktop;

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);

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace()
.UseReactiveUI();
}
using System;
using Avalonia;
#if (ReactiveUIToolkitChosen)
using Avalonia.ReactiveUI;
#endif

namespace AvaloniaTest._1.Desktop;

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);

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
#if (ReactiveUIToolkitChosen)
.UseReactiveUI()
#endif
.LogToTrace();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- This manifest is used on Windows only.
Don't remove it as it might cause problems with window transparency and embedded controls.
For more details visit https://learn.microsoft.com/en-us/windows/win32/sbscs/application-manifests -->
<assemblyIdentity version="1.0.0.0" name="AvaloniaTest.Desktop"/>
<assemblyIdentity version="1.0.0.0" name="AvaloniaTest._1.Desktop"/>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
using Avalonia.Controls;
using Avalonia.iOS;
using Avalonia.Media;
#if (ReactiveUIToolkitChosen)
using Avalonia.ReactiveUI;
#endif

namespace AvaloniaTest.iOS;
namespace AvaloniaTest._1.iOS;

// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
Expand All @@ -19,7 +21,11 @@ public partial class AppDelegate : AvaloniaAppDelegate<App>
protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
{
return base.CustomizeAppBuilder(builder)
#if (CommunityToolkitChosen)
.WithInterFont();
#else
.WithInterFont()
.UseReactiveUI();
#endif
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\AvaloniaTest\AvaloniaTest.csproj" />
<ProjectReference Include="..\AvaloniaTest.1\AvaloniaTest.1.csproj" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>AvaloniaTest</string>
<string>AvaloniaTest.1</string>
<key>CFBundleIdentifier</key>
<string>companyName.AvaloniaTest</string>
<string>companyName.AvaloniaTest._1</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using UIKit;

namespace AvaloniaTest.iOS;
namespace AvaloniaTest._1.iOS;

public class Application
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<color key="textColor" cocoaTouchSystemColor="darkTextColor" />
<nil key="highlightedColor" />
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AvaloniaTest" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="AvaloniaTest.1" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines"
minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
<rect key="frame" x="20" y="140" width="441" height="43" />
<fontDescription key="fontDescription" type="boldSystem" pointSize="36" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32811.315
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest", "AvaloniaTest\AvaloniaTest.csproj", "{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1", "AvaloniaTest.1\AvaloniaTest.1.csproj", "{EBFA8512-1EA5-4D8C-B4AC-AB5B48A6D568}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.Desktop", "AvaloniaTest.Desktop\AvaloniaTest.Desktop.csproj", "{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1.Desktop", "AvaloniaTest.1.Desktop\AvaloniaTest.1.Desktop.csproj", "{ABC31E74-02FF-46EB-B3B2-4E6AE43B456C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.Browser", "AvaloniaTest.Browser\AvaloniaTest.Browser.csproj", "{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1.Browser", "AvaloniaTest.1.Browser\AvaloniaTest.1.Browser.csproj", "{1C1A049E-235C-4CD0-B6FA-D53AC418F4DA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.iOS", "AvaloniaTest.iOS\AvaloniaTest.iOS.csproj", "{EBD9022F-BC83-4846-9A11-6F7F3772DC64}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1.iOS", "AvaloniaTest.1.iOS\AvaloniaTest.1.iOS.csproj", "{EBD9022F-BC83-4846-9A11-6F7F3772DC64}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.Android", "AvaloniaTest.Android\AvaloniaTest.Android.csproj", "{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaTest.1.Android", "AvaloniaTest.1.Android\AvaloniaTest.1.Android.csproj", "{7AD1DAC8-7FBE-49D5-8614-7321233DB82E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3DA99C4E-89E3-4049-9C22-0A7EC60D83D8}"
ProjectSection(SolutionItems) = preProject
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="AvaloniaTest.App"
x:Class="AvaloniaTest._1.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AvaloniaTest"
x:Class="AvaloniaTest.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<FluentTheme />
</Application.Styles>
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:AvaloniaTest._1"
x:Class="AvaloniaTest._1.App"
RequestedThemeVariant="Default">
<!-- "Default" ThemeVariant follows system theme variant. "Dark" or "Light" are other available options. -->

<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>

<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
Loading

0 comments on commit 301b5fc

Please sign in to comment.