소스 검색

Fix iOS build

Benedikt 3 년 전
부모
커밋
acecaf7018
3개의 변경된 파일19개의 추가작업 그리고 5개의 파일을 삭제
  1. 3 0
      samples/ControlCatalog.iOS/ControlCatalog.iOS.csproj
  2. 14 5
      src/iOS/Avalonia.iOS/AvaloniaView.Text.cs
  3. 2 0
      src/iOS/Avalonia.iOS/AvaloniaView.cs

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

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

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

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

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

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