Skip to content

Commit

Permalink
Bump to latest
Browse files Browse the repository at this point in the history
- Adds the GraphicsViewHandler and ShapeViewHandler
- Apply one stop shop UseMauiControls (dotnet#1157)
- Implements new APIs for each IView
- and so on
  • Loading branch information
rookiejava authored and myroot committed Aug 24, 2022
1 parent ecbf7b1 commit 64907fc
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.ComponentModel;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
Expand Down
5 changes: 5 additions & 0 deletions src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ public static void MapSelectionLength(IEditorHandler handler, ITextInput editor)
handler.PlatformView?.UpdateSelectionLength(editor);
}

public static void MapKeyboard(EditorHandler handler, IEditor editor)
{
handler.NativeView?.UpdateKeyboard(editor);
}

[MissingMapper]
public static void MapCharacterSpacing(IEditorHandler handler, IEditor editor) { }

Expand Down
47 changes: 47 additions & 0 deletions src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Tizen.UIExtensions.ElmSharp;
using SmartEvent = ElmSharp.SmartEvent;
using EEntry = ElmSharp.Entry;

namespace Microsoft.Maui.Handlers
Expand Down Expand Up @@ -155,6 +156,21 @@ public static void MapKeyboard(EditorHandler handler, IEntry entry)
handler.PlatformView?.UpdateKeyboard(entry);
}

public static void MapSelectionLength(EntryHandler handler, IEntry entry)
{
handler.NativeView?.UpdateSelectionLength(entry);
}

public static void MapCursorPosition(EntryHandler handler, IEntry entry)
{
handler.NativeView?.UpdateSelectionLength(entry);
}

public static void MapKeyboard(EditorHandler handler, IEditor editor)
{
handler.NativeView?.UpdateKeyboard(editor);
}

[MissingMapper]
public static void MapCharacterSpacing(IEntryHandler handler, IEntry entry) { }

Expand Down Expand Up @@ -208,6 +224,37 @@ void OnSelectionCleared(object? sender, EventArgs e)
}
}

void OnCursorChanged(object? sender, EventArgs e)
{
if (VirtualView == null || NativeView == null)
return;

var position = NativeView.CursorPosition;

NativeView.GetSelectRegion(out int start, out int end);

if (start > -1)
{
position = (start < end) ? start : end;
var selectionLength = Math.Abs(end - start);
VirtualView.SelectionLength = selectionLength;
}

VirtualView.CursorPosition = position;
}

void OnSelectionCleared(object sender, EventArgs e)
{
if (VirtualView == null || NativeView == null)
return;

if (NativeView.IsFocused)
{
VirtualView.SelectionLength = 0;
VirtualView.CursorPosition = NativeView.CursorPosition;
}
}

void OnCompleted(object? sender, EventArgs e)
{
if (PlatformView == null)
Expand Down
5 changes: 5 additions & 0 deletions src/Core/src/Handlers/SearchBar/SearchBarHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ public static void MapCancelButtonColor(ISearchBarHandler handler, ISearchBar se
handler.PlatformView?.UpdateCancelButtonColor(searchBar);
}

public static void MapCancelButtonColor(SearchBarHandler handler, ISearchBar searchBar)
{
handler.NativeView?.UpdateCancelButtonColor(searchBar);
}

[MissingMapper]
public static void MapCharacterSpacing(ISearchBarHandler handler, ISearchBar searchBar) { }

Expand Down
45 changes: 45 additions & 0 deletions src/Core/src/Platform/Tizen/EntryExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,51 @@ static int GetSelectionEnd(Entry platformEntry, ITextInput entry, int start)
return end;
}

/* Updates both the IEntry.CursorPosition and IEntry.SelectionLength properties. */
[PortHandler]
public static void UpdateSelectionLength(this Entry nativeEntry, IEntry entry)
{
var start = GetSelectionStart(nativeEntry, entry);
var end = GetSelectionEnd(nativeEntry, entry, start);
var selectionLength = end - start;

if (selectionLength != entry.SelectionLength)
entry.SelectionLength = selectionLength;

if (selectionLength > 0)
{
nativeEntry.SetSelectionRegion(start, end);
}
else
{
nativeEntry.CursorPosition = entry.CursorPosition;
}
}

static int GetSelectionStart(Entry nativeEntry, IEntry entry)
{
var start = entry.Text?.Length ?? 0;
var cursorPosition = entry.CursorPosition;

if (entry.CursorPosition > 0)
start = Math.Min(start, cursorPosition);

if (start != cursorPosition)
entry.CursorPosition = start;

return start;
}

static int GetSelectionEnd(Entry nativeEntry, IEntry entry, int start)
{
var end = start;

if (entry.SelectionLength > 0)
end = Math.Min((start + entry.SelectionLength), entry.Text?.Length ?? 0);

return end;
}

public static InputPanelReturnKeyType ToInputPanelReturnKeyType(this ReturnType returnType)
{
switch (returnType)
Expand Down
11 changes: 10 additions & 1 deletion src/Core/src/Platform/Tizen/HandlerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ public static EvasObject ToNative(this IView view, IMauiContext context)

var handler = view.Handler;

if (handler?.MauiContext != null &&
handler.MauiContext != context)
{
handler = null;
}

if (handler == null)
{
handler = context.Handlers.GetHandler(view.GetType());
Expand All @@ -24,10 +30,13 @@ public static EvasObject ToNative(this IView view, IMauiContext context)
throw new Exception($"Handler not found for view {view}");

handler.SetMauiContext(context);
handler.SetVirtualView(view);
view.Handler = handler;
}

if (handler.VirtualView != view)
handler.SetVirtualView(view);


if (((INativeViewHandler)handler).NativeView is not EvasObject result)
{
throw new InvalidOperationException($"Unable to convert {view} to {typeof(EvasObject)}");
Expand Down
13 changes: 0 additions & 13 deletions src/Core/src/Platform/Tizen/PageView.cs

This file was deleted.

0 comments on commit 64907fc

Please sign in to comment.