Browse Source

Fix iOS build

Benedikt 3 years ago
parent
commit
acecaf7018

+ 3 - 0
samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj

@@ -9,6 +9,9 @@
     <RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
     <RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
     <!--    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>-->
     <!--    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>-->
   </PropertyGroup>
   </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
+    <CodesignKey>iPhone Developer</CodesignKey>
+  </PropertyGroup>
   <ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj" />
     <ProjectReference Include="..\..\src\iOS\Avalonia.iOS\Avalonia.iOS.csproj" />
     <ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" />
     <ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" />

+ 14 - 5
src/iOS/Avalonia.iOS/AvaloniaView.Text.cs

@@ -13,8 +13,15 @@ namespace Avalonia.iOS;
 [Adopts("UIKeyInput")]
 [Adopts("UIKeyInput")]
 public partial class AvaloniaView : ITextInputMethodImpl
 public partial class AvaloniaView : ITextInputMethodImpl
 {
 {
-    private ITextInputMethodClient? _currentClient;
+    private IUITextInputDelegate _inputDelegate;
+    private ITextInputMethodClient? _client;
 
 
+    class TextInputHandler : UITextInputDelegate
+    {
+    }
+    
+    public ITextInputMethodClient? Client => _client;
+    public bool IsActive => _client != null;
     public override bool CanResignFirstResponder => true;
     public override bool CanResignFirstResponder => true;
     public override bool CanBecomeFirstResponder => true;
     public override bool CanBecomeFirstResponder => true;
 
 
@@ -23,8 +30,8 @@ public partial class AvaloniaView : ITextInputMethodImpl
     {
     {
         get
         get
         {
         {
-            if (_currentClient is { } && _currentClient.SupportsSurroundingText &&
-                _currentClient.SurroundingText.Text.Length > 0)
+            if (Client is { } && Client.SupportsSurroundingText &&
+                Client.SurroundingText.Text.Length > 0)
             {
             {
                 return true;
                 return true;
             }
             }
@@ -47,6 +54,8 @@ public partial class AvaloniaView : ITextInputMethodImpl
         }
         }
     }
     }
 
 
+    public IUITextInputDelegate InputDelegate => _inputDelegate;
+
     [Export("deleteBackward")]
     [Export("deleteBackward")]
     public void DeleteBackward()
     public void DeleteBackward()
     {
     {
@@ -63,9 +72,9 @@ public partial class AvaloniaView : ITextInputMethodImpl
 
 
     void ITextInputMethodImpl.SetClient(ITextInputMethodClient? client)
     void ITextInputMethodImpl.SetClient(ITextInputMethodClient? client)
     {
     {
-        _currentClient = client;
+        _client = client;
 
 
-        if (client is { })
+        if (_client is { })
         {
         {
             BecomeFirstResponder();
             BecomeFirstResponder();
         }
         }

+ 2 - 0
src/iOS/Avalonia.iOS/AvaloniaView.cs

@@ -30,6 +30,8 @@ namespace Avalonia.iOS
             _topLevelImpl = new TopLevelImpl(this);
             _topLevelImpl = new TopLevelImpl(this);
             _touches = new TouchHandler(this, _topLevelImpl);
             _touches = new TouchHandler(this, _topLevelImpl);
             _topLevel = new EmbeddableControlRoot(_topLevelImpl);
             _topLevel = new EmbeddableControlRoot(_topLevelImpl);
+            _inputDelegate = new TextInputHandler();
+            
             _topLevel.Prepare();
             _topLevel.Prepare();
             
             
             _topLevel.Renderer.Start();
             _topLevel.Renderer.Start();