Skip to content

Commit 64907fc

Browse files
rookiejavamyroot
authored andcommitted
Bump to latest
- Adds the GraphicsViewHandler and ShapeViewHandler - Apply one stop shop UseMauiControls (dotnet#1157) - Implements new APIs for each IView - and so on
1 parent ecbf7b1 commit 64907fc

File tree

7 files changed

+113
-14
lines changed

7 files changed

+113
-14
lines changed

src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.ComponentModel;
3+
using Microsoft.Maui.Controls.Platform;
34
using Microsoft.Maui.Controls.Internals;
45
using Microsoft.Maui.Controls.Platform;
56
using Microsoft.Maui.Graphics;

src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ public static void MapSelectionLength(IEditorHandler handler, ITextInput editor)
113113
handler.PlatformView?.UpdateSelectionLength(editor);
114114
}
115115

116+
public static void MapKeyboard(EditorHandler handler, IEditor editor)
117+
{
118+
handler.NativeView?.UpdateKeyboard(editor);
119+
}
120+
116121
[MissingMapper]
117122
public static void MapCharacterSpacing(IEditorHandler handler, IEditor editor) { }
118123

src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using Tizen.UIExtensions.ElmSharp;
3+
using SmartEvent = ElmSharp.SmartEvent;
34
using EEntry = ElmSharp.Entry;
45

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

159+
public static void MapSelectionLength(EntryHandler handler, IEntry entry)
160+
{
161+
handler.NativeView?.UpdateSelectionLength(entry);
162+
}
163+
164+
public static void MapCursorPosition(EntryHandler handler, IEntry entry)
165+
{
166+
handler.NativeView?.UpdateSelectionLength(entry);
167+
}
168+
169+
public static void MapKeyboard(EditorHandler handler, IEditor editor)
170+
{
171+
handler.NativeView?.UpdateKeyboard(editor);
172+
}
173+
158174
[MissingMapper]
159175
public static void MapCharacterSpacing(IEntryHandler handler, IEntry entry) { }
160176

@@ -208,6 +224,37 @@ void OnSelectionCleared(object? sender, EventArgs e)
208224
}
209225
}
210226

227+
void OnCursorChanged(object? sender, EventArgs e)
228+
{
229+
if (VirtualView == null || NativeView == null)
230+
return;
231+
232+
var position = NativeView.CursorPosition;
233+
234+
NativeView.GetSelectRegion(out int start, out int end);
235+
236+
if (start > -1)
237+
{
238+
position = (start < end) ? start : end;
239+
var selectionLength = Math.Abs(end - start);
240+
VirtualView.SelectionLength = selectionLength;
241+
}
242+
243+
VirtualView.CursorPosition = position;
244+
}
245+
246+
void OnSelectionCleared(object sender, EventArgs e)
247+
{
248+
if (VirtualView == null || NativeView == null)
249+
return;
250+
251+
if (NativeView.IsFocused)
252+
{
253+
VirtualView.SelectionLength = 0;
254+
VirtualView.CursorPosition = NativeView.CursorPosition;
255+
}
256+
}
257+
211258
void OnCompleted(object? sender, EventArgs e)
212259
{
213260
if (PlatformView == null)

src/Core/src/Handlers/SearchBar/SearchBarHandler.Tizen.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ public static void MapCancelButtonColor(ISearchBarHandler handler, ISearchBar se
120120
handler.PlatformView?.UpdateCancelButtonColor(searchBar);
121121
}
122122

123+
public static void MapCancelButtonColor(SearchBarHandler handler, ISearchBar searchBar)
124+
{
125+
handler.NativeView?.UpdateCancelButtonColor(searchBar);
126+
}
127+
123128
[MissingMapper]
124129
public static void MapCharacterSpacing(ISearchBarHandler handler, ISearchBar searchBar) { }
125130

src/Core/src/Platform/Tizen/EntryExtensions.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,51 @@ static int GetSelectionEnd(Entry platformEntry, ITextInput entry, int start)
141141
return end;
142142
}
143143

144+
/* Updates both the IEntry.CursorPosition and IEntry.SelectionLength properties. */
145+
[PortHandler]
146+
public static void UpdateSelectionLength(this Entry nativeEntry, IEntry entry)
147+
{
148+
var start = GetSelectionStart(nativeEntry, entry);
149+
var end = GetSelectionEnd(nativeEntry, entry, start);
150+
var selectionLength = end - start;
151+
152+
if (selectionLength != entry.SelectionLength)
153+
entry.SelectionLength = selectionLength;
154+
155+
if (selectionLength > 0)
156+
{
157+
nativeEntry.SetSelectionRegion(start, end);
158+
}
159+
else
160+
{
161+
nativeEntry.CursorPosition = entry.CursorPosition;
162+
}
163+
}
164+
165+
static int GetSelectionStart(Entry nativeEntry, IEntry entry)
166+
{
167+
var start = entry.Text?.Length ?? 0;
168+
var cursorPosition = entry.CursorPosition;
169+
170+
if (entry.CursorPosition > 0)
171+
start = Math.Min(start, cursorPosition);
172+
173+
if (start != cursorPosition)
174+
entry.CursorPosition = start;
175+
176+
return start;
177+
}
178+
179+
static int GetSelectionEnd(Entry nativeEntry, IEntry entry, int start)
180+
{
181+
var end = start;
182+
183+
if (entry.SelectionLength > 0)
184+
end = Math.Min((start + entry.SelectionLength), entry.Text?.Length ?? 0);
185+
186+
return end;
187+
}
188+
144189
public static InputPanelReturnKeyType ToInputPanelReturnKeyType(this ReturnType returnType)
145190
{
146191
switch (returnType)

src/Core/src/Platform/Tizen/HandlerExtensions.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ public static EvasObject ToNative(this IView view, IMauiContext context)
1616

1717
var handler = view.Handler;
1818

19+
if (handler?.MauiContext != null &&
20+
handler.MauiContext != context)
21+
{
22+
handler = null;
23+
}
24+
1925
if (handler == null)
2026
{
2127
handler = context.Handlers.GetHandler(view.GetType());
@@ -24,10 +30,13 @@ public static EvasObject ToNative(this IView view, IMauiContext context)
2430
throw new Exception($"Handler not found for view {view}");
2531

2632
handler.SetMauiContext(context);
27-
handler.SetVirtualView(view);
2833
view.Handler = handler;
2934
}
3035

36+
if (handler.VirtualView != view)
37+
handler.SetVirtualView(view);
38+
39+
3140
if (((INativeViewHandler)handler).NativeView is not EvasObject result)
3241
{
3342
throw new InvalidOperationException($"Unable to convert {view} to {typeof(EvasObject)}");

src/Core/src/Platform/Tizen/PageView.cs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)