Logo de Avalonia Mobile

Avalonia Mobile

Communauté
linuxdevel
avalonia-mobile

Use when building or fixing the Android or iOS (and Mac Catalyst) app side of an Avalonia app — project heads and startup per version (AvaloniaAndroidApplication, AvaloniaMainActivity, AvaloniaAppDelegate, IActivityApplicationLifetime vs ISingleViewApplicationLifetime), safe areas/edge-to-edge (IInsetsManager), soft keyboard (IInputPane), back button, orientation, app activation/background, haptics (PlatformFeedback), touch behavior, and mobile storage/launcher. For packaging/signing see avalonia-deployment.

Présentation

Éditeurlinuxdevel
DépôtAvalonia-skills
Nom de la compétenceavalonia-mobile
Étoiles
50
Forks
4
Fichiers inclus
Instructions uniquement
LicenceMIT
Liens
  • Instructions en Markdown

    Un fichier SKILL.md que le modèle charge à la demande : il ne consomme donc des tokens que lorsqu’une demande correspond réellement à la compétence.

  • Compatible avec tous les LLM

    Les compétences IA sont en simple Markdown, et non en code propre à un fournisseur. Elles fonctionnent donc avec GPT, Claude, Gemini, Grok ou un modèle local.

  • Tout dans les instructions

    Tout ce dont le modèle a besoin se trouve dans les instructions : aucun fichier supplémentaire à synchroniser.

  • Open source

    Publiée par linuxdevel sur GitHub. Consultez les sources avant de l’installer.

Installation

Installez la compétence IA Avalonia Mobile dans TypingMind pour l’utiliser avec n’importe quel LLM, ou ajoutez-la à un autre agent capable de lire SKILL.md.

1

Installer dans TypingMind

TypingMind installe une compétence directement depuis son dossier GitHub : l’application lit SKILL.md, regroupe les fichiers de ressources et enregistre le tout localement.

  1. Ouvrez l’application et accédez à Plugins → Compétences.
  2. Choisissez « Installer depuis GitHub ».
  3. Collez l’URL du dossier de la compétence indiquée ci-dessous, puis confirmez.
    https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-mobile
  4. Activez la compétence dans chaque discussion où vous souhaitez pouvoir l’utiliser.
Plugins → Compétences → Ajouter → Via URL GitHub, puis collez l’URL du dossier et appuyez sur Continuer.
2

Installer dans un autre agent

Tout agent capable de lire le format Agent Skills peut utiliser cette compétence : copiez le dossier dans le répertoire des compétences de cet agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/linuxdevel/Avalonia-skills.git /tmp/Avalonia-skills
mkdir -p .claude/skills
cp -r /tmp/Avalonia-skills/skills/avalonia/avalonia-mobile .claude/skills/avalonia-mobile
Redémarrez Claude Code après la copie pour que la nouvelle compétence soit prise en compte.

Utilisez cette compétence dans TypingMind

Activez Avalonia Mobile dans n’importe quelle discussion TypingMind et le modèle s’occupe du reste. Le nom et la description de la compétence figurent dans le prompt système. Dès qu’une demande correspond, le modèle charge lui-même l’intégralité des instructions : vous n’avez jamais à l’invoquer manuellement, et elle ne consomme aucun token tant qu’elle n’est pas utilisée.

Le modèle charge automatiquement Avalonia Mobile dès qu’une demande correspond à cette compétence.

Compatible avec tous les modèles IA

Les compétences IA sont de simples instructions Markdown, et non du code propre à un fournisseur. Ainsi, Avalonia Mobile n’est pas lié au modèle pour lequel cette compétence a été conçue. Installez-la une seule fois dans TypingMind et utilisez-la avec GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou un modèle local que vous exécutez vous-même, le tout avec vos propres clés API.

  • Chargée uniquement en cas de besoin

    Le prompt système ne contient que le nom et la description. Les instructions sont récupérées à la première demande correspondante : une compétence inutilisée ne coûte donc rien.

  • Changez de modèle en cours de discussion

    La compétence étant constituée d’instructions et non de code, elle reste fonctionnelle lorsque vous changez de modèle : le nouveau modèle lit le même fichier SKILL.md.

Instructions de la compétence

Voici le contenu de SKILL.md que le modèle charge. Lisez-le avant l’installation : une compétence contient des instructions que votre modèle suivra.

Avalonia Mobile (Android & iOS)

App-level concerns only. Packaging, signing, APK/IPA publishing: see avalonia-deployment. Version labels: see avalonia-versions.

Requirements

11.x12.0 / 12.1
TFMnet*-android / net*-ios (pre-net10)net10.0-android / net10.0-ios (net10.0 required)
Mac Catalystno(12.0+) net10.0-maccatalyst via Avalonia.iOS package
PackagesAvalonia.Android / Avalonia.iOSsame, version must match core Avalonia

Standard solution layout (from avalonia-dotnet-templates xplat template): shared App project + *.Android head + *.iOS head (+ Desktop/Browser). Template defaults: Android SupportedOSPlatformVersion 23, iOS 13.0, AndroidX SplashScreen package referenced.

Android startup

(12.0+) Application class + activity

csharp
// Application.cs — initialization moved here from the activity
[Application]
public class AndroidApp : AvaloniaAndroidApplication<App>
{
    public AndroidApp(IntPtr javaReference, JniHandleOwnership transfer)
        : base(javaReference, transfer) { }

    protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
        => base.CustomizeAppBuilder(builder).WithInterFont();
}

// MainActivity.cs — non-generic
[Activity(
    Label = "MyApp",
    Theme = "@style/MyTheme.NoActionBar",
    Icon = "@drawable/icon",
    MainLauncher = true,
    ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity { }

CreateAppBuilder() / CustomizeAppBuilder() were removed from AvaloniaMainActivity — put builder customization in the AvaloniaAndroidApplication<TApp> subclass or App. (The IntPtr, JniHandleOwnership constructor is the standard .NET-Android requirement for Application subclasses; the template may omit/inline it — copy from the generated head.)

Type chain: AppCompatActivity -> AvaloniaActivity -> AvaloniaMainActivity.

(12.0+) App.axaml.cs — set the main view

csharp
public override void OnFrameworkInitializationCompleted()
{
    switch (ApplicationLifetime)
    {
        case IClassicDesktopStyleApplicationLifetime desktop:
            desktop.MainWindow = new MainWindow();
            break;
        case IActivityApplicationLifetime activity:        // Android (12.0+)
            activity.MainViewFactory = () => new MainView();  // Func<Control>
            break;
        case ISingleViewApplicationLifetime single:        // iOS, Browser, embedded Linux
            single.MainView = new MainView();
            break;
    }
    base.OnFrameworkInitializationCompleted();
}

Android no longer uses ISingleViewApplicationLifetime; keep that branch for iOS/Browser. Use a factory (a new view per activity instance), not a shared instance.

(11.x) Generic activity + single view

csharp
[Activity(Label = "MyApp", MainLauncher = true, Theme = "@style/MyTheme.NoActionBar",
    ConfigurationChanges = ConfigChanges.Orientation | ConfigChanges.ScreenSize | ConfigChanges.UiMode)]
public class MainActivity : AvaloniaMainActivity<App>
{
    protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
        => base.CustomizeAppBuilder(builder).WithInterFont();
}
// App: case ISingleViewApplicationLifetime single: single.MainView = new MainView();

Multiple activities (12.0+)

Android may create several instances of the main activity in one process (notification tap, return from another app), and 12.0 lets later activities use your project's Application class. IActivityApplicationLifetime.MainViewFactory (Func<Control>) is called once per new activity instance, so each gets a fresh view with its own state. Never set ISingleViewApplicationLifetime.MainView on Android 12 — the Android lifetime implements both interfaces and wraps MainView in a factory returning the same instance, so a second activity shows a blank screen. The lifetime holds only the factory; keep your own reference if you need the current view. Extra (non-main) activities subclass AvaloniaActivity (AppCompatActivity -> AvaloniaActivity) and set its Content property. AvaloniaActivity also has ActivityResult, RequestPermissionsResult (both Action<...>), event BackRequested, and OnBackPressed() / OnBackInvoked().

Rendering mode

csharp
// in AvaloniaAndroidApplication<TApp>.CustomizeAppBuilder
.With(new AndroidPlatformOptions
{
    RenderingMode = new[] { AndroidRenderingMode.Egl, AndroidRenderingMode.Software }
})

AndroidRenderingMode: Egl (default GPU), Vulkan, Software. First mode that initializes wins; empty list or all failing throws InvalidOperationException — keep Software as fallback.

iOS / Mac Catalyst startup

csharp
[Register("AppDelegate")]
public partial class AppDelegate : AvaloniaAppDelegate<App>
{
    protected override AppBuilder CustomizeAppBuilder(AppBuilder builder)
        => base.CustomizeAppBuilder(builder)
            .WithInterFont()
            .With(new iOSPlatformOptions
            {
                RenderingMode = new[] { iOSRenderingMode.Metal, iOSRenderingMode.OpenGl },
                EnableHighRefreshRate = false   // opt out of high refresh rate
            });
}
  • iOS uses ISingleViewApplicationLifetime (MainView) in all versions.
  • (12.0+) Scene-based lifecycle: a scene delegate is managed internally; most apps need no changes. AvaloniaAppDelegate.Window stays null after startup — to reach the UIWindow, override AvaloniaView.MovedToWindow.
  • (12.0+) Mac Catalyst: <TargetFrameworks>net10.0-ios;net10.0-maccatalyst</TargetFrameworks>; dotnet workload install maccatalyst, dotnet run -f net10.0-maccatalyst.
  • Embedding: Avalonia.iOS.AvaloniaView (UIKit view hosting Avalonia content), Avalonia.Android.AvaloniaView on Android.

Safe areas & edge-to-edge — IInsetsManager

csharp
var insets = TopLevel.GetTopLevel(this)?.InsetsManager;   // IInsetsManager?
if (insets is not null)
{
    insets.DisplayEdgeToEdgePreference = true;      // draw behind system bars
    insets.IsSystemBarVisible = true;               // bool?
    insets.SystemBarColor = Colors.Black;           // Color?
    Thickness pad = insets.SafeAreaPadding;         // notches, bars, (keyboard excluded)
    insets.SafeAreaChanged += (_, e) => Padding = e.SafeAreaPadding;   // SafeAreaChangedArgs
}
MemberNotes
DisplayEdgeToEdgePreference (bool)Request edge-to-edge. Replaces DisplayEdgeToEdge (removed in 12)
DisplaysEdgeToEdgeActual current state
SafeAreaPadding (Thickness) / SafeAreaChangedCurrent safe-area insets / change event
IsSystemBarVisible (bool?), SystemBarColor (Color?)System bar control

Also on TopLevel: attached SystemBarColor (TopLevel.SetSystemBarColor(control, SolidColorBrush?) / GetSystemBarColor) and TopLevel.GetAutoSafeAreaPadding / SetAutoSafeAreaPadding (whether the TopLevel auto-pads for the safe area). SystemBarTheme enum: Light (light bar background, dark foreground) / Dark.

When drawing edge-to-edge, apply SafeAreaPadding to your root layout (or rely on auto safe-area padding) so content isn't under notches/home indicator.

Soft keyboard — IInputPane

csharp
var pane = TopLevel.GetTopLevel(this)?.InputPane;   // IInputPane?
pane!.StateChanged += (_, e) =>
{
    // e.NewState: InputPaneState.Open / Closed
    // e.EndRect: final keyboard bounds; e.StartRect (Rect?); e.AnimationDuration; e.Easing
    BottomSpacer.Height = e.NewState == InputPaneState.Open ? e.EndRect.Height : 0;
};
var occluded = pane.OccludedRect;   // current keyboard bounds
  • Closed also means "keyboard floating / overlay and not part of insets".
  • To request showing the keyboard: TextInputMethodClient.ShowInputPanel was removed in 12; the client now raises InputPaneActivationRequested (EventHandler) and the platform decides. Don't call a show method yourself — focus a TextBox.

Back button

csharp
var top = TopLevel.GetTopLevel(this)!;
top.BackRequested += (_, e) =>      // EventHandler<RoutedEventArgs>, "physical Back Button pressed or back navigation requested"
{
    if (Nav.CanGoBack) { Nav.GoBack(); e.Handled = true; }
};

Android-specific (12.0+, per AvaloniaActivity): event BackRequested of EventHandler<AndroidBackRequestedEventArgs> (has bool Handled), plus OnBackPressed() / OnBackInvoked(). Set Handled = true to stop the default (finishing the activity); do not leave it unhandled when you consumed the back action.

Orientation

  • Lock in the Android activity: [Activity(..., ScreenOrientation = ScreenOrientation.Portrait)] (Android attribute). Keep ConfigurationChanges = Orientation | ScreenSize | UiMode so rotation doesn't recreate the activity.
  • iOS: set supported orientations in Info.plist (UISupportedInterfaceOrientations).
  • Read at runtime: TopLevel.Screens?.Primary?.CurrentOrientation -> Avalonia.Platform.ScreenOrientation (None, Landscape, LandscapeFlipped, Portrait, PortraitFlipped). React to size changes via layout size changes rather than polling.

App lifecycle — IActivatableLifetime

csharp
if (Application.Current?.TryGetFeature<IActivatableLifetime>() is { } life)
{
    life.Activated   += (_, e) => { /* e.Kind: ActivationKind.Background / File / OpenUri / Reopen */ };
    life.Deactivated += (_, e) => { if (e.Kind == ActivationKind.Background) SaveState(); };
}
  • ActivatedEventArgs.Kind is an ActivationKind: Background (enter/leave background), File (FileActivatedEventArgs.Files), OpenUri (ProtocolActivatedEventArgs.Uri), Reopen (macOS).
  • Replaces IActivatableApplicationLifetime / IApplicationPlatformEvents (removed in 12). In 11.x use (ApplicationLifetime as IActivatableApplicationLifetime).
  • Android: IAvaloniaActivity.Activated/Deactivated per activity; file/URI intents arrive as FileActivatedEventArgs / ProtocolActivatedEventArgs. Register intent filters on the activity ([IntentFilter(...)]) — see Avalonia docs "Register your app to open files".
  • iOS: protocol/universal links are delivered as ProtocolActivatedEventArgs with Kind == ActivationKind.OpenUri.
  • Save state on Deactivated (background) — mobile OSes may kill the process without further notice.

Haptics & sound — PlatformFeedback (12.1+)

csharp
// Opt a control in (default is FeedbackType.None for custom controls)
PlatformFeedback.SetFeedbackType(this, FeedbackType.Auto);   // None, Auto, Sound, Haptic
this.PerformFeedback(FeedbackAction.Click);                  // extension on InputElement; also FeedbackAction.Hold
xml
<Button PlatformFeedback.FeedbackType="Auto" />

Namespace Avalonia.Controls. Implemented on Android and iOS. FeedbackAction cannot be constructed by apps (internal constructor). Not available in 12.0/11.x.

System theme (12.1+ on Android)

12.1 detects Android system theme (dark/light) changes at runtime; earlier versions only read it at startup. Keep RequestedThemeVariant = Default (don't hard-set Light/Dark) to follow the OS, and handle ConfigChanges.UiMode on the activity. Read with TopLevel.PlatformSettings?.GetColorValues().ThemeVariant (11.x) or visual.GetPlatformSettings() (12.x).

Touch input

  • (12.0+) Touch/pen select and focus on pointer release, not press; ListBoxItem/TreeViewItem handle their own selection. 11.x selects on press — don't write 12 code that depends on press-selection from touch.
  • (12.0+) Gesture events (e.g. Pinch) are directly on InputElement, no Gestures. prefix in XAML.
  • Hover (:pointerover) styling is meaningless on touch; use :pressed.
  • Make hit targets at least ~44x44 dp (MinHeight/MinWidth).

Storage, permissions, launcher

csharp
var top = TopLevel.GetTopLevel(this)!;
var files = await top.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions { AllowMultiple = false });
await using var s = await files[0].OpenReadAsync();          // use streams, not paths
await top.Launcher.LaunchUriAsync(new Uri("https://avaloniaui.net"));
  • Android pickers go through the system document picker (content URIs); iOS through the document picker. file.Path.LocalPath is unreliable — always use OpenReadAsync/OpenWriteAsync. Details: avalonia-services.
  • Android runtime permissions: declare in AndroidManifest.xml (<uses-permission>), request via Android APIs from the activity; AvaloniaActivity.RequestPermissionsResult / ActivityResult callbacks (Action<...> properties) can receive results; IActivityResultHandler exists for this.
  • iOS: add usage descriptions (NSCameraUsageDescription, etc.) to Info.plist.

Page-based navigation (12.0+)

12.0 adds Page, ContentPage, DrawerPage, CarouselPage and related page types for mobile-style navigation (page lifecycle events fire after transitions complete). Not in 11.x — there use a ContentControl + ViewModel navigation. See avalonia-controls / avalonia-mvvm and the Avalonia docs for the page API; the dotnet template can scaffold a page-hosted main view. Wire TopLevel.BackRequested to the page stack.

Common Mistakes

  • Android 12.x with AvaloniaMainActivity<TApp> or ISingleViewApplicationLifetime — use non-generic AvaloniaMainActivity + [Application] AvaloniaAndroidApplication<TApp> + IActivityApplicationLifetime.MainViewFactory.
  • Overriding CustomizeAppBuilder on the activity (12.x) — removed; put it on the Application class.
  • Missing [Application] attribute on the AvaloniaAndroidApplication<TApp> subclass — app never initializes.
  • Wrong TFM — 12.x mobile heads need net10.0-android/net10.0-ios.
  • DisplayEdgeToEdge / ShowInputPanel / IActivatableApplicationLifetime — removed in 12; use DisplayEdgeToEdgePreference, InputPaneActivationRequested, TryGetFeature<IActivatableLifetime>().
  • Content under notch/status bar after enabling edge-to-edge — apply SafeAreaPadding (and re-apply on SafeAreaChanged).
  • Keyboard covers inputs — listen to InputPane.StateChanged, pad/scroll by EndRect.Height.
  • Accessing TopLevel.InsetsManager/InputPane too early — null before attachment; use Loaded/OnAttachedToVisualTree.
  • Forgetting e.Handled = true on back handling — app exits instead of navigating back.
  • Using PlatformFeedback on 12.0 — 12.1+ only; custom controls default to FeedbackType.None.
  • Assuming selection on press for touch — 12.x selects on release.
  • Using file paths from pickers on mobile — use stream APIs.
  • Removing ConfigChanges.UiMode/Orientation/ScreenSize — activity restarts on rotate/theme change and view state is lost.
  • Reading AvaloniaAppDelegate.Window on iOS 12 — null; scene delegate owns the window.

Sources

Foire aux questions

À quoi sert la compétence IA Avalonia Mobile ?

Use when building or fixing the Android or iOS (and Mac Catalyst) app side of an Avalonia app — project heads and startup per version (AvaloniaAndroidApplication, AvaloniaMainActivity, AvaloniaAppDelegate, IActivityApplicationLifetime vs ISingleViewApplicationLifetime), safe areas/edge-to-edge (IInsetsManager), soft keyboard (IInputPane), back button, orientation, app activation/background, haptics (PlatformFeedback), touch behavior, and mobile storage/launcher. For packaging/signing see avalonia-deployment.

Pourquoi utiliser Avalonia Mobile sur TypingMind ?

Parce que vous l’installez une seule fois pour l’utiliser avec n’importe quel modèle. Avalonia Mobile se compose de simples instructions en Markdown plutôt que de code propre à un fournisseur. La même compétence fonctionne donc avec GPT-5, Claude, Gemini, Grok ou un modèle local, et vous pouvez changer de modèle en cours de discussion sans perturber son fonctionnement. TypingMind utilise vos propres clés API : vous payez donc directement les fournisseurs plutôt qu’un abonnement par siège, et vos compétences et discussions restent dans votre propre espace de stockage.

Comment installer Avalonia Mobile dans TypingMind ?

Dans TypingMind, ouvrez Plugins → Compétences → Installer depuis GitHub et collez https://github.com/linuxdevel/Avalonia-skills/tree/main/skills/avalonia/avalonia-mobile. TypingMind lit le fichier SKILL.md et l’installe sous forme de compétence que vous pouvez activer pour chaque discussion.

Quels modèles d’IA peuvent utiliser Avalonia Mobile ?

N’importe quel modèle que vous connectez dans TypingMind. Les compétences IA sont de simples instructions en Markdown, et non du code propre à un fournisseur. GPT, Claude, Gemini, Grok et les modèles locaux peuvent donc tous charger cette compétence lorsqu’une demande lui correspond.

Combien de modèles d’IA puis-je utiliser avec Avalonia Mobile ?

Autant que vous le souhaitez. Tant qu’un modèle prend en charge les compétences, vous pouvez utiliser Avalonia Mobile avec lui : GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama et bien d’autres, le tout dans TypingMind avec vos propres clés API.

La compétence IA Avalonia Mobile est-elle gratuite ?

Oui. Cette compétence est publiée sur GitHub par linuxdevel sous licence MIT. Vous ne payez que votre propre fournisseur d’IA pour les tokens utilisés.

Que sont les compétences IA ?

Une compétence IA est un ensemble d’instructions réutilisables qui apprend à un modèle d’IA à accomplir une tâche précise. Elle suit le format ouvert Agent Skills : un fichier SKILL.md contenant un nom et une description, ainsi que les éventuels scripts, modèles de documents ou fichiers de référence dont le modèle peut avoir besoin. Le modèle ne lit les instructions que lorsque votre demande correspond à la compétence. Une compétence installée ne coûte donc rien tant qu’elle n’est pas utilisée.

En quoi les compétences IA diffèrent-elles des plugins ou des serveurs MCP ?

Un plugin ou un serveur MCP fournit au modèle de nouveaux outils à appeler : du code qui s’exécute quelque part et renvoie un résultat. Une compétence IA lui apporte plutôt des connaissances et une méthode : comment aborder une tâche, quelles étapes suivre et à quoi ressemble un bon résultat. Les compétences sont de simples instructions en Markdown. Elles ne nécessitent donc ni serveur, ni clé API, ni environnement d’exécution, et fonctionnent avec n’importe quel modèle.

Tout voir

Créez votre propre espace IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇