Compare commits
No commits in common. "beeac586284dfca3a10df7a283d79a047ff39b43" and "7fabee1bd14657fa9ac4f1f0be85682f2bce456d" have entirely different histories.
beeac58628
...
7fabee1bd1
28 changed files with 318 additions and 230 deletions
6
.vscode/launch.json
vendored
6
.vscode/launch.json
vendored
|
|
@ -5,7 +5,7 @@
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
{
|
||||||
"name": "Android",
|
"name": "Debug - Android",
|
||||||
"type": "mono",
|
"type": "mono",
|
||||||
"preLaunchTask": "run-debug-android",
|
"preLaunchTask": "run-debug-android",
|
||||||
"request": "attach",
|
"request": "attach",
|
||||||
|
|
@ -42,13 +42,15 @@
|
||||||
"type": "dotnet",
|
"type": "dotnet",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"projectPath": "${workspaceFolder}/src/PostIt/PostIt.Desktop/PostIt.Desktop.csproj",
|
"projectPath": "${workspaceFolder}/src/PostIt/PostIt.Desktop/PostIt.Desktop.csproj",
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Test PostIt.Android launch (Xamarin.UITest)",
|
"name": "Test PostIt.Android launch (Xamarin.UITest)",
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"program": "${workspaceFolder}/src/PostIt/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests.dll",
|
"program": "${workspaceFolder}/src/PostIt/PostIt.Tests/bin/Debug/net10.0/PostIt.Tests.dll",
|
||||||
"args": [],
|
"args": [
|
||||||
|
],
|
||||||
"cwd": "${workspaceFolder}/src/PostIt/PostIt.Tests",
|
"cwd": "${workspaceFolder}/src/PostIt/PostIt.Tests",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"stopAtEntry": false
|
"stopAtEntry": false
|
||||||
|
|
|
||||||
74
.vscode/tasks.json
vendored
74
.vscode/tasks.json
vendored
|
|
@ -10,32 +10,19 @@
|
||||||
"env": {
|
"env": {
|
||||||
"DOTNET_HOST_PATH": "/usr/share/dotnet",
|
"DOTNET_HOST_PATH": "/usr/share/dotnet",
|
||||||
"ANDROID_HOME": "/opt/android-sdk",
|
"ANDROID_HOME": "/opt/android-sdk",
|
||||||
"JAVA_HOME": "/usr/lib/jvm/java-1.25.0-openjdk-amd64"
|
"JAVA_HOME": "/usr/lib/jvm/java-1.21.0-openjdk-amd64"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"args": [
|
"args": [
|
||||||
"run",
|
"build"
|
||||||
|
"-t:run",
|
||||||
"-p:TargetFramework=net10.0-android",
|
"-p:TargetFramework=net10.0-android",
|
||||||
"-p:Configuration=Debug",
|
"-p:Configuration=Debug",
|
||||||
"-p:AndroidAttachDebugger=true",
|
"-p:AndroidAttachDebugger=true",
|
||||||
"-p:AndroidSdbHostPort=10000",
|
"-p:AndroidSdbHostPort=10000",
|
||||||
"-p:AndroidSdbTargetPort=10000"
|
"-p:AndroidSdbTargetPort=10000"
|
||||||
],
|
],
|
||||||
"problemMatcher": [
|
"problemMatcher": "$msCompile"
|
||||||
{
|
|
||||||
"owner": "dotnet",
|
|
||||||
"fileLocation": ["relative", "${workspaceFolder}"],
|
|
||||||
"source": "dotnet",
|
|
||||||
"pattern": {
|
|
||||||
"regexp": "^(.*):(\\d+):(\\d+):\\s+(error):\\s+(.*)$",
|
|
||||||
"file": 1,
|
|
||||||
"line": 2,
|
|
||||||
"column": 3,
|
|
||||||
"severity": 4,
|
|
||||||
"message": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "build",
|
"label": "build",
|
||||||
|
|
@ -75,6 +62,59 @@
|
||||||
"kind": "build"
|
"kind": "build"
|
||||||
},
|
},
|
||||||
"isBackground": true
|
"isBackground": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "test blogs",
|
||||||
|
"type": "process",
|
||||||
|
"problemMatcher": ["$msCompile"],
|
||||||
|
"command": "dotnet",
|
||||||
|
"args": ["test"],
|
||||||
|
"runOptions": {
|
||||||
|
"instanceLimit": 1
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"cwd": "src/Yavsc.Blogs",
|
||||||
|
"env": {
|
||||||
|
"DOTNET_CLI_UI_LANGUAGE": "en-US",
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"group": {
|
||||||
|
"kind": "test"
|
||||||
|
},
|
||||||
|
"isBackground": true,
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": false,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": true,
|
||||||
|
"clear": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary;ForceNoAlign"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": ["watch", "--project",
|
||||||
|
"src/Yavsc.Org/Yavsc.Org.csproj"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile",
|
||||||
|
"runOptions": {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,6 @@
|
||||||
from without conflicting names.
|
from without conflicting names.
|
||||||
-->
|
-->
|
||||||
<UseProjectNamespaceForGitVersionInformation>true</UseProjectNamespaceForGitVersionInformation>
|
<UseProjectNamespaceForGitVersionInformation>true</UseProjectNamespaceForGitVersionInformation>
|
||||||
<NoWarn>NU1701, NU1901, NU1902, NU1507</NoWarn>
|
<NoWarn>NU1701, NU1901, NU1902</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
24
Makefile
24
Makefile
|
|
@ -125,8 +125,8 @@ release:
|
||||||
#
|
#
|
||||||
# Usage typique :
|
# Usage typique :
|
||||||
# make qemu # lance l'AVD, attend le boot, build l'APK, l'installe
|
# make qemu # lance l'AVD, attend le boot, build l'APK, l'installe
|
||||||
# make android-install # (re)build l'APK et l'installe (AVD doit tourner)
|
# make qemu-install # (re)build l'APK et l'installe (AVD doit tourner)
|
||||||
# make android-build # build l'APK seul (sans install)
|
# make qemu-build # build l'APK seul (sans install)
|
||||||
# make qemu-run # démarre l'AVD en background
|
# make qemu-run # démarre l'AVD en background
|
||||||
# make qemu-stop # arrête l'émulateur
|
# make qemu-stop # arrête l'émulateur
|
||||||
# make qemu-wait-boot # attend que l'AVD ait fini de booter
|
# make qemu-wait-boot # attend que l'AVD ait fini de booter
|
||||||
|
|
@ -150,7 +150,7 @@ release:
|
||||||
# LOGCAT_LINES default: 200
|
# LOGCAT_LINES default: 200
|
||||||
# (nombre de lignes dumpées par `make qemu-logcat`)
|
# (nombre de lignes dumpées par `make qemu-logcat`)
|
||||||
# LOGCAT_FOLLOW default: 0
|
# LOGCAT_FOLLOW default: 0
|
||||||
# (1 = stream live via `make logcat`,
|
# (1 = stream live via `make qemu-logcat`,
|
||||||
# sinon dump one-shot des N dernières lignes)
|
# sinon dump one-shot des N dernières lignes)
|
||||||
# LOGCAT_BOOT_WAIT default: 30
|
# LOGCAT_BOOT_WAIT default: 30
|
||||||
# (secondes d'attente entre le clear du buffer,
|
# (secondes d'attente entre le clear du buffer,
|
||||||
|
|
@ -165,7 +165,7 @@ LOGCAT_LINES ?= 600
|
||||||
LOGCAT_FOLLOW ?= 0
|
LOGCAT_FOLLOW ?= 0
|
||||||
LOGCAT_BOOT_WAIT ?= 30
|
LOGCAT_BOOT_WAIT ?= 30
|
||||||
|
|
||||||
ANDROID_PACKAGE_NAME = fr.pschneider.postit
|
ANDROID_PACKAGE_NAME = fr.pschneider.PostIt
|
||||||
POSTIT_ANDROID_CSPROJ := src/PostIt/PostIt.Android/PostIt.Android.csproj
|
POSTIT_ANDROID_CSPROJ := src/PostIt/PostIt.Android/PostIt.Android.csproj
|
||||||
POSTIT_APK_DIR := src/PostIt/PostIt.Android/bin/$(CONFIG)/net10.0-android/$(POSTIT_RID)
|
POSTIT_APK_DIR := src/PostIt/PostIt.Android/bin/$(CONFIG)/net10.0-android/$(POSTIT_RID)
|
||||||
POSTIT_APK := $(POSTIT_APK_DIR)/$(ANDROID_PACKAGE_NAME)-Signed.apk
|
POSTIT_APK := $(POSTIT_APK_DIR)/$(ANDROID_PACKAGE_NAME)-Signed.apk
|
||||||
|
|
@ -197,7 +197,7 @@ qemu-wait-boot:
|
||||||
echo " Logs: /tmp/yavsc-emu/$(AVD_NAME).log" >&2; \
|
echo " Logs: /tmp/yavsc-emu/$(AVD_NAME).log" >&2; \
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
android-build:
|
qemu-build:
|
||||||
# EmbedAssembliesIntoApk=true: without this, the Debug APK ships
|
# EmbedAssembliesIntoApk=true: without this, the Debug APK ships
|
||||||
# without the managed assemblies in it (they are pushed at runtime
|
# without the managed assemblies in it (they are pushed at runtime
|
||||||
# via `adb push`, "Fast Deployment"). On the qemu emulator, the
|
# via `adb push`, "Fast Deployment"). On the qemu emulator, the
|
||||||
|
|
@ -223,7 +223,7 @@ android-build:
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
android-install: android-build
|
qemu-install: qemu-build
|
||||||
@echo " Installing $(POSTIT_APK) on $(ADB_SERIAL)..."
|
@echo " Installing $(POSTIT_APK) on $(ADB_SERIAL)..."
|
||||||
adb -s $(ADB_SERIAL) install -r "$(POSTIT_APK)" -r
|
adb -s $(ADB_SERIAL) install -r "$(POSTIT_APK)" -r
|
||||||
|
|
||||||
|
|
@ -240,7 +240,7 @@ qemu-uninstall:
|
||||||
# If the app is not running, pidof returns empty and logcat exits
|
# If the app is not running, pidof returns empty and logcat exits
|
||||||
# silently with no output; that is the expected behaviour for
|
# silently with no output; that is the expected behaviour for
|
||||||
# "no logs yet".
|
# "no logs yet".
|
||||||
logcat:
|
qemu-logcat:
|
||||||
@PID=$$(adb -s $(ADB_SERIAL) shell pidof $(ANDROID_PACKAGE_NAME) 2>/dev/null | tr -d '\r\n'); \
|
@PID=$$(adb -s $(ADB_SERIAL) shell pidof $(ANDROID_PACKAGE_NAME) 2>/dev/null | tr -d '\r\n'); \
|
||||||
if [ -z "$$PID" ]; then \
|
if [ -z "$$PID" ]; then \
|
||||||
echo " $(ANDROID_PACKAGE_NAME) is not running on $(ADB_SERIAL)."; \
|
echo " $(ANDROID_PACKAGE_NAME) is not running on $(ADB_SERIAL)."; \
|
||||||
|
|
@ -262,16 +262,12 @@ logcat:
|
||||||
# Override LOGCAT_BOOT_WAIT to extend the post-launch wait
|
# Override LOGCAT_BOOT_WAIT to extend the post-launch wait
|
||||||
# (default 15s; raise to 30+ if the device is slow to boot Avalonia).
|
# (default 15s; raise to 30+ if the device is slow to boot Avalonia).
|
||||||
LOGCAT_BOOT_WAIT ?= 15
|
LOGCAT_BOOT_WAIT ?= 15
|
||||||
|
qemu-logcat-boot:
|
||||||
|
|
||||||
android-start:
|
|
||||||
@echo " Clearing logcat buffer..."
|
@echo " Clearing logcat buffer..."
|
||||||
adb -s $(ADB_SERIAL) logcat -c
|
adb -s $(ADB_SERIAL) logcat -c
|
||||||
@echo " Launching $(ANDROID_PACKAGE_NAME)..."
|
@echo " Launching $(ANDROID_PACKAGE_NAME)..."
|
||||||
adb -s $(ADB_SERIAL) shell am start \
|
adb -s $(ADB_SERIAL) shell am start \
|
||||||
-n $(ANDROID_PACKAGE_NAME)/PostIt.Android.PostItMainActivity
|
-n $(ANDROID_PACKAGE_NAME)/PostIt.Android.PostItMainActivity
|
||||||
|
|
||||||
qemu-logcat-boot: android-start
|
|
||||||
@echo " Waiting $(LOGCAT_BOOT_WAIT)s for the app to start rendering..."
|
@echo " Waiting $(LOGCAT_BOOT_WAIT)s for the app to start rendering..."
|
||||||
@sleep $(LOGCAT_BOOT_WAIT)
|
@sleep $(LOGCAT_BOOT_WAIT)
|
||||||
|
|
||||||
|
|
@ -287,7 +283,7 @@ qemu-logcat-boot: android-start
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi
|
fi
|
||||||
|
|
||||||
qemu: qemu-run qemu-wait-boot android-install
|
qemu: qemu-run qemu-wait-boot qemu-install
|
||||||
@echo " ✓ PostIt.Android installed on $(ADB_SERIAL)"
|
@echo " ✓ PostIt.Android installed on $(ADB_SERIAL)"
|
||||||
|
|
||||||
.PHONY: test release qemu qemu-run qemu-stop qemu-wait-boot android-build android-install logcat qemu-logcat-boot
|
.PHONY: test release qemu qemu-run qemu-stop qemu-wait-boot qemu-build qemu-install qemu-logcat qemu-logcat-boot
|
||||||
|
|
|
||||||
|
|
@ -5,35 +5,33 @@
|
||||||
<!-- https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management -->
|
<!-- https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
|
||||||
<AvaloniaVersionBase>12.1.1</AvaloniaVersionBase>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Avalonia packages -->
|
<!-- Avalonia packages -->
|
||||||
<!-- Important: keep version in sync! -->
|
<!-- Important: keep version in sync! -->
|
||||||
<PackageVersion Include="Avalonia" Version="$(AvaloniaVersionBase)" />
|
<PackageVersion Include="Avalonia" Version="12.1.1" />
|
||||||
<PackageVersion Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersionBase)" />
|
<PackageVersion Include="Avalonia.Themes.Fluent" Version="12.1.1" />
|
||||||
<PackageVersion Include="Avalonia.Desktop" Version="$(AvaloniaVersionBase)" />
|
<PackageVersion Include="Avalonia.Fonts.Inter" Version="12.1.1" />
|
||||||
<PackageVersion Include="Avalonia.Browser" Version="$(AvaloniaVersionBase)" />
|
<PackageVersion Include="Avalonia.Desktop" Version="12.1.1" />
|
||||||
<PackageVersion Include="Avalonia.Android" Version="$(AvaloniaVersionBase)" />
|
<PackageVersion Include="Avalonia.Browser" Version="12.1.1" />
|
||||||
<PackageVersion Include="Avalonia.Headless" Version="$(AvaloniaVersionBase)" />
|
<PackageVersion Include="Avalonia.Android" Version="12.1.1" />
|
||||||
<PackageVersion Include="Avalonia.Headless.Xunit" Version="$(AvaloniaVersionBase)" />
|
<PackageVersion Include="Avalonia.Headless" Version="12.1.1" />
|
||||||
<PackageVersion Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersionBase)" />
|
<PackageVersion Include="Avalonia.Headless.Xunit" Version="12.1.1" />
|
||||||
|
<PackageVersion Include="Avalonia.AvaloniaEdit" Version="12.0.0" />
|
||||||
<PackageVersion Include="Material.Avalonia" Version="3.19.0" />
|
<PackageVersion Include="Material.Avalonia" Version="3.19.0" />
|
||||||
<PackageVersion Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.3" />
|
<PackageVersion Include="AvaloniaUI.DiagnosticsSupport" Version="2.2.3" />
|
||||||
<PackageVersion Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersionBase)" />
|
|
||||||
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
<PackageVersion Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||||
|
|
||||||
<PackageVersion Include="Xamarin.AndroidX.Browser" Version="1.10.0.1" />
|
<PackageVersion Include="Xamarin.AndroidX.Browser" Version="1.10.0.1" />
|
||||||
|
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.15" />
|
||||||
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.2.0" />
|
<PackageVersion Include="Xamarin.AndroidX.Lifecycle.Runtime" Version="2.11.0.1" />
|
||||||
|
<PackageVersion Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.11.0.1" />
|
||||||
<PackageVersion Include="Xamarin.AndroidX.Lifecycle.Runtime" Version="2.10.0.1" />
|
|
||||||
<PackageVersion Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.10.0.1" />
|
|
||||||
|
|
||||||
<PackageVersion Include="Xamarin.UITest" Version="4.4.2" />
|
<PackageVersion Include="Xamarin.UITest" Version="4.4.2" />
|
||||||
|
|
||||||
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.11" />
|
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.11" />
|
||||||
|
<PackageVersion Include="Microsoft.Maui.Essentials" Version="10.0.100" />
|
||||||
|
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
|
|
||||||
clean: clean-PostIt clean-PostIt.Android clean-PostIt.Desktop
|
|
||||||
|
|
||||||
clean-%:
|
|
||||||
rm -rf $*/obj $*/bin
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
|
@ -1,13 +1,8 @@
|
||||||
using Android;
|
using Android.App;
|
||||||
using Android.App;
|
|
||||||
using Android.Content;
|
using Android.Content;
|
||||||
using Android.Content.PM;
|
using Android.Content.PM;
|
||||||
using AndroidX.Core.Provider;
|
|
||||||
using AndroidX.Emoji2.Text;
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Android;
|
using Avalonia.Android;
|
||||||
using AndroidX.Core.Provider;
|
|
||||||
using AndroidX.Emoji2.Text;
|
|
||||||
|
|
||||||
namespace PostIt.Android;
|
namespace PostIt.Android;
|
||||||
|
|
||||||
|
|
@ -21,21 +16,17 @@ namespace PostIt.Android;
|
||||||
public class MainActivity : AvaloniaMainActivity
|
public class MainActivity : AvaloniaMainActivity
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The current MainActivity instance.
|
/// Strongly-typed handle to the current MainActivity instance, set in
|
||||||
|
/// <see cref="OnCreate"/> and consumed by platform services such as
|
||||||
|
/// <see cref="Services.AndroidSystemBrowser"/> which need to launch
|
||||||
|
/// Chrome Custom Tabs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static MainActivity? Current { get; private set; }
|
public static MainActivity? Current { get; private set; }
|
||||||
|
|
||||||
protected override void OnCreate(global::Android.OS.Bundle? savedInstanceState)
|
protected override void OnCreate(global::Android.OS.Bundle? savedInstanceState)
|
||||||
{
|
{
|
||||||
FontRequest fontRequest = new FontRequest(
|
|
||||||
"com.google.android.gms.fonts",
|
|
||||||
"com.google.android.gms",
|
|
||||||
"Noto Color Emoji Compat",
|
|
||||||
Yavsc.Resource.Array.com_google_android_gms_fonts_certs); //com_google_android_gms_fonts_certs
|
|
||||||
EmojiCompat.Config config = new FontRequestEmojiCompatConfig(this, fontRequest);
|
|
||||||
EmojiCompat.Init(config);
|
|
||||||
PlatformBootstrap.EnsureInitialized();
|
|
||||||
base.OnCreate(savedInstanceState);
|
base.OnCreate(savedInstanceState);
|
||||||
|
PlatformBootstrap.EnsureInitialized();
|
||||||
Current = this;
|
Current = this;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,13 @@
|
||||||
<TargetFramework>net10.0-android</TargetFramework>
|
<TargetFramework>net10.0-android</TargetFramework>
|
||||||
<SupportedOSPlatformVersion>23</SupportedOSPlatformVersion>
|
<SupportedOSPlatformVersion>23</SupportedOSPlatformVersion>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ApplicationId>fr.pschneider.postit</ApplicationId>
|
<ApplicationId>fr.pschneider.PostIt</ApplicationId>
|
||||||
<ApplicationVersion>1</ApplicationVersion>
|
<ApplicationVersion>1</ApplicationVersion>
|
||||||
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
|
||||||
<AndroidPackageFormat>apk</AndroidPackageFormat>
|
<AndroidPackageFormat>apk</AndroidPackageFormat>
|
||||||
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
<AndroidEnableProfiledAot>false</AndroidEnableProfiledAot>
|
||||||
|
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
|
||||||
|
<TrimMode>partial</TrimMode>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
@ -21,11 +23,11 @@
|
||||||
<PackageReference Include="Avalonia.Android" />
|
<PackageReference Include="Avalonia.Android" />
|
||||||
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" />
|
<PackageReference Include="Xamarin.AndroidX.Core.SplashScreen" />
|
||||||
<PackageReference Include="Xamarin.AndroidX.Browser" />
|
<PackageReference Include="Xamarin.AndroidX.Browser" />
|
||||||
|
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Runtime" />
|
||||||
|
<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\PostIt\PostIt.csproj" />
|
<ProjectReference Include="..\PostIt\PostIt.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<resources>
|
|
||||||
<array name="com_google_android_gms_fonts_certs">
|
|
||||||
<item>@array/com_google_android_gms_fonts_certs_dev</item>
|
|
||||||
<item>@array/com_google_android_gms_fonts_certs_prod</item>
|
|
||||||
</array>
|
|
||||||
<string-array name="com_google_android_gms_fonts_certs_dev">
|
|
||||||
<item>MIIEqDCCA5CgAwIBAgIJAN5gc16AJfAsMA0GCSqGSIb3DQEBBQUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEQMA4GA1UEChMHR29vZ2xlMRAwDgYDVQQLEwdBbmRyb2lkMRAwDgYDVQQDEwdBbmRyb2lkMSEwHwYJKoZIhvcNAQkBFhJhbmRyb2lkQGFuZHJvaWQuY29tMCAXDTA4MDQxNTIyNDA0M1YYDzQyMDgxMzA0MjI0MDQzWjCBlDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCkNhbGlmb3JuaWExFjAUBgNVBAcTDURvdW50YWluIFZpZXcxEDAOBgNVBAoTB0dvb2dsZTEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDEhMB8GCSqGSIb3DQEJARYSYW5kcm9pZEBhbmRyb2lkLmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALBi1vF0K1vOEHG7AxneTjOHUka46MIidBqvFcO164A49iU2DkYPhUaM4H8JCdzh6N1GzM6h9o6E2V6z8+gEtdI6nqqs0EGA0G0H701bFjLp9+K/1DkMIFeD4P8J7X1/M8t4+X09X/7bQyV3w0v7q+Qh38sY8W/7K29B3f2O2sLw+uX9U8a8Tf4Xv8A==</item>
|
|
||||||
</string-array>
|
|
||||||
<string-array name="com_google_android_gms_fonts_certs_prod">
|
|
||||||
<item>MIIEQzCCAyugAwIBAgIJAMLgh0ZgXpYOMA0GCSqGSIb3DQEBBQUAMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDAeFw0wODA4MjEyMzEzMzRaFw0zNjAxMDcyMzEzMzRaMHQxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpDYWxpZm9ybmlhMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtHb29nbGUgSW5jLjEQMA4GA1UECxMHQW5kcm9pZDEQMA4GA1UEAxMHQW5kcm9pZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKKvSkUIXm+t9M8rXj2V</item>
|
|
||||||
</string-array>
|
|
||||||
</resources>
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class AddCircleMemberDialogTests
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Mount a real <see cref="MainView"/>, build a minimal
|
/// Mount a real <see cref="MainWindow"/>, build a minimal
|
||||||
/// DI graph, push <see cref="CirclesPage"/> then the
|
/// DI graph, push <see cref="CirclesPage"/> then the
|
||||||
/// <see cref="AddCircleMemberDialog"/> on top of it.
|
/// <see cref="AddCircleMemberDialog"/> on top of it.
|
||||||
/// Returns the stack size so the test can pin the delta.
|
/// Returns the stack size so the test can pin the delta.
|
||||||
|
|
@ -98,9 +98,10 @@ public class AddCircleMemberDialogTests
|
||||||
services.AddTransient<AddCircleMemberDialogViewModel>();
|
services.AddTransient<AddCircleMemberDialogViewModel>();
|
||||||
var sp = services.BuildServiceProvider();
|
var sp = services.BuildServiceProvider();
|
||||||
|
|
||||||
context.Window = new MainView();
|
context.Window = new MainWindow();
|
||||||
context.App = (PostIt.App)Application.Current!;
|
context.App = (PostIt.App)Application.Current!;
|
||||||
context.App.AttachMainWindow(context.Window);
|
context.App.AttachMainWindow(context.Window);
|
||||||
|
context.Window.Show();
|
||||||
|
|
||||||
context.page = sp.GetRequiredService<CirclesPage>();
|
context.page = sp.GetRequiredService<CirclesPage>();
|
||||||
context.Window.NavRoot.PushAsync(context.page).GetAwaiter().GetResult();
|
context.Window.NavRoot.PushAsync(context.page).GetAwaiter().GetResult();
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class AndroidAppLaunchTests
|
||||||
_output = output;
|
_output = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
// FIXME [Fact]
|
||||||
public void PostIt_starts_and_draws_a_first_frame_on_the_emulator()
|
public void PostIt_starts_and_draws_a_first_frame_on_the_emulator()
|
||||||
{
|
{
|
||||||
if (!IsPackageInstalledOnAnyDevice())
|
if (!IsPackageInstalledOnAnyDevice())
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ public class MainPageButtonsTests
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Mount a real <see cref="MainView"/> (as
|
/// Mount a real <see cref="MainWindow"/> (as
|
||||||
/// <c>SessionStatusBannerTests</c> does), push a
|
/// <c>SessionStatusBannerTests</c> does), push a
|
||||||
/// <see cref="MainPage"/> with the given VM onto
|
/// <see cref="MainPage"/> with the given VM onto
|
||||||
/// <c>NavRoot</c>. <c>PushAsync</c> is awaited (via
|
/// <c>NavRoot</c>. <c>PushAsync</c> is awaited (via
|
||||||
|
|
@ -109,12 +109,13 @@ public class MainPageButtonsTests
|
||||||
/// realised and <c>KeyPressQwerty</c> has a real
|
/// realised and <c>KeyPressQwerty</c> has a real
|
||||||
/// <see cref="TopLevel"/> to dispatch against.
|
/// <see cref="TopLevel"/> to dispatch against.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static (MainView window, MainPage page) MountMainPage(MainViewModel vm)
|
private static (MainWindow window, MainPage page) MountMainPage(MainViewModel vm)
|
||||||
{
|
{
|
||||||
var window = new MainView();
|
var window = new MainWindow();
|
||||||
var page = new MainPage { DataContext = vm };
|
var page = new MainPage { DataContext = vm };
|
||||||
var app = (PostIt.App)Application.Current!;
|
var app = (PostIt.App)Application.Current!;
|
||||||
app.AttachMainWindow(window);
|
app.AttachMainWindow(window);
|
||||||
|
window.Show();
|
||||||
window.NavRoot.PushAsync(page).GetAwaiter().GetResult();
|
window.NavRoot.PushAsync(page).GetAwaiter().GetResult();
|
||||||
return (window, page);
|
return (window, page);
|
||||||
}
|
}
|
||||||
|
|
@ -124,7 +125,7 @@ public class MainPageButtonsTests
|
||||||
/// supported headless pattern (cf. CalculatorTests in the
|
/// supported headless pattern (cf. CalculatorTests in the
|
||||||
/// Avalonia.Samples repo). Returns the nav-stack count
|
/// Avalonia.Samples repo). Returns the nav-stack count
|
||||||
/// before the click so the caller can assert on the delta.
|
/// before the click so the caller can assert on the delta.
|
||||||
/// KeyPressQwerty is dispatched on the <see cref="MainView"/>
|
/// KeyPressQwerty is dispatched on the <see cref="MainWindow"/>
|
||||||
/// itself — it is the <see cref="TopLevel"/> that owns the
|
/// itself — it is the <see cref="TopLevel"/> that owns the
|
||||||
/// headless implementation, and routing the key through any
|
/// headless implementation, and routing the key through any
|
||||||
/// descendant TopLevel (e.g. one obtained via
|
/// descendant TopLevel (e.g. one obtained via
|
||||||
|
|
@ -133,7 +134,7 @@ public class MainPageButtonsTests
|
||||||
/// because the descendant does not carry the
|
/// because the descendant does not carry the
|
||||||
/// <c>PlatformHandle</c> the harness expects.
|
/// <c>PlatformHandle</c> the harness expects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static int ClickAndCapture(MainView window, Button button)
|
private static int ClickAndCapture(MainWindow window, Button button)
|
||||||
{
|
{
|
||||||
var stackBefore = window.NavRoot.NavigationStack.Count;
|
var stackBefore = window.NavRoot.NavigationStack.Count;
|
||||||
button.Command?.Execute(button.CommandParameter);
|
button.Command?.Execute(button.CommandParameter);
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ public class PostAclDialogTests
|
||||||
/// rebinding the global DI mid-test would trample the
|
/// rebinding the global DI mid-test would trample the
|
||||||
/// Settings singleton the rest of the harness depends on.
|
/// Settings singleton the rest of the harness depends on.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private static (MainView window, BlogAclApiClient aclClient, CircleApiClient circleClient, CountingHttpHandler handler) Mount()
|
private static (MainWindow window, BlogAclApiClient aclClient, CircleApiClient circleClient, CountingHttpHandler handler) Mount()
|
||||||
{
|
{
|
||||||
var handler = new CountingHttpHandler();
|
var handler = new CountingHttpHandler();
|
||||||
var settings = new Settings();
|
var settings = new Settings();
|
||||||
|
|
@ -138,9 +138,10 @@ public class PostAclDialogTests
|
||||||
// CountingHttpHandler.
|
// CountingHttpHandler.
|
||||||
GC.KeepAlive(sp);
|
GC.KeepAlive(sp);
|
||||||
|
|
||||||
var window = new MainView();
|
var window = new MainWindow();
|
||||||
var app = (App)Application.Current!;
|
var app = (App)Application.Current!;
|
||||||
app.AttachMainWindow(window);
|
app.AttachMainWindow(window);
|
||||||
|
window.Show();
|
||||||
|
|
||||||
return (window, aclClient, circleClient, handler);
|
return (window, aclClient, circleClient, handler);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ namespace PostIt.Tests;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UI tests for <see cref="SessionStatusBanner"/>. Mounted inside
|
/// UI tests for <see cref="SessionStatusBanner"/>. Mounted inside
|
||||||
/// a real <see cref="MainView"/> via the headless Avalonia
|
/// a real <see cref="MainWindow"/> via the headless Avalonia
|
||||||
/// platform declared in <c>TestApp.cs</c>.
|
/// platform declared in <c>TestApp.cs</c>.
|
||||||
///
|
///
|
||||||
/// <para>The pattern is the one that <c>UnitTest1.MainPage_Should_Load</c>
|
/// <para>The pattern is the one that <c>UnitTest1.MainPage_Should_Load</c>
|
||||||
|
|
@ -34,8 +34,9 @@ public class SessionStatusBannerTests
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public void Banner_renders_three_buttons_in_the_visual_tree()
|
public void Banner_renders_three_buttons_in_the_visual_tree()
|
||||||
{
|
{
|
||||||
var window = new MainView();
|
var window = new MainWindow();
|
||||||
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
||||||
|
window.Show();
|
||||||
|
|
||||||
var buttons = window.SessionBanner.GetVisualDescendants()
|
var buttons = window.SessionBanner.GetVisualDescendants()
|
||||||
.OfType<Button>()
|
.OfType<Button>()
|
||||||
|
|
@ -54,10 +55,11 @@ public class SessionStatusBannerTests
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public void Banner_login_button_is_visible_when_logged_out()
|
public void Banner_login_button_is_visible_when_logged_out()
|
||||||
{
|
{
|
||||||
var window = new MainView();
|
var window = new MainWindow();
|
||||||
var vm = new SessionStatusViewModel();
|
var vm = new SessionStatusViewModel();
|
||||||
Assert.True(vm.IsLoggedOut); // VM default
|
Assert.True(vm.IsLoggedOut); // VM default
|
||||||
window.SessionBanner.DataContext = vm;
|
window.SessionBanner.DataContext = vm;
|
||||||
|
window.Show();
|
||||||
|
|
||||||
var login = window.SessionBanner.GetVisualDescendants()
|
var login = window.SessionBanner.GetVisualDescendants()
|
||||||
.OfType<Button>()
|
.OfType<Button>()
|
||||||
|
|
@ -71,10 +73,11 @@ public class SessionStatusBannerTests
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public void Banner_logout_button_is_hidden_when_logged_out()
|
public void Banner_logout_button_is_hidden_when_logged_out()
|
||||||
{
|
{
|
||||||
var window = new MainView();
|
var window = new MainWindow();
|
||||||
var vm = new SessionStatusViewModel();
|
var vm = new SessionStatusViewModel();
|
||||||
Assert.False(vm.IsLoggedIn); // VM default
|
Assert.False(vm.IsLoggedIn); // VM default
|
||||||
window.SessionBanner.DataContext = vm;
|
window.SessionBanner.DataContext = vm;
|
||||||
|
window.Show();
|
||||||
|
|
||||||
var logout = window.SessionBanner.GetVisualDescendants()
|
var logout = window.SessionBanner.GetVisualDescendants()
|
||||||
.OfType<Button>()
|
.OfType<Button>()
|
||||||
|
|
@ -86,8 +89,9 @@ public class SessionStatusBannerTests
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public void Banner_settings_button_is_visible_regardless_of_session()
|
public void Banner_settings_button_is_visible_regardless_of_session()
|
||||||
{
|
{
|
||||||
var window = new MainView();
|
var window = new MainWindow();
|
||||||
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
||||||
|
window.Show();
|
||||||
|
|
||||||
var settings = window.SessionBanner.GetVisualDescendants()
|
var settings = window.SessionBanner.GetVisualDescendants()
|
||||||
.OfType<Button>()
|
.OfType<Button>()
|
||||||
|
|
@ -102,8 +106,9 @@ public class SessionStatusBannerTests
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public void Banner_session_label_reflects_DataContext()
|
public void Banner_session_label_reflects_DataContext()
|
||||||
{
|
{
|
||||||
var window = new MainView();
|
var window = new MainWindow();
|
||||||
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
window.SessionBanner.DataContext = new SessionStatusViewModel();
|
||||||
|
window.Show();
|
||||||
|
|
||||||
var label = window.SessionBanner.GetVisualDescendants()
|
var label = window.SessionBanner.GetVisualDescendants()
|
||||||
.OfType<TextBlock>()
|
.OfType<TextBlock>()
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ namespace PostIt.Tests;
|
||||||
|
|
||||||
internal class TestAppContext
|
internal class TestAppContext
|
||||||
{
|
{
|
||||||
public MainView? Window {get; set; }
|
public MainWindow? Window {get; set; }
|
||||||
public CirclesPage? page {get; set; }
|
public CirclesPage? page {get; set; }
|
||||||
public AddCircleMemberDialog? dialog { get; set; }
|
public AddCircleMemberDialog? dialog { get; set; }
|
||||||
public App? App { get; internal set; }
|
public App? App { get; internal set; }
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@ public class MainPageTests
|
||||||
[AvaloniaFact]
|
[AvaloniaFact]
|
||||||
public void MainPage_Should_Load()
|
public void MainPage_Should_Load()
|
||||||
{
|
{
|
||||||
var window = new MainView();
|
var window = new MainWindow();
|
||||||
|
window.Show();
|
||||||
Assert.NotNull(window);
|
Assert.NotNull(window);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,6 @@
|
||||||
|
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<FluentTheme />
|
<FluentTheme />
|
||||||
|
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
</Application>
|
</Application>
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ public partial class App : Application
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IServiceProvider? ServiceProvider { get; private set; }
|
public IServiceProvider? ServiceProvider { get; private set; }
|
||||||
|
|
||||||
public MainView? View { get; private set; }
|
public MainWindow? Window { get; private set; }
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
|
|
@ -44,28 +44,10 @@ public partial class App : Application
|
||||||
|
|
||||||
this.ServiceProvider = new ServiceCollection().BuildServices();
|
this.ServiceProvider = new ServiceCollection().BuildServices();
|
||||||
var settings = ServiceProvider.GetRequiredService<Settings>();
|
var settings = ServiceProvider.GetRequiredService<Settings>();
|
||||||
var sessionStatus = ServiceProvider!.GetRequiredService<SessionStatusViewModel>();
|
|
||||||
sessionStatus.LogoutCompleted += () =>
|
|
||||||
{
|
|
||||||
View.NavRoot.PopToRootAsync();
|
|
||||||
};
|
|
||||||
|
|
||||||
sessionStatus.LoginSucceeded += () =>
|
|
||||||
{
|
|
||||||
PushMainPageAsync();
|
|
||||||
};
|
|
||||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||||
{
|
{
|
||||||
var window = ServiceProvider.GetRequiredService<MainWindow>();
|
desktop.MainWindow = Window = CreateMainWindow();
|
||||||
desktop.MainWindow = window;
|
|
||||||
var api = ServiceProvider!.GetRequiredService<YavscApiClient>();
|
|
||||||
desktop.MainWindow.Opened += async (_, _) => await BootAsync(this.ServiceProvider!, api);
|
|
||||||
|
|
||||||
View = window.MainView;
|
|
||||||
|
|
||||||
View.SessionBanner.DataContext = sessionStatus;
|
|
||||||
// FIXME Window.Opened += async (_, _) => await BootAsync(this.ServiceProvider!, api);
|
|
||||||
|
|
||||||
ApplyDarkMode(settings);
|
ApplyDarkMode(settings);
|
||||||
}
|
}
|
||||||
else if (ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime)
|
else if (ApplicationLifetime is IActivityApplicationLifetime singleViewFactoryApplicationLifetime)
|
||||||
|
|
@ -73,34 +55,54 @@ public partial class App : Application
|
||||||
singleViewFactoryApplicationLifetime.MainViewFactory =
|
singleViewFactoryApplicationLifetime.MainViewFactory =
|
||||||
() =>
|
() =>
|
||||||
{
|
{
|
||||||
View = ServiceProvider.GetRequiredService<MainView>();
|
Window = CreateMainWindow();
|
||||||
ApplyDarkMode(settings);
|
ApplyDarkMode(settings);
|
||||||
View.SessionBanner.DataContext = sessionStatus;
|
Window.Show();
|
||||||
return View;
|
return Window;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
|
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
|
||||||
{
|
{
|
||||||
singleViewPlatform.MainView = View = ServiceProvider.GetRequiredService<MainView>();
|
singleViewPlatform.MainView = Window = CreateMainWindow();
|
||||||
View.SessionBanner.DataContext = sessionStatus;
|
|
||||||
ApplyDarkMode(settings);
|
ApplyDarkMode(settings);
|
||||||
}
|
}
|
||||||
var mainVm = ServiceProvider!.GetRequiredService<HomePageViewModel>();
|
var mainVm = ServiceProvider!.GetRequiredService<HomePageViewModel>();
|
||||||
|
|
||||||
base.OnFrameworkInitializationCompleted();
|
base.OnFrameworkInitializationCompleted();
|
||||||
this.PushPageAsync(mainVm);
|
this.PushPageAsync(mainVm).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private MainWindow CreateMainWindow()
|
||||||
|
{
|
||||||
|
Window = new MainWindow();
|
||||||
|
var api = ServiceProvider!.GetRequiredService<YavscApiClient>();
|
||||||
|
Window.Opened += async (_, _) => await BootAsync(this.ServiceProvider!, api);
|
||||||
|
var sessionStatus = ServiceProvider!.GetRequiredService<SessionStatusViewModel>();
|
||||||
|
sessionStatus.LogoutCompleted += () =>
|
||||||
|
{
|
||||||
|
Window.NavRoot.PopToRootAsync();
|
||||||
|
};
|
||||||
|
|
||||||
|
sessionStatus.LoginSucceeded += () =>
|
||||||
|
{
|
||||||
|
PushMainPageAsync();
|
||||||
|
};
|
||||||
|
|
||||||
|
Window.SessionBanner.DataContext = sessionStatus;
|
||||||
|
return Window;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Test-only hook: bind a concrete <see cref="MainView"/> so
|
/// Test-only hook: bind a concrete <see cref="MainWindow"/> so
|
||||||
/// command-driven navigation paths (<see cref="PushPage"/>) can
|
/// command-driven navigation paths (<see cref="PushPage"/>) can
|
||||||
/// push onto a real <see cref="NavigationPage"/> in headless
|
/// push onto a real <see cref="NavigationPage"/> in headless
|
||||||
/// fixtures that do not run the full desktop lifetime bootstrap.
|
/// fixtures that do not run the full desktop lifetime bootstrap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void AttachMainWindow(MainView mainWindow)
|
internal void AttachMainWindow(MainWindow mainWindow)
|
||||||
{
|
{
|
||||||
View = mainWindow ?? throw new ArgumentNullException(nameof(mainWindow));
|
Window = mainWindow ?? throw new ArgumentNullException(nameof(mainWindow));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ApplyDarkMode(Settings settings)
|
private static void ApplyDarkMode(Settings settings)
|
||||||
|
|
@ -178,6 +180,6 @@ public partial class App : Application
|
||||||
|
|
||||||
internal async Task GoBackAsync()
|
internal async Task GoBackAsync()
|
||||||
{
|
{
|
||||||
await View!.NavRoot.PopAsync();
|
await Window!.NavRoot.PopAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,11 @@ public static class ServiceCollectionHelpers
|
||||||
var circleClient = new CircleApiClient(api, settings.BlogsApiUrl);
|
var circleClient = new CircleApiClient(api, settings.BlogsApiUrl);
|
||||||
var blogAclClient = new BlogAclApiClient(api, settings.BlogsApiUrl);
|
var blogAclClient = new BlogAclApiClient(api, settings.BlogsApiUrl);
|
||||||
var userSearchClient = new UserSearchClient(api, settings.BlogsApiUrl);
|
var userSearchClient = new UserSearchClient(api, settings.BlogsApiUrl);
|
||||||
|
var contactService = new ContactService();
|
||||||
var userDirectory = new UserDirectory(userSearchClient);
|
var userDirectory = new UserDirectory(userSearchClient);
|
||||||
|
|
||||||
// Vues
|
// Vues
|
||||||
services.AddSingleton<MainView>();
|
services.AddTransient<MainPage>();
|
||||||
services.AddSingleton<MainPage>();
|
|
||||||
services.AddSingleton<MainWindow>();
|
|
||||||
|
|
||||||
// SettingsPage is a singleton: there must be one and only one
|
// SettingsPage is a singleton: there must be one and only one
|
||||||
// instance of the settings UI for the lifetime of the app.
|
// instance of the settings UI for the lifetime of the app.
|
||||||
// This guarantees that (a) the bindings always reflect the
|
// This guarantees that (a) the bindings always reflect the
|
||||||
|
|
@ -60,6 +58,7 @@ public static class ServiceCollectionHelpers
|
||||||
services.AddSingleton(circleClient);
|
services.AddSingleton(circleClient);
|
||||||
services.AddSingleton(blogAclClient);
|
services.AddSingleton(blogAclClient);
|
||||||
services.AddSingleton(userSearchClient);
|
services.AddSingleton(userSearchClient);
|
||||||
|
services.AddSingleton<IContactService>(contactService);
|
||||||
services.AddSingleton<IUserDirectory>(userDirectory);
|
services.AddSingleton<IUserDirectory>(userDirectory);
|
||||||
services.AddTransient<MainViewModel>();
|
services.AddTransient<MainViewModel>();
|
||||||
services.AddTransient<HomePageViewModel>();
|
services.AddTransient<HomePageViewModel>();
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public static class ViewModelBaseHelpers
|
||||||
{
|
{
|
||||||
public static async Task PushPageAsync(this App app, ViewModelBase vm)
|
public static async Task PushPageAsync(this App app, ViewModelBase vm)
|
||||||
{
|
{
|
||||||
var window = app.View;
|
var window = app.Window;
|
||||||
if (window is null)
|
if (window is null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("MainWindow is not initialized yet.");
|
throw new InvalidOperationException("MainWindow is not initialized yet.");
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@
|
||||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" />
|
<PackageReference Include="CommunityToolkit.Mvvm" />
|
||||||
|
<PackageReference Include="Avalonia.AvaloniaEdit" />
|
||||||
<PackageReference Include="IdentityModel.OidcClient" />
|
<PackageReference Include="IdentityModel.OidcClient" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
||||||
36
src/PostIt/PostIt/Services/ContactService.Desktop.cs
Normal file
36
src/PostIt/PostIt/Services/ContactService.Desktop.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#if !ANDROID && !IOS
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace PostIt.Services;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desktop stub for <see cref="IContactService"/>.
|
||||||
|
///
|
||||||
|
/// <para>The desktop has no equivalent of the mobile address
|
||||||
|
/// book (no <c>Contacts.Default</c>, no CardDAV out of the
|
||||||
|
/// box). Rather than synthesise a list from a different
|
||||||
|
/// source, this provider returns an empty list and lets the
|
||||||
|
/// UI render an honest "no local contacts on this platform"
|
||||||
|
/// message.</para>
|
||||||
|
///
|
||||||
|
/// <para>If desktop users want to invite people who aren't
|
||||||
|
/// Yavsc members, that flow goes through a separate path
|
||||||
|
/// (manual email entry + invitation endpoint) — not through
|
||||||
|
/// <see cref="IContactService"/>. Finding existing Yavsc
|
||||||
|
/// members is <see cref="IUserDirectory"/>'s job, not this
|
||||||
|
/// one's.</para>
|
||||||
|
///
|
||||||
|
/// <para>Future CardDAV / Google Contacts / Exchange
|
||||||
|
/// providers can plug in here as additional
|
||||||
|
/// <see cref="IContactService"/> implementations selected
|
||||||
|
/// from DI by configuration.</para>
|
||||||
|
/// </summary>
|
||||||
|
public sealed class ContactService : IContactService
|
||||||
|
{
|
||||||
|
public Task<IReadOnlyList<ContactDto>> GetDeviceContactsAsync(CancellationToken ct = default)
|
||||||
|
=> Task.FromResult<IReadOnlyList<ContactDto>>(Array.Empty<ContactDto>());
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
@ -97,15 +97,23 @@
|
||||||
|
|
||||||
<TextBlock Grid.Row="0" Text="Post detail" FontWeight="SemiBold" />
|
<TextBlock Grid.Row="0" Text="Post detail" FontWeight="SemiBold" />
|
||||||
<TextBox Grid.Row="1" Text="{Binding DraftTitle, Mode=TwoWay}" PlaceholderText="Title" />
|
<TextBox Grid.Row="1" Text="{Binding DraftTitle, Mode=TwoWay}" PlaceholderText="Title" />
|
||||||
<TextBox Grid.Row="2" PlaceholderText="Write something here !"
|
<!-- <TextBox Grid.Row="2" PlaceholderText="Write something here !"
|
||||||
Text="{Binding DraftArticle, Mode=TwoWay}"
|
Text="{Binding DraftArticle, Mode=TwoWay}"
|
||||||
MinHeight="320"
|
MinHeight="320"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch">
|
VerticalAlignment="Stretch">
|
||||||
</TextBox>
|
|
||||||
|
|
||||||
|
</TextBox> -->
|
||||||
|
<AvaloniaEdit:TextEditor Grid.Row="2"
|
||||||
|
views:TextEditorBinding.Text="{Binding DraftArticle, Mode=TwoWay}"
|
||||||
|
ShowLineNumbers="True"
|
||||||
|
FontFamily="Cascadia Code, Consolas, Menlo, Monospace"
|
||||||
|
MinHeight="320"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
HorizontalScrollBarVisibility="Auto" />
|
||||||
<TextBlock Grid.Row="3" Text="{Binding StatusMessage}" Foreground="Gray" />
|
<TextBlock Grid.Row="3" Text="{Binding StatusMessage}" Foreground="Gray" />
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
<UserControl xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
||||||
xmlns:vm="using:PostIt.ViewModels"
|
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
||||||
xmlns:views="using:PostIt.Views"
|
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
|
||||||
x:Class="PostIt.Views.MainView"
|
|
||||||
x:DataType="vm:MainViewModel">
|
|
||||||
<Design.DataContext>
|
|
||||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
|
||||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
|
||||||
<vm:MainViewModel />
|
|
||||||
</Design.DataContext>
|
|
||||||
|
|
||||||
<DockPanel LastChildFill="True">
|
|
||||||
<views:SessionStatusBanner
|
|
||||||
x:Name="SessionBanner"
|
|
||||||
DockPanel.Dock="Bottom"/>
|
|
||||||
<NavigationPage x:Name="NavRoot"/>
|
|
||||||
</DockPanel>
|
|
||||||
</UserControl>
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
using Avalonia.Controls;
|
|
||||||
|
|
||||||
namespace PostIt.Views;
|
|
||||||
|
|
||||||
public partial class MainView : UserControl
|
|
||||||
{
|
|
||||||
public MainView()
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -8,5 +8,10 @@
|
||||||
x:Class="PostIt.Views.MainWindow"
|
x:Class="PostIt.Views.MainWindow"
|
||||||
Icon="/Assets/avalonia-logo.ico"
|
Icon="/Assets/avalonia-logo.ico"
|
||||||
Title="PostIt" >
|
Title="PostIt" >
|
||||||
<views:MainView x:Name="MainView" />
|
|
||||||
|
<DockPanel LastChildFill="True">
|
||||||
|
<views:SessionStatusBanner x:Name="SessionBanner"
|
||||||
|
DockPanel.Dock="Bottom"/>
|
||||||
|
<NavigationPage x:Name="NavRoot"/>
|
||||||
|
</DockPanel>
|
||||||
</Window>
|
</Window>
|
||||||
|
|
|
||||||
51
src/PostIt/PostIt/Views/TextEditorBinding.cs
Normal file
51
src/PostIt/PostIt/Views/TextEditorBinding.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Data;
|
||||||
|
using AvaloniaEdit;
|
||||||
|
|
||||||
|
namespace PostIt.Views;
|
||||||
|
|
||||||
|
public sealed class TextEditorBinding
|
||||||
|
{
|
||||||
|
public static readonly AttachedProperty<string?> TextProperty =
|
||||||
|
AvaloniaProperty.RegisterAttached<TextEditorBinding, TextEditor, string?>(
|
||||||
|
"Text",
|
||||||
|
defaultBindingMode: BindingMode.TwoWay);
|
||||||
|
|
||||||
|
private static readonly AttachedProperty<bool> IsTextChangeSubscribedProperty =
|
||||||
|
AvaloniaProperty.RegisterAttached<TextEditorBinding, TextEditor, bool>("IsTextChangeSubscribed");
|
||||||
|
|
||||||
|
static TextEditorBinding()
|
||||||
|
{
|
||||||
|
TextProperty.Changed.AddClassHandler<TextEditor>((editor, args) =>
|
||||||
|
{
|
||||||
|
EnsureTextChangeSubscribed(editor);
|
||||||
|
|
||||||
|
var text = args.GetNewValue<string?>() ?? string.Empty;
|
||||||
|
if (editor.Text != text)
|
||||||
|
{
|
||||||
|
editor.Text = text;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string? GetText(TextEditor editor) => editor.GetValue(TextProperty);
|
||||||
|
|
||||||
|
public static void SetText(TextEditor editor, string? value) => editor.SetValue(TextProperty, value);
|
||||||
|
|
||||||
|
private static void EnsureTextChangeSubscribed(TextEditor editor)
|
||||||
|
{
|
||||||
|
if (editor.GetValue(IsTextChangeSubscribedProperty))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
editor.SetValue(IsTextChangeSubscribedProperty, true);
|
||||||
|
editor.TextChanged += (_, _) =>
|
||||||
|
{
|
||||||
|
if (editor.Text != GetText(editor))
|
||||||
|
{
|
||||||
|
SetText(editor, editor.Text);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue