diff --git a/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets b/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets
index bfa81e0fadab..01d6d8ff280f 100644
--- a/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets
+++ b/.nuspec/Microsoft.Maui.Controls.MultiTargeting.targets
@@ -113,5 +113,4 @@
WINDOWS_UWP;$(DefineConstants)
-
diff --git a/.nuspec/Microsoft.Maui.Controls.SingleProject.targets b/.nuspec/Microsoft.Maui.Controls.SingleProject.targets
index 15f98664a1a3..628e932bee6d 100644
--- a/.nuspec/Microsoft.Maui.Controls.SingleProject.targets
+++ b/.nuspec/Microsoft.Maui.Controls.SingleProject.targets
@@ -111,7 +111,7 @@
BeforeTargets="_MauiInjectXamlCssAdditionalFiles;GenerateMSBuildEditorConfigFileShouldRun"
Condition=" '$(EnableDefaultItems)' == 'true' and '$(SingleProject)' == 'true' ">
-
+
Microsoft.AspNetCore.Components.Web.JSComponentConfigurationStore!
Microsoft.AspNetCore.Components.WebView.Maui.RootComponentsCollection.RootComponentsCollection(Microsoft.AspNetCore.Components.Web.JSComponentConfigurationStore! jsComponents) -> void
Microsoft.AspNetCore.Components.WebView.Maui.TizenWebViewManager
-Microsoft.AspNetCore.Components.WebView.Maui.TizenWebViewManager.TizenWebViewManager(Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler! blazorMauiWebViewHandler, Tizen.WebView.WebView! webview, System.IServiceProvider! provider, Microsoft.AspNetCore.Components.Dispatcher! dispatcher, Microsoft.Extensions.FileProviders.IFileProvider! fileProvider, Microsoft.AspNetCore.Components.Web.JSComponentConfigurationStore! jsComponents, string! contentRootRelativeToAppRoot, string! hostPageRelativePath) -> void
+Microsoft.AspNetCore.Components.WebView.Maui.TizenWebViewManager.TizenWebViewManager(Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler! blazorMauiWebViewHandler, Tizen.NUI.BaseComponents.WebView! webview, System.IServiceProvider! provider, Microsoft.AspNetCore.Components.Dispatcher! dispatcher, Microsoft.Extensions.FileProviders.IFileProvider! fileProvider, Microsoft.AspNetCore.Components.Web.JSComponentConfigurationStore! jsComponents, string! contentRootRelativeToAppRoot, string! hostPageRelativePath) -> void
override Microsoft.AspNetCore.Components.WebView.Maui.TizenWebViewManager.NavigateCore(System.Uri! absoluteUri) -> void
override Microsoft.AspNetCore.Components.WebView.Maui.TizenWebViewManager.SendMessage(string! message) -> void
-Microsoft.AspNetCore.Components.WebView.Maui.WebViewContainer
-Microsoft.AspNetCore.Components.WebView.Maui.WebViewContainer.WebViewContainer(ElmSharp.EvasObject! parent) -> void
-Microsoft.AspNetCore.Components.WebView.Maui.WebViewContainer.WebView.get -> Tizen.WebView.WebView!
Microsoft.AspNetCore.Components.WebView.UrlLoadingEventArgs
Microsoft.AspNetCore.Components.WebView.UrlLoadingEventArgs.Url.get -> System.Uri!
Microsoft.AspNetCore.Components.WebView.UrlLoadingEventArgs.UrlLoadingStrategy.get -> Microsoft.AspNetCore.Components.WebView.UrlLoadingStrategy
@@ -51,13 +48,13 @@ Microsoft.AspNetCore.Components.WebView.UrlLoadingStrategy.CancelLoad = 2 -> Mic
Microsoft.AspNetCore.Components.WebView.UrlLoadingStrategy.OpenExternally = 0 -> Microsoft.AspNetCore.Components.WebView.UrlLoadingStrategy
Microsoft.AspNetCore.Components.WebView.UrlLoadingStrategy.OpenInWebView = 1 -> Microsoft.AspNetCore.Components.WebView.UrlLoadingStrategy
Microsoft.Extensions.DependencyInjection.BlazorWebViewServiceCollectionExtensions
-override Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.CreatePlatformView() -> Microsoft.AspNetCore.Components.WebView.Maui.WebViewContainer!
-override Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.ConnectHandler(Microsoft.AspNetCore.Components.WebView.Maui.WebViewContainer! platformView) -> void
-override Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.DisconnectHandler(Microsoft.AspNetCore.Components.WebView.Maui.WebViewContainer! platformView) -> void
+override Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.CreatePlatformView() -> Tizen.NUI.BaseComponents.WebView!
+override Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.ConnectHandler(Tizen.NUI.BaseComponents.WebView! platformView) -> void
+override Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.DisconnectHandler(Tizen.NUI.BaseComponents.WebView! platformView) -> void
static Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.MapHostPage(Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler! handler, Microsoft.AspNetCore.Components.WebView.Maui.IBlazorWebView! webView) -> void
static Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.MapRootComponents(Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler! handler, Microsoft.AspNetCore.Components.WebView.Maui.IBlazorWebView! webView) -> void
static Microsoft.Extensions.DependencyInjection.BlazorWebViewServiceCollectionExtensions.AddBlazorWebViewDeveloperTools(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!
static Microsoft.Extensions.DependencyInjection.BlazorWebViewServiceCollectionExtensions.AddMauiBlazorWebView(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services) -> Microsoft.AspNetCore.Components.WebView.Maui.IMauiBlazorWebViewBuilder!
static Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebViewHandler.BlazorWebViewMapper -> Microsoft.Maui.PropertyMapper!
virtual Microsoft.AspNetCore.Components.WebView.Maui.BlazorWebView.CreateFileProvider(string! contentRootDir) -> Microsoft.Extensions.FileProviders.IFileProvider!
-~Microsoft.AspNetCore.Components.WebView.BlazorWebViewInitializedEventArgs.WebView.get -> Tizen.WebView.WebView
+~Microsoft.AspNetCore.Components.WebView.BlazorWebViewInitializedEventArgs.WebView.get -> Tizen.NUI.BaseComponents.WebView
diff --git a/src/BlazorWebView/src/Maui/Tizen/BlazorWebViewHandler.Tizen.cs b/src/BlazorWebView/src/Maui/Tizen/BlazorWebViewHandler.Tizen.cs
index 7b45a654c4f0..139b9932dc6a 100644
--- a/src/BlazorWebView/src/Maui/Tizen/BlazorWebViewHandler.Tizen.cs
+++ b/src/BlazorWebView/src/Maui/Tizen/BlazorWebViewHandler.Tizen.cs
@@ -1,21 +1,23 @@
using System;
+using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
using Microsoft.Maui;
using Microsoft.Maui.Dispatching;
using Microsoft.Maui.Handlers;
-using Tizen.WebView;
-using TChromium = Tizen.WebView.Chromium;
-using TWebView = Tizen.WebView.WebView;
+using Tizen.NUI;
+using NWebView = Tizen.NUI.BaseComponents.WebView;
namespace Microsoft.AspNetCore.Components.WebView.Maui
{
///
/// The Tizen for .
///
- public partial class BlazorWebViewHandler : ViewHandler
+ public partial class BlazorWebViewHandler : ViewHandler
{
+ private const string BlazorWebViewIdentifier = "BlazorWebView:";
+ private const string UserAgentHeaderKey = "User-Agent";
private const string AppOrigin = "http://0.0.0.0/";
private const string BlazorInitScript = @"
window.__receiveMessageCallbacks = [];
@@ -42,10 +44,9 @@ public partial class BlazorWebViewHandler : ViewHandler> s_webviewHandlerTable = new Dictionary>();
- private TWebView PlatformWebView => PlatformView.WebView;
+ private TizenWebViewManager? _webviewManager;
private bool RequiredStartupPropertiesSet =>
//_webview != null &&
@@ -53,42 +54,89 @@ public partial class BlazorWebViewHandler : ViewHandler
- protected override WebViewContainer CreatePlatformView()
+ protected override NWebView CreatePlatformView()
{
- TChromium.Initialize();
- MauiApplication.Current.Terminated += (s, e) => TChromium.Shutdown();
-
- return new WebViewContainer(PlatformParent);
+ return new NWebView()
+ {
+ MouseEventsEnabled = true,
+ KeyEventsEnabled = true,
+ };
}
///
- protected override void ConnectHandler(WebViewContainer platformView)
+ protected override void ConnectHandler(NWebView platformView)
{
- _interceptRequestCallback = OnRequestInterceptCallback;
- PlatformWebView.LoadFinished += OnLoadFinished;
- PlatformWebView.AddJavaScriptMessageHandler("BlazorHandler", PostMessageFromJS);
- PlatformWebView.SetInterceptRequestCallback(_interceptRequestCallback);
- PlatformWebView.GetSettings().JavaScriptEnabled = true;
+ platformView.PageLoadFinished += OnLoadFinished;
+ platformView.Context.RegisterHttpRequestInterceptedCallback(OnRequestInterceptStaticCallback);
+ platformView.AddJavaScriptMessageHandler("BlazorHandler", PostMessageFromJS);
+ platformView.UserAgent += $" {BlazorWebViewIdentifier}{GetHashCode()}";
+ s_webviewHandlerTable[GetHashCode().ToString()] = new WeakReference(this);
}
///
- protected override void DisconnectHandler(WebViewContainer platformView)
+ protected override void DisconnectHandler(NWebView platformView)
{
- PlatformWebView.LoadFinished -= OnLoadFinished;
+ platformView.PageLoadFinished -= OnLoadFinished;
base.DisconnectHandler(platformView);
+ s_webviewHandlerTable.Remove(GetHashCode().ToString());
+ }
+
+
+ private void PostMessageFromJS(string message)
+ {
+ _webviewManager!.MessageReceivedInternal(new Uri(PlatformView.Url), message);
}
- private void PostMessageFromJS(JavaScriptMessage message)
+ private void OnLoadFinished(object? sender, WebViewPageLoadEventArgs e)
{
- if (message is null)
+ //FocusManager.Instance.SetCurrentFocusView(NativeView);
+ var url = PlatformView.Url;
+
+ if (url == AppOrigin)
+ PlatformView.EvaluateJavaScript(BlazorInitScript);
+ }
+
+ private static void OnRequestInterceptStaticCallback(WebHttpRequestInterceptor interceptor)
+ {
+ if (interceptor.Headers.TryGetValue(UserAgentHeaderKey, out var agent))
{
- throw new ArgumentNullException(nameof(message));
+ var idx = agent.IndexOf(BlazorWebViewIdentifier);
+ if (idx >= 0)
+ {
+ var webviewKey = agent.Substring(idx + BlazorWebViewIdentifier.Length);
+ if (s_webviewHandlerTable.TryGetValue(webviewKey, out var weakHandler)
+ && weakHandler.TryGetTarget(out var handler))
+ {
+ handler.OnRequestInterceptCallback(interceptor);
+ return;
+ }
+ }
}
+ interceptor.Ignore();
+ }
- if (message.Name.Equals("BlazorHandler", StringComparison.Ordinal))
+ private void OnRequestInterceptCallback(WebHttpRequestInterceptor interceptor)
+ {
+ var url = interceptor.Url;
+ if (url.StartsWith(AppOrigin))
{
- _webviewManager!.MessageReceivedInternal(new Uri(PlatformWebView.Url), message.GetBodyAsString());
+ var allowFallbackOnHostPage = url.EndsWith("/");
+ url = QueryStringHelper.RemovePossibleQueryString(url);
+ if (_webviewManager!.TryGetResponseContentInternal(url, allowFallbackOnHostPage, out var statusCode, out var statusMessage, out var content, out var headers))
+ {
+ var header = $"HTTP/1.0 200 OK\r\n";
+ foreach (var item in headers)
+ {
+ header += $"{item.Key}:{item.Value}\r\n";
+ }
+ header += "\r\n";
+ MemoryStream memstream = new MemoryStream();
+ content.CopyTo(memstream);
+ interceptor.SetResponse(header, memstream.ToArray());
+ return;
+ }
}
+ interceptor.Ignore();
}
private void StartWebViewCoreIfPossible()
@@ -105,14 +153,14 @@ private void StartWebViewCoreIfPossible()
// We assume the host page is always in the root of the content directory, because it's
// unclear there's any other use case. We can add more options later if so.
- var contentRootDir = Path.GetDirectoryName(HostPage!) ?? string.Empty;
- var hostPageRelativePath = Path.GetRelativePath(contentRootDir, HostPage!);
+ var contentRootDir = System.IO.Path.GetDirectoryName(HostPage!) ?? string.Empty;
+ var hostPageRelativePath = System.IO.Path.GetRelativePath(contentRootDir, HostPage!);
var fileProvider = VirtualView.CreateFileProvider(contentRootDir);
_webviewManager = new TizenWebViewManager(
this,
- PlatformWebView,
+ PlatformView,
Services!,
new MauiDispatcher(Services!.GetRequiredService()),
fileProvider,
@@ -125,7 +173,7 @@ private void StartWebViewCoreIfPossible()
VirtualView.BlazorWebViewInitializing(new BlazorWebViewInitializingEventArgs());
VirtualView.BlazorWebViewInitialized(new BlazorWebViewInitializedEventArgs
{
- WebView = PlatformWebView,
+ WebView = PlatformView,
});
if (RootComponents != null)
@@ -139,50 +187,6 @@ private void StartWebViewCoreIfPossible()
_webviewManager.Navigate("/");
}
- private void OnRequestInterceptCallback(IntPtr context, IntPtr request, IntPtr userdata)
- {
- if (request == IntPtr.Zero)
- {
- return;
- }
-
- var url = PlatformWebView.GetInterceptRequestUrl(request);
-
- if (url.StartsWith(AppOrigin))
- {
- var allowFallbackOnHostPage = url.EndsWith("/");
- url = QueryStringHelper.RemovePossibleQueryString(url);
- if (_webviewManager!.TryGetResponseContentInternal(url, allowFallbackOnHostPage, out var statusCode, out var statusMessage, out var content, out var headers))
- {
- var header = $"HTTP/1.0 200 OK\r\n";
- foreach (var item in headers)
- {
- header += $"{item.Key}:{item.Value}\r\n";
- }
- header += "\r\n";
-
- using (MemoryStream memstream = new MemoryStream())
- {
- content.CopyTo(memstream);
- var body = memstream.ToArray();
- PlatformWebView.SetInterceptRequestResponse(request, header, body, (uint)body.Length);
- }
- return;
- }
- }
-
- PlatformWebView.IgnoreInterceptRequest(request);
- }
-
- private void OnLoadFinished(object? sender, EventArgs e)
- {
- PlatformWebView.SetFocus(true);
- var url = PlatformWebView.Url;
-
- if (url == AppOrigin)
- PlatformWebView.Eval(BlazorInitScript);
- }
-
internal IFileProvider CreateFileProvider(string contentRootDir)
{
return new TizenMauiAssetFileProvider(contentRootDir);
diff --git a/src/BlazorWebView/src/Maui/Tizen/TizenWebViewManager.cs b/src/BlazorWebView/src/Maui/Tizen/TizenWebViewManager.cs
index 967fe158cafa..01476c1e901c 100644
--- a/src/BlazorWebView/src/Maui/Tizen/TizenWebViewManager.cs
+++ b/src/BlazorWebView/src/Maui/Tizen/TizenWebViewManager.cs
@@ -4,7 +4,7 @@
using System.Text.Encodings.Web;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.Extensions.FileProviders;
-using TWebView = Tizen.WebView.WebView;
+using NWebView = Tizen.NUI.BaseComponents.WebView;
namespace Microsoft.AspNetCore.Components.WebView.Maui
{
@@ -17,7 +17,7 @@ public class TizenWebViewManager : WebViewManager
private const string AppOrigin = "http://0.0.0.0/";
private readonly BlazorWebViewHandler _blazorMauiWebViewHandler;
- private readonly TWebView _webview;
+ private readonly NWebView _webview;
private readonly string _contentRootRelativeToAppRoot;
///
@@ -31,7 +31,7 @@ public class TizenWebViewManager : WebViewManager
/// Describes configuration for adding, removing, and updating root components from JavaScript code.
/// Path to the directory containing application content files.
/// Path to the host page within the fileProvider.
- public TizenWebViewManager(BlazorWebViewHandler blazorMauiWebViewHandler, TWebView webview, IServiceProvider provider, Dispatcher dispatcher, IFileProvider fileProvider, JSComponentConfigurationStore jsComponents, string contentRootRelativeToAppRoot, string hostPageRelativePath)
+ public TizenWebViewManager(BlazorWebViewHandler blazorMauiWebViewHandler, NWebView webview, IServiceProvider provider, Dispatcher dispatcher, IFileProvider fileProvider, JSComponentConfigurationStore jsComponents, string contentRootRelativeToAppRoot, string hostPageRelativePath)
: base(provider, dispatcher, new Uri(AppOrigin), fileProvider, jsComponents, hostPageRelativePath)
{
_blazorMauiWebViewHandler = blazorMauiWebViewHandler ?? throw new ArgumentNullException(nameof(blazorMauiWebViewHandler));
@@ -58,7 +58,7 @@ protected override void NavigateCore(Uri absoluteUri)
protected override void SendMessage(string message)
{
var messageJSStringLiteral = JavaScriptEncoder.Default.Encode(message);
- _webview.Eval($"__dispatchMessageCallback(\"{messageJSStringLiteral}\")");
+ _webview.EvaluateJavaScript($"__dispatchMessageCallback(\"{messageJSStringLiteral}\")");
}
internal void MessageReceivedInternal(Uri uri, string message)
diff --git a/src/BlazorWebView/src/Maui/Tizen/WebViewContainer.cs b/src/BlazorWebView/src/Maui/Tizen/WebViewContainer.cs
deleted file mode 100644
index beb14251deee..000000000000
--- a/src/BlazorWebView/src/Maui/Tizen/WebViewContainer.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System;
-using Tizen.UIExtensions.ElmSharp;
-using ElmSharp;
-using TWebView = Tizen.WebView.WebView;
-
-namespace Microsoft.AspNetCore.Components.WebView.Maui
-{
- ///
- /// A Tizen WebView browser control container.
- ///
- public class WebViewContainer : WidgetLayout
- {
-
- ///
- /// A Tizen WebView.
- ///
- public TWebView WebView { get; }
-
- ///
- /// Initializes a new instance of
- ///
- /// The .
- public WebViewContainer(EvasObject parent) : base(parent)
- {
- WebView = new TWebView(parent);
- SetContent(WebView);
- AllowFocus(true);
- Focused += OnFocused;
- Unfocused += OnUnfocused;
- }
-
- void OnFocused(object? sender, EventArgs e)
- {
- WebView.SetFocus(true);
- }
-
- void OnUnfocused(object? sender, EventArgs e)
- {
- WebView.SetFocus(false);
- }
- }
-}
diff --git a/src/BlazorWebView/src/Maui/Tizen/WebViewExtensions.cs b/src/BlazorWebView/src/Maui/Tizen/WebViewExtensions.cs
deleted file mode 100644
index fcd21554eea7..000000000000
--- a/src/BlazorWebView/src/Maui/Tizen/WebViewExtensions.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using TWebView = Tizen.WebView.WebView;
-
-namespace Microsoft.AspNetCore.Components.WebView.Maui
-{
- ///
- /// WebViewExtension
- ///
- internal static class WebViewExtensions
- {
- public const string ChromiumEwk = "libchromium-ewk.so";
-
- public static void SetInterceptRequestCallback(this TWebView webView, InterceptRequestCallback callback)
- {
- var context = webView.GetContext();
- var handleField = context.GetType().GetField("_handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
- var contextHandle = (IntPtr?)handleField?.GetValue(context);
- if (contextHandle != null)
- ewk_context_intercept_request_callback_set(contextHandle.Value, callback, IntPtr.Zero);
- }
-
- public static void SetInspectorStart(this TWebView webView, uint port)
- {
- var context = webView.GetContext();
- var handleField = context.GetType().GetField("_handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
- var contextHandle = (IntPtr?)handleField?.GetValue(context);
- if (contextHandle != null)
- ewk_context_inspector_server_start(contextHandle.Value, port);
- }
-
- public static bool SetInterceptRequestResponse(this TWebView webView, IntPtr request, string header, byte[] body, uint length)
- {
- return ewk_intercept_request_response_set(request, header, body, length);
- }
-
- public static bool IgnoreInterceptRequest(this TWebView webView, IntPtr request)
- {
- return ewk_intercept_request_ignore(request);
- }
-
- public static string GetInterceptRequestUrl(this TWebView webView, IntPtr request)
- {
- return Marshal.PtrToStringAnsi(_ewk_intercept_request_url_get(request)) ?? string.Empty;
- }
-
- [DllImport(ChromiumEwk)]
- internal static extern IntPtr ewk_view_context_get(IntPtr obj);
-
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- public delegate void InterceptRequestCallback(IntPtr context, IntPtr request, IntPtr userData);
-
- [DllImport(ChromiumEwk)]
- internal static extern void ewk_context_intercept_request_callback_set(IntPtr context, InterceptRequestCallback callback, IntPtr userData);
-
- [DllImport(ChromiumEwk, EntryPoint = "ewk_intercept_request_url_get")]
- internal static extern IntPtr _ewk_intercept_request_url_get(IntPtr request);
-
- [DllImport(ChromiumEwk, EntryPoint = "ewk_intercept_request_http_method_get")]
- internal static extern IntPtr _ewk_intercept_request_http_method_get(IntPtr request);
-
- internal static string ewk_intercept_request_http_method_get(IntPtr request)
- {
- return Marshal.PtrToStringAnsi(_ewk_intercept_request_http_method_get(request)) ?? string.Empty;
- }
-
- [DllImport(ChromiumEwk)]
- public static extern uint ewk_context_inspector_server_start(IntPtr context, uint port);
-
- [DllImport(ChromiumEwk)]
- internal static extern bool ewk_intercept_request_ignore(IntPtr request);
-
- [DllImport(ChromiumEwk)]
- internal static extern bool ewk_intercept_request_response_set(IntPtr request, string header, string body, uint length);
-
- [DllImport(ChromiumEwk)]
- internal static extern bool ewk_intercept_request_response_set(IntPtr request, string header, byte[] body, uint length);
- }
-}
diff --git a/src/BlazorWebView/src/SharedSource/BlazorWebViewInitializedEventArgs.cs b/src/BlazorWebView/src/SharedSource/BlazorWebViewInitializedEventArgs.cs
index a7de76a6afd9..4d7c1b27ab1c 100644
--- a/src/BlazorWebView/src/SharedSource/BlazorWebViewInitializedEventArgs.cs
+++ b/src/BlazorWebView/src/SharedSource/BlazorWebViewInitializedEventArgs.cs
@@ -14,7 +14,7 @@
#elif IOS || MACCATALYST
using WebKit;
#elif TIZEN
-using TWebView = Tizen.WebView.WebView;
+using TWebView = Tizen.NUI.BaseComponents.WebView;
#endif
namespace Microsoft.AspNetCore.Components.WebView
diff --git a/src/Compatibility/Core/src/AppHostBuilderExtensions.Tizen.cs b/src/Compatibility/Core/src/AppHostBuilderExtensions.Tizen.cs
index 3142d9fcf9e2..16733fe69a85 100644
--- a/src/Compatibility/Core/src/AppHostBuilderExtensions.Tizen.cs
+++ b/src/Compatibility/Core/src/AppHostBuilderExtensions.Tizen.cs
@@ -27,7 +27,7 @@ static void OnConfigureLifeCycle(ITizenLifecycleBuilder tizen)
var options = services.GetService();
if (options == null)
{
- options = new InitializationOptions(MauiApplication.Current)
+ options = new InitializationOptions()
{
DisplayResolutionUnit = TDeviceInfo.DisplayResolutionUnit.ToCompatibility(TDeviceInfo.ViewPortWidth)
};
@@ -38,6 +38,7 @@ static void OnConfigureLifeCycle(ITizenLifecycleBuilder tizen)
TDeviceInfo.DisplayResolutionUnit = options.DisplayResolutionUnit.ToDeviceInfo();
}
options.Flags |= InitializationFlags.SkipRenderers;
+#pragma warning disable CS0612 // Type or member is obsolete
Forms.Init(state, options);
#pragma warning disable CS0612 // Type or member is obsolete
})
diff --git a/src/Compatibility/Core/src/AppHostBuilderExtensions.cs b/src/Compatibility/Core/src/AppHostBuilderExtensions.cs
index 05ba74189f44..7435028e5c20 100644
--- a/src/Compatibility/Core/src/AppHostBuilderExtensions.cs
+++ b/src/Compatibility/Core/src/AppHostBuilderExtensions.cs
@@ -36,20 +36,10 @@
#elif TIZEN
using Microsoft.Maui.Controls.Compatibility.Platform.Tizen;
using Microsoft.Maui.Graphics.Skia;
-using BoxRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.BoxViewRenderer;
-using CollectionViewRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.StructuredItemsViewRenderer;
using OpenGLViewRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.DefaultRenderer;
using StreamImagesourceHandler = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.StreamImageSourceHandler;
using ImageLoaderSourceHandler = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.UriImageSourceHandler;
using DefaultRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.DefaultRenderer;
-using FrameRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp.FrameRenderer;
-using ImageRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp.ImageRenderer;
-using EllipseRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp.EllipseRenderer;
-using LineRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp.LineRenderer;
-using PathRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp.PathRenderer;
-using PolygonRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp.PolygonRenderer;
-using PolylineRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp.PolylineRenderer;
-using RectangleRenderer = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp.RectangleRenderer;
#endif
namespace Microsoft.Maui.Controls.Compatibility.Hosting
@@ -106,32 +96,11 @@ public static MauiAppBuilder UseMauiCompatibility(this MauiAppBuilder builder)
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CS0612 // Type or member is obsolete
-#if TIZEN
-#pragma warning disable CS0618 // Type or member is obsolete
-#pragma warning disable CS0612 // Type or member is obsolete
- handlers.TryAddCompatibilityRenderer(typeof(ContentView), typeof(LayoutRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(TabbedPage), typeof(TabbedPageRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(NavigationPage), typeof(NavigationPageRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(FlyoutPage), typeof(FlyoutPageRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(ListView), typeof(ListViewRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(Cell), typeof(CellRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(ImageCell), typeof(ImageCellRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(EntryCell), typeof(EntryCellRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(TextCell), typeof(TextCellRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(ViewCell), typeof(ViewCellRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(SwitchCell), typeof(SwitchCellRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(TableView), typeof(TableViewRenderer));
- handlers.TryAddCompatibilityRenderer(typeof(Frame), typeof(FrameRenderer));
-#pragma warning disable CS0612 // Type or member is obsolete
-#pragma warning disable CS0618 // Type or member is obsolete
-#endif
// Shimmed renderers go directly to the registrar to load Image Handlers
Internals.Registrar.Registered.Register(typeof(FileImageSource), typeof(FileImageSourceHandler));
Internals.Registrar.Registered.Register(typeof(StreamImageSource), typeof(StreamImagesourceHandler));
Internals.Registrar.Registered.Register(typeof(UriImageSource), typeof(ImageLoaderSourceHandler));
-#if !TIZEN
Internals.Registrar.Registered.Register(typeof(FontImageSource), typeof(FontImageSourceHandler));
-#endif
Internals.Registrar.Registered.Register(typeof(Microsoft.Maui.EmbeddedFont), typeof(Microsoft.Maui.EmbeddedFontLoader));
#endif
diff --git a/src/Compatibility/Core/src/RendererToHandlerShim.Tizen.cs b/src/Compatibility/Core/src/RendererToHandlerShim.Tizen.cs
index 691b94b57da1..dedec31b3bba 100644
--- a/src/Compatibility/Core/src/RendererToHandlerShim.Tizen.cs
+++ b/src/Compatibility/Core/src/RendererToHandlerShim.Tizen.cs
@@ -3,9 +3,7 @@
using static Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Platform;
#pragma warning disable CS0612 // Type or member is obsolete
using Microsoft.Maui.Graphics;
-using Rect = Microsoft.Maui.Graphics.Rect;
-using ERect = ElmSharp.Rect;
-using PlatformView = ElmSharp.EvasObject;
+using PlatformView = Tizen.NUI.BaseComponents.View;
namespace Microsoft.Maui.Controls.Compatibility
{
@@ -40,17 +38,14 @@ public override void UpdateValue(string property)
}
}
+ public override bool NeedsContainer => false;
+
public override void PlatformArrange(Rect frame)
{
base.PlatformArrange(frame);
VisualElementRenderer.UpdateLayout();
}
- public override ERect GetPlatformContentGeometry()
- {
- return VisualElementRenderer?.GetNativeContentGeometry() ?? new ERect();
- }
-
protected override void Dispose(bool disposing)
{
if (disposing)
diff --git a/src/Compatibility/Core/src/RendererToHandlerShim.cs b/src/Compatibility/Core/src/RendererToHandlerShim.cs
index a4355932412a..3a78c9059f0b 100644
--- a/src/Compatibility/Core/src/RendererToHandlerShim.cs
+++ b/src/Compatibility/Core/src/RendererToHandlerShim.cs
@@ -21,10 +21,9 @@
#elif TIZEN
#pragma warning disable CS0612 // Type or member is obsolete
using static Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Platform;
-#pragma warning disable CS0612 // Type or member is obsolete
-using PlatformView = ElmSharp.EvasObject;
+using PlatformView = Tizen.NUI.BaseComponents.View;
using Microsoft.Maui.Controls.Compatibility.Platform.Tizen;
-using ViewHandler = Microsoft.Maui.Handlers.ViewHandler;
+using ViewHandler = Microsoft.Maui.Handlers.ViewHandler;
#elif (NETSTANDARD || !PLATFORM)
using PlatformView = System.Object;
using ViewHandler = Microsoft.Maui.Handlers.ViewHandler;
diff --git a/src/Compatibility/Core/src/Tizen/Cells/CellRenderer.cs b/src/Compatibility/Core/src/Tizen/Cells/CellRenderer.cs
deleted file mode 100644
index 9ef5ce207515..000000000000
--- a/src/Compatibility/Core/src/Tizen/Cells/CellRenderer.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-using System.Collections.Generic;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public abstract class CellRenderer : IRegisterable
- {
- const string HeightProperty = "Height";
- readonly Dictionary> _realizedNativeViews = new Dictionary>();
-
- Native.ListView.ItemContext _currentItem;
- GenItemClass _itemClass;
-
- protected CellRenderer(string style)
- {
- Style = style;
- }
-
- public GenItemClass Class
- {
- get
- {
- if (_itemClass == null)
- _itemClass = CreateItemClass(Style);
- return _itemClass;
- }
- protected set
- {
- _itemClass?.Dispose();
- _itemClass = value;
- }
- }
-
- public virtual void SetGroupMode(bool enable)
- {
- }
-
- public string Style { get; protected set; }
-
- protected GenItemClass CreateItemClass(string style)
- {
- return new GenItemClass(style)
- {
- GetTextHandler = GetText,
- GetContentHandler = GetContent,
- DeleteHandler = ItemDeleted,
- ReusableContentHandler = ReusableContent,
- };
- }
-
- protected virtual bool OnCellPropertyChanged(Cell cell, string property, Dictionary realizedView)
- {
- if (property == HeightProperty)
- {
- return true;
- }
- return false;
- }
-
- protected virtual Span OnGetText(Cell cell, string part)
- {
- return null;
- }
- protected virtual EvasObject OnGetContent(Cell cell, string part)
- {
- return null;
- }
-
- protected virtual void OnCreated(Cell cell, bool isGroup)
- {
- }
-
- protected virtual void OnDeleted(Cell cell)
- {
- }
-
- protected virtual void OnUnrealizedCell(Cell cell)
- {
- }
-
- protected virtual EvasObject OnReusableContent(Cell cell, string part, EvasObject old)
- {
- return null;
- }
-
- protected double FindCellContentHeight(Cell cell)
- {
- ViewCell viewCell = cell as ViewCell;
- if (viewCell != null)
- {
- var parentWidth = (cell.Parent as VisualElement).Width;
- var view = viewCell.View;
- return view.Measure(parentWidth, double.PositiveInfinity).Request.Height;
- }
- else
- return -1;
- }
-
- static Native.Span ToNative(Span span)
- {
- var nativeSpan = new Native.Span();
- nativeSpan.Text = span.Text;
- nativeSpan.ForegroundColor = span.TextColor.ToNative();
- nativeSpan.FontAttributes = span.FontAttributes;
- nativeSpan.BackgroundColor = span.BackgroundColor.ToNative();
- nativeSpan.FontSize = span.FontSize;
- nativeSpan.FontFamily = span.FontFamily;
- return nativeSpan;
- }
-
- public void SendCellPropertyChanged(Cell cell, GenItem item, string property)
- {
- Dictionary realizedView = null;
- _realizedNativeViews.TryGetValue(cell, out realizedView);
-
- // just to prevent null reference exception in OnCellPropertyChanged
- realizedView = realizedView ?? new Dictionary();
-
- if (property == Cell.IsEnabledProperty.PropertyName)
- {
- item.IsEnabled = cell.IsEnabled;
- }
- // if true was returned, item was updated
- // if it's possible to update the cell property without Update(), return false
- else if (OnCellPropertyChanged(cell, property, realizedView))
- {
- item.Update();
- }
- }
-
- public void SendUnrealizedCell(Cell cell)
- {
- Dictionary realizedView = null;
- _realizedNativeViews.TryGetValue(cell, out realizedView);
- realizedView?.Clear();
- OnUnrealizedCell(cell);
- }
-
- public void SendCreatedCell(Cell cell, bool isGroup = false)
- {
- OnCreated(cell, isGroup);
- }
-
- internal Native.ListView.ItemContext GetCurrentItem()
- {
- return _currentItem;
- }
-
- string GetText(object data, string part)
- {
- _currentItem = data as Native.ListView.ItemContext;
- var span = OnGetText(_currentItem.Cell, part);
- return span != null ? ToNative(span).GetMarkupText() : null;
- }
-
- EvasObject GetContent(object data, string part)
- {
- _currentItem = data as Native.ListView.ItemContext;
- var cell = _currentItem.Cell;
- EvasObject nativeView = OnGetContent(cell, part);
- UpdateRealizedView(cell, part, nativeView);
- return nativeView;
- }
-
- EvasObject ReusableContent(object data, string part, EvasObject old)
- {
- _currentItem = data as Native.ListView.ItemContext;
- var cell = _currentItem.Cell;
- EvasObject nativeView = OnReusableContent(cell, part, old);
- UpdateRealizedView(cell, part, nativeView);
- return nativeView;
- }
-
- void UpdateRealizedView(Cell cell, string part, EvasObject nativeView)
- {
- if (part != null && nativeView != null)
- {
- Dictionary realizedView = null;
- _realizedNativeViews.TryGetValue(cell, out realizedView);
- if (realizedView == null)
- {
- realizedView = new Dictionary();
- _realizedNativeViews[cell] = realizedView;
- }
- realizedView[part] = nativeView;
- }
- }
-
- void ItemDeleted(object data)
- {
- _currentItem = data as Native.ListView.ItemContext;
- var cell = _currentItem.Cell;
- _realizedNativeViews.Remove(cell);
- OnDeleted(cell);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Cells/EntryCellRenderer.cs b/src/Compatibility/Core/src/Tizen/Cells/EntryCellRenderer.cs
deleted file mode 100644
index 55ab30338cef..000000000000
--- a/src/Compatibility/Core/src/Tizen/Cells/EntryCellRenderer.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using ElmSharp;
-using XStackLayout = Microsoft.Maui.Controls.StackLayout;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class EntryCellRenderer : ViewCellRenderer
- {
- readonly Dictionary _cacheCandidate = new Dictionary();
-
- public EntryCellRenderer()
- {
- }
-
- protected override EvasObject OnGetContent(Cell cell, string part)
- {
- if (part == MainContentPart)
- {
- var entryCell = cell as EntryCell;
- int pixelHeight = Forms.ConvertToScaledPixel(entryCell.RenderHeight);
- pixelHeight = pixelHeight > 0 ? pixelHeight : this.GetDefaultHeightPixel();
-
- var label = new Label()
- {
- HorizontalOptions = LayoutOptions.Start,
- VerticalOptions = LayoutOptions.Center,
- VerticalTextAlignment = TextAlignment.Center,
- FontSize = -1
- };
- label.SetBinding(Label.TextProperty, new Binding(EntryCell.LabelProperty.PropertyName));
- label.SetBinding(Label.TextColorProperty, new Binding(EntryCell.LabelColorProperty.PropertyName, converter: new DefaultColorConverter()));
-
- var entry = new Entry()
- {
- HorizontalOptions = LayoutOptions.Fill,
- VerticalOptions = LayoutOptions.Center,
- FontSize = -1,
- };
- entry.SetBinding(Entry.TextProperty, new Binding(EntryCell.TextProperty.PropertyName, BindingMode.TwoWay));
- entry.SetBinding(Entry.PlaceholderProperty, new Binding(EntryCell.PlaceholderProperty.PropertyName));
- entry.SetBinding(InputView.KeyboardProperty, new Binding(EntryCell.KeyboardProperty.PropertyName));
- entry.SetBinding(Entry.HorizontalTextAlignmentProperty, new Binding(EntryCell.HorizontalTextAlignmentProperty.PropertyName));
-
- var layout = new XStackLayout()
- {
- Orientation = StackOrientation.Horizontal,
- Children = {
- label,
- entry
- }
- };
- layout.Parent = cell;
- layout.BindingContext = entryCell;
- layout.MinimumHeightRequest = Forms.ConvertToScaledDP(pixelHeight);
-
- var renderer = Platform.GetOrCreateRenderer(layout);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
-
- var nativeEntry = Platform.GetRenderer(entry)?.NativeView ?? null;
- if (nativeEntry != null)
- {
- nativeEntry.PropagateEvents = false;
- }
-
- var nativeView = renderer.NativeView;
- nativeView.MinimumHeight = pixelHeight;
- _cacheCandidate[nativeView] = layout;
- nativeView.Deleted += (sender, e) =>
- {
- _cacheCandidate.Remove(sender as EvasObject);
- };
-
- return nativeView;
- }
- return null;
- }
-
- protected override EvasObject OnReusableContent(Cell cell, string part, EvasObject old)
- {
- if (!_cacheCandidate.ContainsKey(old))
- {
- return null;
- }
-
- var layout = _cacheCandidate[old];
- layout.BindingContext = cell;
- int height = Forms.ConvertToScaledPixel(cell.RenderHeight);
- height = height > 0 ? height : this.GetDefaultHeightPixel();
- old.MinimumHeight = height;
- return old;
- }
-
- class DefaultColorConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (value == null || ((Color)value).IsDefault) ? ThemeConstants.EntryCell.ColorClass.DefaultLabelColor : value;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return value;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Cells/ImageCellRenderer.cs b/src/Compatibility/Core/src/Tizen/Cells/ImageCellRenderer.cs
deleted file mode 100644
index d11c12561ded..000000000000
--- a/src/Compatibility/Core/src/Tizen/Cells/ImageCellRenderer.cs
+++ /dev/null
@@ -1,60 +0,0 @@
-using System.Collections.Generic;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ImageCellRenderer : TextCellRenderer
- {
- public ImageCellRenderer() : this(ThemeManager.GetImageCellRendererStyle())
- {
- ImagePart = this.GetImagePart();
- }
-
- protected ImageCellRenderer(string style) : base(style)
- {
- }
-
- protected string ImagePart { get; set; }
-
- protected override EvasObject OnGetContent(Cell cell, string part)
- {
- if (part == ImagePart)
- {
- var imgCell = cell as ImageCell;
- int pixelSize = Forms.ConvertToScaledPixel(imgCell.RenderHeight);
- if (pixelSize <= 0)
- {
- pixelSize = this.GetDefaultHeightPixel();
- }
-
- var image = new Native.Image(Forms.NativeParent)
- {
- MinimumWidth = pixelSize,
- MinimumHeight = pixelSize
- };
- image.SetAlignment(-1.0, -1.0); // fill
- image.SetWeight(1.0, 1.0); // expand
-
- var task = image.LoadFromImageSourceAsync(imgCell.ImageSource);
- return image;
- }
- else
- {
- return null;
- }
- }
-
- protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary realizedView)
- {
- if (property == ImageCell.ImageSourceProperty.PropertyName)
- {
- EvasObject image;
- realizedView.TryGetValue(ImagePart, out image);
- (image as Native.Image)?.LoadFromImageSourceAsync((cell as ImageCell)?.ImageSource);
- return false;
- }
- return base.OnCellPropertyChanged(cell, property, realizedView);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Cells/SwitchCellRenderer.cs b/src/Compatibility/Core/src/Tizen/Cells/SwitchCellRenderer.cs
deleted file mode 100644
index ff1475b201bd..000000000000
--- a/src/Compatibility/Core/src/Tizen/Cells/SwitchCellRenderer.cs
+++ /dev/null
@@ -1,95 +0,0 @@
-using System.Collections.Generic;
-using Microsoft.Maui.Devices;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class SwitchCellRenderer : CellRenderer
- {
- readonly Dictionary _cacheCandidate = new Dictionary();
-
- protected SwitchCellRenderer(string style) : base(style)
- {
- }
-
- public SwitchCellRenderer() : this(ThemeManager.GetSwitchCellRendererStyle())
- {
- MainPart = this.GetMainPart();
- SwitchPart = this.GetSwitchPart();
- }
-
- protected string MainPart { get; set; }
- protected string SwitchPart { get; set; }
-
- protected override Span OnGetText(Cell cell, string part)
- {
- if (part == MainPart)
- {
- return new Span()
- {
- Text = (cell as SwitchCell).Text
- };
- }
- return null;
- }
-
- protected override EvasObject OnGetContent(Cell cell, string part)
- {
- if (part == SwitchPart)
- {
- var toggle = new Switch()
- {
- BindingContext = cell,
- Parent = cell.Parent
- };
- toggle.SetBinding(Switch.IsToggledProperty, new Binding(SwitchCell.OnProperty.PropertyName));
- toggle.SetBinding(Switch.OnColorProperty, new Binding(SwitchCell.OnColorProperty.PropertyName));
- var nativeView = Platform.GetOrCreateRenderer(toggle).NativeView;
-
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- nativeView.MinimumWidth += 8;
- }
-
- //It is a temporary way to prevent that the check of the Cell gets focus until the UX about views in the Cell for TV is defined.
- if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- ((Check)nativeView).AllowFocus(false);
- }
- else
- {
- nativeView.PropagateEvents = false;
- }
-
- _cacheCandidate[nativeView] = toggle;
- nativeView.Deleted += (sender, e) =>
- {
- _cacheCandidate.Remove(sender as EvasObject);
- };
-
- return nativeView;
- }
- return null;
- }
-
- protected override EvasObject OnReusableContent(Cell cell, string part, EvasObject old)
- {
- if (!_cacheCandidate.ContainsKey(old))
- {
- return null;
- }
- _cacheCandidate[old].BindingContext = cell;
- return old;
- }
-
- protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary realizedView)
- {
- if (property == SwitchCell.TextProperty.PropertyName)
- {
- return true;
- }
- return base.OnCellPropertyChanged(cell, property, realizedView);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Cells/TextCellRenderer.cs b/src/Compatibility/Core/src/Tizen/Cells/TextCellRenderer.cs
deleted file mode 100644
index 4c89702d5e11..000000000000
--- a/src/Compatibility/Core/src/Tizen/Cells/TextCellRenderer.cs
+++ /dev/null
@@ -1,79 +0,0 @@
-using System.Collections.Generic;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class TextCellRenderer : CellRenderer
- {
- bool _groupMode = false;
- // TextCell.Detail property is not supported on TV profile due to UX limitation.
- public TextCellRenderer() : this(ThemeManager.GetTextCellRendererStyle()) { }
-
- protected TextCellRenderer(string style) : base(style)
- {
- MainPart = this.GetMainPart();
- DetailPart = this.GetDetailPart();
- }
-
- protected string MainPart { get; set; }
- protected string DetailPart { get; set; }
-
- public override void SetGroupMode(bool enable)
- {
- if (_groupMode == enable)
- return;
-
- _groupMode = enable;
- Class = null;
- Style = ThemeManager.GetTextCellGroupModeStyle(enable);
- DetailPart = this.GetDetailPart();
- }
-
- protected override Span OnGetText(Cell cell, string part)
- {
- var textCell = (TextCell)cell;
- if (part == MainPart)
- {
- return OnMainText(textCell);
- }
- if (part == DetailPart)
- {
- return OnDetailText(textCell);
- }
- return null;
- }
-
- protected virtual Span OnMainText(TextCell cell)
- {
- return new Span()
- {
- Text = cell.Text,
- TextColor = cell.TextColor,
- FontSize = -1
- };
- }
-
- protected virtual Span OnDetailText(TextCell cell)
- {
- return new Span()
- {
- Text = cell.Detail,
- TextColor = cell.DetailColor,
- FontSize = -1
- };
- }
-
- protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary realizedView)
- {
- if (property == TextCell.TextProperty.PropertyName ||
- property == TextCell.TextColorProperty.PropertyName ||
- property == TextCell.DetailProperty.PropertyName ||
- property == TextCell.DetailColorProperty.PropertyName)
- {
- return true;
- }
- return base.OnCellPropertyChanged(cell, property, realizedView);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Cells/ViewCellRenderer.cs b/src/Compatibility/Core/src/Tizen/Cells/ViewCellRenderer.cs
deleted file mode 100644
index 7351d27fe6fb..000000000000
--- a/src/Compatibility/Core/src/Tizen/Cells/ViewCellRenderer.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using System.Collections.Generic;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ViewCellRenderer : CellRenderer
- {
- readonly Dictionary _cacheCandidate = new Dictionary();
- public ViewCellRenderer() : base(ThemeManager.GetViewCellRendererStyle())
- {
- MainContentPart = this.GetMainContentPart();
- }
-
- protected string MainContentPart { get; set; }
-
- protected override EvasObject OnReusableContent(Cell cell, string part, EvasObject old)
- {
- if (_cacheCandidate.ContainsKey(old))
- {
- var viewCell = _cacheCandidate[old];
- var widget = (old as Widget);
- if (widget != null)
- widget.IsEnabled = true;
- viewCell.BindingContext = cell.BindingContext;
- return old;
- }
- return null;
- }
-
- protected override EvasObject OnGetContent(Cell cell, string part)
- {
- if (part == MainContentPart)
- {
- var viewCell = (ViewCell)cell;
-
- var listView = viewCell?.RealParent as ListView;
-
- // It is a condition for reusable the cell
- if (listView != null &&
- listView.HasUnevenRows == false &&
- !(listView.ItemTemplate is DataTemplateSelector) && !GetCurrentItem().IsGroupItem)
- {
- return CreateReusableContent(viewCell);
- }
-
- Platform.GetRenderer(viewCell.View)?.Dispose();
- var renderer = Platform.GetOrCreateRenderer(viewCell.View);
- double height = viewCell.RenderHeight;
- height = height > 0 ? height : FindCellContentHeight(viewCell);
-
- renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(height);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
-
- UpdatePropagateEvent(viewCell.View);
-
- return renderer.NativeView;
- }
- return null;
- }
-
- protected override bool OnCellPropertyChanged(Cell cell, string property, Dictionary realizedView)
- {
- if (property == "View")
- {
- return true;
- }
- return base.OnCellPropertyChanged(cell, property, realizedView);
- }
-
- EvasObject CreateReusableContent(ViewCell viewCell)
- {
- var listView = viewCell.RealParent as ListView;
- ViewCell duplicatedCell = (ViewCell)listView.ItemTemplate.CreateContent();
- duplicatedCell.BindingContext = viewCell.BindingContext;
- duplicatedCell.Parent = listView;
-
- var renderer = Platform.GetOrCreateRenderer(duplicatedCell.View);
- double height = duplicatedCell.RenderHeight;
- height = height > 0 ? height : FindCellContentHeight(duplicatedCell);
- renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(height);
-
- _cacheCandidate[renderer.NativeView] = duplicatedCell;
- renderer.NativeView.Deleted += (sender, e) =>
- {
- _cacheCandidate.Remove((EvasObject)sender);
- };
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
-
- UpdatePropagateEvent(duplicatedCell.View);
- return renderer.NativeView;
- }
-
- void UpdatePropagateEvent(View view)
- {
- if (!view.IsPlatformEnabled)
- return;
- foreach (var element in view.Descendants())
- {
- if (element is Button || element is Switch)
- {
- var nativeView = Platform.GetRenderer(element)?.NativeView ?? null;
- if (nativeView != null)
- {
- nativeView.PropagateEvents = false;
- }
- }
- }
- }
-
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/DragGestureHandler.cs b/src/Compatibility/Core/src/Tizen/DragGestureHandler.cs
deleted file mode 100644
index dc1e4001adb0..000000000000
--- a/src/Compatibility/Core/src/Tizen/DragGestureHandler.cs
+++ /dev/null
@@ -1,247 +0,0 @@
-using System;
-using System.Threading;
-using ElmSharp;
-using Tizen.Common;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp;
-using EGestureType = ElmSharp.GestureLayer.GestureType;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class DragGestureHandler : GestureHandler
- {
- bool _isApi4;
-
- DragDropExtensions.Interop.DragIconCreateCallback _iconCallback;
- DragDropExtensions.Interop.DragStateCallback _dragDoneCallback;
-
- static bool s_isDragging;
- static CustomDragStateData s_currentDragStateData;
-
- public DragGestureHandler(IGestureRecognizer recognizer, IVisualElementRenderer renderer) : base(recognizer)
- {
- _iconCallback = OnIconCallback;
- _dragDoneCallback = OnDragDoneCallback;
- _isApi4 = DotnetUtil.TizenAPIVersion <= 4;
- Renderer = renderer;
- }
-
- public override EGestureType Type => EGestureType.LongTap;
-
- public IVisualElementRenderer Renderer { get; }
-
- public static CustomDragStateData CurrentStateData
- {
- get
- {
- return s_currentDragStateData;
- }
- }
-
- EvasObject NativeView
- {
- get
- {
- var native = Renderer.NativeView;
- if (Renderer is SkiaSharp.ICanvasRenderer canvasRenderer)
- {
- native = canvasRenderer.RealNativeView;
- }
- return native;
- }
- }
-
- public void ResetCurrentStateData()
- {
- s_currentDragStateData = null;
- }
-
- protected override void OnStarted(View sender, object data)
- {
- }
-
- protected override void OnMoved(View sender, object data)
- {
- //Workaround to prevent an error occuring by multiple StartDrag calling in Tizen 6.5
- if (!s_isDragging)
- {
- ResetCurrentStateData();
- StartDrag();
- }
- }
-
- protected override void OnCompleted(View sender, object data)
- {
- }
-
- protected override void OnCanceled(View sender, object data)
- {
- }
-
- void StartDrag()
- {
- if (Recognizer is DragGestureRecognizer dragGestureRecognizer && dragGestureRecognizer.CanDrag)
- {
- if (Renderer == null)
- return;
-
- if (Renderer.Element is not View view)
- return;
-
- var arg = dragGestureRecognizer.SendDragStarting(view);
-
- if (arg.Cancel)
- return;
-
- s_currentDragStateData = new CustomDragStateData();
- s_currentDragStateData.DataPackage = arg.Data;
-
- var target = DragDropExtensions.DragDropContentType.Text;
- var strData = string.IsNullOrEmpty(arg.Data.Text) ? " " : arg.Data.Text;
-
- s_isDragging = true;
-
- DragDropExtensions.StartDrag(NativeView,
- target,
- strData,
- DragDropExtensions.DragDropActionType.Move,
- _iconCallback,
- null,
- null,
- _dragDoneCallback);
- }
- }
-
- IntPtr OnIconCallback(IntPtr data, IntPtr window, ref int xoff, ref int yoff)
- {
- EvasObject icon = null;
- EvasObject parent = new CustomWindow(NativeView, window);
-
- if (s_currentDragStateData.DataPackage.Image != null)
- {
- icon = GetImageIcon(parent);
- }
- else if (NativeView is ShapeView)
- {
- icon = GetShapeView(parent);
- }
- else
- {
- icon = GetDefaultIcon(parent);
- }
- var bound = NativeView.Geometry;
- bound.X = 0;
- bound.Y = 0;
- icon.Geometry = bound;
-
- if (icon is Native.Label)
- {
- icon.Resized += (s, e) =>
- {
- var map = new EvasMap(4);
- map.PopulatePoints(icon.Geometry, 0);
- map.Zoom(0.5, 0.5, 0, 0);
- icon.IsMapEnabled = true;
- icon.EvasMap = map;
- };
- }
- else
- {
- var map = new EvasMap(4);
- map.PopulatePoints(icon.Geometry, 0);
- map.Zoom(0.5, 0.5, 0, 0);
- icon.IsMapEnabled = true;
- icon.EvasMap = map;
- }
-
-
- return icon;
- }
-
- EvasObject GetDefaultIcon(EvasObject parent)
- {
- if (!string.IsNullOrEmpty(s_currentDragStateData.DataPackage.Text))
- {
- var label = new Native.Label(parent);
- label.Text = s_currentDragStateData.DataPackage.Text;
-
- if (Renderer.Element is Label lb)
- label.FontSize = lb.FontSize;
- else if (Renderer.Element is Entry et)
- label.FontSize = et.FontSize;
- else if (Renderer.Element is Editor ed)
- label.FontSize = ed.FontSize;
-
- return label;
- }
- else
- {
- var box = new ElmSharp.Rectangle(parent);
- box.Color = new ElmSharp.Color(128, 128, 128, 128);
- return box;
- }
- }
-
- EvasObject GetImageIcon(EvasObject parent)
- {
- var image = new Native.Image(parent);
- _ = image.LoadFromImageSourceAsync(s_currentDragStateData.DataPackage.Image);
- return image;
- }
-
- EvasObject GetShapeView(EvasObject parent)
- {
- var copiedImg = new EvasImage(parent);
- copiedImg.IsFilled = true;
-
- if (NativeView is ShapeView shapeView)
- {
- var canvas = shapeView.SKCanvasView;
- var realHandle = DragDropExtensions.Interop.elm_object_part_content_get(canvas, "elm.swallow.content");
-
- DragDropExtensions.Interop.evas_object_image_size_get(realHandle, out int w, out int h);
- DragDropExtensions.Interop.evas_object_image_size_set(copiedImg, w, h);
-
- var imgData = DragDropExtensions.Interop.evas_object_image_data_get(realHandle, false);
- DragDropExtensions.Interop.evas_object_image_data_set(copiedImg, imgData);
- }
-
- return copiedImg;
- }
-
- void OnDragDoneCallback(IntPtr data, IntPtr obj)
- {
- s_isDragging = false;
- if (Recognizer is DragGestureRecognizer dragGestureRecognizer && dragGestureRecognizer.CanDrag)
- {
- dragGestureRecognizer.SendDropCompleted(new DropCompletedEventArgs());
- }
- }
-
- public class CustomWindow : EvasObject
- {
- IntPtr _handle;
-
- public CustomWindow(EvasObject parent, IntPtr handle) : base()
- {
- _handle = handle;
- Realize(parent);
- }
-
- public CustomWindow(EvasObject handle) : base(handle)
- {
- }
-
- protected override IntPtr CreateHandle(EvasObject parent)
- {
- return _handle;
- }
- }
-
- public class CustomDragStateData
- {
- public DataPackage DataPackage { get; set; }
- public DataPackageOperation AcceptedOperation { get; set; } = DataPackageOperation.Copy;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/DropGestureHandler.cs b/src/Compatibility/Core/src/Tizen/DropGestureHandler.cs
deleted file mode 100644
index 13b73ae158f2..000000000000
--- a/src/Compatibility/Core/src/Tizen/DropGestureHandler.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using System.Linq;
-using ElmSharp;
-using Tizen.Common;
-using EGestureType = ElmSharp.GestureLayer.GestureType;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class DropGestureHandler : GestureHandler
- {
- bool _isApi4;
-
- DragDropExtensions.Interop.DragStateCallback _dragEnterCallback;
- DragDropExtensions.Interop.DragStateCallback _dragLeaveCallback;
- DragDropExtensions.Interop.DropCallback _dropCallback;
-
- public override EGestureType Type => default(EGestureType);
-
- public DropGestureHandler(IGestureRecognizer recognizer, IVisualElementRenderer renderer) : base(recognizer)
- {
- _dragEnterCallback = OnEnterCallback;
- _dragLeaveCallback = OnLeaveCallback;
- _dropCallback = OnDropCallback;
- _isApi4 = DotnetUtil.TizenAPIVersion <= 4;
- Renderer = renderer;
- }
-
- public IVisualElementRenderer Renderer { get; }
-
- EvasObject NativeView
- {
- get
- {
- var native = Renderer.NativeView;
- if (Renderer is SkiaSharp.ICanvasRenderer canvasRenderer)
- {
- native = canvasRenderer.RealNativeView;
- }
-
- if (native is Native.Canvas canvas)
- {
- var child = canvas.Children.LastOrDefault();
-
- if (child != null)
- {
- if (child.PassEvents)
- child.PassEvents = false;
-
- return child;
- }
- }
- return native;
- }
- }
-
-
- public void AddDropGesture()
- {
- if (Renderer == null)
- return;
-
- var target = DragDropExtensions.DragDropContentType.Targets;
-
- DragDropExtensions.AddDropTarget(NativeView,
- target,
- _dragEnterCallback,
- _dragLeaveCallback, null,
- _dropCallback);
- }
-
- void OnEnterCallback(IntPtr data, IntPtr obj)
- {
- var currentStateData = DragGestureHandler.CurrentStateData;
- if (currentStateData == null)
- return;
-
- var arg = new DragEventArgs(currentStateData.DataPackage);
-
- if (Recognizer is DropGestureRecognizer dropRecognizer && dropRecognizer.AllowDrop)
- dropRecognizer.SendDragOver(arg);
-
- DragGestureHandler.CurrentStateData.AcceptedOperation = arg.AcceptedOperation;
- }
-
- void OnLeaveCallback(IntPtr data, IntPtr obj)
- {
- var currentStateData = DragGestureHandler.CurrentStateData;
- if (currentStateData == null)
- return;
-
- var arg = new DragEventArgs(currentStateData.DataPackage);
-
- if (Recognizer is DropGestureRecognizer dropRecognizer && dropRecognizer.AllowDrop)
- dropRecognizer.SendDragLeave(arg);
-
- DragGestureHandler.CurrentStateData.AcceptedOperation = arg.AcceptedOperation;
- }
-
- bool OnDropCallback(IntPtr data, IntPtr obj, IntPtr selectionData)
- {
- var currentStateData = DragGestureHandler.CurrentStateData;
-
- if (currentStateData.DataPackage == null || currentStateData.AcceptedOperation == DataPackageOperation.None)
- return false;
-
- Application.Current?.Dispatcher.Dispatch(async () =>
- {
- if (Recognizer is DropGestureRecognizer dropRecognizer && dropRecognizer.AllowDrop)
- await dropRecognizer.SendDrop(new DropEventArgs(currentStateData.DataPackage.View));
- });
-
- return true;
- }
-
- #region GestureHandler
- protected override void OnStarted(View sender, object data)
- {
- }
-
- protected override void OnMoved(View sender, object data)
- {
- }
-
- protected override void OnCompleted(View sender, object data)
- {
- }
-
- protected override void OnCanceled(View sender, object data)
- {
- }
- #endregion
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/AccessibilityExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/AccessibilityExtensions.cs
deleted file mode 100644
index 31d5923c59f0..000000000000
--- a/src/Compatibility/Core/src/Tizen/Extensions/AccessibilityExtensions.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using ElmSharp.Accessible;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete]
- public static class AccessibilityExtensions
- {
- public static string SetAccessibilityName(this IAccessibleObject Control, Element Element, string _defaultAccessibilityName = null)
- {
- if (Element == null || Control == null)
- return _defaultAccessibilityName;
-
- if (_defaultAccessibilityName == null)
- _defaultAccessibilityName = Control.Name;
-
- Control.Name = (string)Element.GetValue(AutomationProperties.NameProperty) ?? _defaultAccessibilityName;
- return _defaultAccessibilityName;
- }
-
- public static string SetAccessibilityDescription(this IAccessibleObject Control, Element Element, string _defaultAccessibilityDescription = null)
- {
- if (Element == null || Control == null)
- return _defaultAccessibilityDescription;
-
- if (_defaultAccessibilityDescription == null)
- _defaultAccessibilityDescription = Control.Description;
-
- Control.Description = (string)Element.GetValue(AutomationProperties.HelpTextProperty) ?? _defaultAccessibilityDescription;
- return _defaultAccessibilityDescription;
- }
-
- public static bool? SetIsAccessibilityElement(this IAccessibleObject Control, Element Element, bool? _defaultIsAccessibilityElement = null)
- {
- if (Element == null || Control == null)
- return _defaultIsAccessibilityElement;
-
- if (!_defaultIsAccessibilityElement.HasValue)
- _defaultIsAccessibilityElement = Control.CanHighlight;
-
- Control.CanHighlight = (bool)((bool?)Element.GetValue(AutomationProperties.IsInAccessibleTreeProperty) ?? _defaultIsAccessibilityElement);
-
- // Images are ignored by default on Tizen. So, make accessible in order to enable the gesture and narration
- if (Control.CanHighlight && Element is Image)
- {
- Control.Role = AccessRole.PushButton;
- }
- return _defaultIsAccessibilityElement;
- }
-
- public static void SetLabeledBy(this IAccessibleObject Control, Element Element)
- {
- if (Element == null || Control == null)
- return;
-
- var targetElement = (VisualElement)Element.GetValue(AutomationProperties.LabeledByProperty);
- AccessibleObject view = (AccessibleObject)Platform.GetRenderer(targetElement)?.NativeView;
- if (view != null)
- {
- Control.AppendRelation(new LabelledBy() { Target = view });
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/BrushExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/BrushExtensions.cs
index 4d641e206cc8..1f78c07e5ce3 100644
--- a/src/Compatibility/Core/src/Tizen/Extensions/BrushExtensions.cs
+++ b/src/Compatibility/Core/src/Tizen/Extensions/BrushExtensions.cs
@@ -1,8 +1,9 @@
using System;
using System.Linq;
+using Microsoft.Maui.Graphics;
using SkiaSharp;
using SkiaSharp.Views.Tizen;
-using Microsoft.Maui.Graphics;
+using EColor = ElmSharp.Color;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
@@ -83,7 +84,7 @@ public static SKShader CreateShader(this GradientBrush gradientBrush, SKRect bou
public static SKColor ToSolidColor(this SolidColorBrush solidColorBrush)
{
- return solidColorBrush.Color.IsDefault() ? SKColor.Empty : solidColorBrush.Color.ToNative().ToSKColor();
+ return solidColorBrush.Color.IsDefault() ? SKColor.Empty : solidColorBrush.Color.ToNativeEFL().ToSKColor();
}
static SKShader CreateLinearGradient(LinearGradientBrush linearGradientBrush, SKRect pathBounds)
@@ -91,7 +92,7 @@ static SKShader CreateLinearGradient(LinearGradientBrush linearGradientBrush, SK
var startPoint = new SKPoint(pathBounds.Left + (float)linearGradientBrush.StartPoint.X * pathBounds.Width, pathBounds.Top + (float)linearGradientBrush.StartPoint.Y * pathBounds.Height);
var endPoint = new SKPoint(pathBounds.Left + (float)linearGradientBrush.EndPoint.X * pathBounds.Width, pathBounds.Top + (float)linearGradientBrush.EndPoint.Y * pathBounds.Height);
var orderedGradientStops = linearGradientBrush.GradientStops.OrderBy(x => x.Offset).ToList();
- var gradientColors = orderedGradientStops.Select(x => x.Color.ToNative().ToSKColor()).ToArray();
+ var gradientColors = orderedGradientStops.Select(x => x.Color.ToNativeEFL().ToSKColor()).ToArray();
var gradientColorPos = orderedGradientStops.Select(x => x.Offset).ToArray();
return SKShader.CreateLinearGradient(startPoint, endPoint, gradientColors, gradientColorPos, SKShaderTileMode.Clamp);
}
@@ -101,9 +102,14 @@ static SKShader CreateRadialGradient(RadialGradientBrush radialGradientBrush, SK
var center = new SKPoint((float)radialGradientBrush.Center.X * pathBounds.Width + pathBounds.Left, (float)radialGradientBrush.Center.Y * pathBounds.Height + pathBounds.Top);
var radius = (float)radialGradientBrush.Radius * Math.Max(pathBounds.Height, pathBounds.Width);
var orderedGradientStops = radialGradientBrush.GradientStops.OrderBy(x => x.Offset).ToList();
- var gradientColors = orderedGradientStops.Select(x => x.Color.ToNative().ToSKColor()).ToArray();
+ var gradientColors = orderedGradientStops.Select(x => x.Color.ToNativeEFL().ToSKColor()).ToArray();
var gradientColorPos = orderedGradientStops.Select(x => x.Offset).ToArray();
return SKShader.CreateRadialGradient(center, radius, gradientColors, gradientColorPos, SKShaderTileMode.Clamp);
}
+
+ public static EColor ToNativeEFL(this Color c)
+ {
+ return c == null ? EColor.Default : new EColor((int)(255.0 * c.Red), (int)(255.0 * c.Green), (int)(255.0 * c.Blue), (int)(255.0 * c.Alpha));
+ }
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/ColorExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/ColorExtensions.cs
index 0f86966258f1..eeddc6a3af62 100644
--- a/src/Compatibility/Core/src/Tizen/Extensions/ColorExtensions.cs
+++ b/src/Compatibility/Core/src/Tizen/Extensions/ColorExtensions.cs
@@ -1,5 +1,6 @@
using Microsoft.Maui.Graphics;
-using EColor = ElmSharp.Color;
+using TColor = Tizen.UIExtensions.Common.Color;
+using NColor = Tizen.NUI.Color;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
@@ -10,18 +11,22 @@ public static class ColorExtensions
/// | |
/// ElmSharp.Color instance representing a color which corresponds to the provided Microsoft.Maui.Controls.Compatibility.Color
/// The Microsoft.Maui.Controls.Compatibility.Color instance which will be converted to a ElmSharp.Color
- public static EColor ToNative(this Color c)
+ public static TColor ToNative(this Color c)
{
if (c == null)
{
// Trying to convert the default color, this may result in black color.
- return EColor.Default;
+ return TColor.Default;
}
else
{
- return new EColor((int)(255.0 * c.Red), (int)(255.0 * c.Green), (int)(255.0 * c.Blue), (int)(255.0 * c.Alpha));
+ return new TColor(c.Red, c.Green, c.Blue, c.Alpha);
}
}
+ public static NColor ToNativeNUI(this Color c)
+ {
+ return new NColor((float)c.Red, (float)c.Green, (float)c.Blue, (float)c.Alpha);
+ }
public static Color WithAlpha(this Color color, double alpha)
{
@@ -32,19 +37,5 @@ public static Color WithPremultiplied(this Color color, double alpha)
{
return new Color((int)(color.Red * alpha), (int)(color.Green * alpha), (int)(color.Blue * alpha), color.Alpha);
}
-
- ///
- /// Returns a string representing the provided ElmSharp.Color instance in a hexagonal notation
- ///
- /// string value containing the encoded color
- /// The ElmSharp.Color class instance which will be serialized
- internal static string ToHex(this EColor c)
- {
- if (c.IsDefault)
- {
- Log.Warn("Trying to convert the default color to hexagonal notation, it does not works as expected.");
- }
- return string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", c.R, c.G, c.B, c.A);
- }
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/DensityIndependentPixelExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/DensityIndependentPixelExtensions.cs
index fb5402569265..c67889f81364 100644
--- a/src/Compatibility/Core/src/Tizen/Extensions/DensityIndependentPixelExtensions.cs
+++ b/src/Compatibility/Core/src/Tizen/Extensions/DensityIndependentPixelExtensions.cs
@@ -1,7 +1,8 @@
using Microsoft.Maui.Graphics;
using Rect = Microsoft.Maui.Graphics.Rect;
-using ERect = ElmSharp.Rect;
-using ESize = ElmSharp.Size;
+using TRect = Tizen.UIExtensions.Common.Rect;
+using TSize = Tizen.UIExtensions.Common.Size;
+using NSize = Tizen.NUI.Size2D;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
@@ -10,24 +11,29 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
///
public static class DensityIndependentPixelExtensions
{
- public static Rect ToDP(this ERect rect)
+ public static Rect ToDP(this TRect rect)
{
return new Rect(Forms.ConvertToScaledDP(rect.X), Forms.ConvertToScaledDP(rect.Y), Forms.ConvertToScaledDP(rect.Width), Forms.ConvertToScaledDP(rect.Height));
}
- public static ERect ToPixel(this Rect rect)
+ public static TRect ToPixel(this Rect rect)
{
- return new ERect(Forms.ConvertToScaledPixel(rect.X), Forms.ConvertToScaledPixel(rect.Y), Forms.ConvertToScaledPixel(rect.Width), Forms.ConvertToScaledPixel(rect.Height));
+ return new TRect(Forms.ConvertToScaledPixel(rect.X), Forms.ConvertToScaledPixel(rect.Y), Forms.ConvertToScaledPixel(rect.Width), Forms.ConvertToScaledPixel(rect.Height));
}
- public static Size ToDP(this ESize size)
+ public static Size ToDP(this TSize size)
{
return new Size(Forms.ConvertToScaledDP(size.Width), Forms.ConvertToScaledDP(size.Height));
}
- public static ESize ToPixel(this Size size)
+ public static Size ToDP(this NSize size)
{
- return new ESize(Forms.ConvertToScaledPixel(size.Width), Forms.ConvertToScaledPixel(size.Height));
+ return new Size(Forms.ConvertToScaledDP(size.Width), Forms.ConvertToScaledDP(size.Height));
+ }
+
+ public static TSize ToPixel(this Size size)
+ {
+ return new TSize(Forms.ConvertToScaledPixel(size.Width), Forms.ConvertToScaledPixel(size.Height));
}
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/DragDropExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/DragDropExtensions.cs
deleted file mode 100644
index 77a9ccf0603d..000000000000
--- a/src/Compatibility/Core/src/Tizen/Extensions/DragDropExtensions.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public static class DragDropExtensions
- {
- public static void AddDropTarget(EvasObject obj, DragDropContentType contentType,
- Interop.DragStateCallback enterCallback,
- Interop.DragStateCallback leaveCallback,
- Interop.DragPositionCallback positionCallback,
- Interop.DropCallback dropCallback)
- {
- Interop.elm_drop_target_add(obj.RealHandle, contentType,
- enterCallback, IntPtr.Zero,
- leaveCallback, IntPtr.Zero,
- positionCallback, IntPtr.Zero,
- dropCallback, IntPtr.Zero);
- }
-
- public static void StartDrag(EvasObject obj, DragDropContentType contentType,
- string data, DragDropActionType actionType,
- Interop.DragIconCreateCallback iconCallback,
- Interop.DragPositionCallback positionCallback,
- Interop.DragAcceptCallback acceptCallback,
- Interop.DragStateCallback statCallback)
- {
- var strData = Marshal.StringToHGlobalAnsi(data);
- Interop.elm_drag_start(obj.RealHandle, contentType, strData, actionType,
- iconCallback, IntPtr.Zero,
- positionCallback, IntPtr.Zero,
- acceptCallback, IntPtr.Zero,
- statCallback, IntPtr.Zero);
- }
-
- public enum DragDropContentType
- {
- Targets = -1,
- None = 0,
- Text = 1,
- MarkUp = 2,
- Image = 4,
- VCard = 8,
- Html = 16
- }
-
- public enum DragDropActionType
- {
- Unknown = 0,
- Copy,
- Move,
- Private,
- Ask,
- List,
- Link,
- Description
- }
-
- public class Interop
- {
- public const string LibElementary = "libelementary.so.1";
- public const string LibEvas = "libevas.so.1";
-
-
- public delegate IntPtr DragIconCreateCallback(IntPtr data, IntPtr window, ref int xoff, ref int yoff);
- public delegate void DragPositionCallback(IntPtr data, IntPtr obj, int x, int y, int actionType);
- public delegate void DragAcceptCallback(IntPtr data, IntPtr obj, bool accept);
- public delegate void DragStateCallback(IntPtr data, IntPtr obj);
- public delegate bool DropCallback(IntPtr data, IntPtr obj, IntPtr selectionData);
-
- [DllImport(LibElementary)]
- internal static extern void elm_drop_target_add(IntPtr obj,
- DragDropContentType type,
- DragStateCallback enterCallback,
- IntPtr enterData,
- DragStateCallback leaveCallback,
- IntPtr leaveData,
- DragPositionCallback positionCallback,
- IntPtr positionData,
- DropCallback dropcallback,
- IntPtr dropData);
-
- [DllImport(LibElementary)]
- internal static extern void elm_drag_start(IntPtr obj,
- DragDropContentType contentType,
- IntPtr data,
- DragDropActionType actionType,
- DragIconCreateCallback iconCreateCallback,
- IntPtr iconCreateData,
- DragPositionCallback dragPositionCallback,
- IntPtr dragPositonData,
- DragAcceptCallback dragAcceptCallback,
- IntPtr dragAcceptData,
- DragStateCallback dragStateCallback,
- IntPtr dragStateData);
-
- [DllImport(LibElementary)]
- internal static extern IntPtr elm_object_part_content_get(IntPtr obj, string part);
-
- [DllImport(LibEvas)]
- internal static extern IntPtr evas_object_image_data_get(IntPtr obj, bool forWriting);
-
- [DllImport(LibEvas)]
- internal static extern void evas_object_image_data_set(IntPtr obj, IntPtr data);
-
- [DllImport(LibEvas)]
- internal static extern void evas_object_image_size_get(IntPtr obj, out int w, out int h);
-
- [DllImport(LibEvas)]
- internal static extern void evas_object_image_size_set(IntPtr obj, int w, int h);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/EntryExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/EntryExtensions.cs
deleted file mode 100644
index 49a2fcd8aa7a..000000000000
--- a/src/Compatibility/Core/src/Tizen/Extensions/EntryExtensions.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using ElmSharp;
-using EEntry = ElmSharp.Entry;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- internal static class EntryExtensions
- {
- internal static InputPanelReturnKeyType ToInputPanelReturnKeyType(this ReturnType returnType)
- {
- switch (returnType)
- {
- case ReturnType.Go:
- return InputPanelReturnKeyType.Go;
- case ReturnType.Next:
- return InputPanelReturnKeyType.Next;
- case ReturnType.Send:
- return InputPanelReturnKeyType.Send;
- case ReturnType.Search:
- return InputPanelReturnKeyType.Search;
- case ReturnType.Done:
- return InputPanelReturnKeyType.Done;
- case ReturnType.Default:
- return InputPanelReturnKeyType.Default;
- default:
- throw new System.NotImplementedException($"ReturnType {returnType} not supported");
- }
- }
- public static void GetSelectRegion(this EEntry entry, out int start, out int end)
- {
- elm_entry_select_region_get(entry.RealHandle, out start, out end);
- }
-
- [DllImport("libelementary.so.1")]
- static extern void elm_entry_select_region_get(IntPtr obj, out int start, out int end);
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/EvasMapExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/EvasMapExtensions.cs
deleted file mode 100644
index b6bf133a42a3..000000000000
--- a/src/Compatibility/Core/src/Tizen/Extensions/EvasMapExtensions.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public static class EvasMapExtensions
- {
- public static void Perspective3D(this EvasMap map, int px, int py, int z0, int foc)
- {
- var mapType = typeof(EvasMap);
- var propInfo = mapType.GetProperty("Handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
- var handle = (IntPtr)propInfo.GetValue(map);
- evas_map_util_3d_perspective(handle, px, py, z0, foc);
- }
-
- [DllImport("libevas.so.1")]
- static extern void evas_map_util_3d_perspective(IntPtr map, int px, int py, int z0, int foc);
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/ImageExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/ImageExtensions.cs
index 72602c3966d2..6d55fcb0285a 100644
--- a/src/Compatibility/Core/src/Tizen/Extensions/ImageExtensions.cs
+++ b/src/Compatibility/Core/src/Tizen/Extensions/ImageExtensions.cs
@@ -1,35 +1,11 @@
using System.Threading.Tasks;
-using EImage = ElmSharp.Image;
+using NImage = Tizen.NUI.BaseComponents.ImageView;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
public static class ImageExtensions
{
- public static void ApplyAspect(this EImage image, Aspect aspect)
- {
- Aspect _aspect = aspect;
-
- switch (_aspect)
- {
- case Aspect.AspectFit:
- image.IsFixedAspect = true;
- image.CanFillOutside = false;
- break;
- case Aspect.AspectFill:
- image.IsFixedAspect = true;
- image.CanFillOutside = true;
- break;
- case Aspect.Fill:
- image.IsFixedAspect = false;
- image.CanFillOutside = false;
- break;
- default:
- Log.Warn("Invalid Aspect value: {0}", _aspect);
- break;
- }
- }
-
- public static async Task LoadFromImageSourceAsync(this EImage image, ImageSource source)
+ public static async Task LoadFromImageSourceAsync(this NImage image, ImageSource source)
{
IImageSourceHandler handler;
bool isLoadComplate = false;
@@ -37,24 +13,9 @@ public static async Task LoadFromImageSourceAsync(this EImage image, Image
{
isLoadComplate = await handler.LoadImageAsync(image, source);
}
- if (!isLoadComplate)
- {
- //If it fails, call the Load function to remove the previous image.
- image.Load(string.Empty);
- }
-
return isLoadComplate;
}
- public static bool LoadFromFile(this EImage image, string file)
- {
- if (!string.IsNullOrEmpty(file))
- {
- return image.Load(ResourcePath.GetPath(file));
- }
- return false;
- }
-
public static bool IsNullOrEmpty(this ImageSource imageSource) =>
imageSource == null || imageSource.IsEmpty;
}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/KeyboardExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/KeyboardExtensions.cs
deleted file mode 100644
index d07cbba0edba..000000000000
--- a/src/Compatibility/Core/src/Tizen/Extensions/KeyboardExtensions.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using ElmSharp;
-using EEntry = ElmSharp.Entry;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public static class KeyboardExtensions
- {
- ///
- /// Creates an instance of ElmSharp.Keyboard reflecting the provided Microsoft.Maui.Controls.Compatibility.Keyboard instance
- ///
- /// Keyboard type corresponding to the provided Microsoft.Maui.Controls.Compatibility.Keyboard
- /// The Microsoft.Maui.Controls.Compatibility.Keyboard class instance to be converted to ElmSharp.Keyboard.
- public static Native.Keyboard ToNative(this Keyboard keyboard)
- {
- if (keyboard == Keyboard.Numeric)
- {
- return Native.Keyboard.Numeric;
- }
- else if (keyboard == Keyboard.Telephone)
- {
- return Native.Keyboard.PhoneNumber;
- }
- else if (keyboard == Keyboard.Email)
- {
- return Native.Keyboard.Email;
- }
- else if (keyboard == Keyboard.Url)
- {
- return Native.Keyboard.Url;
- }
- else
- {
- return Native.Keyboard.Normal;
- }
- }
-
- public static AutoCapital ToAutoCapital(this KeyboardFlags keyboardFlags)
- {
- if (keyboardFlags.HasFlag(KeyboardFlags.CapitalizeSentence))
- {
- return AutoCapital.Sentence;
- }
- else if (keyboardFlags.HasFlag(KeyboardFlags.CapitalizeWord))
- {
- return AutoCapital.Word;
- }
- else if (keyboardFlags.HasFlag(KeyboardFlags.CapitalizeCharacter))
- {
- return AutoCapital.All;
- }
- else
- {
- return AutoCapital.None;
- }
- }
-
- public static InputHints ToInputHints(this Keyboard keyboard, bool isSpellCheckEnabled, bool isTextPredictionEnabled)
- {
- if (keyboard is CustomKeyboard customKeyboard)
- {
- return customKeyboard.Flags.HasFlag(KeyboardFlags.Suggestions) || customKeyboard.Flags.HasFlag(KeyboardFlags.Spellcheck) ? InputHints.AutoComplete : InputHints.None;
- }
- return isSpellCheckEnabled && isTextPredictionEnabled ? InputHints.AutoComplete : InputHints.None;
- }
-
- public static void UpdateKeyboard(this Native.IEntry control, Keyboard keyboard, bool isSpellCheckEnabled, bool isTextPredictionEnabled)
- {
- control.Keyboard = keyboard.ToNative();
- if (keyboard is CustomKeyboard customKeyboard)
- {
- (control as EEntry).AutoCapital = customKeyboard.Flags.ToAutoCapital();
- }
- else
- {
- (control as EEntry).AutoCapital = AutoCapital.None;
- }
- (control as EEntry).InputHint = keyboard.ToInputHints(isSpellCheckEnabled, isTextPredictionEnabled);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/LayoutExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/LayoutExtensions.cs
index cf26d2f53f6e..ff745dccd056 100644
--- a/src/Compatibility/Core/src/Tizen/Extensions/LayoutExtensions.cs
+++ b/src/Compatibility/Core/src/Tizen/Extensions/LayoutExtensions.cs
@@ -1,5 +1,5 @@
using System.Collections.Generic;
-using ElmSharp;
+using NView = Tizen.NUI.BaseComponents.View;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
@@ -19,7 +19,7 @@ public static class LayoutExtensions
/// The extended class.
/// Object to be added.
/// Optional delegate which provides measurements for the added object.
- public static void Add(this IList children, EvasObject obj, MeasureDelegate measureDelegate = null)
+ public static void Add(this IList children, NView obj, MeasureDelegate measureDelegate = null)
{
children.Add(obj.ToView(measureDelegate));
}
@@ -30,7 +30,7 @@ public static void Add(this IList children, EvasObject obj, MeasureDelegat
/// The Xamarin view which wraps the evas object.
/// The extended class.
/// Optional delegate which provides measurements for the evas object.
- public static View ToView(this EvasObject obj, MeasureDelegate measureDelegate = null)
+ public static View ToView(this NView obj, MeasureDelegate measureDelegate = null)
{
return new NativeViewWrapper(obj, measureDelegate);
}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/NativeBindingExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/NativeBindingExtensions.cs
index a833dd5bf914..5cbb35f62b12 100644
--- a/src/Compatibility/Core/src/Tizen/Extensions/NativeBindingExtensions.cs
+++ b/src/Compatibility/Core/src/Tizen/Extensions/NativeBindingExtensions.cs
@@ -1,33 +1,33 @@
using System;
using System.Collections.Generic;
using Microsoft.Maui.Controls.Internals;
-using EObject = ElmSharp.EvasObject;
+using NView = Tizen.NUI.BaseComponents.View;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
public static class NativeBindingExtensions
{
- public static void SetBinding(this EObject view, string propertyName, BindingBase binding, string updateSourceEventName = null)
+ public static void SetBinding(this NView view, string propertyName, BindingBase binding, string updateSourceEventName = null)
{
PlatformBindingHelpers.SetBinding(view, propertyName, binding, updateSourceEventName);
}
- public static void SetBinding(this EObject view, BindableProperty targetProperty, BindingBase binding)
+ public static void SetBinding(this NView view, BindableProperty targetProperty, BindingBase binding)
{
PlatformBindingHelpers.SetBinding(view, targetProperty, binding);
}
- public static void SetValue(this EObject target, BindableProperty targetProperty, object value)
+ public static void SetValue(this NView target, BindableProperty targetProperty, object value)
{
PlatformBindingHelpers.SetValue(target, targetProperty, value);
}
- public static void SetBindingContext(this EObject target, object bindingContext, Func> getChildren = null)
+ public static void SetBindingContext(this NView target, object bindingContext, Func> getChildren = null)
{
PlatformBindingHelpers.SetBindingContext(target, bindingContext, getChildren);
}
- internal static void TransferBindablePropertiesToWrapper(this EObject target, View wrapper)
+ internal static void TransferBindablePropertiesToWrapper(this NView target, View wrapper)
{
PlatformBindingHelpers.TransferBindablePropertiesToWrapper(target, wrapper);
}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/PageExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/PageExtensions.cs
deleted file mode 100644
index 490ffb4b2c46..000000000000
--- a/src/Compatibility/Core/src/Tizen/Extensions/PageExtensions.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility
-{
- [Obsolete]
- public static class PageExtensions
- {
- public static EvasObject CreateEvasObject(this Page page, EvasObject parent, bool hasAlpha = false)
- {
- if (!Forms.IsInitialized)
- throw new InvalidOperationException("call Forms.Init() before this");
-
- if (parent == null)
- throw new InvalidOperationException("Window could not be null");
-
- if (!(page.RealParent is Application))
- {
- Application app = new DefaultApplication();
- app.MainPage = page;
- }
-
- var platform = Platform.Tizen.Platform.CreatePlatform(parent);
- platform.HasAlpha = hasAlpha;
- platform.SetPage(page);
- return platform.GetRootNativeView();
- }
-
- class DefaultApplication : Application
- {
- }
- }
-}
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public static class PageExtensions
- {
- public static EvasObject CreateEvasObject(this ContentPage page, EvasObject parent, bool hasAlpha = false)
- {
- return Microsoft.Maui.Controls.Compatibility.PageExtensions.CreateEvasObject(page, parent, hasAlpha);
- }
-
- public static void UpdateFocusTreePolicy<[DynamicallyAccessedMembers(BindableProperty.DeclaringTypeMembers)] T>(this MultiPage multiPage) where T : Page
- {
- foreach (var pageItem in multiPage.Children)
- {
- if (Platform.GetRenderer(pageItem)?.NativeView is ElmSharp.Widget nativeWidget)
- {
- if (pageItem == multiPage.CurrentPage)
- {
- nativeWidget.AllowTreeFocus = true;
- continue;
- }
- nativeWidget.AllowTreeFocus = false;
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/ScrollToPositionExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/ScrollToPositionExtensions.cs
deleted file mode 100644
index 31a1fde1a9af..000000000000
--- a/src/Compatibility/Core/src/Tizen/Extensions/ScrollToPositionExtensions.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using EScrollToPosition = ElmSharp.ScrollToPosition;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public static class ScrollToPositionExtensions
- {
- public static EScrollToPosition ToNative(this ScrollToPosition position)
- {
- switch (position)
- {
- case ScrollToPosition.Center:
- return EScrollToPosition.Middle;
-
- case ScrollToPosition.End:
- return EScrollToPosition.Bottom;
-
- case ScrollToPosition.MakeVisible:
- return EScrollToPosition.In;
-
- case ScrollToPosition.Start:
- return EScrollToPosition.Top;
-
- default:
- return EScrollToPosition.Top;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Extensions/TextAlignmentExtensions.cs b/src/Compatibility/Core/src/Tizen/Extensions/TextAlignmentExtensions.cs
deleted file mode 100644
index 7abde6d2c244..000000000000
--- a/src/Compatibility/Core/src/Tizen/Extensions/TextAlignmentExtensions.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Microsoft.Extensions.Logging;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public static class TextAlignmentExtensions
- {
- public static Native.TextAlignment ToNative(this TextAlignment alignment)
- {
- switch (alignment)
- {
- case TextAlignment.Center:
- return Native.TextAlignment.Center;
-
- case TextAlignment.Start:
- return Native.TextAlignment.Start;
-
- case TextAlignment.End:
- return Native.TextAlignment.End;
-
- default:
- Application.Current?.FindMauiContext()?.CreateLogger()?.LogWarning("Warning: unrecognized HorizontalTextAlignment value {0}. " +
- "Expected: {Start|Center|End}.", alignment);
- Application.Current?.FindMauiContext()?.CreateLogger()?.LogDebug("Falling back to platform's default settings.");
- return Native.TextAlignment.Auto;
- }
- }
-
- public static double ToNativeDouble(this TextAlignment alignment)
- {
- switch (alignment)
- {
- case TextAlignment.Center:
- return 0.5d;
-
- case TextAlignment.Start:
- return 0;
-
- case TextAlignment.End:
- return 1d;
-
- default:
- Log.Warn("Warning: unrecognized HorizontalTextAlignment value {0}. " +
- "Expected: {Start|Center|End}.", alignment);
- Log.Debug("Falling back to platform's default settings.");
- return 0.5d;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Forms.cs b/src/Compatibility/Core/src/Tizen/Forms.cs
index a1bde68e84e0..12b1b1d700d4 100644
--- a/src/Compatibility/Core/src/Tizen/Forms.cs
+++ b/src/Compatibility/Core/src/Tizen/Forms.cs
@@ -1,20 +1,16 @@
using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
-using ElmSharp;
-using ElmSharp.Wearable;
-using Tizen.Applications;
-using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Compatibility.Platform.Tizen;
-using Microsoft.Maui.Controls.Shapes;
+using Microsoft.Maui.Controls.Internals;
+using Tizen.Applications;
using Microsoft.Maui.Devices;
-using ELayout = ElmSharp.Layout;
-using TSystemInfo = Tizen.System.Information;
-using Size = Microsoft.Maui.Graphics.Size;
using Color = Microsoft.Maui.Graphics.Color;
+using NView = Tizen.NUI.BaseComponents.View;
+using TDeviceInfo = Tizen.UIExtensions.Common.DeviceInfo;
+using Size = Microsoft.Maui.Graphics.Size;
namespace Microsoft.Maui.Controls.Compatibility
{
@@ -36,7 +32,6 @@ public class InitializationOptions
{
public CoreApplication Context { get; set; }
public bool UseDeviceIndependentPixel { get; set; }
- public bool UseSkiaSharp { get; set; } = true;
public HandlerAttribute[] Handlers { get; set; }
public Dictionary> CustomHandlers { get; set; } // for static registers
public Assembly[] Assemblies { get; set; }
@@ -45,7 +40,9 @@ public class InitializationOptions
public StaticRegistrarStrategy StaticRegistarStrategy { get; set; }
public PlatformType PlatformType { get; set; }
public bool UseMessagingCenter { get; set; } = true;
- public bool UseFastLayout { get; set; } = false;
+
+ public bool UseSkiaSharp { get; set; }
+
public DisplayResolutionUnit DisplayResolutionUnit { get; set; }
@@ -54,25 +51,19 @@ public struct EffectScope
public string Name;
public ExportEffectAttribute[] Effects;
}
- public InitializationOptions()
- {
- }
- public InitializationOptions(CoreApplication application)
+ public InitializationOptions()
{
- Context = application;
}
- public InitializationOptions(CoreApplication application, bool useDeviceIndependentPixel, HandlerAttribute[] handlers)
+ public InitializationOptions(bool useDeviceIndependentPixel, HandlerAttribute[] handlers)
{
- Context = application;
UseDeviceIndependentPixel = useDeviceIndependentPixel;
Handlers = handlers;
}
- public InitializationOptions(CoreApplication application, bool useDeviceIndependentPixel, params Assembly[] assemblies)
+ public InitializationOptions(bool useDeviceIndependentPixel, params Assembly[] assemblies)
{
- Context = application;
UseDeviceIndependentPixel = useDeviceIndependentPixel;
Assemblies = assemblies;
}
@@ -92,156 +83,27 @@ public static class Forms
#pragma warning disable CS0612 // Type or member is obsolete
#pragma warning disable CS0618 // Type or member is obsolete
{
- static Lazy s_profile = new Lazy(() =>
- {
- //TODO : Fix me if elm_config_profile_get() unavailable
- return Elementary.GetProfile();
- });
-
- static Lazy s_dpi = new Lazy(() =>
- {
- int dpi = 0;
- if (s_profile.Value == "tv")
- {
- // Use fixed DPI value (72) if TV profile
- return 72;
- }
- TSystemInfo.TryGetValue("http://tizen.org/feature/screen.dpi", out dpi);
- return dpi;
- });
-
- static Lazy s_elmScale = new Lazy(() =>
- {
- return s_deviceScale.Value / Elementary.GetScale();
- });
-
- static Lazy s_deviceType = new Lazy(() =>
- {
- if (!TSystemInfo.TryGetValue("http://tizen.org/system/device_type", out string deviceType))
- {
- // Since, above key("http://tizen.org/system/device_type") is not available on Tizen 4.0, we uses profile to decide the type of device on 4.0.
- var profile = GetProfile();
- if (profile == "mobile")
- {
- deviceType = "Mobile";
- }
- else if (profile == "tv")
- {
- deviceType = "TV";
- }
- else if (profile == "wearable")
- {
- deviceType = "Wearable";
- }
- else
- {
- deviceType = "Unknown";
- }
- }
- return deviceType;
- });
-
- static Lazy s_deviceScale = new Lazy(() =>
- {
- // This is the base scale value and varies from profile
- return ThemeManager.GetBaseScale(s_deviceType.Value);
- });
-
- static Lazy s_scalingFactor = new Lazy(() =>
- {
- int width = 0;
- int height = 0;
-
- TSystemInfo.TryGetValue("http://tizen.org/feature/screen.width", out width);
- TSystemInfo.TryGetValue("http://tizen.org/feature/screen.height", out height);
-
- var scalingFactor = 1.0; // scaling is disabled, we're using pixels as Xamarin's geometry units
- if (DisplayResolutionUnit.UseVP && DisplayResolutionUnit.ViewportWidth > 0)
- {
- scalingFactor = width / DisplayResolutionUnit.ViewportWidth;
- }
- else
- {
- if (DisplayResolutionUnit.UseDP)
- {
- scalingFactor = s_dpi.Value / 160.0;
- }
-
- if (DisplayResolutionUnit.UseDeviceScale)
- {
- var portraitSize = Math.Min(PhysicalScreenSize.Width, PhysicalScreenSize.Height);
- if (portraitSize > 2000)
- {
- scalingFactor *= 4;
- }
- else if (portraitSize > 1000)
- {
- scalingFactor *= 2.5;
- }
- }
- }
- return scalingFactor;
- });
-
- static StaticRegistrarStrategy s_staticRegistrarStrategy = StaticRegistrarStrategy.None;
-
- static PlatformType s_platformType = PlatformType.Defalut;
-
- static bool s_useMessagingCenter = true;
+ static IReadOnlyList s_flags;
public static event EventHandler ViewInitialized;
- public static IMauiContext MauiContext
- {
- get;
- internal set;
- }
+ public static bool IsInitialized { get; private set; }
- public static CoreApplication Context
- {
- get;
- internal set;
- }
+ public static StaticRegistrarStrategy StaticRegistrarStrategy { get; private set; }
- public static EvasObject NativeParent
- {
- get; internal set;
- }
+ public static PlatformType PlatformType { get; private set; }
- public static ELayout BaseLayout => NativeParent as ELayout;
+ public static bool UseMessagingCenter { get; private set; }
- public static CircleSurface CircleSurface
- {
- get; internal set;
- }
+ public static DisplayResolutionUnit DisplayResolutionUnit { get; private set; }
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static Element RotaryFocusObject
- {
- get; internal set;
- }
-
- public static bool IsInitialized
- {
- get;
- private set;
- }
-
- public static StaticRegistrarStrategy StaticRegistrarStrategy => s_staticRegistrarStrategy;
-
- public static PlatformType PlatformType => s_platformType;
-
- public static bool UseMessagingCenter => s_useMessagingCenter;
-
- public static bool UseSkiaSharp { get; private set; }
+ public static int ScreenDPI => TDeviceInfo.DPI;
- public static bool UseFastLayout { get; private set; }
-
- public static DisplayResolutionUnit DisplayResolutionUnit { get; private set; } = DisplayResolutionUnit.Pixel();
+ public static Size PhysicalScreenSize => DeviceDisplay.MainDisplayInfo.GetScaledScreenSize();
- public static int ScreenDPI => s_dpi.Value;
+ public static IReadOnlyList Flags => s_flags ?? (s_flags = new string[0]);
- public static Size PhysicalScreenSize => DeviceDisplay.MainDisplayInfo.GetScaledScreenSize();
+ public static IMauiContext MauiContext { get; internal set;}
internal static TizenTitleBarVisibility TitleBarVisibility
{
@@ -249,7 +111,7 @@ internal static TizenTitleBarVisibility TitleBarVisibility
private set;
}
- internal static void SendViewInitialized(this VisualElement self, EvasObject nativeView)
+ internal static void SendViewInitialized(this VisualElement self, NView nativeView)
{
EventHandler viewInitialized = Forms.ViewInitialized;
if (viewInitialized != null)
@@ -271,7 +133,7 @@ public static void SetTitleBarVisibility(TizenTitleBarVisibility visibility)
public static TOut GetHandler(Type type, params object[] args) where TOut : class, IRegisterable
{
- if (s_staticRegistrarStrategy == StaticRegistrarStrategy.None)
+ if (StaticRegistrarStrategy == StaticRegistrarStrategy.None)
{
// Find hander in internal registrar, that is using reflection (default).
return Registrar.Registered.GetHandler(type, args);
@@ -282,7 +144,7 @@ public static TOut GetHandler(Type type, params object[] args) where TOut
TOut ret = StaticRegistrar.Registered.GetHandler(type, args);
// 2. If there is no handler, try to find hander in internal registrar, that is using reflection.
- if (ret == null && s_staticRegistrarStrategy == StaticRegistrarStrategy.All)
+ if (ret == null && StaticRegistrarStrategy == StaticRegistrarStrategy.All)
{
ret = Registrar.Registered.GetHandler(type, args);
}
@@ -292,7 +154,7 @@ public static TOut GetHandler(Type type, params object[] args) where TOut
public static TOut GetHandlerForObject(object obj) where TOut : class, IRegisterable
{
- if (s_staticRegistrarStrategy == StaticRegistrarStrategy.None)
+ if (StaticRegistrarStrategy == StaticRegistrarStrategy.None)
{
// Find hander in internal registrar, that is using reflection (default).
return Registrar.Registered.GetHandlerForObject(obj);
@@ -303,7 +165,7 @@ public static TOut GetHandlerForObject(object obj) where TOut : class, IRe
TOut ret = StaticRegistrar.Registered.GetHandlerForObject(obj);
// 2. If there is no handler, try to find hander in internal registrar, that is using reflection.
- if (ret == null && s_staticRegistrarStrategy == StaticRegistrarStrategy.All)
+ if (ret == null && StaticRegistrarStrategy == StaticRegistrarStrategy.All)
{
ret = Registrar.Registered.GetHandlerForObject(obj);
}
@@ -313,7 +175,7 @@ public static TOut GetHandlerForObject(object obj) where TOut : class, IRe
public static TOut GetHandlerForObject(object obj, params object[] args) where TOut : class, IRegisterable
{
- if (s_staticRegistrarStrategy == StaticRegistrarStrategy.None)
+ if (StaticRegistrarStrategy == StaticRegistrarStrategy.None)
{
// Find hander in internal registrar, that is using reflection (default).
return Registrar.Registered.GetHandlerForObject(obj, args);
@@ -324,7 +186,7 @@ public static TOut GetHandlerForObject(object obj, params object[] args) w
TOut ret = StaticRegistrar.Registered.GetHandlerForObject(obj, args);
// 2. If there is no handler, try to find hander in internal registrar, that is using reflection.
- if (ret == null && s_staticRegistrarStrategy == StaticRegistrarStrategy.All)
+ if (ret == null && StaticRegistrarStrategy == StaticRegistrarStrategy.All)
{
ret = StaticRegistrar.Registered.GetHandlerForObject(obj, args);
}
@@ -352,8 +214,6 @@ public static void Init(IMauiContext context, InitializationOptions options = nu
static void SetupInit(IMauiContext context, InitializationOptions options = null)
{
MauiContext = context;
- Context = options?.Context ?? MauiApplication.Current;
- NativeParent = context.GetPlatformParent();
Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim);
if (!IsInitialized)
@@ -363,9 +223,7 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null
TizenSynchronizationContext.Initialize();
}
- Elementary.Initialize();
- Elementary.ThemeOverlay();
- Utility.AppendGlobalFontPath(@"/usr/share/fonts");
+ Tizen.NUI.FontClient.Instance.AddCustomFontDirectory(@"/usr/share/fonts");
}
Device.DefaultRendererAssembly = typeof(Forms).Assembly;
@@ -375,18 +233,13 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null
if (options != null)
{
- s_platformType = options.PlatformType;
- s_useMessagingCenter = options.UseMessagingCenter;
- UseSkiaSharp = options.UseSkiaSharp;
- UseFastLayout = options.UseFastLayout;
+ PlatformType = options.PlatformType;
+ UseMessagingCenter = options.UseMessagingCenter;
}
Application.AccentColor = GetAccentColor();
ExpressionSearch.Default = new TizenExpressionSearch();
- if (Context is WatchApplication)
- s_platformType = PlatformType.Lightweight;
-
IsInitialized = true;
}
@@ -438,21 +291,6 @@ internal static void RegisterCompatRenderers(InitializationOptions maybeOptions
}
}
- static void RegisterSkiaSharpRenderers()
- {
- // Register all skiasharp-based rednerers here.
- Registrar.Registered.Register(typeof(Frame), typeof(Platform.Tizen.SkiaSharp.FrameRenderer));
- Registrar.Registered.Register(typeof(BoxView), typeof(Platform.Tizen.SkiaSharp.BoxViewRenderer));
- Registrar.Registered.Register(typeof(Image), typeof(Platform.Tizen.SkiaSharp.ImageRenderer));
-
- Registrar.Registered.Register(typeof(Ellipse), typeof(Platform.Tizen.SkiaSharp.EllipseRenderer));
- Registrar.Registered.Register(typeof(Line), typeof(Platform.Tizen.SkiaSharp.LineRenderer));
- Registrar.Registered.Register(typeof(Path), typeof(Platform.Tizen.SkiaSharp.PathRenderer));
- Registrar.Registered.Register(typeof(Shapes.Polygon), typeof(Platform.Tizen.SkiaSharp.PolygonRenderer));
- Registrar.Registered.Register(typeof(Polyline), typeof(Platform.Tizen.SkiaSharp.PolylineRenderer));
- Registrar.Registered.Register(typeof(Shapes.Rectangle), typeof(Platform.Tizen.SkiaSharp.RectangleRenderer));
- }
-
static Color GetAccentColor()
{
// On Windows Phone, this is the complementary color chosen by the user.
@@ -482,7 +320,7 @@ static Color GetAccentColor()
///
public static int ConvertToPixel(double dp)
{
- return (int)Math.Round(dp * s_dpi.Value / 160.0);
+ return (int)Math.Round(dp * TDeviceInfo.DPI / 160.0);
}
///
@@ -496,7 +334,7 @@ public static int ConvertToPixel(double dp)
///
public static int ConvertToScaledPixel(double dp)
{
- return (int)Math.Round(dp * s_scalingFactor.Value);
+ return (int)Math.Round(dp * TDeviceInfo.ScalingFactor);
}
///
@@ -511,7 +349,7 @@ public static double ConvertToScaledDP(int pixel)
{
if (pixel == int.MaxValue)
return double.PositiveInfinity;
- return pixel / s_scalingFactor.Value;
+ return pixel / TDeviceInfo.ScalingFactor;
}
///
@@ -526,7 +364,7 @@ public static double ConvertToScaledDP(double pixel)
{
if (pixel == double.PositiveInfinity)
return double.PositiveInfinity;
- return pixel / s_scalingFactor.Value;
+ return pixel / TDeviceInfo.ScalingFactor;
}
///
@@ -536,7 +374,9 @@ public static double ConvertToScaledDP(double pixel)
///
public static int ConvertToEflFontPoint(double sp)
{
- return (int)Math.Round(ConvertToScaledPixel(sp) * s_elmScale.Value);
+ if (sp == -1)
+ return -1;
+ return (int)sp.ToScaledPoint();
}
///
@@ -546,7 +386,7 @@ public static int ConvertToEflFontPoint(double sp)
///
public static double ConvertToDPFont(int eflPt)
{
- return ConvertToScaledDP(eflPt / s_elmScale.Value);
+ return eflPt.ToScaledDP();
}
///
@@ -555,23 +395,12 @@ public static double ConvertToDPFont(int eflPt)
///
public static string GetProfile()
{
- return s_profile.Value;
+ return TDeviceInfo.Profile;
}
public static string GetDeviceType()
{
- return s_deviceType.Value;
- }
-
- // for internal use only
- [EditorBrowsable(EditorBrowsableState.Never)]
- public static void Preload()
- {
- Elementary.Initialize();
- Elementary.ThemeOverlay();
- var window = new Microsoft.Maui.Controls.Compatibility.Platform.Tizen.PreloadedWindow();
- TSystemInfo.TryGetValue("http://tizen.org/feature/screen.width", out int width);
- TSystemInfo.TryGetValue("http://tizen.org/feature/screen.height", out int height);
+ return TDeviceInfo.DeviceType.ToString();
}
}
diff --git a/src/Compatibility/Core/src/Tizen/FormsApplication.cs b/src/Compatibility/Core/src/Tizen/FormsApplication.cs
index 330de47c62cb..cfb45d68868b 100644
--- a/src/Compatibility/Core/src/Tizen/FormsApplication.cs
+++ b/src/Compatibility/Core/src/Tizen/FormsApplication.cs
@@ -1,30 +1,19 @@
using System;
using System.ComponentModel;
-using System.Diagnostics;
-using System.Reflection;
using System.Threading.Tasks;
-using ElmSharp;
-using ElmSharp.Wearable;
-using Tizen.Applications;
using Tizen.Common;
-using Microsoft.Maui.Controls.Internals;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Microsoft.Maui.Devices;
-using EWindow = ElmSharp.Window;
-using ELayout = ElmSharp.Layout;
-using EDisplayRotation = ElmSharp.DisplayRotation;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.Application;
+using Tizen.NUI;
+using NWindow = Tizen.NUI.Window;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[Obsolete]
- public class FormsApplication : CoreUIApplication
+ public class FormsApplication : NUIApplication
{
ITizenPlatform _platform;
Application _application;
- EWindow _window;
- bool _useBezelInteration;
+ NWindow _window;
protected FormsApplication()
{
@@ -34,7 +23,7 @@ protected FormsApplication()
/// Gets the main window or null if it's not set.
///
/// The main window or null.
- public EWindow MainWindow
+ public NWindow MainWindow
{
get
{
@@ -47,18 +36,6 @@ protected set
}
}
- public ELayout BaseLayout
- {
- get; protected set;
- }
-
- public CircleSurface BaseCircleSurface
- {
- get; protected set;
- }
-
- public bool UseBezelInteration => _useBezelInteration;
-
protected override void OnPreCreate()
{
base.OnPreCreate();
@@ -70,26 +47,7 @@ protected override void OnPreCreate()
Environment.SetEnvironmentVariable("XDG_DATA_HOME", Current.DirectoryInfo.Data);
}
- var type = typeof(EWindow);
- // Use reflection to avoid breaking compatibility. ElmSharp.Window.CreateWindow() is has been added since API6.
- var methodInfo = type.GetMethod("CreateWindow", BindingFlags.NonPublic | BindingFlags.Static);
- EWindow window = null;
- if (methodInfo != null)
- {
- window = (EWindow)methodInfo.Invoke(null, new object[] { "FormsWindow" });
- BaseLayout = (ELayout)window.GetType().GetProperty("BaseLayout")?.GetValue(window);
- BaseCircleSurface = (CircleSurface)window.GetType().GetProperty("BaseCircleSurface")?.GetValue(window);
- Forms.CircleSurface = BaseCircleSurface;
- }
- else // in case of Xamarin Preload
- {
- window = PreloadedWindow.GetInstance() ?? new EWindow("FormsWindow");
- if (window is PreloadedWindow precreated)
- {
- BaseLayout = precreated.BaseLayout;
- }
- }
- MainWindow = window;
+ MainWindow = NWindow.Instance;
}
protected override void OnTerminate()
@@ -143,11 +101,6 @@ public async void LoadApplication(Application application)
application.SendStart();
application.PropertyChanged += new PropertyChangedEventHandler(this.AppOnPropertyChanged);
SetPage(_application.MainPage);
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- _useBezelInteration = Specific.GetUseBezelInteraction(_application);
- UpdateOverlayContent();
- }
}
void AppOnPropertyChanged(object sender, PropertyChangedEventArgs args)
@@ -156,30 +109,6 @@ void AppOnPropertyChanged(object sender, PropertyChangedEventArgs args)
{
SetPage(_application.MainPage);
}
- else if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- if (Specific.UseBezelInteractionProperty.PropertyName == args.PropertyName)
- {
- _useBezelInteration = Specific.GetUseBezelInteraction(_application);
- }
- else if (Specific.OverlayContentProperty.PropertyName == args.PropertyName)
- {
- UpdateOverlayContent();
- }
- }
- }
-
- void UpdateOverlayContent()
- {
- EvasObject nativeView = null;
- var content = Specific.GetOverlayContent(_application);
- if (content != null)
- {
- var renderer = Platform.GetOrCreateRenderer(content);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
- nativeView = renderer?.NativeView;
- }
- Forms.BaseLayout.SetOverlayPart(nativeView);
}
void SetPage(Page page)
@@ -188,59 +117,38 @@ void SetPage(Page page)
{
throw new InvalidOperationException("Call Forms.Init (UIApplication) before this");
}
-
- _platform.HasAlpha = MainWindow.Alpha;
_platform.SetPage(page);
}
void InitializeWindow()
{
- Debug.Assert(MainWindow != null, "EWindow cannot be null");
-
- MainWindow.Active();
MainWindow.Show();
- // in case of no use of preloaded window
- if (BaseLayout == null)
+ MainWindow.KeyEvent += (s, e) =>
{
- var conformant = new Conformant(MainWindow);
- conformant.Show();
-
- var layout = new ApplicationLayout(conformant);
-
- layout.Show();
-
- BaseLayout = layout;
-
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
+ if (e.Key.State == Key.StateType.Down && (e.Key.KeyPressedName == "XF86Back" || e.Key.KeyPressedName == "Escape"))
{
- BaseCircleSurface = new CircleSurface(conformant);
- Forms.CircleSurface = BaseCircleSurface;
- }
- conformant.SetContent(BaseLayout);
- }
-
- MainWindow.AvailableRotations = EDisplayRotation.Degree_0 | EDisplayRotation.Degree_90 | EDisplayRotation.Degree_180 | EDisplayRotation.Degree_270;
- MainWindow.Deleted += (s, e) =>
- {
- Exit();
- };
+ if (global::Tizen.UIExtensions.NUI.Popup.HasOpenedPopup)
+ {
+ global::Tizen.UIExtensions.NUI.Popup.CloseLast();
+ return;
+ }
- MainWindow.BackButtonPressed += (sender, e) =>
- {
- if (_platform != null)
- {
- if (!_platform.SendBackButtonPressed())
+ if (!(_platform?.SendBackButtonPressed() ?? false))
{
Exit();
}
}
};
- _platform = Platform.CreatePlatform(BaseLayout);
- BaseLayout.SetContent(_platform.GetRootNativeView());
- _platform.RootNativeViewChanged += (s, e) => BaseLayout.SetContent(e.RootNativeView);
+ MainWindow.AddAvailableOrientation(NWindow.WindowOrientation.Landscape);
+ MainWindow.AddAvailableOrientation(NWindow.WindowOrientation.LandscapeInverse);
+ MainWindow.AddAvailableOrientation(NWindow.WindowOrientation.Portrait);
+ MainWindow.AddAvailableOrientation(NWindow.WindowOrientation.PortraitInverse);
+
+ _platform = new DefaultPlatform();
+ MainWindow.GetDefaultLayer().Add(_platform.GetRootNativeView());
}
public void Run()
diff --git a/src/Compatibility/Core/src/Tizen/Gesture/GestureDetector.cs b/src/Compatibility/Core/src/Tizen/Gesture/GestureDetector.cs
new file mode 100644
index 000000000000..cbfee6afff8f
--- /dev/null
+++ b/src/Compatibility/Core/src/Tizen/Gesture/GestureDetector.cs
@@ -0,0 +1,105 @@
+using System.Collections.Generic;
+
+namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
+{
+ public class GestureDetector
+ {
+ Dictionary _handlers = new Dictionary();
+
+ IVisualElementRenderer _renderer;
+
+ bool _isEnabled = true;
+
+ public GestureDetector(IVisualElementRenderer renderer)
+ {
+ _renderer = renderer;
+ }
+
+ public bool IsEnabled
+ {
+ get => _isEnabled;
+ set
+ {
+ if (_isEnabled != value)
+ {
+ _isEnabled = value;
+ UpdateIsEnabled();
+ }
+ }
+ }
+
+ public void AddGestures(IEnumerable gestures)
+ {
+ foreach (var gesture in gestures)
+ {
+ AddGesture(gesture);
+ }
+ }
+
+ public void AddGesture(IGestureRecognizer gesture)
+ {
+ var handler = CreateHandler(gesture);
+ if (handler == null)
+ return;
+
+ _handlers.Add(gesture, handler);
+
+ if (IsEnabled)
+ handler.Attach(_renderer);
+ }
+
+ public void RemoveGestures(IEnumerable gestures)
+ {
+ foreach (var gesture in gestures)
+ {
+ RemoveGesture(gesture);
+ }
+ }
+
+ public void RemoveGesture(IGestureRecognizer gesture)
+ {
+ if (_handlers.TryGetValue(gesture, out GestureHandler handler))
+ {
+ _handlers.Remove(gesture);
+ handler.Dispose();
+ }
+ }
+
+ public void Clear()
+ {
+ foreach (var handler in _handlers)
+ {
+ handler.Value.Dispose();
+ }
+ _handlers.Clear();
+ }
+
+ void UpdateIsEnabled()
+ {
+ if (IsEnabled)
+ {
+ foreach (var handler in _handlers.Values)
+ {
+ handler.Attach(_renderer);
+ }
+ }
+ else
+ {
+ foreach (var handler in _handlers.Values)
+ {
+ handler.Detach();
+ }
+ }
+ }
+
+ GestureHandler CreateHandler(IGestureRecognizer recognizer)
+ {
+ if (recognizer is TapGestureRecognizer)
+ return new TapGestureHandler(recognizer);
+ if (recognizer is PanGestureRecognizer)
+ return new PanGestureHandler(recognizer);
+ return Forms.GetHandlerForObject(recognizer, recognizer);
+ }
+
+ }
+}
diff --git a/src/Compatibility/Core/src/Tizen/Gesture/GestureHandler.cs b/src/Compatibility/Core/src/Tizen/Gesture/GestureHandler.cs
new file mode 100644
index 000000000000..fab70c699269
--- /dev/null
+++ b/src/Compatibility/Core/src/Tizen/Gesture/GestureHandler.cs
@@ -0,0 +1,54 @@
+using System;
+using NGestureDetector = Tizen.NUI.GestureDetector;
+
+namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
+{
+ public abstract class GestureHandler : IRegisterable, IDisposable
+ {
+ bool _disposedValue;
+
+ public IGestureRecognizer Recognizer { get; private set; }
+
+ public NGestureDetector NativeDetector { get; }
+
+ protected IVisualElementRenderer Renderer { get; private set; }
+ protected View View => Renderer.Element as View;
+
+ public void Attach(IVisualElementRenderer renderer)
+ {
+ Renderer = renderer;
+ NativeDetector.Attach(Renderer.NativeView);
+ }
+
+ public void Detach()
+ {
+ NativeDetector.Detach(Renderer.NativeView);
+ }
+
+ public void Dispose()
+ {
+ Dispose(disposing: true);
+ GC.SuppressFinalize(this);
+ }
+
+ protected abstract NGestureDetector CreateNativeDetector(IGestureRecognizer recognizer);
+
+ protected GestureHandler(IGestureRecognizer recognizer)
+ {
+ Recognizer = recognizer;
+ NativeDetector = CreateNativeDetector(recognizer);
+ }
+
+ protected virtual void Dispose(bool disposing)
+ {
+ if (!_disposedValue)
+ {
+ if (disposing)
+ {
+ NativeDetector.Dispose();
+ }
+ _disposedValue = true;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Gesture/PanGestureHandler.cs b/src/Compatibility/Core/src/Tizen/Gesture/PanGestureHandler.cs
new file mode 100644
index 000000000000..ec2a1e435ce1
--- /dev/null
+++ b/src/Compatibility/Core/src/Tizen/Gesture/PanGestureHandler.cs
@@ -0,0 +1,53 @@
+using NGestureDetector = Tizen.NUI.GestureDetector;
+using PanGestureDetector = Tizen.NUI.PanGestureDetector;
+using GestureStateType = Tizen.NUI.Gesture.StateType;
+
+namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
+{
+ public class PanGestureHandler : GestureHandler
+ {
+ int _gestureId = 0;
+
+ double _totalX;
+ double _totalY;
+
+ public PanGestureHandler(IGestureRecognizer recognizer) : base(recognizer)
+ {
+ NativeDetector.Detected += OnDetected;
+ }
+
+ new IPanGestureController Recognizer => base.Recognizer as IPanGestureController;
+ new PanGestureDetector NativeDetector => base.NativeDetector as PanGestureDetector;
+
+ protected override NGestureDetector CreateNativeDetector(IGestureRecognizer recognizer)
+ {
+ return new PanGestureDetector();
+ }
+
+ void OnDetected(object source, PanGestureDetector.DetectedEventArgs e)
+ {
+ if (e.PanGesture.State == GestureStateType.Started)
+ {
+ _gestureId++;
+ _totalX = 0;
+ _totalY = 0;
+ Recognizer.SendPanStarted(View, _gestureId);
+ }
+ else if (e.PanGesture.State == GestureStateType.Continuing)
+ {
+ _totalX += e.PanGesture.Displacement.X;
+ _totalY += e.PanGesture.Displacement.Y;
+ Recognizer.SendPan(View, Forms.ConvertToScaledDP(_totalX), Forms.ConvertToScaledDP(_totalY), _gestureId);
+ }
+ else if (e.PanGesture.State == GestureStateType.Cancelled)
+ {
+ Recognizer.SendPanCanceled(View, _gestureId);
+ }
+ else if (e.PanGesture.State == GestureStateType.Finished)
+ {
+ Recognizer.SendPanCompleted(View, _gestureId);
+ }
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Gesture/TapGestureHandler.cs b/src/Compatibility/Core/src/Tizen/Gesture/TapGestureHandler.cs
new file mode 100644
index 000000000000..c4da708f91a9
--- /dev/null
+++ b/src/Compatibility/Core/src/Tizen/Gesture/TapGestureHandler.cs
@@ -0,0 +1,29 @@
+using System;
+using NGestureDetector = Tizen.NUI.GestureDetector;
+using TapGestureDetector = Tizen.NUI.TapGestureDetector;
+
+namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
+{
+ public class TapGestureHandler : GestureHandler
+ {
+ public TapGestureHandler(IGestureRecognizer recognizer) : base(recognizer)
+ {
+ NativeDetector.Detected += OnTapped;
+ }
+
+ new TapGestureRecognizer Recognizer => base.Recognizer as TapGestureRecognizer;
+ new TapGestureDetector NativeDetector => base.NativeDetector as TapGestureDetector;
+
+ protected override NGestureDetector CreateNativeDetector(IGestureRecognizer recognizer)
+ {
+ return new TapGestureDetector((uint)(recognizer as TapGestureRecognizer).NumberOfTapsRequired);
+ }
+
+ void OnTapped(object source, TapGestureDetector.DetectedEventArgs e)
+ {
+ if (e.TapGesture.NumberOfTaps == Recognizer.NumberOfTapsRequired)
+ Recognizer.SendTapped(View);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/GestureDetector.cs b/src/Compatibility/Core/src/Tizen/GestureDetector.cs
deleted file mode 100644
index a5c7fca2630b..000000000000
--- a/src/Compatibility/Core/src/Tizen/GestureDetector.cs
+++ /dev/null
@@ -1,602 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using Microsoft.Maui.Devices;
-using ElmSharp;
-using EGestureType = ElmSharp.GestureLayer.GestureType;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- internal class GestureDetector
- {
- readonly IDictionary> _handlerCache;
-
- readonly IVisualElementRenderer _renderer;
- GestureLayer _gestureLayer;
- double _doubleTapTime = 0;
- double _longTapTime = 0;
- bool _inputTransparent = false;
- bool _isEnabled;
-
- View View => _renderer.Element as View;
-
- public bool IsEnabled
- {
- get
- {
- return _isEnabled;
- }
- set
- {
- _isEnabled = value;
- UpdateGestureLayerEnabled();
- }
- }
-
- public bool InputTransparent
- {
- get
- {
- return _inputTransparent;
- }
- set
- {
- _inputTransparent = value;
- UpdateGestureLayerEnabled();
- }
- }
-
- public GestureDetector(IVisualElementRenderer renderer)
- {
- _handlerCache = new Dictionary>();
- _renderer = renderer;
- _isEnabled = View.IsEnabled;
- _inputTransparent = View.InputTransparent;
- }
-
- public void Clear()
- {
- // this will clear all callbacks in ElmSharp GestureLayer
- _gestureLayer?.Unrealize();
- _gestureLayer = null;
- foreach (var handlers in _handlerCache.Values)
- {
- foreach (var handler in handlers)
- {
- handler.PropertyChanged -= OnGestureRecognizerPropertyChanged;
- }
- }
- _handlerCache.Clear();
-
- if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- _renderer.NativeView.KeyDown -= OnKeyDown;
- }
- }
-
- public void AddGestures(IEnumerable recognizers)
- {
- if (_gestureLayer == null)
- {
- CreateGestureLayer();
- }
-
- foreach (var item in recognizers)
- AddGesture(item);
- }
-
- public void RemoveGestures(IEnumerable recognizers)
- {
- foreach (var item in recognizers)
- RemoveGesture(item);
- }
-
- void CreateGestureLayer()
- {
- _gestureLayer = new GestureLayer(_renderer.NativeView);
- _gestureLayer.Attach(_renderer.NativeView);
- _gestureLayer.Deleted += (s, e) =>
- {
- _gestureLayer = null;
- Clear();
- };
- UpdateGestureLayerEnabled();
-
- if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- _renderer.NativeView.KeyDown += OnKeyDown;
- }
- }
-
- void UpdateGestureLayerEnabled()
- {
- if (_gestureLayer != null)
- {
- _gestureLayer.IsEnabled = !_inputTransparent && _isEnabled;
- }
- }
-
- void AddGesture(IGestureRecognizer recognizer)
- {
- var handler = CreateHandler(recognizer);
- if (handler == null)
- return;
-
- var gestureType = handler.Type;
- var timeout = handler.Timeout;
- var cache = _handlerCache;
-
- if (!cache.ContainsKey(gestureType))
- {
- cache[gestureType] = new List();
- }
-
- handler.PropertyChanged += OnGestureRecognizerPropertyChanged;
- cache[gestureType].Add(handler);
-
- if (cache[gestureType].Count == 1)
- {
- switch (gestureType)
- {
- case EGestureType.Tap:
- case EGestureType.TripleTap:
- AddTapGesture(gestureType);
- break;
-
- case EGestureType.DoubleTap:
- AddDoubleTapGesture(gestureType, timeout);
- break;
-
- case EGestureType.LongTap:
- AddLongTapGesture(gestureType, timeout);
- break;
-
- case EGestureType.Line:
- AddLineGesture(gestureType);
- break;
-
- case EGestureType.Flick:
- AddFlickGesture(gestureType, timeout);
- break;
-
- case EGestureType.Rotate:
- AddRotateGesture(gestureType);
- break;
-
- case EGestureType.Momentum:
- AddMomentumGesture(gestureType);
- break;
-
- case EGestureType.Zoom:
- AddPinchGesture(gestureType);
- break;
-
- default:
- break;
- }
- }
-
- if (handler is DropGestureHandler dropGestureHandler)
- {
- dropGestureHandler.AddDropGesture();
- }
- }
-
- void RemoveGesture(IGestureRecognizer recognizer)
- {
- var cache = _handlerCache;
- var handler = LookupHandler(recognizer);
- var gestureType = cache.FirstOrDefault(x => x.Value.Contains(handler)).Key;
-
- handler.PropertyChanged -= OnGestureRecognizerPropertyChanged;
- cache[gestureType].Remove(handler);
-
- if (cache[gestureType].Count == 0)
- {
- switch (gestureType)
- {
- case EGestureType.Tap:
- case EGestureType.DoubleTap:
- case EGestureType.TripleTap:
- case EGestureType.LongTap:
- RemoveTapGesture(gestureType);
- break;
-
- case EGestureType.Line:
- RemoveLineGesture();
- break;
-
- case EGestureType.Flick:
- RemoveFlickGesture();
- break;
-
- case EGestureType.Rotate:
- RemoveRotateGesture();
- break;
-
- case EGestureType.Momentum:
- RemoveMomentumGesture();
- break;
-
- case EGestureType.Zoom:
- RemovePinchGesture();
- break;
-
- default:
- break;
- }
- }
- }
-
- void AddLineGesture(EGestureType type)
- {
- _gestureLayer.SetLineCallback(GestureLayer.GestureState.Start, (data) => { OnGestureStarted(type, data); });
- _gestureLayer.SetLineCallback(GestureLayer.GestureState.Move, (data) => { OnGestureMoved(type, data); });
- _gestureLayer.SetLineCallback(GestureLayer.GestureState.End, (data) => { OnGestureCompleted(type, data); });
- _gestureLayer.SetLineCallback(GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
- }
-
- void AddPinchGesture(EGestureType type)
- {
- _gestureLayer.SetZoomCallback(GestureLayer.GestureState.Start, (data) => { OnGestureStarted(type, data); });
- _gestureLayer.SetZoomCallback(GestureLayer.GestureState.Move, (data) => { OnGestureMoved(type, data); });
- _gestureLayer.SetZoomCallback(GestureLayer.GestureState.End, (data) => { OnGestureCompleted(type, data); });
- _gestureLayer.SetZoomCallback(GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
- }
-
- void AddTapGesture(EGestureType type)
- {
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Start, (data) => { OnGestureStarted(type, data); });
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.End, (data) => { OnGestureCompleted(type, data); });
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
- }
-
- void AddDoubleTapGesture(EGestureType type, double timeout)
- {
- if (timeout > 0)
- _gestureLayer.DoubleTapTimeout = timeout;
-
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Start, (data) => { OnDoubleTapStarted(type, data); });
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.End, (data) => { OnDoubleTapCompleted(type, data); });
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
- }
-
- void AddLongTapGesture(EGestureType type, double timeout)
- {
- if (timeout > 0)
- _gestureLayer.LongTapTimeout = timeout;
-
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Start, (data) => { OnLongTapStarted(type, data); });
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Move, (data) => { OnLongTapMoved(type, data); });
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.End, (data) => { OnLongTapCompleted(type, data); });
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
- }
-
- void AddFlickGesture(EGestureType type, double timeout)
- {
- if (timeout > 0)
- _gestureLayer.FlickTimeLimit = (int)(timeout * 1000);
-
- // Task to correct wrong coordinates information when applying EvasMap(Xamarin ex: Translation, Scale, Rotate property)
- // Always change to the absolute coordinates of the pointer.
- int startX = 0;
- int startY = 0;
- _gestureLayer.SetFlickCallback(GestureLayer.GestureState.Start, (data) =>
- {
- startX = _gestureLayer.EvasCanvas.Pointer.X;
- startY = _gestureLayer.EvasCanvas.Pointer.Y;
- data.X1 = startX;
- data.Y1 = startY;
- OnGestureStarted(type, data);
- });
- _gestureLayer.SetFlickCallback(GestureLayer.GestureState.Move, (data) =>
- {
- data.X1 = startX;
- data.Y1 = startY;
- data.X2 = _gestureLayer.EvasCanvas.Pointer.X;
- data.Y2 = _gestureLayer.EvasCanvas.Pointer.Y;
- OnGestureMoved(type, data);
- });
- _gestureLayer.SetFlickCallback(GestureLayer.GestureState.End, (data) =>
- {
- data.X1 = startX;
- data.Y1 = startY;
- data.X2 = _gestureLayer.EvasCanvas.Pointer.X;
- data.Y2 = _gestureLayer.EvasCanvas.Pointer.Y;
- OnGestureCompleted(type, data);
- });
- _gestureLayer.SetFlickCallback(GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
- }
-
- void AddRotateGesture(EGestureType type)
- {
- _gestureLayer.SetRotateCallback(GestureLayer.GestureState.Start, (data) => { OnGestureStarted(type, data); });
- _gestureLayer.SetRotateCallback(GestureLayer.GestureState.Move, (data) => { OnGestureMoved(type, data); });
- _gestureLayer.SetRotateCallback(GestureLayer.GestureState.End, (data) => { OnGestureCompleted(type, data); });
- _gestureLayer.SetRotateCallback(GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
- }
-
- void AddMomentumGesture(EGestureType type)
- {
- // Task to correct wrong coordinates information when applying EvasMap(Xamarin ex: Translation, Scale, Rotate property)
- // Always change to the absolute coordinates of the pointer.
- int startX = 0;
- int startY = 0;
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Start, (data) =>
- {
- startX = _gestureLayer.EvasCanvas.Pointer.X;
- startY = _gestureLayer.EvasCanvas.Pointer.Y;
- OnGestureStarted(type, data);
- });
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Move, (data) =>
- {
- data.X1 = startX;
- data.Y1 = startY;
- data.X2 = _gestureLayer.EvasCanvas.Pointer.X;
- data.Y2 = _gestureLayer.EvasCanvas.Pointer.Y;
- OnGestureMoved(type, data);
- });
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.End, (data) => { OnGestureCompleted(type, data); });
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Abort, (data) => { OnGestureCanceled(type, data); });
- }
-
- void RemoveLineGesture()
- {
- _gestureLayer.SetLineCallback(GestureLayer.GestureState.Start, null);
- _gestureLayer.SetLineCallback(GestureLayer.GestureState.Move, null);
- _gestureLayer.SetLineCallback(GestureLayer.GestureState.End, null);
- _gestureLayer.SetLineCallback(GestureLayer.GestureState.Abort, null);
- }
-
- void RemovePinchGesture()
- {
- _gestureLayer.SetZoomCallback(GestureLayer.GestureState.Start, null);
- _gestureLayer.SetZoomCallback(GestureLayer.GestureState.Move, null);
- _gestureLayer.SetZoomCallback(GestureLayer.GestureState.End, null);
- _gestureLayer.SetZoomCallback(GestureLayer.GestureState.Abort, null);
- }
-
- void RemoveTapGesture(EGestureType type)
- {
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Start, null);
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.End, null);
- _gestureLayer.SetTapCallback(type, GestureLayer.GestureState.Abort, null);
- }
-
- void RemoveFlickGesture()
- {
- _gestureLayer.SetFlickCallback(GestureLayer.GestureState.Start, null);
- _gestureLayer.SetFlickCallback(GestureLayer.GestureState.Move, null);
- _gestureLayer.SetFlickCallback(GestureLayer.GestureState.End, null);
- _gestureLayer.SetFlickCallback(GestureLayer.GestureState.Abort, null);
- }
-
- void RemoveRotateGesture()
- {
- _gestureLayer.SetRotateCallback(GestureLayer.GestureState.Start, null);
- _gestureLayer.SetRotateCallback(GestureLayer.GestureState.Move, null);
- _gestureLayer.SetRotateCallback(GestureLayer.GestureState.End, null);
- _gestureLayer.SetRotateCallback(GestureLayer.GestureState.Abort, null);
- }
-
- void RemoveMomentumGesture()
- {
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Start, null);
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Move, null);
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.End, null);
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Abort, null);
- }
-
- #region GestureCallback
-
- void OnGestureStarted(EGestureType type, object data)
- {
- var cache = _handlerCache;
- if (cache.ContainsKey(type))
- {
- foreach (var handler in cache[type])
- {
- (handler as IGestureController)?.SendStarted(View, data);
- }
- }
- }
-
- void OnGestureMoved(EGestureType type, object data)
- {
- var cache = _handlerCache;
- if (cache.ContainsKey(type))
- {
- foreach (var handler in cache[type])
- {
- (handler as IGestureController)?.SendMoved(View, data);
- }
- }
- }
-
- void OnGestureCompleted(EGestureType type, object data)
- {
- var cache = _handlerCache;
- if (cache.ContainsKey(type))
- {
- foreach (var handler in cache[type])
- {
- (handler as IGestureController)?.SendCompleted(View, data);
- }
- }
- }
-
- void OnGestureCanceled(EGestureType type, object data)
- {
- var cache = _handlerCache;
- if (cache.ContainsKey(type))
- {
- foreach (var handler in cache[type])
- {
- (handler as IGestureController)?.SendCanceled(View, data);
- }
- }
- }
-
- void OnDoubleTapStarted(EGestureType type, object data)
- {
- _doubleTapTime = ((GestureLayer.TapData)data).Timestamp;
- OnGestureStarted(type, data);
- }
-
- void OnDoubleTapCompleted(EGestureType type, object data)
- {
- _doubleTapTime = ((GestureLayer.TapData)data).Timestamp - _doubleTapTime;
- var cache = _handlerCache;
-
- if (cache.ContainsKey(type))
- {
- foreach (var handler in cache[type])
- {
- if ((handler.Timeout * 1000) >= _longTapTime)
- (handler as IGestureController)?.SendCompleted(View, data);
- else
- (handler as IGestureController)?.SendCanceled(View, data);
- }
- }
- }
-
- void OnLongTapStarted(EGestureType type, object data)
- {
- _longTapTime = ((GestureLayer.TapData)data).Timestamp;
- OnGestureStarted(type, data);
- }
-
- void OnLongTapMoved(EGestureType type, object data)
- {
- OnGestureMoved(type, data);
- }
-
- void OnLongTapCompleted(EGestureType type, object data)
- {
- _longTapTime = ((GestureLayer.TapData)data).Timestamp - _longTapTime;
- var cache = _handlerCache;
-
- if (cache.ContainsKey(type))
- {
- foreach (var handler in cache[type])
- {
- if ((handler.Timeout * 1000) <= _longTapTime)
- (handler as IGestureController)?.SendCompleted(View, data);
- else
- (handler as IGestureController)?.SendCanceled(View, data);
- }
- }
- }
-
- #endregion GestureCallback
-
- GestureHandler CreateHandler(IGestureRecognizer recognizer)
- {
- if (recognizer is TapGestureRecognizer)
- {
- return new TapGestureHandler(recognizer);
- }
- else if (recognizer is PinchGestureRecognizer)
- {
- return new PinchGestureHandler(recognizer);
- }
- else if (recognizer is PanGestureRecognizer)
- {
- return new PanGestureHandler(recognizer);
- }
- else if (recognizer is SwipeGestureRecognizer)
- {
- return new SwipeGestureHandler(recognizer);
- }
- else if (recognizer is DragGestureRecognizer)
- {
- return new DragGestureHandler(recognizer, _renderer);
- }
- else if (recognizer is DropGestureRecognizer)
- {
- return new DropGestureHandler(recognizer, _renderer);
- }
- return Forms.GetHandlerForObject(recognizer, recognizer);
- }
-
- GestureHandler LookupHandler(IGestureRecognizer recognizer)
- {
- var cache = _handlerCache;
-
- foreach (var handlers in cache.Values)
- {
- foreach (var handler in handlers)
- {
- if (handler.Recognizer == recognizer)
- return handler;
- }
- }
- return null;
- }
-
- void UpdateTapGesture(GestureHandler handler)
- {
- RemoveGesture(handler.Recognizer);
- AddGesture(handler.Recognizer);
-
- if (handler.Timeout > _gestureLayer.DoubleTapTimeout)
- _gestureLayer.DoubleTapTimeout = handler.Timeout;
- }
-
- void UpdateLongTapGesture(GestureHandler handler)
- {
- if (handler.Timeout > 0 && handler.Timeout < _gestureLayer.LongTapTimeout)
- _gestureLayer.LongTapTimeout = handler.Timeout;
- }
-
- void UpdateFlickGesture(GestureHandler handler)
- {
- if (handler.Timeout > _gestureLayer.FlickTimeLimit)
- _gestureLayer.FlickTimeLimit = (int)(handler.Timeout * 1000);
- }
-
- void OnGestureRecognizerPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- var handler = sender as GestureHandler;
- if (handler != null)
- {
- switch (handler.Type)
- {
- case EGestureType.Tap:
- case EGestureType.DoubleTap:
- case EGestureType.TripleTap:
- UpdateTapGesture(handler);
- break;
-
- case EGestureType.LongTap:
- UpdateLongTapGesture(handler);
- break;
-
- case EGestureType.Flick:
- UpdateFlickGesture(handler);
- break;
-
- default:
- break;
- }
- }
- }
-
- void OnKeyDown(object sender, EvasKeyEventArgs e)
- {
- if (e.KeyName == "Return" && _gestureLayer.IsEnabled)
- {
- var cache = _handlerCache;
- if (cache.ContainsKey(EGestureType.Tap))
- {
- foreach (var handler in cache[EGestureType.Tap])
- {
- (handler as IGestureController)?.SendStarted(View, null);
- (handler as IGestureController)?.SendCompleted(View, null);
- }
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/GestureHandler.cs b/src/Compatibility/Core/src/Tizen/GestureHandler.cs
deleted file mode 100644
index 0df0a9928058..000000000000
--- a/src/Compatibility/Core/src/Tizen/GestureHandler.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using System;
-using System.ComponentModel;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public abstract class GestureHandler : IGestureController, INotifyPropertyChanged, IRegisterable
- {
- public IGestureRecognizer Recognizer { get; private set; }
-
- public abstract GestureLayer.GestureType Type { get; }
-
- public virtual double Timeout { get; }
-
- protected GestureHandler(IGestureRecognizer recognizer)
- {
- Recognizer = recognizer;
- Recognizer.PropertyChanged += OnRecognizerPropertyChanged;
- }
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- protected abstract void OnStarted(View sender, object data);
-
- protected abstract void OnMoved(View sender, object data);
-
- protected abstract void OnCompleted(View sender, object data);
-
- protected abstract void OnCanceled(View sender, object data);
-
- void IGestureController.SendStarted(View sender, object data)
- {
- OnStarted(sender, data);
- }
-
- void IGestureController.SendCompleted(View sender, object data)
- {
- OnCompleted(sender, data);
- }
-
- void IGestureController.SendMoved(View sender, object data)
- {
- OnMoved(sender, data);
- }
-
- void IGestureController.SendCanceled(View sender, object data)
- {
- OnCanceled(sender, data);
- }
-
- protected virtual void OnRecognizerPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- PropertyChanged?.Invoke(this, e);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs b/src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs
index fe07cba3ba82..8cb11efa8040 100644
--- a/src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs
+++ b/src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs
@@ -3,10 +3,7 @@
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Graphics;
-using Microsoft.Maui.Handlers;
-using Rect = Microsoft.Maui.Graphics.Rect;
-using ERect = ElmSharp.Rect;
-using EvasObject = ElmSharp.EvasObject;
+using NView = Tizen.NUI.BaseComponents.View;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
@@ -26,7 +23,7 @@ public HandlerToRendererShim(IPlatformViewHandler vh)
public VisualElement Element { get; private set; }
- public EvasObject NativeView => ViewHandler.ContainerView ?? ViewHandler.PlatformView;
+ public NView NativeView => ViewHandler.ContainerView ?? ViewHandler.PlatformView;
public event EventHandler ElementChanged;
public event EventHandler ElementPropertyChanged;
@@ -64,16 +61,6 @@ public void SetElement(VisualElement element)
if (ViewHandler.VirtualView != element)
ViewHandler.SetVirtualView((IView)element);
- if (element.RealParent is IView view && view.Handler is IPlatformViewHandler nvh)
- {
- ViewHandler.SetParent(nvh);
- }
- else
- {
- ViewHandler.SetParent(new MockParentHandler(element.RealParent as VisualElement));
- }
-
- NativeView.Deleted += OnNativeDeleted;
ElementChanged?.Invoke(this, new VisualElementChangedEventArgs(oldElement, Element));
}
@@ -106,94 +93,5 @@ public void UpdateLayout()
{
ViewHandler.PlatformArrange(Element.Bounds);
}
-
- public ERect GetNativeContentGeometry()
- {
- return NativeView.Geometry;
- }
-
- class MockParentHandler : IPlatformViewHandler
- {
-
- public MockParentHandler(VisualElement parent)
- {
- RealParent = parent;
- }
-
- VisualElement RealParent { get; }
-
- public bool ForceContainer { get; set; }
-
- IVisualElementRenderer Renderer => RealParent != null ? Platform.GetRenderer(RealParent) : null;
- public EvasObject PlatformView => Renderer.NativeView;
-
- public EvasObject ContainerView => PlatformView;
-
- public IPlatformViewHandler Parent => null;
-
- public IView VirtualView => Renderer.Element as IView;
-
- public IMauiContext MauiContext => null;
-
- object IElementHandler.PlatformView => PlatformView;
-
- object IViewHandler.ContainerView => PlatformView;
-
- bool IViewHandler.HasContainer { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
-
- Maui.IElement IElementHandler.VirtualView => throw new NotImplementedException();
-
- public void DisconnectHandler() { }
-
- public void Dispose()
- {
- }
-
- public Size GetDesiredSize(double widthConstraint, double heightConstraint)
- {
- throw new NotImplementedException();
- }
-
- public ERect GetPlatformContentGeometry()
- {
- return Renderer?.GetNativeContentGeometry() ?? new ERect(0, 0, 0, 0);
- }
-
- public void PlatformArrange(Rect frame)
- {
- throw new NotImplementedException();
- }
-
- public void SetMauiContext(IMauiContext mauiContext)
- {
- throw new NotImplementedException();
- }
-
- public void SetParent(IPlatformViewHandler parent)
- {
- throw new NotImplementedException();
- }
-
- public void SetVirtualView(IView view)
- {
- throw new NotImplementedException();
- }
-
- public void UpdateValue(string property)
- {
- throw new NotImplementedException();
- }
-
- public void SetVirtualView(Maui.IElement view)
- {
- throw new NotImplementedException();
- }
-
- public void Invoke(string command, object args)
- {
- throw new NotImplementedException();
- }
- }
-
}
}
diff --git a/src/Compatibility/Core/src/Tizen/IGestureController.cs b/src/Compatibility/Core/src/Tizen/IGestureController.cs
deleted file mode 100644
index 7882064e1bff..000000000000
--- a/src/Compatibility/Core/src/Tizen/IGestureController.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public interface IGestureController
- {
- void SendStarted(View sender, object data);
-
- void SendMoved(View sender, object data);
-
- void SendCompleted(View sender, object data);
-
- void SendCanceled(View sender, object data);
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/IMEApplication.cs b/src/Compatibility/Core/src/Tizen/IMEApplication.cs
deleted file mode 100644
index 96c07ef7802f..000000000000
--- a/src/Compatibility/Core/src/Tizen/IMEApplication.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using ElmSharp;
-using Tizen.Uix.InputMethod;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class IMEApplication : FormsApplication
- {
- public EditorWindow EditorWindow
- {
- get { return MainWindow as EditorWindow; }
- }
-
- protected IMEApplication()
- {
- }
-
- protected override void OnPreCreate()
- {
- Application.ClearCurrent();
-
- /*
- * Since the IMEWindow class acquires window handle from InputMethod module and
- * the handle is created internally when calling InputMethodEditor.Create() function,
- * this needs to be called BEFORE creating new IMEWindow instance.
- */
- InputMethodEditor.Create();
- MainWindow = InputMethodEditor.GetMainWindow();
- MainWindow.IndicatorMode = IndicatorMode.Hide;
- }
-
- protected override void OnTerminate()
- {
- InputMethodEditor.Destroy();
- base.OnTerminate();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/IRotaryInteraction.cs b/src/Compatibility/Core/src/Tizen/IRotaryInteraction.cs
deleted file mode 100644
index 16e34cfbdd97..000000000000
--- a/src/Compatibility/Core/src/Tizen/IRotaryInteraction.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using ElmSharp.Wearable;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public interface IRotaryInteraction
- {
- IRotaryActionWidget RotaryWidget { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/LightweightPlatform.cs b/src/Compatibility/Core/src/Tizen/LightweightPlatform.cs
deleted file mode 100644
index 71e404694419..000000000000
--- a/src/Compatibility/Core/src/Tizen/LightweightPlatform.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using ElmSharp;
-using Microsoft.Maui.Controls.Internals;
-using Microsoft.Maui.Devices;
-using EColor = ElmSharp.Color;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class LightweightPlatform : ITizenPlatform, INavigation, IDisposable
- {
- NavigationModel _navModel = new NavigationModel();
- Native.Canvas _viewStack;
- readonly PopupManager _popupManager;
- bool _hasAlpha;
- readonly EColor _defaultPlatformColor;
-
- public LightweightPlatform(EvasObject parent)
- {
- Forms.NativeParent = parent;
- _defaultPlatformColor = DeviceInfo.Idiom == DeviceIdiom.Phone ? EColor.White : EColor.Transparent;
- _viewStack = new Native.Canvas(parent)
- {
- BackgroundColor = _defaultPlatformColor,
- };
- _viewStack.SetAlignment(-1, -1);
- _viewStack.SetWeight(1.0, 1.0);
- _viewStack.LayoutUpdated += OnLayout;
- _viewStack.Show();
-
- if (Forms.UseMessagingCenter)
- {
- _popupManager = new PopupManager(this);
- }
- }
-
-#pragma warning disable 0067
- public event EventHandler RootNativeViewChanged;
-#pragma warning restore 0067
-
- public bool HasAlpha
- {
- get => _hasAlpha;
- set
- {
- _hasAlpha = value;
- _viewStack.BackgroundColor = _hasAlpha ? EColor.Transparent : _defaultPlatformColor;
- }
- }
-
- IPageController CurrentPageController => _navModel.CurrentPage as IPageController;
-
- IReadOnlyList INavigation.ModalStack => _navModel.Modals.ToList();
-
- IReadOnlyList INavigation.NavigationStack => new List();
-
- public void SetPage(Page page)
- {
- ResetChildren();
- _navModel = new NavigationModel();
- if (page == null)
- return;
-
- _navModel.Push(page, null);
-
- ((Application)page.RealParent).NavigationProxy.Inner = this;
-
- var renderer = Platform.CreateRenderer(page);
- renderer.NativeView.Geometry = _viewStack.Geometry;
- _viewStack.Children.Add(renderer.NativeView);
-
- CurrentPageController?.SendAppearing();
- }
-
- public bool SendBackButtonPressed()
- {
- return _navModel?.CurrentPage?.SendBackButtonPressed() ?? false;
- }
-
- public EvasObject GetRootNativeView()
- {
- return _viewStack;
- }
-
- public bool PageIsChildOfPlatform(Page page)
- {
- var parent = page.AncestorToRoot();
- return _navModel.Modals.FirstOrDefault() == page || _navModel.Roots.Contains(parent);
- }
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- _popupManager?.Dispose();
- _viewStack?.Unrealize();
- }
- }
-
- Task INavigation.PopModalAsync()
- {
- return (this as INavigation).PopModalAsync(true);
- }
-
- Task INavigation.PopModalAsync(bool animated)
- {
- Page page = _navModel.PopModal();
- (page as IPageController)?.SendDisappearing();
-
- var renderer = Platform.GetRenderer(page);
- _viewStack.Children.Remove(renderer.NativeView);
- renderer.Dispose();
-
- _viewStack.Children.LastOrDefault()?.Show();
-
- CurrentPageController?.SendAppearing();
- return Task.FromResult(page);
- }
-
- Task INavigation.PushModalAsync(Page modal)
- {
- return (this as INavigation).PushModalAsync(modal, true);
- }
-
- Task INavigation.PushModalAsync(Page page, bool animated)
- {
- var previousPage = CurrentPageController;
- previousPage?.SendDisappearing();
-
- _navModel.PushModal(page);
-
- var lastTop = _viewStack.Children.LastOrDefault();
-
- var renderer = Platform.GetOrCreateRenderer(page);
- renderer.NativeView.Geometry = _viewStack.Geometry;
-
- _viewStack.Children.Add(renderer.NativeView);
- if (lastTop != null)
- {
- lastTop.Hide();
- renderer.NativeView.StackAbove(lastTop);
- }
-
- // Verify that the modal is still on the stack
- if (_navModel.CurrentPage == page)
- CurrentPageController.SendAppearing();
- return Task.CompletedTask;
- }
-
- void INavigation.InsertPageBefore(Page page, Page before)
- {
- throw new InvalidOperationException("InsertPageBefore is not supported globally on Tizen, please use a NavigationPage.");
- }
-
- Task INavigation.PopAsync()
- {
- return ((INavigation)this).PopAsync(true);
- }
-
- Task INavigation.PopAsync(bool animated)
- {
- throw new InvalidOperationException("PopAsync is not supported globally on Tizen, please use a NavigationPage.");
- }
-
- Task INavigation.PopToRootAsync()
- {
- return ((INavigation)this).PopToRootAsync(true);
- }
-
- Task INavigation.PopToRootAsync(bool animated)
- {
- throw new InvalidOperationException("PopToRootAsync is not supported globally on Tizen, please use a NavigationPage.");
- }
-
- Task INavigation.PushAsync(Page root)
- {
- return ((INavigation)this).PushAsync(root, true);
- }
-
- Task INavigation.PushAsync(Page root, bool animated)
- {
- throw new InvalidOperationException("PushAsync is not supported globally on Tizen, please use a NavigationPage.");
- }
-
- void INavigation.RemovePage(Page page)
- {
- throw new InvalidOperationException("RemovePage is not supported globally on Tizen, please use a NavigationPage.");
- }
-
- void OnLayout(object sender, Native.LayoutEventArgs e)
- {
- foreach (var child in _viewStack.Children)
- {
- child.Geometry = _viewStack.Geometry;
- }
- }
-
- void ResetChildren()
- {
- var children = _viewStack.Children.ToList();
- _viewStack.Children.Clear();
- foreach (var child in children)
- {
- child.Unrealize();
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Native/BatchableExtensions.cs b/src/Compatibility/Core/src/Tizen/Native/BatchableExtensions.cs
deleted file mode 100644
index f931ddc1280c..000000000000
--- a/src/Compatibility/Core/src/Tizen/Native/BatchableExtensions.cs
+++ /dev/null
@@ -1,64 +0,0 @@
-using System.Runtime.CompilerServices;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native
-{
- internal static class BatchableExtensions
- {
- static readonly ConditionalWeakTable s_counters = new ConditionalWeakTable();
-
- public static void BatchBegin(this IBatchable target)
- {
- BatchCount value = null;
-
- if (s_counters.TryGetValue(target, out value))
- {
- value.Count++;
- }
- else
- {
- s_counters.Add(target, new BatchCount());
- }
- }
-
- public static void BatchCommit(this IBatchable target)
- {
- BatchCount value = null;
- if (s_counters.TryGetValue(target, out value))
- {
- value.Count--;
- if (value.Count == 0)
- {
- target.OnBatchCommitted();
- }
- else if (value.Count < 0)
- {
- Log.Error("Called BatchCommit() without BatchBegin().");
- value.Count = 0;
- }
- }
- else
- {
- Log.Error("Called BatchCommit() without BatchBegin().");
- }
- }
-
- public static bool IsBatched(this IBatchable target)
- {
- BatchCount value = null;
-
- if (s_counters.TryGetValue(target, out value))
- {
- return value.Count != 0;
- }
- else
- {
- return false;
- }
- }
-
- class BatchCount
- {
- public int Count = 1;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Native/BorderRectangle.cs b/src/Compatibility/Core/src/Tizen/Native/BorderRectangle.cs
deleted file mode 100644
index db0dcdb2c3bc..000000000000
--- a/src/Compatibility/Core/src/Tizen/Native/BorderRectangle.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-using System;
-using System.Collections.Generic;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native
-{
- public class BorderRectangle : RoundRectangle
- {
- public BorderRectangle(EvasObject parent) : base(parent) { }
-
- public int BorderWidth { get; set; }
-
- protected override void DrawPoints()
- {
- ClearPoints();
- if (BorderWidth > 0)
- {
- IReadOnlyList radius = GetRadius();
- DrawRect(radius[0], radius[1], radius[2], radius[3],
- 0, 0, Width, Height);
- DrawRect(Math.Max(radius[0] - BorderWidth, 0),
- Math.Max(radius[1] - BorderWidth, 0),
- Math.Max(radius[2] - BorderWidth, 0),
- Math.Max(radius[3] - BorderWidth, 0),
- BorderWidth, BorderWidth, Width - BorderWidth * 2, Height - BorderWidth * 2);
- }
- }
-
- protected void DrawRect(int topLeft, int topRight, int bottomLeft, int bottomRight, int startX, int startY, int width, int height)
- {
- int[] radius = new int[4];
- int maxR = Math.Min(width / 2, height / 2);
- radius[0] = Math.Min(topLeft, maxR);
- radius[1] = Math.Min(topRight, maxR);
- radius[2] = Math.Min(bottomLeft, maxR);
- radius[3] = Math.Min(bottomRight, maxR);
-
- Graphics.Point first = new Graphics.Point(-1, -1);
- for (int i = 0; i <= radius[0]; i++)
- {
- int x = i;
- int dx = radius[0] - x;
- int y = radius[0] - (int)Math.Sqrt((radius[0] * radius[0]) - (dx * dx));
- AddRelativePoint(startX + x, startY + y);
- if (first.X < 0 && first.Y < 0)
- {
- first.X = startX + x;
- first.Y = startY + y;
- }
- }
-
- AddRelativePoint(startX + width - radius[1], startY);
-
- for (int i = width - radius[1]; i <= width; i++)
- {
- int x = i;
- int dx = radius[1] - (width - x);
- int y = radius[1] - (int)Math.Sqrt((radius[1] * radius[1]) - (dx * dx));
- AddRelativePoint(startX + x, startY + y);
- }
-
- AddRelativePoint(startX + width, startY + height - radius[3]);
-
- for (int i = width; i >= width - radius[3]; i--)
- {
- int x = i;
- int dx = radius[3] - (width - x);
- int y = height - radius[3] + (int)Math.Sqrt((radius[3] * radius[3]) - (dx * dx));
- AddRelativePoint(startX + x, startY + y);
- }
-
- AddRelativePoint(startX + radius[2], startY + height);
-
- for (int i = radius[2]; i >= 0; i--)
- {
- int x = i;
- int dx = radius[2] - x;
- int y = height - radius[2] + (int)Math.Sqrt((radius[2] * radius[2]) - (dx * dx));
- AddRelativePoint(startX + x, startY + y);
- }
- AddRelativePoint((int)first.X, (int)first.Y);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Native/Box.cs b/src/Compatibility/Core/src/Tizen/Native/Box.cs
deleted file mode 100644
index 10e6d240f74e..000000000000
--- a/src/Compatibility/Core/src/Tizen/Native/Box.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using System;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-using ERect = ElmSharp.Rect;
-
-#if __MATERIAL__
-using Tizen.NET.MaterialComponents;
-#endif
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native
-{
-#if __MATERIAL__
- public class MaterialBox : MCard
- {
- public MaterialBox(EvasObject parent) : base(parent)
- {
- SetLayoutCallback(() => { NotifyOnLayout(); });
- }
-#else
- ///
- /// Extends the ElmSharp.Box class with functionality useful to Microsoft.Maui.Controls.Compatibility renderer.
- ///
- ///
- /// This class overrides the layout mechanism. Instead of using the native layout,
- /// LayoutUpdated event is sent.
- ///
- public class Box : EBox
- {
- public Box(EvasObject parent) : base(parent)
- {
- SetLayoutCallback(() => { NotifyOnLayout(); });
- }
-#endif
-
- ///
- /// Notifies that the layout has been updated.
- ///
- public event EventHandler LayoutUpdated;
-
- ///
- /// Triggers the LayoutUpdated event.
- ///
- ///
- /// This method is called whenever there is a possibility that the size and/or position has been changed.
- ///
- void NotifyOnLayout()
- {
- if (null != LayoutUpdated)
- {
- LayoutUpdated(this, new LayoutEventArgs() { Geometry = Geometry });
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Native/Button.cs b/src/Compatibility/Core/src/Tizen/Native/Button.cs
deleted file mode 100644
index f53ecefb664d..000000000000
--- a/src/Compatibility/Core/src/Tizen/Native/Button.cs
+++ /dev/null
@@ -1,282 +0,0 @@
-using System;
-using ElmSharp;
-using EButton = ElmSharp.Button;
-using EColor = ElmSharp.Color;
-using ESize = ElmSharp.Size;
-using TSButtonStyle = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.ButtonStyle;
-
-#if __MATERIAL__
-using Tizen.NET.MaterialComponents;
-#endif
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native
-{
-#if __MATERIAL__
- public class MaterialButton : MButton, IMeasurable, IBatchable, IButton
- {
- public MaterialButton(EvasObject parent) : base(parent)
- {
- }
-#else
- ///
- /// Extends the EButton control, providing basic formatting features,
- /// i.e. font color, size, additional image.
- ///
- public class Button : EButton, IMeasurable, IBatchable, IButton
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// Parent evas object.
- public Button(EvasObject parent) : base(parent)
- {
- }
-#endif
- ///
- /// Holds the formatted text of the button.
- ///
- readonly Span _span = new Span();
-
- ///
- /// Optional image, if set will be drawn on the button.
- ///
- Image _image;
-
- ///
- /// Gets or sets the button's text.
- ///
- /// The text.
- public override string Text
- {
- get
- {
- return _span.Text;
- }
-
- set
- {
- if (value != _span.Text)
- {
- _span.Text = value;
- ApplyTextAndStyle();
- }
- }
- }
-
- ///
- /// Gets or sets the color of the text.
- ///
- /// The color of the text.
- public EColor TextColor
- {
- get
- {
- return _span.ForegroundColor;
- }
-
- set
- {
- if (!_span.ForegroundColor.Equals(value))
- {
- _span.ForegroundColor = value;
- ApplyTextAndStyle();
- }
- }
- }
-
- ///
- /// Gets or sets the color of the text background.
- ///
- /// The color of the text background.
- public EColor TextBackgroundColor
- {
- get
- {
- return _span.BackgroundColor;
- }
-
- set
- {
- if (!_span.BackgroundColor.Equals(value))
- {
- _span.BackgroundColor = value;
- ApplyTextAndStyle();
- }
- }
- }
-
- ///
- /// Gets or sets the font family.
- ///
- /// The font family.
- public string FontFamily
- {
- get
- {
- return _span.FontFamily;
- }
-
- set
- {
- if (value != _span.FontFamily)
- {
- _span.FontFamily = value;
- ApplyTextAndStyle();
- }
- }
- }
-
- ///
- /// Gets or sets the font attributes.
- ///
- /// The font attributes.
- public FontAttributes FontAttributes
- {
- get
- {
- return _span.FontAttributes;
- }
-
- set
- {
- if (value != _span.FontAttributes)
- {
- _span.FontAttributes = value;
- ApplyTextAndStyle();
- }
- }
- }
-
- ///
- /// Gets or sets the size of the font.
- ///
- /// The size of the font.
- public double FontSize
- {
- get
- {
- return _span.FontSize;
- }
-
- set
- {
- if (value != _span.FontSize)
- {
- _span.FontSize = value;
- ApplyTextAndStyle();
- }
- }
- }
-
- ///
- /// Gets or sets the image to be displayed next to the button's text.
- ///
- /// The image displayed on the button.
- public Image Image
- {
- get
- {
- return _image;
- }
-
- set
- {
- if (value != _image)
- {
- ApplyImage(value);
- }
- }
- }
-
- ///
- /// Implementation of the IMeasurable.Measure() method.
- ///
- public virtual ESize Measure(int availableWidth, int availableHeight)
- {
- if (Style == TSButtonStyle.Circle)
- {
- return new ESize(MinimumWidth, MinimumHeight);
- }
- else
- {
- if (Image != null)
- MinimumWidth += Image.Geometry.Width;
-
- var rawSize = this.GetTextBlockNativeSize();
- return new ESize(rawSize.Width + MinimumWidth, Math.Max(MinimumHeight, rawSize.Height));
- }
- }
-
- void IBatchable.OnBatchCommitted()
- {
- ApplyTextAndStyle();
- }
-
- ///
- /// Applies the button's text and its style.
- ///
- void ApplyTextAndStyle()
- {
- if (!this.IsBatched())
- {
- SetInternalTextAndStyle(_span.GetDecoratedText(), _span.GetStyle());
- }
- }
-
- ///
- /// Sets the button's internal text and its style.
- ///
- /// Formatted text, supports HTML tags.
- /// Style applied to the formattedText.
- void SetInternalTextAndStyle(string formattedText, string textStyle)
- {
- bool isVisible = true;
- if (string.IsNullOrEmpty(formattedText))
- {
- formattedText = null;
- textStyle = null;
- isVisible = false;
- }
- base.Text = formattedText;
- this.SetTextBlockStyle(textStyle);
- this.SendTextVisibleSignal(isVisible);
- }
-
- ///
- /// Applies the image to be displayed on the button. If value is null,
- /// image will be removed.
- ///
- /// Image to be displayed or null.
- void ApplyImage(Image image)
- {
- _image = image;
-
- SetInternalImage();
- }
-
- ///
- /// Sets the internal image. If value is null, image will be removed.
- ///
- void SetInternalImage()
- {
- this.SetIconPart(_image);
- }
-
- ///
- /// Update the button's style
- ///
- /// The style of button
- public void UpdateStyle(string style)
- {
- if (Style != style)
- {
- Style = style;
- if (Style == TSButtonStyle.Default)
- _span.HorizontalTextAlignment = TextAlignment.Auto;
- else
- _span.HorizontalTextAlignment = TextAlignment.Center;
- ApplyTextAndStyle();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Native/Canvas.cs b/src/Compatibility/Core/src/Tizen/Native/Canvas.cs
deleted file mode 100644
index c90634a29d2b..000000000000
--- a/src/Compatibility/Core/src/Tizen/Native/Canvas.cs
+++ /dev/null
@@ -1,131 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using ElmSharp;
-
-#if __MATERIAL__
-using Tizen.NET.MaterialComponents;
-#endif
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native
-{
-#if __MATERIAL__
- public class MaterialCanvas : MaterialBox, IContainable
- {
- public MaterialCanvas(EvasObject parent) : base(parent)
- {
- Initilize();
- }
-
-#else
- ///
- /// A Canvas provides a class which can be a container for other controls.
- ///
- ///
- /// This class is used as a container view for Layouts from Microsoft.Maui.Controls.Compatibility.Platform.Tizen framework.
- /// It is used for implementing xamarin pages and layouts.
- ///
- public class Canvas : Box, IContainable
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// Canvas doesn't support replacing its children, this will be ignored.
- /// Parent of this instance.
- public Canvas(EvasObject parent) : base(parent)
- {
- Initilize();
- }
-#endif
-
- ///
- /// The list of Views.
- ///
- readonly ObservableCollection _children = new ObservableCollection();
-
- ///
- /// Gets list of native elements that are placed in the canvas.
- ///
- public new IList Children
- {
- get
- {
- return _children;
- }
- }
-
- ///
- /// Provides destruction for native element and contained elements.
- ///
- protected override void OnUnrealize()
- {
- foreach (var child in _children)
- {
- child.Unrealize();
- }
-
- base.OnUnrealize();
- }
-
- ///
- /// Initializes a new instance of the the class
- ///
- void Initilize()
- {
- _children.CollectionChanged += (o, e) =>
- {
- if (e.Action == NotifyCollectionChangedAction.Add)
- {
- foreach (var v in e.NewItems)
- {
- var view = v as EvasObject;
- if (null != view)
- {
- OnAdd(view);
- }
- }
- }
- else if (e.Action == NotifyCollectionChangedAction.Remove)
- {
- foreach (var v in e.OldItems)
- {
- var view = v as EvasObject;
- if (null != view)
- {
- OnRemove(view);
- }
- }
- }
- else if (e.Action == NotifyCollectionChangedAction.Reset)
- {
- OnRemoveAll();
- }
- };
- }
-
- ///
- /// Adds a new child to a container.
- ///
- /// Native element which will be added
- void OnAdd(EvasObject view)
- {
- PackEnd(view);
- }
-
- ///
- /// Removes a child from a container.
- ///
- /// Child element to be removed from canvas
- void OnRemove(EvasObject view)
- {
- UnPack(view);
- }
-
- ///
- /// Removes all children from a canvas.
- ///
- void OnRemoveAll()
- {
- UnPackAll();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Native/CollectionView/CarouselView.cs b/src/Compatibility/Core/src/Tizen/Native/CollectionView/CarouselView.cs
deleted file mode 100644
index a1207c500fad..000000000000
--- a/src/Compatibility/Core/src/Tizen/Native/CollectionView/CarouselView.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using ElmSharp;
-using EScroller = ElmSharp.Scroller;
-using ESize = ElmSharp.Size;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native
-{
- public class CarouselView : CollectionView, ICollectionViewController
- {
- public CarouselView(EvasObject parent) : base(parent)
- {
- SelectionMode = CollectionViewSelectionMode.Single;
- Scroll.ScrollBlock = ScrollBlock.None;
- SnapPointsType = SnapPointsType.MandatorySingle;
- }
-
- public EScroller Scroll => base.Scroller;
-
- ESize ICollectionViewController.GetItemSize(int widthConstraint, int heightConstraint)
- {
- return AllocatedSize;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Native/CollectionView/CollectionView.cs b/src/Compatibility/Core/src/Tizen/Native/CollectionView/CollectionView.cs
deleted file mode 100644
index 46dbbefb1d95..000000000000
--- a/src/Compatibility/Core/src/Tizen/Native/CollectionView/CollectionView.cs
+++ /dev/null
@@ -1,793 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.Linq;
-using Microsoft.Maui.Devices;
-using ElmSharp;
-using ElmSharp.Wearable;
-using EBox = ElmSharp.Box;
-using EPoint = ElmSharp.Point;
-using ERect = ElmSharp.Rect;
-using EScroller = ElmSharp.Scroller;
-using ESize = ElmSharp.Size;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native
-{
- public class CollectionView : EBox, ICollectionViewController, IRotaryInteraction
- {
- RecyclerPool _pool = new RecyclerPool();
- ICollectionViewLayoutManager _layoutManager;
- ItemAdaptor _adaptor;
- EBox _innerLayout;
- EvasObject _emptyView;
-
- Dictionary _viewHolderIndexTable = new Dictionary();
- ViewHolder _lastSelectedViewHolder;
- int _selectedItemIndex = -1;
- CollectionViewSelectionMode _selectionMode = CollectionViewSelectionMode.None;
-
- bool _requestLayoutItems = false;
- SnapPointsType _snapPoints;
- ESize _itemSize = new ESize(-1, -1);
-
- EvasObject _headerView;
- EvasObject _footerView;
- SmartEvent _scrollAnimationStop;
- SmartEvent _scrollAnimationStart;
- bool _isScrollAnimationStarted;
- bool _allowFocusOnItem;
-
- public event EventHandler Scrolled;
-
- public CollectionView(EvasObject parent) : base(parent)
- {
- AllowFocus(true);
- SetLayoutCallback(OnLayout);
- Scroller = CreateScroller(parent);
- Scroller.Show();
- PackEnd(Scroller);
- Scroller.Scrolled += OnScrolled;
-
- _scrollAnimationStart = new SmartEvent(Scroller, ThemeConstants.Scroller.Signals.StartScrollAnimation);
- _scrollAnimationStart.On += OnScrollStarted;
-
- _scrollAnimationStop = new SmartEvent(Scroller, ThemeConstants.Scroller.Signals.StopScrollAnimation);
- _scrollAnimationStop.On += OnScrollStopped;
-
- Scroller.DragStart += OnDragStart;
- Scroller.KeyDown += OnKeyDown;
-
- _innerLayout = new EBox(parent);
- _innerLayout.SetLayoutCallback(OnInnerLayout);
- _innerLayout.Show();
- Scroller.SetContent(_innerLayout);
- }
-
- public IRotaryActionWidget RotaryWidget { get => Scroller as IRotaryActionWidget; }
-
- public CollectionViewSelectionMode SelectionMode
- {
- get => _selectionMode;
- set
- {
- _selectionMode = value;
- UpdateSelectionMode();
- }
- }
-
- public int SelectedItemIndex
- {
- get => _selectedItemIndex;
- set
- {
- if (_selectedItemIndex != value)
- {
- _selectedItemIndex = value;
- UpdateSelectedItemIndex();
- }
- }
- }
-
- public SnapPointsType SnapPointsType
- {
- get => _snapPoints;
- set
- {
- _snapPoints = value;
- UpdateSnapPointsType(_snapPoints);
- }
- }
-
- protected EScroller Scroller { get; }
-
- public ICollectionViewLayoutManager LayoutManager
- {
- get => _layoutManager;
- set
- {
- OnLayoutManagerChanging();
- _layoutManager = value;
- OnLayoutManagerChanged();
- }
- }
-
- public ItemAdaptor Adaptor
- {
- get => _adaptor;
- set
- {
- OnAdaptorChanging();
- _adaptor = value;
- OnAdaptorChanged();
- }
- }
-
- public ScrollBarVisiblePolicy VerticalScrollBarVisiblePolicy
- {
- get => Scroller.VerticalScrollBarVisiblePolicy;
- set => Scroller.VerticalScrollBarVisiblePolicy = value;
- }
-
- public ScrollBarVisiblePolicy HorizontalScrollBarVisiblePolicy
- {
- get => Scroller.HorizontalScrollBarVisiblePolicy;
- set => Scroller.HorizontalScrollBarVisiblePolicy = value;
- }
-
- public ScrollToPosition FocusedItemScrollPosition { get; set; }
-
- int ICollectionViewController.Count
- {
- get
- {
- if (Adaptor == null || Adaptor is IEmptyAdaptor)
- return 0;
- return Adaptor.Count;
- }
- }
-
- EPoint ICollectionViewController.ParentPosition => new EPoint
- {
- X = Scroller.Geometry.X - Scroller.CurrentRegion.X,
- Y = Scroller.Geometry.Y - Scroller.CurrentRegion.Y
- };
-
- protected ESize AllocatedSize { get; set; }
-
- ERect ViewPort => Scroller.CurrentRegion;
-
- public void ScrollTo(int index, ScrollToPosition position = ScrollToPosition.MakeVisible, bool animate = true)
- {
- var itemBound = LayoutManager.GetItemBound(index);
- int itemStart;
- int itemEnd;
- int scrollStart;
- int scrollEnd;
- int itemPadding = 0;
- int itemSize;
- int viewportSize;
-
- if (LayoutManager.IsHorizontal)
- {
- itemStart = itemBound.Left;
- itemEnd = itemBound.Right;
- itemSize = itemBound.Width;
- scrollStart = Scroller.CurrentRegion.Left;
- scrollEnd = Scroller.CurrentRegion.Right;
- viewportSize = AllocatedSize.Width;
- }
- else
- {
- itemStart = itemBound.Top;
- itemEnd = itemBound.Bottom;
- itemSize = itemBound.Height;
- scrollStart = Scroller.CurrentRegion.Top;
- scrollEnd = Scroller.CurrentRegion.Bottom;
- viewportSize = AllocatedSize.Height;
- }
-
- if (position == ScrollToPosition.MakeVisible)
- {
- if (itemStart < scrollStart)
- {
- position = ScrollToPosition.Start;
- }
- else if (itemEnd > scrollEnd)
- {
- position = ScrollToPosition.End;
- }
- else
- {
- // already visible
- return;
- }
- }
-
- if (itemSize < viewportSize)
- {
- switch (position)
- {
- case ScrollToPosition.Center:
- itemPadding = (viewportSize - itemSize) / 2;
- break;
- case ScrollToPosition.End:
- itemPadding = (viewportSize - itemSize);
- break;
- }
- itemSize = viewportSize;
- }
-
- if (LayoutManager.IsHorizontal)
- {
- itemBound.X -= itemPadding;
- itemBound.Width = itemSize;
- }
- else
- {
- itemBound.Y -= itemPadding;
- itemBound.Height = itemSize;
- }
-
- Scroller.ScrollTo(itemBound, animate);
- }
-
- public void ScrollTo(object item, ScrollToPosition position = ScrollToPosition.MakeVisible, bool animate = true)
- {
- ScrollTo(Adaptor.GetItemIndex(item), position, animate);
- }
-
- public void ItemMeasureInvalidated(int index)
- {
- // If a first item size was updated, need to reset _itemSize
- if (index == 0)
- {
- _itemSize = new ESize(-1, -1);
- }
- LayoutManager?.ItemMeasureInvalidated(index);
- }
-
- void ICollectionViewController.RequestLayoutItems() => RequestLayoutItems();
-
- ESize ICollectionViewController.GetItemSize()
- {
- return (this as ICollectionViewController).GetItemSize(LayoutManager.IsHorizontal ? AllocatedSize.Width * 100 : AllocatedSize.Width, LayoutManager.IsHorizontal ? AllocatedSize.Height : AllocatedSize.Height * 100);
- }
-
- ESize ICollectionViewController.GetItemSize(int widthConstraint, int heightConstraint)
- {
- if (Adaptor == null)
- {
- return new ESize(0, 0);
- }
-
- if (_itemSize.Width > 0 && _itemSize.Height > 0)
- {
- return _itemSize;
- }
-
- _itemSize = Adaptor.MeasureItem(widthConstraint, heightConstraint);
- _itemSize.Width = Math.Max(_itemSize.Width, 10);
- _itemSize.Height = Math.Max(_itemSize.Height, 10);
-
- if (_snapPoints != SnapPointsType.None)
- {
- Scroller.SetPageSize(_itemSize.Width, _itemSize.Height);
- }
- return _itemSize;
- }
-
- ESize ICollectionViewController.GetItemSize(int index, int widthConstraint, int heightConstraint)
- {
- if (Adaptor == null)
- {
- return new ESize(0, 0);
- }
- return Adaptor.MeasureItem(index, widthConstraint, heightConstraint);
- }
-
- protected virtual ViewHolder CreateViewHolder()
- {
- return new ViewHolder(this);
- }
-
- ViewHolder ICollectionViewController.RealizeView(int index)
- {
- if (Adaptor == null)
- return null;
-
- var holder = _pool.GetRecyclerView(Adaptor.GetViewCategory(index));
- if (holder != null)
- {
- holder.Show();
- }
- else
- {
- var content = Adaptor.CreateNativeView(index, this);
- holder = CreateViewHolder();
- holder.RequestSelected += OnRequestItemSelection;
- holder.StateUpdated += OnItemStateChanged;
- holder.Content = content;
- holder.ViewCategory = Adaptor.GetViewCategory(index);
- _innerLayout.PackEnd(holder);
- }
-
- holder.AllowItemFocus = _allowFocusOnItem;
-
- Adaptor.SetBinding(holder.Content, index);
- _viewHolderIndexTable[holder] = index;
- if (index == SelectedItemIndex)
- {
- OnRequestItemSelection(holder, EventArgs.Empty);
- }
- return holder;
- }
-
- void OnItemStateChanged(object sender, EventArgs e)
- {
- ViewHolder holder = (ViewHolder)sender;
- if (holder.Content != null)
- {
- Adaptor?.UpdateViewState(holder.Content, holder.State);
- }
-
- if (holder.State == ViewHolderState.Focused && FocusedItemScrollPosition != ScrollToPosition.MakeVisible)
- {
-
- Application.Current.Dispatcher.Dispatch(() =>
- {
- if (holder.State == ViewHolderState.Focused && _viewHolderIndexTable.TryGetValue(holder, out int itemIndex))
- {
- ScrollTo(itemIndex, FocusedItemScrollPosition, true);
- }
- });
- }
- }
-
- void OnRequestItemSelection(object sender, EventArgs e)
- {
- if (SelectionMode == CollectionViewSelectionMode.None)
- return;
-
- if (_lastSelectedViewHolder != null)
- {
- _lastSelectedViewHolder.ResetState();
- }
-
- _lastSelectedViewHolder = sender as ViewHolder;
- if (_lastSelectedViewHolder != null)
- {
- _lastSelectedViewHolder.State = ViewHolderState.Selected;
- if (_viewHolderIndexTable.TryGetValue(_lastSelectedViewHolder, out int index))
- {
- _selectedItemIndex = index;
- Adaptor?.SendItemSelected(index);
- }
- }
- }
-
- void ICollectionViewController.UnrealizeView(ViewHolder view)
- {
- _viewHolderIndexTable.Remove(view);
- Adaptor.UnBinding(view.Content);
- view.ResetState();
- view.Hide();
-
- _pool.AddRecyclerView(view);
- if (_lastSelectedViewHolder == view)
- {
- _lastSelectedViewHolder = null;
- }
- }
-
- void ICollectionViewController.ContentSizeUpdated()
- {
- OnInnerLayout();
- }
-
- protected virtual EScroller CreateScroller(EvasObject parent)
- {
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- return new CircleScroller(parent, Forms.CircleSurface);
- }
- else
- {
- return new EScroller(parent);
- }
- }
-
- void UpdateSelectedItemIndex()
- {
- if (SelectionMode == CollectionViewSelectionMode.None)
- return;
-
- ViewHolder holder = null;
- foreach (var item in _viewHolderIndexTable)
- {
- if (item.Value == SelectedItemIndex)
- {
- holder = item.Key;
- break;
- }
- }
- OnRequestItemSelection(holder, EventArgs.Empty);
- }
-
- void UpdateSelectionMode()
- {
- if (SelectionMode == CollectionViewSelectionMode.None)
- {
- if (_lastSelectedViewHolder != null)
- {
- _lastSelectedViewHolder.ResetState();
- _lastSelectedViewHolder = null;
- }
- _selectedItemIndex = -1;
- }
- }
-
- void OnLayoutManagerChanging()
- {
- _layoutManager?.Reset();
- }
-
- void OnLayoutManagerChanged()
- {
- if (_layoutManager == null)
- return;
-
- _itemSize = new ESize(-1, -1);
- _layoutManager.CollectionView = this;
- _layoutManager.SizeAllocated(AllocatedSize);
- UpdateSnapPointsType(SnapPointsType);
- if (Adaptor != null)
- {
- LayoutManager?.SetHeader(_headerView, Adaptor.MeasureHeader(AllocatedSize.Width, AllocatedSize.Height));
- LayoutManager?.SetFooter(_footerView, Adaptor.MeasureFooter(AllocatedSize.Width, AllocatedSize.Height));
- }
- RequestLayoutItems();
- }
-
- void OnAdaptorChanging()
- {
- if (Adaptor is IEmptyAdaptor)
- {
- RemoveEmptyView();
- }
- else
- {
- if (_headerView != null)
- {
- _innerLayout.UnPack(_headerView);
- _headerView.Unrealize();
- }
- if (_footerView != null)
- {
- _innerLayout.UnPack(_footerView);
- _footerView.Unrealize();
- }
- }
- _headerView = null;
- _footerView = null;
-
- _layoutManager?.Reset();
- if (Adaptor != null)
- {
- _pool.Clear(Adaptor);
- (Adaptor as INotifyCollectionChanged).CollectionChanged -= OnCollectionChanged;
- Adaptor.CollectionView = null;
- }
- }
-
- void OnAdaptorChanged()
- {
- if (_adaptor == null)
- return;
-
- _itemSize = new ESize(-1, -1);
- Adaptor.CollectionView = this;
- (Adaptor as INotifyCollectionChanged).CollectionChanged += OnCollectionChanged;
-
- UpdateSnapPointsType(SnapPointsType);
- LayoutManager?.ItemSourceUpdated();
- RequestLayoutItems();
-
- if (Adaptor is IEmptyAdaptor)
- {
- CreateEmptyView();
- }
- else
- {
- _headerView = Adaptor.GetHeaderView(this);
- if (_headerView != null)
- {
- _innerLayout.PackEnd(_headerView);
- }
- _footerView = Adaptor.GetFooterView(this);
- if (_footerView != null)
- {
- _innerLayout.PackEnd(_footerView);
- }
- LayoutManager?.SetHeader(_headerView, Adaptor.MeasureHeader(AllocatedSize.Width, AllocatedSize.Height));
- LayoutManager?.SetFooter(_footerView, Adaptor.MeasureFooter(AllocatedSize.Width, AllocatedSize.Height));
- }
- }
-
- void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- // CollectionChanged could be called when Apaptor was changed on CollectionChanged event
- if (Adaptor is IEmptyAdaptor)
- {
- return;
- }
-
- if (e.Action == NotifyCollectionChangedAction.Add)
- {
- int idx = e.NewStartingIndex;
- if (idx == -1)
- {
- idx = Adaptor.Count - e.NewItems.Count;
- }
- foreach (var item in e.NewItems)
- {
- foreach (var viewHolder in _viewHolderIndexTable.Keys.ToList())
- {
- if (_viewHolderIndexTable[viewHolder] >= idx)
- {
- _viewHolderIndexTable[viewHolder]++;
- }
- }
- LayoutManager.ItemInserted(idx++);
- }
- }
- else if (e.Action == NotifyCollectionChangedAction.Remove)
- {
- int idx = e.OldStartingIndex;
-
- // Can't tracking remove if there is no data of old index
- if (idx == -1)
- {
- LayoutManager.ItemSourceUpdated();
- }
- else
- {
- foreach (var item in e.OldItems)
- {
- LayoutManager.ItemRemoved(idx);
- foreach (var viewHolder in _viewHolderIndexTable.Keys.ToList())
- {
- if (_viewHolderIndexTable[viewHolder] > idx)
- {
- _viewHolderIndexTable[viewHolder]--;
- }
- }
- }
- }
- }
- else if (e.Action == NotifyCollectionChangedAction.Move)
- {
- LayoutManager.ItemRemoved(e.OldStartingIndex);
- LayoutManager.ItemInserted(e.NewStartingIndex);
- }
- else if (e.Action == NotifyCollectionChangedAction.Replace)
- {
- // Can't tracking if there is no information old data
- if (e.OldItems.Count > 1 || e.NewStartingIndex == -1)
- {
- LayoutManager.ItemSourceUpdated();
- }
- else
- {
- LayoutManager.ItemUpdated(e.NewStartingIndex);
- }
- }
- else if (e.Action == NotifyCollectionChangedAction.Reset)
- {
- LayoutManager.Reset();
- LayoutManager.ItemSourceUpdated();
- }
- RequestLayoutItems();
- }
-
- ERect _lastGeometry;
- void OnLayout()
- {
- if (_lastGeometry == Geometry)
- {
- return;
- }
-
- _lastGeometry = Geometry;
- Scroller.Geometry = Geometry;
- Scroller.ScrollBlock = ScrollBlock.None;
- AllocatedSize = Geometry.Size;
- _itemSize = new ESize(-1, -1);
-
- if (_adaptor != null && _layoutManager != null)
- {
- _layoutManager?.SizeAllocated(Geometry.Size);
-
- _layoutManager?.LayoutItems(ViewPort);
- _layoutManager?.SetHeader(_headerView, Adaptor.MeasureHeader(AllocatedSize.Width, AllocatedSize.Height));
- _layoutManager?.SetFooter(_footerView, Adaptor.MeasureFooter(AllocatedSize.Width, AllocatedSize.Height));
- Scroller.ScrollBlock = LayoutManager.IsHorizontal ? ScrollBlock.Vertical : ScrollBlock.Horizontal;
- Scroller.HorizontalStepSize = _layoutManager.GetScrollBlockSize();
- Scroller.VerticalStepSize = _layoutManager.GetScrollBlockSize();
- UpdateSnapPointsType(SnapPointsType);
- Application.Current.Dispatcher.Dispatch(SendScrolledEvent);
- }
- }
-
- void RequestLayoutItems()
- {
- if (AllocatedSize.Width <= 0 || AllocatedSize.Height <= 0)
- return;
-
- if (!_requestLayoutItems)
- {
- _requestLayoutItems = true;
- Application.Current.Dispatcher.Dispatch(() =>
- {
- _requestLayoutItems = false;
- if (_adaptor != null && _layoutManager != null)
- {
- OnInnerLayout();
- _layoutManager?.LayoutItems(ViewPort, true);
- }
- });
- }
- }
-
- void OnInnerLayout()
- {
- // OnInnerLayout was called when child item was added
- // so, need to check scroll canvas size
- var size = _layoutManager.GetScrollCanvasSize();
- _innerLayout.MinimumWidth = size.Width;
- _innerLayout.MinimumHeight = size.Height;
- }
-
- int _previousHorizontalOffset = 0;
- int _previousVerticalOffset = 0;
-
- void OnScrollStarted(object sender, EventArgs e)
- {
- _isScrollAnimationStarted = true;
- }
-
- void OnScrollStopped(object sender, EventArgs e)
- {
- SendScrolledEvent();
- _isScrollAnimationStarted = false;
- }
-
- void OnScrolled(object sender, EventArgs e)
- {
- _layoutManager.LayoutItems(ViewPort);
- if (!_isScrollAnimationStarted)
- {
- SendScrolledEvent();
- }
- }
-
- void OnKeyDown(object sender, EvasKeyEventArgs e)
- {
- _allowFocusOnItem = true;
- UpdateAllowFocusOnItem(_allowFocusOnItem);
- }
-
- void OnDragStart(object sender, EventArgs e)
- {
- _allowFocusOnItem = false;
- UpdateAllowFocusOnItem(_allowFocusOnItem);
- }
-
- void SendScrolledEvent()
- {
- var args = new ItemsViewScrolledEventArgs();
- args.FirstVisibleItemIndex = _layoutManager.GetVisibleItemIndex(ViewPort.X, ViewPort.Y);
- args.CenterItemIndex = _layoutManager.GetVisibleItemIndex(ViewPort.X + (ViewPort.Width / 2), ViewPort.Y + (ViewPort.Height / 2));
- args.LastVisibleItemIndex = _layoutManager.GetVisibleItemIndex(ViewPort.X + ViewPort.Width, ViewPort.Y + ViewPort.Height);
- args.HorizontalOffset = ViewPort.X;
- args.HorizontalDelta = ViewPort.X - _previousHorizontalOffset;
- args.VerticalOffset = ViewPort.Y;
- args.VerticalDelta = ViewPort.Y - _previousVerticalOffset;
-
- Scrolled?.Invoke(this, args);
-
- _previousHorizontalOffset = ViewPort.X;
- _previousVerticalOffset = ViewPort.Y;
- }
-
- void UpdateSnapPointsType(SnapPointsType snapPoints)
- {
- if (LayoutManager == null)
- return;
-
- int itemSize = 0;
- switch (snapPoints)
- {
- case SnapPointsType.None:
- Scroller.HorizontalPageScrollLimit = 0;
- Scroller.VerticalPageScrollLimit = 0;
- itemSize = 0;
- break;
- case SnapPointsType.MandatorySingle:
- Scroller.HorizontalPageScrollLimit = 1;
- Scroller.VerticalPageScrollLimit = 1;
- itemSize = LayoutManager.GetScrollBlockSize();
- break;
- case SnapPointsType.Mandatory:
- Scroller.HorizontalPageScrollLimit = 0;
- Scroller.VerticalPageScrollLimit = 0;
- itemSize = LayoutManager.GetScrollBlockSize();
- break;
- }
-
- if (LayoutManager.IsHorizontal)
- {
- Scroller.SetPageSize(itemSize, 0);
- }
- else
- {
- Scroller.SetPageSize(0, itemSize);
- }
- }
-
- void CreateEmptyView()
- {
- _emptyView = Adaptor.CreateNativeView(this);
- _emptyView.Show();
- Adaptor.SetBinding(_emptyView, 0);
- _emptyView.Geometry = Geometry;
- _emptyView.MinimumHeight = Geometry.Height;
- _emptyView.MinimumWidth = Geometry.Width;
-
- Scroller.SetContent(_emptyView, true);
- _innerLayout.Hide();
- }
-
- void RemoveEmptyView()
- {
- _innerLayout.Show();
- Scroller.SetContent(_innerLayout, true);
- Adaptor.RemoveNativeView(_emptyView);
- _emptyView = null;
- }
-
- void UpdateAllowFocusOnItem(bool allowFocus)
- {
- foreach (var holer in _viewHolderIndexTable)
- {
- holer.Key.AllowItemFocus = allowFocus;
- }
- }
- }
-
- public interface ICollectionViewController
- {
- EPoint ParentPosition { get; }
-
- ViewHolder RealizeView(int index);
-
- void UnrealizeView(ViewHolder view);
-
- void RequestLayoutItems();
-
- int Count { get; }
-
- ESize GetItemSize();
-
- ESize GetItemSize(int widthConstraint, int heightConstraint);
-
- ESize GetItemSize(int index, int widthConstraint, int heightConstraint);
-
- void ContentSizeUpdated();
- }
-
- public enum CollectionViewSelectionMode
- {
- None,
- Single,
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Native/CollectionView/EmptyItemAdaptor.cs b/src/Compatibility/Core/src/Tizen/Native/CollectionView/EmptyItemAdaptor.cs
deleted file mode 100644
index f194c7e3a678..000000000000
--- a/src/Compatibility/Core/src/Tizen/Native/CollectionView/EmptyItemAdaptor.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using ElmSharp;
-using ESize = ElmSharp.Size;
-using XLabel = Microsoft.Maui.Controls.Label;
-using XStackLayout = Microsoft.Maui.Controls.StackLayout;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native
-{
- [System.Obsolete]
- public class EmptyItemAdaptor : ItemTemplateAdaptor, IEmptyAdaptor
- {
- static DataTemplate s_defaultEmptyTemplate = new DataTemplate(typeof(EmptyView));
-
- StructuredItemsView _structuredItemsView;
- public EmptyItemAdaptor(ItemsView itemsView, IEnumerable items, DataTemplate template) : base(itemsView, items, template)
- {
- _structuredItemsView = itemsView as StructuredItemsView;
- }
-
- public static EmptyItemAdaptor Create(ItemsView itemsView)
- {
- DataTemplate template = null;
- if (itemsView.EmptyView is View emptyView)
- {
- template = new DataTemplate(() =>
- {
- return emptyView;
- });
- }
- else
- {
- template = itemsView.EmptyViewTemplate ?? s_defaultEmptyTemplate;
- }
- var empty = new List
/// The native view.
- EvasObject NativeView
+ NView NativeView
{
get;
}
@@ -39,7 +38,5 @@ EvasObject NativeView
SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint);
void UpdateLayout();
-
- ERect GetNativeContentGeometry();
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/ImageButtonRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/ImageButtonRenderer.cs
deleted file mode 100644
index 28bf84ee0c65..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/ImageButtonRenderer.cs
+++ /dev/null
@@ -1,197 +0,0 @@
-using System;
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-using EButton = ElmSharp.Button;
-using ERect = ElmSharp.Rect;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ImageButtonRenderer : ViewRenderer
- {
- public ImageButtonRenderer()
- {
- RegisterPropertyHandler(ImageButton.SourceProperty, UpdateSource);
- RegisterPropertyHandler(ImageButton.PaddingProperty, UpdatePadding);
- RegisterPropertyHandler(ImageButton.CornerRadiusProperty, UpdateRadius);
- RegisterPropertyHandler(ImageButton.BorderWidthProperty, UpdateBorderWidth);
- RegisterPropertyHandler(ImageButton.BorderColorProperty, UpdateBorderColor);
- RegisterPropertyHandler(ImageButton.AspectProperty, UpdateAspect);
- }
-
- Native.Image _image;
- EButton _button;
- Native.RoundRectangle _round;
- Native.BorderRectangle _border;
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new Box(Forms.NativeParent));
- Control.SetLayoutCallback(OnLayout);
- _round = new Native.RoundRectangle(Forms.NativeParent);
- _round.Show();
- _border = new Native.BorderRectangle(Forms.NativeParent);
- _border.Show();
- _image = new Native.Image(Forms.NativeParent);
- _image.Show();
- _button = new EButton(Forms.NativeParent).SetTransparentStyle();
- _button.Clicked += OnClicked;
- _button.Pressed += OnPressed;
- _button.Released += OnReleased;
- _button.Show();
- _button.Focused += OnFocused;
- _button.Unfocused += OnUnfocused;
- Control.PackEnd(_round);
- Control.PackEnd(_image);
- Control.PackEnd(_border);
- Control.PackEnd(_button);
- }
- base.OnElementChanged(e);
- }
-
- protected virtual void UpdateAfterLoading()
- {
- if (_image.IsOpaque != Element.IsOpaque)
- _image.IsOpaque = Element.IsOpaque;
- }
-
- protected override ElmSharp.Size Measure(int availableWidth, int availableHeight)
- {
- var size = _image.Measure(availableHeight, availableHeight);
- size.Width += Forms.ConvertToScaledPixel(Element.Padding.HorizontalThickness);
- size.Height += Forms.ConvertToScaledPixel(Element.Padding.VerticalThickness);
- return size;
- }
-
- protected override void UpdateBackgroundColor(bool initialize)
- {
- _round.Color = Element.BackgroundColor.ToNative();
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (_button != null)
- {
- _button.Clicked -= OnClicked;
- _button.Pressed -= OnPressed;
- _button.Released -= OnReleased;
- _button.Focused -= OnFocused;
- _button.Unfocused -= OnUnfocused;
- _button = null;
- }
- }
- base.Dispose(disposing);
- }
-
- void OnReleased(object sender, EventArgs e)
- {
- (Element as IButtonController)?.SendReleased();
- }
-
- void OnPressed(object sender, EventArgs e)
- {
- (Element as IButtonController)?.SendPressed();
- }
-
- void OnClicked(object sender, EventArgs e)
- {
- (Element as IButtonController)?.SendClicked();
- }
-
- void OnLayout()
- {
- var outter = Control.Geometry;
- var width = outter.Width - Forms.ConvertToScaledPixel(Element.Padding.HorizontalThickness);
- var height = outter.Height - Forms.ConvertToScaledPixel(Element.Padding.VerticalThickness);
- var left = outter.Left + Forms.ConvertToScaledPixel(Element.Padding.Left);
- var top = outter.Top + Forms.ConvertToScaledPixel(Element.Padding.Top);
- var imageBound = new ERect(left, top, width, height);
-
- _image.Geometry = imageBound;
- _button.Geometry = outter;
- _round.Draw(outter);
- _border.Draw(outter);
- }
-
- void UpdatePadding()
- {
- Control.MarkChanged();
- }
-
- async void UpdateSource()
- {
- ImageSource source = Element.Source;
- (Element as IImageController)?.SetIsLoading(true);
-
- if (Control != null)
- {
- bool success;
- if (source is FileImageSource fis)
- {
- success = _image.LoadFromFile(fis.File);
- }
- else
- {
- success = await _image.LoadFromImageSourceAsync(source);
- }
-
- if (!IsDisposed && success)
- {
- (Element as IVisualElementController)?.PlatformSizeChanged();
- UpdateAfterLoading();
- }
- }
-
- if (!IsDisposed)
- ((IImageController)Element).SetIsLoading(false);
- }
-
- void UpdateRadius(bool init)
- {
- if (Element.CornerRadius > 0)
- {
- _round.SetRadius(Forms.ConvertToScaledPixel(Element.CornerRadius));
- _border.SetRadius(Forms.ConvertToScaledPixel(Element.CornerRadius));
- }
- else
- {
- _round.SetRadius(0);
- _border.SetRadius(0);
- }
- if (!init)
- {
- _round.Draw();
- _border.Draw();
- }
- }
-
- void UpdateBorderWidth(bool init)
- {
- if (Element.BorderWidth > 0)
- {
- _border.BorderWidth = Forms.ConvertToScaledPixel(Element.BorderWidth);
- }
- else
- {
- _border.BorderWidth = 0;
- }
- if (!init)
- {
- _border.Draw();
- }
- }
-
- void UpdateBorderColor()
- {
- _border.Color = Element.BorderColor.ToNative();
- }
-
- void UpdateAspect()
- {
- _image.ApplyAspect(Element.Aspect);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/ImageRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/ImageRenderer.cs
index 63c9c977d333..693f8f6744b9 100644
--- a/src/Compatibility/Core/src/Tizen/Renderers/ImageRenderer.cs
+++ b/src/Compatibility/Core/src/Tizen/Renderers/ImageRenderer.cs
@@ -1,30 +1,29 @@
-using System.ComponentModel;
+using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Maui.Controls.Platform;
-using EImage = ElmSharp.Image;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.Image;
+using Tizen.UIExtensions.NUI;
+using CAspect = Tizen.UIExtensions.Common.Aspect;
+using NImage = Tizen.UIExtensions.NUI.Image;
+using NUIImage = Tizen.NUI.BaseComponents.ImageView;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ImageRenderer : ViewRenderer
+ public class ImageRenderer : ViewRenderer
{
public ImageRenderer()
{
RegisterPropertyHandler(Image.SourceProperty, UpdateSource);
RegisterPropertyHandler(Image.AspectProperty, UpdateAspect);
- RegisterPropertyHandler(Image.IsOpaqueProperty, UpdateIsOpaque);
RegisterPropertyHandler(Image.IsAnimationPlayingProperty, UpdateIsAnimationPlaying);
- RegisterPropertyHandler(Specific.BlendColorProperty, UpdateBlendColor);
- RegisterPropertyHandler(Specific.FileProperty, UpdateFile);
}
protected override void OnElementChanged(ElementChangedEventArgs e)
{
if (Control == null)
{
- SetNativeControl(new Native.Image(Forms.NativeParent));
+ SetNativeControl(new NImage());
}
base.OnElementChanged(e);
}
@@ -52,112 +51,82 @@ async void UpdateSource(bool initialize)
((IImageController)Element).SetIsLoading(false);
}
- void UpdateFile(bool initialize)
- {
- if (initialize && Specific.GetFile(Element) == default || Element.Source != default(ImageSource))
- return;
-
- if (Control != null)
- {
- bool success = Control.LoadFromFile(Specific.GetFile(Element));
-
- if (!IsDisposed && success)
- {
- ((IVisualElementController)Element).PlatformSizeChanged();
- UpdateAfterLoading(initialize);
- }
- }
- }
-
protected virtual void UpdateAfterLoading(bool initialize)
{
- UpdateIsOpaque(initialize);
- UpdateBlendColor(initialize);
- UpdateIsAnimationPlaying(initialize);
- }
-
- void UpdateAspect(bool initialize)
- {
- if (initialize && Element.Aspect == Aspect.AspectFit)
- return;
-
- Control.ApplyAspect(Element.Aspect);
}
- void UpdateIsOpaque(bool initialize)
+ void UpdateAspect()
{
- if (initialize && !Element.IsOpaque)
- return;
-
- Control.IsOpaque = Element.IsOpaque;
+ Control.Aspect = (CAspect)Element.Aspect;
}
void UpdateIsAnimationPlaying(bool initialize)
{
- if (initialize && !Element.IsAnimationPlaying)
+ // Default behavior of animation is true on NUI
+ if (initialize && Element.IsAnimationPlaying)
return;
-
- Control.IsAnimated = Element.IsAnimationPlaying;
- Control.IsAnimationPlaying = Element.IsAnimationPlaying;
- }
-
- void UpdateBlendColor(bool initialize)
- {
- if (initialize && Specific.GetBlendColor(Element) == null)
- return;
-
- Control.Color = Specific.GetBlendColor(Element).ToPlatformEFL();
+ Control.SetIsAnimationPlaying(Element.IsAnimationPlaying);
}
}
public interface IImageSourceHandler : IRegisterable
{
- Task LoadImageAsync(EImage image, ImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken));
+ Task LoadImageAsync(NUIImage image, ImageSource imageSource, CancellationToken cancellationToken = default(CancellationToken));
}
public sealed class FileImageSourceHandler : IImageSourceHandler
{
- public Task LoadImageAsync(EImage image, ImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken))
+ public async Task LoadImageAsync(NUIImage image, ImageSource imageSource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (image == null)
+ return false;
+ var path = ResourcePath.GetPath(imageSource);
+ return await image.LoadAsync(path);
+ }
+ }
+
+ public sealed class UriImageSourceHandler : IImageSourceHandler
+ {
+ public async Task LoadImageAsync(NUIImage image, ImageSource imageSource, CancellationToken cancellationToken = default(CancellationToken))
{
- var filesource = imageSource as FileImageSource;
- if (filesource != null)
+ if (image == null)
+ return false;
+
+ if (imageSource is UriImageSource src)
+ {
+ return await image.LoadAsync(src.Uri.AbsoluteUri);
+ }
+ else
{
- string file = filesource.File;
- if (!string.IsNullOrEmpty(file))
- return image.LoadAsync(ResourcePath.GetPath(file), cancelationToken);
+ return false;
}
- return Task.FromResult(false);
}
}
public sealed class StreamImageSourceHandler : IImageSourceHandler
{
- public async Task LoadImageAsync(EImage image, ImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken))
+ public async Task LoadImageAsync(NUIImage image, ImageSource imageSource, CancellationToken cancellationToken = default(CancellationToken))
{
- var streamsource = imageSource as StreamImageSource;
- if (streamsource != null && streamsource.Stream != null)
+ if (image == null)
+ return false;
+
+ if (imageSource is StreamImageSource streamsource && streamsource.Stream != null)
{
- using (var streamImage = await ((IStreamImageSource)streamsource).GetStreamAsync(cancelationToken))
+ using (var streamImage = await ((IStreamImageSource)streamsource).GetStreamAsync(cancellationToken))
{
- if (streamImage != null)
- return await image.LoadAsync(streamImage, cancelationToken);
+ if (streamImage != null && image is NImage nimage)
+ return await nimage.LoadAsync(streamImage);
}
}
return false;
}
}
- public sealed class UriImageSourceHandler : IImageSourceHandler
+ public sealed class FontImageSourceHandler : IImageSourceHandler
{
- public Task LoadImageAsync(EImage image, ImageSource imageSource, CancellationToken cancelationToken = default(CancellationToken))
+ public Task LoadImageAsync(NUIImage image, ImageSource imageSource, CancellationToken cancellationToken = default(CancellationToken))
{
- var urisource = imageSource as UriImageSource;
- if (urisource != null && urisource.Uri != null)
- {
- return image.LoadAsync(urisource.Uri, cancelationToken);
- }
-
- return Task.FromResult(false);
+ throw new NotSupportedException($"FontImageSource: {imageSource}");
}
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/IndicatorViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/IndicatorViewRenderer.cs
deleted file mode 100644
index b7f8b5f8b51f..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/IndicatorViewRenderer.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class IndicatorViewRenderer : ViewRenderer
- {
- public IndicatorViewRenderer()
- {
- RegisterPropertyHandler(IndicatorView.CountProperty, UpdateCount);
- RegisterPropertyHandler(IndicatorView.PositionProperty, UpdatePosition);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new Native.IndicatorView(Forms.NativeParent));
- }
- if (e.NewElement != null)
- {
- Control.SelectedPosition += OnSelectedPosition;
- }
- if (e.OldElement != null)
- {
- Control.SelectedPosition -= OnSelectedPosition;
- }
- base.OnElementChanged(e);
- }
-
- void OnSelectedPosition(object sender, SelectedPositionChangedEventArgs e)
- {
- Element.SetValueFromRenderer(IndicatorView.PositionProperty, (int)e.SelectedPosition);
- }
-
- void UpdateCount()
- {
- Control.ClearIndex();
- Control.AppendIndex(Element.Count);
- Control.Update(0);
- UpdatePosition();
- }
-
- void UpdatePosition()
- {
- Control.UpdateSelectedIndex(Element.Position);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/ItemsViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/ItemsViewRenderer.cs
deleted file mode 100644
index 4b7bb631f85d..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/ItemsViewRenderer.cs
+++ /dev/null
@@ -1,222 +0,0 @@
-using System.Collections.Specialized;
-using System.Linq;
-
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.ItemsView;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public abstract class ItemsViewRenderer : ViewRenderer
- where TItemsView : ItemsView
- where TNative : Native.CollectionView
- {
- INotifyCollectionChanged _observableSource;
-
- protected IItemsLayout ItemsLayout { get; private set; }
-
- public ItemsViewRenderer()
- {
- RegisterPropertyHandler(ItemsView.ItemsSourceProperty, UpdateItemsSource);
- RegisterPropertyHandler(ItemsView.ItemTemplateProperty, UpdateAdaptor);
- RegisterPropertyHandler(ItemsView.HorizontalScrollBarVisibilityProperty, UpdateHorizontalScrollBarVisibility);
- RegisterPropertyHandler(ItemsView.VerticalScrollBarVisibilityProperty, UpdateVerticalScrollBarVisibility);
- RegisterPropertyHandler(Specific.FocusedItemScrollPositionProperty, UpdateFocusedItemScrollPosition);
- }
-
- protected abstract TNative CreateNativeControl(ElmSharp.EvasObject parent);
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(CreateNativeControl(Forms.NativeParent));
- Control.Scrolled += OnScrolled;
- }
- if (e.NewElement != null)
- {
- e.NewElement.ScrollToRequested += OnScrollToRequest;
- }
- base.OnElementChanged(e);
- ItemsLayout = GetItemsLayout();
- UpdateAdaptor(false);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Element != null)
- {
- Element.ScrollToRequested -= OnScrollToRequest;
- ItemsLayout.PropertyChanged -= OnLayoutPropertyChanged;
- Control.Scrolled -= OnScrolled;
- }
- if (_observableSource != null)
- {
- _observableSource.CollectionChanged -= OnCollectionChanged;
- }
- }
- base.Dispose(disposing);
- }
-
- protected void UpdateItemsLayout()
- {
- if (ItemsLayout != null)
- {
- ItemsLayout.PropertyChanged -= OnLayoutPropertyChanged;
- }
- ItemsLayout = GetItemsLayout();
- if (ItemsLayout != null)
- {
- Control.LayoutManager = ItemsLayout.ToLayoutManager((Element as CollectionView)?.ItemSizingStrategy ?? ItemSizingStrategy.MeasureFirstItem);
- Control.SnapPointsType = ((ItemsLayout)ItemsLayout)?.SnapPointsType ?? SnapPointsType.None;
- ItemsLayout.PropertyChanged += OnLayoutPropertyChanged;
- }
- }
-
- protected override void AddChild(Element child)
- {
- // empty on purpose
- }
- protected override void RemoveChild(VisualElement view)
- {
- // empty on purpose
- }
-
- protected virtual void OnLayoutPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- if (e.PropertyName == nameof(Microsoft.Maui.Controls.ItemsLayout.SnapPointsType))
- {
- Control.SnapPointsType = (sender as ItemsLayout)?.SnapPointsType ?? SnapPointsType.None;
- }
- else if (e.PropertyName == nameof(GridItemsLayout.Span))
- {
- ((GridLayoutManager)(Control.LayoutManager)).UpdateSpan(((GridItemsLayout)sender).Span);
- }
- else if (e.PropertyName == nameof(LinearItemsLayout.ItemSpacing)
- || e.PropertyName == nameof(GridItemsLayout.VerticalItemSpacing)
- || e.PropertyName == nameof(GridItemsLayout.HorizontalItemSpacing))
- {
- UpdateItemsLayout();
- }
- }
-
- protected abstract IItemsLayout GetItemsLayout();
-
- protected virtual void OnItemSelectedFromUI(object sender, SelectedItemChangedEventArgs e)
- {
- }
-
- void OnScrolled(object sender, ItemsViewScrolledEventArgs e)
- {
- Element.SendScrolled(e);
- if (Element.RemainingItemsThreshold >= 0)
- {
- if (Control.Adaptor.Count - 1 - e.LastVisibleItemIndex <= Element.RemainingItemsThreshold)
- Element.SendRemainingItemsThresholdReached();
- }
- }
-
- void OnScrollToRequest(object sender, ScrollToRequestEventArgs e)
- {
- if (e.Mode == ScrollToMode.Position)
- {
- Control.ScrollTo(e.Index, e.ScrollToPosition, e.IsAnimated);
- }
- else
- {
- Control.ScrollTo(e.Item, e.ScrollToPosition, e.IsAnimated);
- }
- }
-
- void UpdateItemsSource(bool initialize)
- {
- if (Element.ItemsSource is INotifyCollectionChanged collectionChanged)
- {
- if (_observableSource != null)
- {
- _observableSource.CollectionChanged -= OnCollectionChanged;
- }
- _observableSource = collectionChanged;
- _observableSource.CollectionChanged += OnCollectionChanged;
- }
- UpdateAdaptor(initialize);
- }
-
- void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- if (Element.ItemsSource == null || !Element.ItemsSource.Cast().Any())
- {
- Control.Adaptor = EmptyItemAdaptor.Create(Element);
- }
- else
- {
- if (Control.Adaptor is EmptyItemAdaptor)
- {
- UpdateAdaptor(false);
- }
- }
- }
-
- protected void UpdateAdaptor(bool initialize)
- {
- if (!initialize)
- {
- if (Element.ItemsSource == null || !Element.ItemsSource.Cast().Any())
- {
- Control.Adaptor = EmptyItemAdaptor.Create(Element);
- }
- else if (Element.ItemTemplate == null)
- {
- Control.Adaptor = new ItemDefaultTemplateAdaptor(Element);
- }
- else
- {
- Control.Adaptor = new ItemTemplateAdaptor(Element);
- Control.Adaptor.ItemSelected += OnItemSelectedFromUI;
- }
- }
- }
-
- protected virtual void UpdateHorizontalScrollBarVisibility()
- {
- Control.HorizontalScrollBarVisiblePolicy = Element.HorizontalScrollBarVisibility.ToPlatform();
- }
-
- protected virtual void UpdateVerticalScrollBarVisibility()
- {
- Control.VerticalScrollBarVisiblePolicy = Element.VerticalScrollBarVisibility.ToPlatform();
- }
-
- void UpdateFocusedItemScrollPosition(bool init)
- {
- if (init && Specific.GetFocusedItemScrollPosition(Element) == ScrollToPosition.MakeVisible)
- return;
- Control.FocusedItemScrollPosition = Specific.GetFocusedItemScrollPosition(Element);
- }
- }
-
- static class ItemsLayoutExtension
- {
- public static ICollectionViewLayoutManager ToLayoutManager(this IItemsLayout layout, ItemSizingStrategy sizing = ItemSizingStrategy.MeasureFirstItem)
- {
- switch (layout)
- {
- case LinearItemsLayout listItemsLayout:
- return new LinearLayoutManager(listItemsLayout.Orientation == ItemsLayoutOrientation.Horizontal, sizing, Forms.ConvertToScaledPixel(listItemsLayout.ItemSpacing));
- case GridItemsLayout gridItemsLayout:
- return new GridLayoutManager(gridItemsLayout.Orientation == ItemsLayoutOrientation.Horizontal,
- gridItemsLayout.Span,
- sizing,
- Forms.ConvertToScaledPixel(gridItemsLayout.VerticalItemSpacing),
- Forms.ConvertToScaledPixel(gridItemsLayout.HorizontalItemSpacing));
- default:
- break;
- }
-
- return new LinearLayoutManager(false);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/LabelRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/LabelRenderer.cs
index 0387c4dcd086..f63588eaab19 100644
--- a/src/Compatibility/Core/src/Tizen/Renderers/LabelRenderer.cs
+++ b/src/Compatibility/Core/src/Tizen/Renderers/LabelRenderer.cs
@@ -1,13 +1,13 @@
-using Microsoft.Maui.Graphics;
using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.Label;
+using Microsoft.Maui.Graphics;
+using NLabel = Tizen.UIExtensions.NUI.Label;
+using TFormattedString = Tizen.UIExtensions.Common.FormattedString;
+using TSpan = Tizen.UIExtensions.Common.Span;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
-
- public class LabelRenderer : ViewRenderer
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class LayoutRenderer : ViewRenderer, SkiaSharp.IBackgroundCanvas, ILayoutRenderer
+ public class LayoutRenderer : ViewRenderer, ILayoutRenderer
{
bool _layoutUpdatedRegistered = false;
- Lazy _backgroundCanvas;
-
- public SKCanvasView BackgroundCanvas => _backgroundCanvas.Value;
-
public void RegisterOnLayoutUpdated()
{
if (!_layoutUpdatedRegistered)
@@ -30,24 +26,11 @@ protected override void OnElementChanged(ElementChangedEventArgs e)
{
if (null == Control)
{
- SetNativeControl(new Native.Canvas(Forms.NativeParent));
- }
-
- if (Forms.UseSkiaSharp)
- {
- Control.LayoutUpdated += OnBackgroundLayoutUpdated;
- _backgroundCanvas = new Lazy(() =>
- {
- var canvas = new SKCanvasView(Forms.NativeParent);
- canvas.PassEvents = true;
- canvas.PaintSurface += OnBackgroundPaint;
- canvas.Show();
- Control.Children.Add(canvas);
- canvas.Lower();
- return canvas;
- });
+ SetNativeControl(new NViewGroup());
}
base.OnElementChanged(e);
+
+ RegisterOnLayoutUpdated();
}
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
@@ -68,18 +51,6 @@ protected override void Dispose(bool disposing)
Control.LayoutUpdated -= OnLayoutUpdated;
_layoutUpdatedRegistered = false;
}
-
- if (Forms.UseSkiaSharp && Control != null)
- {
- Control.LayoutUpdated -= OnBackgroundLayoutUpdated;
-
- if (_backgroundCanvas.IsValueCreated)
- {
- BackgroundCanvas.PaintSurface -= OnBackgroundPaint;
- BackgroundCanvas.Unrealize();
- _backgroundCanvas = null;
- }
- }
}
base.Dispose(disposing);
}
@@ -91,30 +62,37 @@ protected override void UpdateInputTransparent(bool initialize)
return;
}
+
+ if (initialize)
+ {
+ // On initialize time, GestureDetector was not created even if GestureRecognizer was existed
+ Application.Current.Dispatcher.Dispatch(() => UpdateInputTransparent(false));
+ return;
+ }
+
if (Element.InputTransparent)
{
+ // Disabling event
if (Element.CascadeInputTransparent)
{
- //Ignore all events of both layout and it's chidren
- NativeView.PassEvents = true;
+ // disabling all event including child
+ NativeView.Sensitive = false;
}
else
{
- //Ignore Layout's event only. Children's events should be allowded.
- NativeView.PassEvents = false;
- NativeView.RepeatEvents = true;
+ // Child can get event, but layout blocking all event
+ // acutally, it allow event on view, so we need to manually block a event.
+ NativeView.Sensitive = true;
}
+ // Disabling gesture detecting on layout
+ if (GestureDetector != null)
+ GestureDetector.IsEnabled = false;
}
else
{
- //Allow layout's events and children's events would be determined by CascadeInputParent.
- NativeView.PassEvents = false;
- NativeView.RepeatEvents = false;
- }
-
- if (GestureDetector != null)
- {
- GestureDetector.InputTransparent = Element.InputTransparent;
+ if (GestureDetector != null)
+ GestureDetector.IsEnabled = true;
+ NativeView.Sensitive = true;
}
}
@@ -130,35 +108,12 @@ protected override void UpdateLayout()
}
}
- protected virtual void OnBackgroundPaint(object sender, SKPaintSurfaceEventArgs e)
- {
- var canvas = e.Surface.Canvas;
- canvas.Clear();
-
- var bounds = e.Info.Rect;
- var paint = Element.GetBackgroundPaint(bounds);
-
- if (paint != null)
- {
- using (paint)
- using (var path = bounds.ToPath())
- {
- canvas.DrawPath(path, paint);
- }
- }
- }
-
- protected virtual void OnBackgroundLayoutUpdated(object sender, Native.LayoutEventArgs e)
- {
- if (_backgroundCanvas.IsValueCreated)
- {
- BackgroundCanvas.Geometry = Control.Geometry;
- }
- }
-
- void OnLayoutUpdated(object sender, Native.LayoutEventArgs e)
+ void OnLayoutUpdated(object sender, TLayoutEventArgs e)
{
- Element.Layout(e.Geometry.ToDP());
+ var bound = e.Geometry.ToDP();
+ bound.X = Element.X;
+ bound.Y = Element.Y;
+ Element.Layout(bound);
}
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/ListViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/ListViewRenderer.cs
deleted file mode 100644
index 25fc7bb642b3..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/ListViewRenderer.cs
+++ /dev/null
@@ -1,403 +0,0 @@
-using System;
-using System.Collections.Specialized;
-using ElmSharp;
-using Microsoft.Maui.Controls.Internals;
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Devices;
-using EColor = ElmSharp.Color;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- ///
- /// Renderer class for Xamarin ListView class. This provides necessary logic translating
- /// Xamarin API to Tizen Native API. This is a derivate of a ViewRenderer base class.
- /// This is a template class with two template parameters. First one is restricted to
- /// Microsoft.Maui.Controls.Compatibility.View and can be accessed via property Element. This represent actual
- /// xamarin view which represents control logic. Second one is restricted to ElmSharp.Widget
- /// types, and can be accessed with Control property. This represents actual native control
- /// which is used to draw control and realize xamarin forms api.
- ///
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ListViewRenderer : ViewRenderer
- {
- IListViewController Controller => Element;
- ITemplatedItemsView TemplatedItemsView => Element;
-
- ///
- /// The _lastSelectedItem and _selectedItemChanging are used for realizing ItemTapped event. Since Xamarin
- /// needs information only when an item has been taped, native handlers need to be agreagated
- /// and NotifyRowTapped has to be realized with this.
- ///
-
- GenListItem _lastSelectedItem = null;
- int _selectedItemChanging = 0;
-
- ///
- /// Initializes a new instance of the class.
- /// Note that at this stage of construction renderer dose not have required native element. This should
- /// only be used with xamarin engine.
- ///
- public ListViewRenderer()
- {
- RegisterPropertyHandler(ListView.IsGroupingEnabledProperty, UpdateIsGroupingEnabled);
- RegisterPropertyHandler(ListView.HasUnevenRowsProperty, UpdateHasUnevenRows);
- RegisterPropertyHandler(ListView.RowHeightProperty, UpdateRowHeight);
- RegisterPropertyHandler(ListView.SelectedItemProperty, UpdateSelectedItem);
- RegisterPropertyHandler(ListView.ItemsSourceProperty, UpdateSource);
- RegisterPropertyHandler(nameof(Element.HeaderElement), UpdateHeader);
- RegisterPropertyHandler(nameof(Element.FooterElement), UpdateFooter);
- RegisterPropertyHandler(ListView.SelectionModeProperty, UpdateSelectionMode);
- RegisterPropertyHandler(ListView.VerticalScrollBarVisibilityProperty, UpdateVerticalScrollBarVisibility);
- RegisterPropertyHandler(ListView.HorizontalScrollBarVisibilityProperty, UpdateHorizontalScrollBarVisibility);
- RegisterPropertyHandler(ListView.SeparatorColorProperty, UpdateSeparator);
- RegisterPropertyHandler(ListView.SeparatorVisibilityProperty, UpdateSeparator);
- }
-
- ///
- /// Invoked on creation of new ListView renderer. Handles the creation of a native
- /// element and initialization of the renderer.
- ///
- /// .
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(CreateNativeControl());
-
- Control.Scrolled += OnScrolled;
- Control.ItemSelected += OnListViewItemSelected;
- Control.ItemUnselected += OnListViewItemUnselected;
- }
-
- if (e.OldElement != null)
- {
- e.OldElement.ScrollToRequested -= OnScrollToRequested;
- e.OldElement.TemplatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged;
- e.OldElement.TemplatedItems.CollectionChanged -= OnCollectionChanged;
- }
-
- if (e.NewElement != null)
- {
- Element.ScrollToRequested += OnScrollToRequested;
- Element.TemplatedItems.GroupedCollectionChanged += OnGroupedCollectionChanged;
- Element.TemplatedItems.CollectionChanged += OnCollectionChanged;
- }
-
- base.OnElementChanged(e);
- }
-
- protected virtual Native.ListView CreateNativeControl()
- {
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- return new Native.Watch.WatchListView(Forms.NativeParent, Forms.CircleSurface);
- }
- else
- {
- return new Native.ListView(Forms.NativeParent);
- }
- }
-
- ///
- /// Handles the disposing of an existing renderer instance. Results in event handlers
- /// being detached and a Dispose() method from base class (VisualElementRenderer) being invoked.
- ///
- /// A boolean flag passed to the invocation of base class' Dispose() method.
- /// True if the memory release was requested on demand.
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Element != null)
- {
- Element.ScrollToRequested -= OnScrollToRequested;
- Element.TemplatedItems.CollectionChanged -= OnCollectionChanged;
- Element.TemplatedItems.GroupedCollectionChanged -= OnGroupedCollectionChanged;
- }
-
- if (Control != null)
- {
- Control.Scrolled -= OnScrolled;
- Control.ItemSelected -= OnListViewItemSelected;
- Control.ItemUnselected -= OnListViewItemUnselected;
- }
- }
- base.Dispose(disposing);
- }
-
- ///
- /// Handles item selected event. Note that it has to handle selection also for grouping mode as well.
- /// As a result of this method, ItemTapped event should be invoked in Xamarin.
- ///
- /// A native list instance from which the event has originated.
- /// Argument associated with handler, it holds native item for which event was raised
- protected void OnListViewItemSelected(object sender, GenListItemEventArgs e)
- {
- GenListItem item = e.Item;
-
- _lastSelectedItem = item;
-
- if (_selectedItemChanging == 0)
- {
- if (item != null)
- {
- int index = -1;
- if (Element.IsGroupingEnabled)
- {
- Native.ListView.ItemContext itemContext = item.Data as Native.ListView.ItemContext;
- if (itemContext.IsGroupItem)
- {
- return;
- }
- else
- {
- int groupIndex = (Element.TemplatedItems as System.Collections.IList).IndexOf(itemContext.ListOfSubItems);
- int inGroupIndex = itemContext.ListOfSubItems.IndexOf(itemContext.Cell);
-
- ++_selectedItemChanging;
- Element.NotifyRowTapped(groupIndex, inGroupIndex);
- --_selectedItemChanging;
- }
- }
- else
- {
- index = Element.TemplatedItems.IndexOf((item.Data as Native.ListView.ItemContext).Cell);
-
- ++_selectedItemChanging;
- Element.NotifyRowTapped(index);
- --_selectedItemChanging;
- }
- }
- }
- }
-
- ///
- /// Handles item unselected event.
- ///
- /// A native list instance from which the event has originated.
- /// Argument associated with handler, it holds native item for which event was raised
- protected void OnListViewItemUnselected(object sender, GenListItemEventArgs e)
- {
- if (_selectedItemChanging == 0)
- {
- _lastSelectedItem = null;
- }
- }
-
- void OnScrolled(object sender, EventArgs e)
- {
- var region = Control.CurrentRegion.ToDP();
- Element.SendScrolled(new ScrolledEventArgs(region.X, region.Y));
- }
-
- ///
- /// This is method handles "scroll to" requests from xamarin events.
- /// It allows for scrolling to specified item on list view.
- ///
- /// A native list instance from which the event has originated.
- /// ScrollToRequestedEventArgs.
- void OnScrollToRequested(object sender, ScrollToRequestedEventArgs e)
- {
- Cell cell;
- int position;
- var scrollArgs = (ITemplatedItemsListScrollToRequestedEventArgs)e;
-
- var templatedItems = TemplatedItemsView.TemplatedItems;
- if (Element.IsGroupingEnabled)
- {
- var results = templatedItems.GetGroupAndIndexOfItem(scrollArgs.Group, scrollArgs.Item);
- if (results.Item1 == -1 || results.Item2 == -1)
- return;
-
- var group = templatedItems.GetGroup(results.Item1);
- cell = group[results.Item2];
- }
- else
- {
- position = templatedItems.GetGlobalIndexOfItem(scrollArgs.Item);
- cell = templatedItems[position];
- }
-
- Control.ApplyScrollTo(cell, e.Position, e.ShouldAnimate);
- }
-
- ///
- /// This method is called whenever something changes in list view data model.
- /// Method will not be invoked for grouping mode, but for example event with
- /// action reset will be handled here when switching between group and no-group mode.
- ///
- /// TemplatedItemsList{ItemsView{Cell}, Cell}.
- /// NotifyCollectionChangedEventArgs.
- void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- if (e.Action == NotifyCollectionChangedAction.Add)
- {
- Cell before = null;
- if (e.NewStartingIndex + e.NewItems.Count < Element.TemplatedItems.Count)
- {
- before = Element.TemplatedItems[e.NewStartingIndex + e.NewItems.Count];
- }
- Control.AddSource(e.NewItems, before);
- }
- else if (e.Action == NotifyCollectionChangedAction.Remove)
- {
- Control.Remove(e.OldItems);
- }
- else if (e.Action == NotifyCollectionChangedAction.Reset)
- {
- UpdateSource();
- }
- }
-
- ///
- /// This method is called whenever something changes in list view data model.
- /// Method will be invoked for grouping mode, but some action can be also handled
- /// by OnCollectionChanged handler.
- ///
- /// TemplatedItemsList{ItemsView{Cell}, Cell}.
- /// NotifyCollectionChangedEventArgs.
- void OnGroupedCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- if (e.Action == NotifyCollectionChangedAction.Add)
- {
- TemplatedItemsList, Cell> itemsGroup = sender as TemplatedItemsList, Cell>;
- Cell before = null;
- if (e.NewStartingIndex + e.NewItems.Count < itemsGroup.Count)
- {
- before = itemsGroup[e.NewStartingIndex + e.NewItems.Count];
- }
- Control.AddItemsToGroup(itemsGroup, e.NewItems, before);
- }
- else if (e.Action == NotifyCollectionChangedAction.Remove)
- {
- Control.Remove(e.OldItems);
- }
- else if (e.Action == NotifyCollectionChangedAction.Reset)
- {
- Control.ResetGroup(sender as TemplatedItemsList, Cell>);
- }
- }
-
- ///
- /// Updates the source.
- ///
- void UpdateSource()
- {
- Control.Clear();
- UpdateHeader(false);
- Control.AddSource(Element.TemplatedItems);
- UpdateFooter(false);
- UpdateSelectedItem();
- }
-
- ///
- /// Updates the header.
- ///
- void UpdateHeader(bool initialize)
- {
- if (initialize)
- return;
- Control.SetHeader(((IListViewController)Element).HeaderElement as VisualElement);
- }
-
- ///
- /// Updates the footer.
- ///
- void UpdateFooter(bool initialize)
- {
- if (initialize)
- return;
- Control.SetFooter(((IListViewController)Element).FooterElement as VisualElement);
- }
-
- ///
- /// Updates the has uneven rows.
- ///
- void UpdateHasUnevenRows()
- {
- Control.SetHasUnevenRows(Element.HasUnevenRows);
- }
-
- ///
- /// Updates the height of the row.
- ///
- void UpdateRowHeight(bool initialize)
- {
- if (initialize)
- return;
-
- Control.UpdateRealizedItems();
- }
-
- ///
- /// Updates the is grouping enabled.
- ///
- /// If set to true, this method is invoked during initialization
- /// (otherwise it will be invoked only after property changes).
- void UpdateIsGroupingEnabled(bool initialize)
- {
- Control.IsGroupingEnabled = Element.IsGroupingEnabled;
- }
-
- ///
- /// Method is used for programaticaly selecting choosen item.
- ///
- void UpdateSelectedItem()
- {
- if (Element.SelectedItem == null)
- {
- if (_lastSelectedItem != null)
- {
- _lastSelectedItem.IsSelected = false;
- _lastSelectedItem = null;
- }
- if (Control.SelectedItem != null)
- {
- Control.SelectedItem.IsSelected = false;
- }
- }
- else
- {
- var templatedItems = TemplatedItemsView.TemplatedItems;
- var results = templatedItems.GetGroupAndIndexOfItem(Element.SelectedItem);
- if (results.Item1 != -1 && results.Item2 != -1)
- {
- var itemGroup = templatedItems.GetGroup(results.Item1);
- var cell = itemGroup[results.Item2];
-
- ++_selectedItemChanging;
- Control.ApplySelectedItem(cell);
- --_selectedItemChanging;
- }
- }
- }
-
- void UpdateSelectionMode()
- {
- if (Element.SelectionMode == ListViewSelectionMode.None)
- {
- Element.SelectedItem = null;
- Control.IsHighlight = false;
- }
- else
- {
- Control.IsHighlight = true;
- }
- }
-
- void UpdateVerticalScrollBarVisibility()
- {
- Control.VerticalScrollBarVisibility = Element.VerticalScrollBarVisibility.ToPlatform();
- }
-
- void UpdateHorizontalScrollBarVisibility()
- {
- Control.HorizontalScrollBarVisibility = Element.HorizontalScrollBarVisibility.ToPlatform();
- }
-
- void UpdateSeparator()
- {
- Control.BottomLineColor = Element.SeparatorVisibility == SeparatorVisibility.Default ? Element.SeparatorColor.ToPlatformEFL() : EColor.Transparent;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/NativeViewWrapperRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/NativeViewWrapperRenderer.cs
deleted file mode 100644
index ef868692bba2..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/NativeViewWrapperRenderer.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-using ESize = ElmSharp.Size;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
-#pragma warning disable CS0618 // Type or member is obsolete
- public class NativeViewWrapperRenderer : ViewRenderer
-#pragma warning disable CS0618 // Type or member is obsolete
- {
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- SetNativeControl(Element.EvasObject);
-
- base.OnElementChanged(e);
- }
-
- protected override ESize Measure(int availableWidth, int availableHeight)
- {
- if (Element?.MeasureDelegate == null)
- {
- return base.Measure(availableWidth, availableHeight);
- }
-
- // The user has specified a different implementation of MeasureDelegate
- ESize? result = Element.MeasureDelegate(this, availableWidth, availableHeight);
-
- // If the delegate returns a ElmSharp.Size, we use it; if it returns null,
- // fall back to the default implementation
- return result ?? base.Measure(availableWidth, availableHeight);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/NavigationPageRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/NavigationPageRenderer.cs
index 1c765c06fffd..dc98091e4f86 100644
--- a/src/Compatibility/Core/src/Tizen/Renderers/NavigationPageRenderer.cs
+++ b/src/Compatibility/Core/src/Tizen/Renderers/NavigationPageRenderer.cs
@@ -1,88 +1,57 @@
using System;
using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.ComponentModel;
using System.Linq;
+using System.Reflection;
using System.Threading.Tasks;
-using ElmSharp;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific;
-using EButton = ElmSharp.Button;
-using EToolbar = ElmSharp.Toolbar;
-using EToolbarItem = ElmSharp.ToolbarItem;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.NavigationPage;
-using SpecificPage = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.Page;
+using Tizen.NUI.BaseComponents;
+using Tizen.UIExtensions.Common.GraphicsView;
+using Tizen.UIExtensions.NUI;
+using NColor = Tizen.NUI.Color;
+using NShadow = Tizen.NUI.Shadow;
+using NVector2 = Tizen.NUI.Vector2;
+using NView = Tizen.NUI.BaseComponents.View;
+using TButton = Tizen.UIExtensions.NUI.Button;
+using TColor = Tizen.UIExtensions.Common.Color;
+using TDeviceInfo = Tizen.UIExtensions.Common.DeviceInfo;
+using TMaterialIconButton = Tizen.UIExtensions.NUI.GraphicsView.MaterialIconButton;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
public class NavigationPageRenderer : VisualElementRenderer
{
- enum ToolbarButtonPosition
- {
- Left,
- Right
- };
+ const double s_toolbarItemTextSize = 16d;
+ const double s_titleViewTextSize = 20d;
+
+ Dictionary _pageMap = new Dictionary();
- readonly List _naviItemContentPartList = new List();
- Naviframe _naviFrame = null;
Page _previousPage = null;
- TaskCompletionSource _currentTaskSource = null;
+ NavigationStack Control => NativeView as NavigationStack;
ToolbarTracker _toolbarTracker = null;
- IDictionary _naviItemMap;
-
- Page CurrentPage => Element.CurrentPage;
- Page PreviousPage => Element.Navigation.NavigationStack.Count > 1 ? Element.Navigation.NavigationStack[Element.Navigation.NavigationStack.Count - 2] : null;
- NaviItem CurrentNaviItem => _naviFrame.NavigationStack.Count > 0 ? _naviFrame.NavigationStack.Last() : null;
- NaviItem PreviousNaviItem => _naviFrame.NavigationStack.Count > 1 ? _naviFrame.NavigationStack[_naviFrame.NavigationStack.Count - 2] : null;
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (_naviFrame != null)
- {
- _naviFrame.AnimationFinished -= OnAnimationFinished;
- }
- if (_toolbarTracker != null)
- {
- _toolbarTracker.CollectionChanged -= OnToolbarCollectionChanged;
- }
- }
- base.Dispose(disposing);
- }
+ TColor _accentColor = TColor.White;
protected override void OnElementChanged(ElementChangedEventArgs e)
{
- if (_naviFrame == null)
+ if (NativeView == null)
{
- _naviFrame = new Naviframe(Forms.NativeParent);
- _naviFrame.PreserveContentOnPop = true;
- _naviFrame.DefaultBackButtonEnabled = false;
- _naviFrame.AnimationFinished += OnAnimationFinished;
-
- SetNativeView(_naviFrame);
- _naviItemMap = new Dictionary();
+ SetNativeView(new NavigationStack
+ {
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ WidthSpecification = LayoutParamPolicies.MatchParent,
+ PushAnimation = (v, p) => v.Opacity = 0.5f + 0.5f * (float)p,
+ PopAnimation = (v, p) => v.Opacity = 0.5f + 0.5f * (float)(1 - p),
+ });
}
-
if (_toolbarTracker == null)
{
_toolbarTracker = new ToolbarTracker();
_toolbarTracker.CollectionChanged += OnToolbarCollectionChanged;
}
- if (e.OldElement != null)
- {
- var navigation = e.OldElement as INavigationPageController;
- navigation.PopRequested -= OnPopRequested;
- navigation.PopToRootRequested -= OnPopToRootRequested;
- navigation.PushRequested -= OnPushRequested;
- navigation.RemovePageRequested -= OnRemovePageRequested;
- navigation.InsertPageBeforeRequested -= OnInsertPageBeforeRequested;
-
- var pageController = e.OldElement as IPageController;
- pageController.InternalChildren.CollectionChanged -= OnPageCollectionChanged;
- }
-
if (e.NewElement != null)
{
var navigation = e.NewElement as INavigationPageController;
@@ -91,29 +60,22 @@ protected override void OnElementChanged(ElementChangedEventArgs
navigation.PushRequested += OnPushRequested;
navigation.RemovePageRequested += OnRemovePageRequested;
navigation.InsertPageBeforeRequested += OnInsertPageBeforeRequested;
+ (Element as IPageController).InternalChildren.CollectionChanged += OnPageCollectionChanged;
- _toolbarTracker.Target = e.NewElement;
+ _toolbarTracker.Target = Element;
_previousPage = e.NewElement.CurrentPage;
}
base.OnElementChanged(e);
- }
- protected override void OnElementReady()
- {
- base.OnElementReady();
var pageController = Element as IPageController;
- pageController.InternalChildren.CollectionChanged += OnPageCollectionChanged;
-
foreach (Page page in pageController.InternalChildren)
{
- _naviItemMap[page] = _naviFrame.Push(CreateNavItem(page), SpanTitle(page.Title));
- page.PropertyChanged += NavigationBarPropertyChangedHandler;
-
- UpdateHasNavigationBar(page);
+ Control.Push(GetNavigationItem(page), false);
+ page.PropertyChanged += OnPagePropertyChanged;
}
}
- protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
{
base.OnElementPropertyChanged(sender, e);
@@ -121,351 +83,336 @@ protected override void OnElementPropertyChanged(object sender, System.Component
{
Application.Current.Dispatcher.Dispatch(() =>
{
+ if (IsDisposed)
+ return;
+
(_previousPage as IPageController)?.SendDisappearing();
_previousPage = Element.CurrentPage;
(_previousPage as IPageController)?.SendAppearing();
});
}
- else if (e.PropertyName == NavigationPage.BarTextColorProperty.PropertyName)
- UpdateTitle(CurrentPage);
- // Tizen does not support 'Tint', but only 'BarBackgroundColor'
- else if (e.PropertyName == NavigationPage.BarBackgroundColorProperty.PropertyName)
- UpdateBarBackgroundColor(CurrentNaviItem);
- else if (e.PropertyName == Specific.HasBreadCrumbsBarProperty.PropertyName)
- UpdateBreadCrumbsBar(CurrentNaviItem);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (_toolbarTracker != null)
+ {
+ _toolbarTracker.CollectionChanged -= OnToolbarCollectionChanged;
+ }
+ var navigation = Element as INavigationPageController;
+ navigation.PopRequested -= OnPopRequested;
+ navigation.PopToRootRequested -= OnPopToRootRequested;
+ navigation.PushRequested -= OnPushRequested;
+ navigation.RemovePageRequested -= OnRemovePageRequested;
+ navigation.InsertPageBeforeRequested -= OnInsertPageBeforeRequested;
+ (Element as IPageController).InternalChildren.CollectionChanged -= OnPageCollectionChanged;
+ foreach (var child in (Element as IPageController).InternalChildren)
+ {
+ child.PropertyChanged -= OnPagePropertyChanged;
+ }
+ }
+ base.Dispose(disposing);
}
- void OnPageCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
+
+ void OnPageCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
foreach (Page page in e.OldItems)
- page.PropertyChanged -= NavigationBarPropertyChangedHandler;
+ page.PropertyChanged -= OnPagePropertyChanged;
if (e.NewItems != null)
foreach (Page page in e.NewItems)
- page.PropertyChanged += NavigationBarPropertyChangedHandler;
+ page.PropertyChanged += OnPagePropertyChanged;
}
- void OnToolbarCollectionChanged(object sender, EventArgs eventArgs)
+ void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e)
{
- UpdateToolbarItem(Element.CurrentPage);
- }
-
- void NavigationBarPropertyChangedHandler(object sender, System.ComponentModel.PropertyChangedEventArgs e)
- {
- // this handler is invoked only for child pages (contained on a navigation stack)
if (e.PropertyName == NavigationPage.HasNavigationBarProperty.PropertyName)
- UpdateHasNavigationBar(sender as Page);
- else if (e.PropertyName == NavigationPage.HasBackButtonProperty.PropertyName ||
- e.PropertyName == NavigationPage.BackButtonTitleProperty.PropertyName)
- UpdateHasBackButton(sender as Page);
+ UpdateNavigationBar(sender as Page);
+ else if (e.PropertyName == NavigationPage.HasBackButtonProperty.PropertyName)
+ UpdateNavigationBar(sender as Page);
else if (e.PropertyName == Page.TitleProperty.PropertyName)
- UpdateTitle(sender as Page);
- else if (e.PropertyName == SpecificPage.BreadCrumbProperty.PropertyName)
- UpdateBreadCrumbsBar(GetNaviItemForPage(sender as Page));
+ UpdateNavigationBar(sender as Page);
}
- void UpdateHasNavigationBar(Page page)
+ async void OnPopRequested(object sender, NavigationRequestedEventArgs nre)
{
- NaviItem item = GetNaviItemForPage(page);
- if (NavigationPage.GetTitleView(page) != null)
+ var tcs = new TaskCompletionSource();
+ nre.Task = tcs.Task;
+ nre.Page?.SendDisappearing();
+
+ try
{
- item.TitleBarVisible = false;
- Native.TitleViewPage tvPage = item.Content as Native.TitleViewPage;
- if (tvPage != null)
- {
- tvPage.HasNavigationBar = (bool)page.GetValue(NavigationPage.HasNavigationBarProperty);
- }
- return;
+ await Control.Pop(nre.Animated);
+ tcs.SetResult(true);
+ }
+ catch
+ {
+ tcs.SetResult(false);
+ }
+ finally
+ {
+ _pageMap.Remove(nre.Page);
+ Platform.GetRenderer(nre.Page)?.Dispose();
}
-
- item.SetTabBarStyle();
- item.TitleBarVisible = (bool)page.GetValue(NavigationPage.HasNavigationBarProperty);
- UpdateToolbarItem(page, item);
- UpdateBarBackgroundColor(item);
- UpdateBreadCrumbsBar(item);
}
- void UpdateToolbarItem(Page page, NaviItem item = null)
+ void OnPopToRootRequested(object sender, NavigationRequestedEventArgs nre)
{
- if (item == null)
- item = GetNaviItemForPage(page);
-
- if (_naviFrame.NavigationStack.Count == 0 || item == null || item != _naviFrame.NavigationStack.Last())
+ if (Control.Stack.Count <= 1)
+ {
+ nre.Task = Task.FromResult(true);
return;
+ }
- Native.Button rightButton = GetToolbarButton(ToolbarButtonPosition.Right);
- item.SetRightToolbarButton(rightButton);
-
- Native.Button leftButton = GetToolbarButton(ToolbarButtonPosition.Left);
- item.SetLeftToolbarButton(leftButton);
- UpdateHasBackButton(page, item);
- }
-
- void UpdateHasBackButton(Page page, NaviItem item = null)
- {
- if (item == null)
- item = GetNaviItemForPage(page);
+ var rootPage = nre.Page;
+ var rootNaviPage = _pageMap[rootPage];
- EButton button = null;
+ Control.PopToRoot();
- if ((bool)page.GetValue(NavigationPage.HasBackButtonProperty) && _naviFrame.NavigationStack.Count > 1)
+ foreach (var child in _pageMap.Keys)
{
- button = CreateNavigationButton((string)page.GetValue(NavigationPage.BackButtonTitleProperty));
+ if (child != rootPage)
+ {
+ // remove popped page renderer
+ Platform.GetRenderer(child)?.Dispose();
+ }
}
- item.SetBackButton(button);
- }
-
- void UpdateTitle(Page page, NaviItem item = null)
- {
- if (item == null)
- item = GetNaviItemForPage(page);
- item.SetTitle(SpanTitle(page.Title));
+ _pageMap.Clear();
+ _pageMap[rootPage] = rootNaviPage;
+ nre.Task = Task.FromResult(true);
}
- string SpanTitle(string Title)
+ async void OnPushRequested(object sender, NavigationRequestedEventArgs nre)
{
- Native.Span span = new Native.Span
+ var tcs = new TaskCompletionSource();
+ nre.Task = tcs.Task;
+ try
{
- Text = Title,
- HorizontalTextAlignment = Native.TextAlignment.Center,
- ForegroundColor = Element.BarTextColor.ToPlatformEFL()
- };
- return span.GetMarkupText();
+ await Control.Push(GetNavigationItem(nre.Page), nre.Animated);
+ tcs.SetResult(true);
+ }
+ catch
+ {
+ tcs.SetResult(false);
+ }
}
- void UpdateBarBackgroundColor(NaviItem item)
+ void OnRemovePageRequested(object sender, NavigationRequestedEventArgs nre)
{
- item.TitleBarBackgroundColor = Element.BarBackgroundColor.ToPlatformEFL();
+ Control.RemovePage(GetNavigationItem(nre.Page));
+ _pageMap.Remove(nre.Page);
+ Platform.GetRenderer(nre.Page)?.Dispose();
+ nre.Task = Task.FromResult(true);
}
- void UpdateNavigationBar(Page page, NaviItem item = null)
+ void OnInsertPageBeforeRequested(object sender, NavigationRequestedEventArgs nre)
{
- if (item == null)
- item = GetNaviItemForPage(page);
+ if (nre.BeforePage == null)
+ throw new ArgumentException("BeforePage is null");
+ if (nre.Page == null)
+ throw new ArgumentException("Page is null");
- UpdateTitle(page, item);
- UpdateBarBackgroundColor(item);
+ Control.Insert(GetNavigationItem(nre.BeforePage), GetNavigationItem(nre.Page));
+ nre.Task = Task.FromResult(true);
}
- void UpdateBreadCrumbsBar(NaviItem item)
+ NaviPage GetNavigationItem(Page page)
{
- if (Element.OnThisPlatform().HasBreadCrumbsBar())
- {
- item.SetNavigationBarStyle();
- item.SetNavigationBar(GetBreadCrumbsBar());
- }
- else
+ if (_pageMap.ContainsKey(page))
{
- item.SetNavigationBar(null, false);
+ return _pageMap[page];
}
- }
- EButton CreateNavigationButton(string text)
- {
- EButton button = new EButton(Forms.NativeParent)
- {
- Text = text
- };
- button.SetNavigationBackStyle();
- button.Clicked += (sender, e) =>
+ var content = Platform.GetOrCreateRenderer(page).NativeView;
+ content.WidthSpecification = LayoutParamPolicies.MatchParent;
+ content.HeightSpecification = LayoutParamPolicies.MatchParent;
+
+ var naviPage = new NaviPage
{
- if (!Element.SendBackButtonPressed())
- Forms.Context.Exit();
+ Content = content
};
- _naviItemContentPartList.Add(button);
- button.Deleted += NaviItemPartContentDeletedHandler;
- return button;
+ _pageMap[page] = naviPage;
+ UpdateNavigationBar(page);
+ return naviPage;
}
- void NaviItemPartContentDeletedHandler(object sender, EventArgs e)
+ void OnToolbarCollectionChanged(object sender, EventArgs eventArgs)
{
- _naviItemContentPartList.Remove(sender as Widget);
+ UpdateNavigationBar(Element.CurrentPage);
}
- NaviItem GetNaviItemForPage(Page page)
+ void UpdateNavigationBar(Page page)
{
- NaviItem item;
- if (_naviItemMap.TryGetValue(page, out item))
+ var naviPage = GetNaviItemForPage(page);
+ if (naviPage == null)
+ return;
+
+ if (!NavigationPage.GetHasNavigationBar(page))
{
- return item;
+ DisposeTitleViewRenderer(page);
+ naviPage.TitleView = null;
+ return;
}
- return null;
- }
-
- Native.Button GetToolbarButton(ToolbarButtonPosition position)
- {
- ToolbarItem item = _toolbarTracker.ToolbarItems.Where(
- i => (position == ToolbarButtonPosition.Right && i.Order <= ToolbarItemOrder.Primary)
- || (position == ToolbarButtonPosition.Left && i.Order == ToolbarItemOrder.Secondary))
- .OrderBy(i => i.Priority).FirstOrDefault();
- if (item == default(ToolbarItem))
- return null;
-
- Native.ToolbarItemButton button = new Native.ToolbarItemButton(item);
- return button;
- }
-
- EToolbar GetBreadCrumbsBar()
- {
- EToolbar toolbar = new EToolbar(Forms.NativeParent)
+ if (naviPage.TitleView == null)
{
- ItemAlignment = 0,
- Homogeneous = false,
- ShrinkMode = ToolbarShrinkMode.Scroll
- };
- toolbar.SetNavigationBarStyle();
+ naviPage.TitleView = new TitleView();
+ naviPage.TitleView.BoxShadow = new NShadow((float)20d.ToScaledDP(), NColor.Black, new NVector2(0, 0));
+ naviPage.TitleView.Label.FontSize = s_titleViewTextSize.ToScaledPoint();
+ }
- foreach (var p in Element.Navigation.NavigationStack)
+ var titleView = naviPage.TitleView;
+ if (Element.BarBackgroundColor.IsNotDefault())
{
- string breadCrumb = p.OnThisPlatform().GetBreadCrumb();
- if (!string.IsNullOrEmpty(breadCrumb))
- {
- EToolbarItem toolbarItem = toolbar.Append(breadCrumb);
- toolbarItem.Selected += (s, e) =>
- {
- var copyOfStack = Element.Navigation.NavigationStack.Reverse().Skip(1);
- foreach (var lp in copyOfStack)
- {
- if (lp == p)
- break;
- Element.Navigation.RemovePage(lp);
- }
- if (Element.Navigation.NavigationStack.Last() != p)
- Element.Navigation.PopAsync();
- };
- }
+ titleView.UpdateBackgroundColor(Element.BarBackgroundColor.ToNative());
}
- return toolbar;
- }
-
- void OnPopRequested(object sender, NavigationRequestedEventArgs nre)
- {
- if ((Element as IPageController).InternalChildren.Count == _naviFrame.NavigationStack.Count)
+ if (Element.BarTextColor.IsNotDefault())
{
- nre.Page?.SendDisappearing();
- UpdateNavigationBar(PreviousPage, PreviousNaviItem);
-
- if (nre.Animated)
- {
- _naviFrame.Pop();
-
- _currentTaskSource = new TaskCompletionSource();
- nre.Task = _currentTaskSource.Task;
-
- // There is no TransitionFinished (AnimationFinished) event after Pop the last page
- if (_naviFrame.NavigationStack.Count == 0)
- CompleteCurrentNavigationTask();
- }
- else
- {
- CurrentNaviItem?.Delete();
- }
-
- if (_naviItemMap.ContainsKey(nre.Page))
- _naviItemMap.Remove(nre.Page);
+ titleView.Label.TextColor = _accentColor = Element.BarTextColor.ToNative();
+ }
+ else
+ {
+ var grayscale = (titleView.BackgroundColor.R + titleView.BackgroundColor.G + titleView.BackgroundColor.B) / 3.0f;
+ titleView.Label.TextColor = _accentColor = grayscale > 0.5 ? TColor.Black : TColor.White;
}
- }
- void OnPopToRootRequested(object sender, NavigationRequestedEventArgs nre)
- {
- List copyOfStack = new List(_naviFrame.NavigationStack);
- NaviItem rootItem = copyOfStack.FirstOrDefault();
- NaviItem topItem = copyOfStack.LastOrDefault();
- foreach (NaviItem naviItem in copyOfStack)
- if (naviItem != rootItem && naviItem != topItem)
- naviItem.Delete();
+ var hasBackButton = NavigationPage.GetHasBackButton(page) && Control.Stack.Count > 0 && Control.Stack.IndexOf(naviPage) != 0;
+ var leftToolbarButton = GetLeftToolbar();
- if (topItem != rootItem)
+ if (leftToolbarButton != null)
{
- UpdateNavigationBar(Element.Navigation.NavigationStack.Last(), rootItem);
- if (nre.Animated)
- {
- _naviFrame.Pop();
-
- _currentTaskSource = new TaskCompletionSource();
- nre.Task = _currentTaskSource.Task;
- }
- else
- topItem?.Delete();
+ titleView.Icon = leftToolbarButton;
+ }
+ else if (hasBackButton)
+ {
+ titleView.Icon = CreateBackButton();
+ }
+ else
+ {
+ titleView.Icon = null;
}
- _naviItemMap.Clear();
- _naviItemMap[Element.Navigation.NavigationStack.Last()] = rootItem;
- }
-
- void OnPushRequested(object sender, NavigationRequestedEventArgs nre)
- {
- if (nre.Animated || _naviFrame.NavigationStack.Count == 0)
+ titleView.Actions.Clear();
+ foreach (var action in GetActions())
{
- _naviItemMap[nre.Page] = _naviFrame.Push(CreateNavItem(nre.Page), SpanTitle(nre.Page.Title));
- _currentTaskSource = new TaskCompletionSource();
- nre.Task = _currentTaskSource.Task;
+ titleView.Actions.Add(action);
+ }
- // There is no TransitionFinished (AnimationFinished) event after the first Push
- if (_naviFrame.NavigationStack.Count == 1)
- CompleteCurrentNavigationTask();
+ var titleContent = GetTitleContent(page);
+ if (titleContent != null)
+ {
+ titleView.Title = string.Empty;
+ titleView.Content = titleContent;
}
else
{
- _naviItemMap[nre.Page] = _naviFrame.InsertAfter(_naviFrame.NavigationStack.Last(), CreateNavItem(nre.Page), SpanTitle(nre.Page.Title));
+ titleView.Title = page.Title;
}
- UpdateHasNavigationBar(nre.Page);
}
- void OnRemovePageRequested(object sender, NavigationRequestedEventArgs nre)
+ NView GetLeftToolbar()
{
- GetNaviItemForPage(nre.Page).Delete();
- if (_naviItemMap.ContainsKey(nre.Page))
- _naviItemMap.Remove(nre.Page);
- }
+ ToolbarItem item = _toolbarTracker.ToolbarItems.Where(
+ i => i.Order == ToolbarItemOrder.Secondary)
+ .OrderBy(i => i.Priority).FirstOrDefault();
- void OnInsertPageBeforeRequested(object sender, NavigationRequestedEventArgs nre)
- {
- if (nre.BeforePage == null)
- throw new ArgumentException("BeforePage is null");
- if (nre.Page == null)
- throw new ArgumentException("Page is null");
+ if (item == default(ToolbarItem))
+ return null;
- _naviItemMap[nre.Page] = _naviFrame.InsertBefore(GetNaviItemForPage(nre.BeforePage), CreateNavItem(nre.Page), SpanTitle(nre.Page.Title));
- UpdateHasNavigationBar(nre.Page);
+ return CreateToolbarButton(item);
}
- void OnAnimationFinished(object sender, EventArgs e)
+ IEnumerable GetActions()
{
- CompleteCurrentNavigationTask();
+ return _toolbarTracker.ToolbarItems.Where(i => i.Order <= ToolbarItemOrder.Primary).OrderBy(i => i.Priority).Select(i => CreateToolbarButton(i));
}
- void CompleteCurrentNavigationTask()
+ NView CreateToolbarButton(ToolbarItem item)
{
- if (_currentTaskSource != null)
+ var button = new TButton
+ {
+ FontSize = s_toolbarItemTextSize.ToScaledPoint(),
+ Text = item.Text,
+ TextColor = _accentColor,
+ HeightSpecification = LayoutParamPolicies.MatchParent,
+ WidthSpecification = LayoutParamPolicies.WrapContent,
+ };
+ button.SizeWidth = (float)button.Measure(TDeviceInfo.ScalingFactor * 80, double.PositiveInfinity).Width;
+ button.UpdateBackgroundColor(TColor.Transparent);
+
+ if (item.IconImageSource != null)
{
- var tmp = _currentTaskSource;
- _currentTaskSource = null;
- tmp.SetResult(true);
+ button.Text = string.Empty;
+ button.Icon.AdjustViewSize = true;
+ button.Icon.HeightSpecification = LayoutParamPolicies.MatchParent;
+ _ = button.Icon.LoadFromImageSourceAsync(item.IconImageSource);
+ button.SizeWidth = 0;
+ button.WidthSpecification = LayoutParamPolicies.WrapContent;
}
+ button.Clicked += (s, e) =>
+ {
+ item.Command?.Execute(item.CommandParameter);
+ };
+ return button;
+ }
+
+ NView CreateBackButton()
+ {
+ var button = new TMaterialIconButton
+ {
+ Icon = MaterialIcons.ArrowBack,
+ Color = _accentColor,
+ };
+ button.Clicked += (s, e) =>
+ {
+ Element.SendBackButtonPressed();
+ };
+ return button;
}
- EvasObject CreateNavItem(Page page)
+ NView GetTitleContent(Page page)
{
View titleView = NavigationPage.GetTitleView(page);
- EvasObject nativeView = null;
if (titleView != null)
{
- titleView.Parent = this.Element;
- nativeView = new Native.TitleViewPage(Forms.NativeParent, page, titleView);
- nativeView.Show();
+ titleView.Parent = Element;
+ return Platform.GetOrCreateRenderer(titleView).NativeView;
}
- else
- {
- nativeView = Platform.GetOrCreateRenderer(page).NativeView;
+ return null;
+ }
+ NaviPage GetNaviItemForPage(Page page)
+ {
+ NaviPage item;
+ if (_pageMap.TryGetValue(page, out item))
+ {
+ return item;
}
- return nativeView;
+ return null;
+ }
+
+ void DisposeTitleViewRenderer(Page page)
+ {
+ View titleView = NavigationPage.GetTitleView(page);
+ if (titleView != null)
+ Platform.GetRenderer(titleView)?.Dispose();
+ }
+ }
+ static class NavigationStackEx
+ {
+ public static void RemovePage(this NavigationStack stack, NaviPage page)
+ {
+ var property = typeof(NavigationStack).GetProperty("InternalStack", BindingFlags.NonPublic | BindingFlags.Instance);
+ List internalStack = (List)property.GetValue(stack);
+ stack.Remove(page);
+ internalStack.Remove(page);
}
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/PageRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/PageRenderer.cs
index fc15cad3370c..2e2aaae44a4d 100644
--- a/src/Compatibility/Core/src/Tizen/Renderers/PageRenderer.cs
+++ b/src/Compatibility/Core/src/Tizen/Renderers/PageRenderer.cs
@@ -1,11 +1,6 @@
using System;
-using System.Collections.Specialized;
-using ElmSharp.Wearable;
-using SkiaSharp.Views.Tizen;
using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.Watch;
-using Microsoft.Maui.Devices;
-using EColor = ElmSharp.Color;
+using ViewGroup = Tizen.UIExtensions.NUI.ViewGroup;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
@@ -13,60 +8,21 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
/// Renderer of ContentPage.
/// |
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class PageRenderer : VisualElementRenderer, SkiaSharp.IBackgroundCanvas
+ public class PageRenderer : VisualElementRenderer
{
- Native.Page _page;
- Lazy _moreOption;
- Lazy _backgroundCanvas;
-
- public SKCanvasView BackgroundCanvas => _backgroundCanvas.Value;
-
- public PageRenderer()
- {
- RegisterPropertyHandler(Page.BackgroundImageSourceProperty, UpdateBackgroundImage);
- }
+ ViewGroup _page;
protected override void OnElementChanged(ElementChangedEventArgs e)
{
if (null == _page)
{
- _page = new Native.Page(Forms.NativeParent);
+ _page = new ViewGroup();
_page.LayoutUpdated += OnLayoutUpdated;
SetNativeView(_page);
}
-
- if (Forms.UseSkiaSharp)
- {
- _backgroundCanvas = new Lazy(() =>
- {
- var canvas = new SKCanvasView(Forms.NativeParent);
- canvas.PassEvents = true;
- canvas.PaintSurface += OnBackgroundPaint;
- canvas.Show();
- _page.Children.Add(canvas);
- canvas.Lower();
- return canvas;
- });
- }
base.OnElementChanged(e);
}
- protected override void OnElementReady()
- {
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- _moreOption = new Lazy(CreateMoreOption);
- if (Element.ToolbarItems is INotifyCollectionChanged items)
- {
- items.CollectionChanged += OnToolbarCollectionChanged;
- }
- if (Element.ToolbarItems.Count > 0)
- {
- UpdateToolbarItems(true);
- }
- }
- }
-
protected override void Dispose(bool disposing)
{
if (disposing)
@@ -75,180 +31,20 @@ protected override void Dispose(bool disposing)
{
_page.LayoutUpdated -= OnLayoutUpdated;
}
-
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- if (Element.ToolbarItems is INotifyCollectionChanged items)
- {
- items.CollectionChanged -= OnToolbarCollectionChanged;
- }
-
- if (_moreOption.IsValueCreated)
- {
- _moreOption.Value.Clicked -= OnMoreOptionItemClicked;
- _moreOption.Value.Closed -= SendMoreOptionClosed;
- _moreOption.Value.Opened -= SendMoreOptionOpened;
- _moreOption.Value.Items.Clear();
- _moreOption.Value.Unrealize();
- }
- }
-
- if (Forms.UseSkiaSharp && _backgroundCanvas.IsValueCreated)
- {
- BackgroundCanvas.PaintSurface -= OnBackgroundPaint;
- BackgroundCanvas.Unrealize();
- _backgroundCanvas = null;
- }
}
base.Dispose(disposing);
}
- protected override void UpdateBackgroundColor(bool initialize)
- {
- if (initialize && Element.BackgroundColor.IsDefault())
- return;
-
- // base.UpdateBackgroundColor() is not called on purpose, we don't want the regular background setting
- if (Element.BackgroundColor.IsDefault() || Element.BackgroundColor.Alpha == 0)
- _page.Color = EColor.Transparent;
- else
- _page.Color = Element.BackgroundColor.ToNative();
- }
-
protected override void UpdateLayout()
{
// empty on purpose
}
- protected virtual FormsMoreOptionItem CreateMoreOptionItem(ToolbarItem item)
- {
- var moreOptionItem = new FormsMoreOptionItem
- {
- MainText = item.Text,
- ToolbarItem = item
- };
- var icon = item.IconImageSource as FileImageSource;
- if (icon != null)
- {
- var img = new ElmSharp.Image(_moreOption.Value);
- img.Load(ResourcePath.GetPath(icon));
- moreOptionItem.Icon = img;
- }
- return moreOptionItem;
- }
-
- protected virtual void OnMoreOptionClosed()
- {
- }
-
- protected virtual void OnMoreOptionOpened()
- {
- }
-
- void UpdateBackgroundImage(bool initialize)
- {
- if (initialize && Element.BackgroundImageSource.IsNullOrEmpty())
- return;
-
- // TODO: investigate if we can use the other image source types: stream, font, uri
-
- var bgImage = Element.BackgroundImageSource as FileImageSource;
- if (bgImage.IsNullOrEmpty())
- _page.File = null;
- else
- _page.File = ResourcePath.GetPath(bgImage);
- }
- void OnLayoutUpdated(object sender, Native.LayoutEventArgs e)
+ void OnLayoutUpdated(object sender, global::Tizen.UIExtensions.Common.LayoutEventArgs e)
{
Element.Layout(e.Geometry.ToDP());
-
- if (_moreOption != null && _moreOption.IsValueCreated)
- {
- _moreOption.Value.Geometry = _page.Geometry;
- }
-
- if (_backgroundCanvas != null && _backgroundCanvas.IsValueCreated)
- {
- BackgroundCanvas.Geometry = _page.Geometry;
- }
- }
-
- void OnBackgroundPaint(object sender, SKPaintSurfaceEventArgs e)
- {
- var canvas = e.Surface.Canvas;
- canvas.Clear();
-
- var bounds = e.Info.Rect;
- var paint = Element.GetBackgroundPaint(bounds);
-
- if (paint != null)
- {
- using (paint)
- using (var path = bounds.ToPath())
- {
- canvas.DrawPath(path, paint);
- }
- }
}
- MoreOption CreateMoreOption()
- {
- var moreOption = new MoreOption(_page);
- moreOption.Geometry = _page.Geometry;
- _page.Children.Add(moreOption);
- moreOption.Show();
- moreOption.Clicked += OnMoreOptionItemClicked;
- moreOption.Closed += SendMoreOptionClosed;
- moreOption.Opened += SendMoreOptionOpened;
- return moreOption;
- }
-
- void SendMoreOptionClosed(object sender, EventArgs e)
- {
- OnMoreOptionClosed();
- }
-
- void SendMoreOptionOpened(object sender, EventArgs e)
- {
- OnMoreOptionOpened();
- }
-
- void OnToolbarCollectionChanged(object sender, EventArgs eventArgs)
- {
- UpdateToolbarItems(false);
- }
-
- void UpdateToolbarItems(bool initialize)
- {
- //clear existing more option items and add toolbar item again on purpose.
- if (!initialize && _moreOption.Value.Items.Count > 0)
- {
- _moreOption.Value.Items.Clear();
- }
-
- if (Element.ToolbarItems.Count > 0)
- {
- _moreOption.Value.Show();
- foreach (var item in Element.ToolbarItems)
- {
- _moreOption.Value.Items.Add(CreateMoreOptionItem(item));
- }
- }
- else
- {
- _moreOption.Value.Hide();
- }
- }
-
- void OnMoreOptionItemClicked(object sender, MoreOptionItemEventArgs e)
- {
- var formsMoreOptionItem = e.Item as FormsMoreOptionItem;
- if (formsMoreOptionItem != null)
- {
- ((IMenuItemController)formsMoreOptionItem.ToolbarItem)?.Activate();
- }
- _moreOption.Value.IsOpened = false;
- }
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/PickerRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/PickerRenderer.cs
deleted file mode 100644
index 3f6fa0661530..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/PickerRenderer.cs
+++ /dev/null
@@ -1,238 +0,0 @@
-using System;
-using System.Collections.Generic;
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.Watch;
-using Microsoft.Maui.Devices;
-using EEntry = ElmSharp.Entry;
-using NIEntry = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.IEntry;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class PickerRenderer : ViewRenderer
- {
- List _list;
- Dialog _dialog;
- Dictionary _itemToItemNumber = new Dictionary();
-
- public PickerRenderer()
- {
- RegisterPropertyHandler(Picker.SelectedIndexProperty, UpdateSelectedIndex);
- RegisterPropertyHandler(Picker.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(Picker.FontSizeProperty, UpdateFontSize);
- RegisterPropertyHandler(Picker.FontFamilyProperty, UpdateFontFamily);
- RegisterPropertyHandler(Picker.FontAttributesProperty, UpdateFontAttributes);
- RegisterPropertyHandler(Picker.TitleProperty, UpdateTitle);
- RegisterPropertyHandler(Picker.TitleColorProperty, UpdateTitleColor);
- RegisterPropertyHandler(Picker.HorizontalTextAlignmentProperty, UpdateHorizontalTextAlignment);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- if (Control is NIEntry ie)
- {
- ie.TextBlockFocused -= OnTextBlockFocused;
- ie.EntryLayoutFocused -= OnFocused;
- ie.EntryLayoutUnfocused -= OnUnfocused;
- if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- ie.EntryLayoutFocused -= OnLayoutFocused;
- ie.EntryLayoutUnfocused -= OnLayoutUnfocused;
- }
- }
- CleanView();
- }
- }
- base.Dispose(disposing);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- var entry = CreateNativeControl();
- entry.SetVerticalTextAlignment(0.5);
- if (entry is NIEntry ie)
- {
- ie.TextBlockFocused += OnTextBlockFocused;
- ie.EntryLayoutFocused += OnFocused;
- ie.EntryLayoutUnfocused += OnUnfocused;
-
- if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- ie.EntryLayoutFocused += OnLayoutFocused;
- ie.EntryLayoutUnfocused += OnLayoutUnfocused;
- }
- }
- SetNativeControl(entry);
- }
- base.OnElementChanged(e);
- }
-
- protected virtual EEntry CreateNativeControl()
- {
- return new EditfieldEntry(Forms.NativeParent)
- {
- IsSingleLine = true,
- InputPanelShowByOnDemand = true,
- IsEditable = false,
- HorizontalTextAlignment = Native.TextAlignment.Center
- };
- }
-
- protected virtual void UpdateSelectedIndex()
- {
- Control.Text = (Element.SelectedIndex == -1 || Element.Items == null ?
- "" : Element.Items[Element.SelectedIndex]);
- }
-
- protected virtual void UpdateTitleColor()
- {
- if (Control is NIEntry ie)
- {
- ie.PlaceholderColor = Element.TitleColor.ToPlatformEFL();
- }
- }
-
- protected virtual void UpdateTextColor()
- {
- if (Control is NIEntry ie)
- {
- ie.TextColor = Element.TextColor.ToPlatformEFL();
- }
- }
-
- void UpdateFontSize()
- {
- if (Control is NIEntry ie)
- {
- ie.FontSize = Element.FontSize;
- }
- }
-
- void UpdateFontFamily()
- {
- if (Control is NIEntry ie)
- {
- ie.FontFamily = Element.FontFamily;
- }
- }
-
- void UpdateFontAttributes()
- {
- if (Control is NIEntry ie)
- {
- ie.FontAttributes = Element.FontAttributes;
- }
- }
-
- void UpdateTitle()
- {
- if (Control is NIEntry ie)
- {
- ie.Placeholder = Element.Title;
- }
- }
-
- void UpdateHorizontalTextAlignment()
- {
- if (Control is NIEntry ie)
- {
- ie.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative();
- }
- }
-
- void OnLayoutFocused(object sender, EventArgs e)
- {
- if (Control is NIEntry ie)
- {
- ie.FontSize = ie.FontSize * 1.5;
- }
- }
-
- void OnLayoutUnfocused(object sender, EventArgs e)
- {
- if (Control is NIEntry ie)
- {
- ie.FontSize = ie.FontSize / 1.5;
- }
- }
-
- void OnTextBlockFocused(object sender, EventArgs e)
- {
- // For EFL Entry, the event will occur even if it is currently disabled.
- // If the problem is resolved, no conditional statement is required.
- if (Element.IsEnabled)
- {
- int i = 0;
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- _dialog = new WatchDialog(Forms.NativeParent, false);
- }
- else
- {
- _dialog = new Dialog(Forms.NativeParent);
- }
- _dialog.AlignmentX = -1;
- _dialog.AlignmentY = -1;
- _dialog.Title = Element.Title;
- _dialog.TitleColor = Element.TitleColor.ToPlatformEFL();
- _dialog.Dismissed += OnDialogDismissed;
- _dialog.BackButtonPressed += (object senders, EventArgs es) =>
- {
- _dialog.Dismiss();
- };
-
- _list = new List(_dialog);
- foreach (var s in Element.Items)
- {
- ListItem item = _list.Append(s);
- _itemToItemNumber[item] = i;
- i++;
- }
- _list.ItemSelected += OnItemSelected;
- _dialog.Content = _list;
-
- // You need to call Show() after ui thread occupation because of EFL problem.
- // Otherwise, the content of the popup will not receive focus.
- Application.Current.Dispatcher.Dispatch(() =>
- {
- _dialog.Show();
- _list.Show();
- });
- }
- }
-
- void OnItemSelected(object senderObject, EventArgs ev)
- {
- Element.SetValueFromRenderer(Picker.SelectedIndexProperty, _itemToItemNumber[(senderObject as List).SelectedItem]);
- _dialog.Dismiss();
- }
-
- void OnDialogDismissed(object sender, EventArgs e)
- {
- CleanView();
- }
-
- void CleanView()
- {
- if (null != _list)
- {
- _list.Unrealize();
- _itemToItemNumber.Clear();
- _list = null;
- }
- if (null != _dialog)
- {
- _dialog.Unrealize();
- _dialog = null;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/ProgressBarRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/ProgressBarRenderer.cs
deleted file mode 100644
index 486b165926ab..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/ProgressBarRenderer.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System.ComponentModel;
-using Microsoft.Maui.Controls.Platform;
-using EColor = ElmSharp.Color;
-using EProgressBar = ElmSharp.ProgressBar;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.ProgressBar;
-using SpecificVE = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.VisualElement;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ProgressBarRenderer : ViewRenderer
- {
- static readonly EColor s_defaultColor = ThemeConstants.ProgressBar.ColorClass.Default;
-
- public ProgressBarRenderer()
- {
- RegisterPropertyHandler(ProgressBar.ProgressColorProperty, UpdateProgressColor);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new EProgressBar(Forms.NativeParent));
- }
-
- if (e.NewElement != null)
- {
- if (e.NewElement.MinimumWidthRequest == -1 &&
- e.NewElement.MinimumHeightRequest == -1 &&
- e.NewElement.WidthRequest == -1 &&
- e.NewElement.HeightRequest == -1)
- {
- Log.Warn("Need to size request");
- }
-
- UpdateAll();
- }
-
- base.OnElementChanged(e);
- }
-
- protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- base.OnElementPropertyChanged(sender, e);
- if (e.PropertyName == ProgressBar.ProgressProperty.PropertyName)
- {
- UpdateProgress();
- }
- else if (e.PropertyName == Specific.ProgressBarPulsingStatusProperty.PropertyName)
- {
- UpdatePulsingStatus();
- }
- }
-
- protected override void UpdateThemeStyle()
- {
- var themeStyle = SpecificVE.GetStyle(Element);
- if (!string.IsNullOrEmpty(themeStyle))
- {
- Control.Style = themeStyle;
- UpdateBackgroundColor(false);
- UpdateProgressColor(false);
- }
- }
-
- void UpdateAll()
- {
- UpdateProgress();
- UpdatePulsingStatus();
- }
-
- protected virtual void UpdateProgressColor(bool initialize)
- {
- if (initialize && Element.ProgressColor.IsDefault())
- return;
-
- Control.Color = Element.ProgressColor.IsDefault() ? s_defaultColor : Element.ProgressColor.ToPlatformEFL();
- }
-
- void UpdateProgress()
- {
- Control.Value = Element.Progress;
- }
-
- void UpdatePulsingStatus()
- {
- bool isPulsing = Specific.GetPulsingStatus(Element);
- if (isPulsing)
- {
- Control.PlayPulse();
- }
- else
- {
- Control.StopPulse();
- }
- }
- }
-}
-
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/RadioButtonRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/RadioButtonRenderer.cs
deleted file mode 100644
index 4b26a7c68484..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/RadioButtonRenderer.cs
+++ /dev/null
@@ -1,116 +0,0 @@
-using System;
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-using ESize = ElmSharp.Size;
-using TSpan = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.Span;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class RadioButtonRenderer : ViewRenderer
- {
- readonly TSpan _span = new TSpan();
- public RadioButtonRenderer()
- {
- RegisterPropertyHandler(RadioButton.IsCheckedProperty, UpdateIsChecked);
- RegisterPropertyHandler(RadioButton.ContentProperty, UpdateText);
- RegisterPropertyHandler(RadioButton.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(RadioButton.FontFamilyProperty, UpdateFont);
- RegisterPropertyHandler(RadioButton.FontAttributesProperty, UpdateFont);
- RegisterPropertyHandler(RadioButton.FontSizeProperty, UpdateFont);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new Radio(Forms.NativeParent) { StateValue = 1 });
- Control.ValueChanged += OnValueChanged;
- }
- base.OnElementChanged(e);
- ApplyTextAndStyle();
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.ValueChanged -= OnValueChanged;
- }
- }
- base.Dispose(disposing);
- }
-
- protected override Graphics.Size MinimumSize()
- {
- return Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
- }
-
- protected override ESize Measure(int availableWidth, int availableHeight)
- {
- var size = Control.Geometry;
- Control.Resize(availableWidth, size.Height);
- var formattedSize = Control.GetTextBlockFormattedSize();
- Control.Resize(size.Width, size.Height);
- return new ESize()
- {
- Width = Control.MinimumWidth + formattedSize.Width,
- Height = Math.Max(Control.MinimumHeight, formattedSize.Height),
- };
- }
-
- void OnValueChanged(object sender, EventArgs e)
- {
- Element.SetValueFromRenderer(RadioButton.IsCheckedProperty, Control.GroupValue == 1 ? true : false);
- }
-
- void UpdateIsChecked()
- {
- Control.GroupValue = Element.IsChecked ? 1 : 0;
- }
-
- void UpdateText(bool isInitialized)
- {
- _span.Text = Element.ContentAsString() ?? "";
- if (!isInitialized)
- ApplyTextAndStyle();
- }
-
- void UpdateTextColor(bool isInitialized)
- {
- _span.ForegroundColor = Element.TextColor.ToNative();
- if (!isInitialized)
- ApplyTextAndStyle();
- }
-
- void UpdateFont(bool isInitialized)
- {
- _span.FontSize = Element.FontSize;
- _span.FontAttributes = Element.FontAttributes;
- _span.FontFamily = Element.FontFamily;
- if (!isInitialized)
- ApplyTextAndStyle();
- }
-
- void ApplyTextAndStyle()
- {
- SetInternalTextAndStyle(_span.GetDecoratedText(), _span.GetStyle());
- }
-
- void SetInternalTextAndStyle(string formattedText, string textStyle)
- {
- bool isVisible = true;
- if (string.IsNullOrEmpty(formattedText))
- {
- formattedText = null;
- textStyle = null;
- isVisible = false;
- }
- Control.Text = formattedText;
- Control.SetTextBlockStyle(textStyle);
- Control.SendTextVisibleSignal(isVisible);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/RefreshViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/RefreshViewRenderer.cs
deleted file mode 100644
index b127d53b5b2d..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/RefreshViewRenderer.cs
+++ /dev/null
@@ -1,385 +0,0 @@
-using System;
-using System.Diagnostics.CodeAnalysis;
-using System.Reflection;
-using System.Threading.Tasks;
-using Microsoft.Maui.Layouts;
-using Microsoft.Maui.Graphics;
-using Microsoft.Maui.Controls.Platform;
-using Rect = Microsoft.Maui.Graphics.Rect;
-using ERect = ElmSharp.Rect;
-using EvasObject = ElmSharp.EvasObject;
-using GestureLayer = ElmSharp.GestureLayer;
-using Scroller = ElmSharp.Scroller;
-using TWebView = Tizen.WebView.WebView;
-using XStackLayout = Microsoft.Maui.Controls.StackLayout;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- class RefreshIcon : AbsoluteLayout
- {
- public const int IconSize = ThemeConstants.RefreshView.Resources.IconSize;
- static readonly Color DefaultColor = ThemeConstants.RefreshView.ColorClass.DefaultColor;
- const string IconPath = ThemeConstants.RefreshView.Resources.IconPath;
-
- bool _isPlaying;
- Image _icon;
-
- public RefreshIcon()
- {
- HeightRequest = IconSize;
- WidthRequest = IconSize;
-
- Children.Add(new BoxView
- {
- Color = Color.FromRgb(200, 200, 200),
- CornerRadius = new CornerRadius(IconSize),
- }, new Rect(0.5, 0.5, IconSize, IconSize), AbsoluteLayoutFlags.PositionProportional);
-
- _icon = new Image
- {
- Source = ImageSource.FromResource(IconPath, typeof(ShellItemRenderer).Assembly),
- };
-
- Children.Add(_icon, new Rect(0.5, 0.5, IconSize - 8, IconSize - 8), AbsoluteLayoutFlags.PositionProportional);
-
- IconColor = DefaultColor;
- }
-
- public Color IconColor
- {
- get
- {
- return PlatformConfiguration.TizenSpecific.Image.GetBlendColor(_icon);
- }
- set
- {
- PlatformConfiguration.TizenSpecific.Image.SetBlendColor(_icon, value == null ? DefaultColor : value);
- }
- }
-
- public double IconRotation
- {
- get
- {
- return _icon.Rotation;
- }
- set
- {
- _icon.Rotation = value;
- }
- }
-
- public void Start()
- {
- Stop();
- _isPlaying = true;
- TurnInternal();
- }
-
- public void Stop()
- {
- _isPlaying = false;
- _icon.AbortAnimation("RotateTo");
- }
-
- async void TurnInternal()
- {
- await _icon.RelRotateTo(360, 1000);
- if (_isPlaying)
- TurnInternal();
- }
- }
-
- [Obsolete]
- class RefreshLayout : XStackLayout
- {
- static readonly int MaximumDistance = 100;
-
- public RefreshLayout()
- {
- HeightRequest = 200;
- HorizontalOptions = LayoutOptions.Fill;
-
- RefreshIcon = new RefreshIcon
- {
- HorizontalOptions = LayoutOptions.Center,
- VerticalOptions = LayoutOptions.Center,
- TranslationY = -RefreshIcon.IconSize,
- Opacity = 0.5,
- };
- Children.Add(RefreshIcon);
- Children.Add(new BoxView
- {
- HeightRequest = 200
- });
- }
-
- RefreshIcon RefreshIcon { get; set; }
-
- public Color RefreshIconColor
- {
- get => RefreshIcon.IconColor;
- set => RefreshIcon.IconColor = value;
- }
-
- public void SetDistance(double distance)
- {
- var calculated = -RefreshIcon.IconSize + distance;
- if (calculated > MaximumDistance)
- calculated = MaximumDistance;
- RefreshIcon.TranslationY = calculated;
- RefreshIcon.IconRotation = 180 * (calculated / (float)MaximumDistance);
- RefreshIcon.Opacity = 0.5 + (calculated / (float)MaximumDistance);
- }
-
- public void Start()
- {
- _ = RefreshIcon.TranslateTo(0, MaximumDistance / 2.0, length: 200);
- RefreshIcon.Start();
- }
-
- public bool ShouldRefresh()
- {
- return RefreshIcon.TranslationY > (MaximumDistance - 30);
- }
-
- public async Task StopAsync()
- {
- _ = RefreshIcon.FadeTo(0);
- await RefreshIcon.ScaleTo(0.2);
- RefreshIcon.Stop();
- }
-
- public async Task ResetRefreshIconAsync()
- {
- new Animation((r) =>
- {
- RefreshIcon.IconRotation = 180 * (RefreshIcon.TranslationY / (float)MaximumDistance);
- }).Commit(RefreshIcon, "reset", length: 250);
- _ = RefreshIcon.FadeTo(0.5, length: 250);
- await RefreshIcon.TranslateTo(0, -RefreshIcon.IconSize, length: 250);
- }
- }
-
- enum RefreshState
- {
- Idle,
- Drag,
- Loading,
- }
-
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class RefreshViewRenderer : LayoutRenderer
- {
- ElmSharp.GestureLayer _gestureLayer;
-
- RefreshLayout _refreshLayout;
- IVisualElementRenderer _refreshLayoutRenderer;
-
- public RefreshViewRenderer()
- {
- RegisterPropertyHandler(RefreshView.RefreshColorProperty, UpdateRefreshColor);
- RegisterPropertyHandler(RefreshView.IsRefreshingProperty, UpdateIsRefreshing);
- }
-
- RefreshView RefreshView => Element as RefreshView;
- RefreshState RefreshState { get; set; }
-
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- base.OnElementChanged(e);
- Initialize();
- }
-
- void Initialize()
- {
- _gestureLayer?.Unrealize();
- _gestureLayer = new GestureLayer(NativeView);
- _gestureLayer.Attach(NativeView);
-
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Move, OnMoved);
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.End, OnEnd);
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Abort, OnEnd);
- }
-
- void UpdateRefreshLayout()
- {
- _refreshLayout = new RefreshLayout();
- _refreshLayout.Parent = Element;
- _refreshLayout.RefreshIconColor = RefreshView.RefreshColor;
- _refreshLayoutRenderer = Platform.GetOrCreateRenderer(_refreshLayout);
- (_refreshLayoutRenderer as ILayoutRenderer).RegisterOnLayoutUpdated();
-
- Control.Children.Add(_refreshLayoutRenderer.NativeView);
- var measured = _refreshLayout.Measure(Element.Width, Element.Height);
- var parentBound = NativeView.Geometry;
- var bound = new ERect
- {
- X = parentBound.X,
- Y = parentBound.Y,
- Width = parentBound.Width,
- Height = Forms.ConvertToScaledPixel(measured.Request.Height)
- };
-
- _refreshLayoutRenderer.NativeView.Geometry = bound;
- RefreshState = RefreshState.Drag;
- }
-
- bool IsEdgeScrolling()
- {
- if (RefreshView.Content is ScrollView scrollview)
- {
- if (scrollview.ScrollY == 0)
- {
- return true;
- }
- }
- else if (Platform.GetRenderer(RefreshView.Content) is CarouselViewRenderer carouselViewRenderer)
- {
- var collectionView = carouselViewRenderer.NativeView;
-
- var scroller = collectionView.GetType().GetProperty("Scroller", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(collectionView);
-
- if (scroller != null)
- {
- if ((scroller as Scroller)?.CurrentRegion.Y == 0)
- {
- return true;
- }
- }
- }
- else if (Platform.GetRenderer(RefreshView.Content) is StructuredItemsViewRenderer itemsViewRenderer)
- {
- var collectionView = itemsViewRenderer.NativeView;
-
- var scroller = collectionView.GetType().GetProperty("Scroller", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(collectionView);
-
- if (scroller != null)
- {
- if ((scroller as Scroller)?.CurrentRegion.Y == 0)
- {
- return true;
- }
- }
- }
- else if (Platform.GetRenderer(RefreshView.Content) is ListViewRenderer listViewRenderer)
- {
- if (GetScrollYOnGenList(listViewRenderer.Control.RealHandle) == 0)
- {
- return true;
- }
- }
- else if (Platform.GetRenderer(RefreshView.Content) is WebViewRenderer webviewRenderer)
- {
- if (GetScrollYOnWebView(webviewRenderer.Control.WebView) == 0)
- {
- return true;
- }
- }
-
- return false;
- }
-
- //TODO: the following method is not trimming safe
- [UnconditionalSuppressMessage("Trimming", "IL2026")]
- [UnconditionalSuppressMessage("Trimming", "IL2075")]
- [UnconditionalSuppressMessage("Trimming", "IL2091")]
- int GetScrollYOnGenList(IntPtr handle)
- {
- var interop = typeof(EvasObject).Assembly.GetType("Interop");
- var elementary = interop?.GetNestedType("Elementary", BindingFlags.NonPublic | BindingFlags.Static) ?? null;
-
- if (elementary != null)
- {
- object[] parameters = new object[] { handle, -1, -1, -1, -1 };
- elementary.GetMethod("elm_scroller_region_get", BindingFlags.NonPublic | BindingFlags.Static)?.Invoke(null, parameters);
- return (int)parameters[2];
- }
- return -1;
- }
-
- int GetScrollYOnWebView(TWebView webview)
- {
- var property = webview.GetType().GetProperty("ScrollPosition");
- if (property != null)
- {
- var point = (ElmSharp.Point)property.GetValue(webview);
- return point.Y;
- }
- return -1;
- }
-
- void OnMoved(GestureLayer.MomentumData moment)
- {
- if (RefreshState == RefreshState.Idle)
- {
- if (IsEdgeScrolling())
- {
- UpdateRefreshLayout();
- }
- }
-
- if (RefreshState == RefreshState.Drag)
- {
- var dy = moment.Y2 - moment.Y1;
- _refreshLayout?.SetDistance(Forms.ConvertToScaledDP(dy));
- }
- }
-
- void OnEnd(GestureLayer.MomentumData moment)
- {
- if (RefreshState == RefreshState.Drag && _refreshLayout != null && _refreshLayoutRenderer != null)
- {
- if (_refreshLayout.ShouldRefresh())
- {
- _refreshLayout.Start();
- RefreshState = RefreshState.Loading;
- RefreshView.SetValueFromRenderer(RefreshView.IsRefreshingProperty, true);
- }
- else
- {
- _ = ResetRefreshAsync();
- }
- }
- }
-
- async Task ResetRefreshAsync()
- {
- var refreshLayout = _refreshLayout;
- var refreshIconRenderer = _refreshLayoutRenderer;
- _refreshLayout = null;
- _refreshLayoutRenderer = null;
- await refreshLayout.ResetRefreshIconAsync();
- refreshIconRenderer?.Dispose();
- RefreshState = RefreshState.Idle;
- }
-
- void UpdateRefreshColor()
- {
- if (_refreshLayout != null)
- {
- _refreshLayout.RefreshIconColor = RefreshView.RefreshColor;
- }
- }
-
- async void UpdateIsRefreshing(bool init)
- {
- if (init)
- return;
-
- if (!RefreshView.IsRefreshing && RefreshState == RefreshState.Loading)
- {
- var refreshLayout = _refreshLayout;
- var refreshIconRenderer = _refreshLayoutRenderer;
- _refreshLayout = null;
- _refreshLayoutRenderer = null;
- await refreshLayout?.StopAsync();
- refreshIconRenderer?.Dispose();
-
- RefreshState = RefreshState.Idle;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/ScrollViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/ScrollViewRenderer.cs
index b0ff4ff10b07..c44cf4e46021 100644
--- a/src/Compatibility/Core/src/Tizen/Renderers/ScrollViewRenderer.cs
+++ b/src/Compatibility/Core/src/Tizen/Renderers/ScrollViewRenderer.cs
@@ -1,41 +1,22 @@
using System;
using System.ComponentModel;
-using ElmSharp;
+using System.Linq;
using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Microsoft.Maui.Devices;
-using EContainer = ElmSharp.Container;
-using ERect = ElmSharp.Rect;
-using NBox = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.Box;
-using NScroller = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.Scroller;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.ScrollView;
+using Microsoft.Maui.Graphics;
+using NScrollView = Tizen.UIExtensions.NUI.ScrollView;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
[System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ScrollViewRenderer : ViewRenderer
+ public class ScrollViewRenderer : ViewRenderer
{
- EContainer _scrollCanvas;
- int _defaultVerticalStepSize;
- int _defaultHorizontalStepSize;
-
- EvasBox EvasFormsCanvas => _scrollCanvas as EvasBox;
-
- NBox Canvas => _scrollCanvas as NBox;
-
public ScrollViewRenderer()
{
RegisterPropertyHandler("Content", FillContent);
RegisterPropertyHandler(ScrollView.OrientationProperty, UpdateOrientation);
RegisterPropertyHandler(ScrollView.VerticalScrollBarVisibilityProperty, UpdateVerticalScrollBarVisibility);
RegisterPropertyHandler(ScrollView.HorizontalScrollBarVisibilityProperty, UpdateHorizontalScrollBarVisibility);
- RegisterPropertyHandler(Specific.VerticalScrollStepProperty, UpdateVerticalScrollStep);
- RegisterPropertyHandler(Specific.HorizontalScrollStepProperty, UpdateHorizontalScrollStep);
- }
-
- public override ERect GetNativeContentGeometry()
- {
- return Forms.UseFastLayout ? EvasFormsCanvas.Geometry : Canvas.Geometry;
+ RegisterPropertyHandler(ScrollView.ContentSizeProperty, UpdateContentSize);
}
protected override void OnElementChanged(ElementChangedEventArgs e)
@@ -43,22 +24,7 @@ protected override void OnElementChanged(ElementChangedEventArgs e)
if (Control == null)
{
SetNativeControl(CreateNativeControl());
- Control.Scrolled += OnScrolled;
-
- if (Forms.UseFastLayout)
- {
- _scrollCanvas = new EvasBox(Control);
- EvasFormsCanvas.LayoutUpdated += OnContentLayoutUpdated;
- }
- else
- {
- _scrollCanvas = new NBox(Control);
- Canvas.LayoutUpdated += OnContentLayoutUpdated;
- }
-
- Control.SetContent(_scrollCanvas);
- _defaultVerticalStepSize = Control.VerticalStepSize;
- _defaultHorizontalStepSize = Control.HorizontalStepSize;
+ Control.Scrolling += OnScrolled;
}
if (e.OldElement != null)
@@ -86,16 +52,9 @@ protected override void OnElementPropertyChanged(object sender, PropertyChangedE
}
}
- protected virtual NScroller CreateNativeControl()
+ protected virtual NScrollView CreateNativeControl()
{
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- return new Native.Watch.WatchScroller(Forms.NativeParent, Forms.CircleSurface);
- }
- else
- {
- return new NScroller(Forms.NativeParent);
- }
+ return new NScrollView();
}
protected override void Dispose(bool disposing)
@@ -109,161 +68,69 @@ protected override void Dispose(bool disposing)
if (Control != null)
{
- Control.Scrolled -= OnScrolled;
- }
- if (Canvas != null)
- {
- Canvas.LayoutUpdated -= OnContentLayoutUpdated;
- }
- if (EvasFormsCanvas != null)
- {
- EvasFormsCanvas.LayoutUpdated -= OnContentLayoutUpdated;
+ Control.Scrolling -= OnScrolled;
}
}
-
base.Dispose(disposing);
}
void FillContent()
{
- if (Forms.UseFastLayout)
- {
- EvasFormsCanvas.UnPackAll();
- if (Element.Content != null)
- {
- EvasFormsCanvas.PackEnd(Platform.GetOrCreateRenderer(Element.Content).NativeView);
- UpdateContentSize();
- }
- }
- else
- {
- Canvas.UnPackAll();
- if (Element.Content != null)
- {
- Canvas.PackEnd(Platform.GetOrCreateRenderer(Element.Content).NativeView);
- UpdateContentSize();
- }
- }
- }
-
- void OnContentLayoutUpdated(object sender, Native.LayoutEventArgs e)
- {
- // It is workaround,
- // in some case, before set a size of ScrollView, if content of content was filled with sized items,
- // after size of ScrollView was updated, a content position was moved to somewhere.
- if (Element.Content != null)
+ foreach (var child in Control.ContentContainer.Children.ToList())
{
- Platform.GetRenderer(Element.Content)?.NativeView?.Move(e.Geometry.X, e.Geometry.Y);
+ Control.ContentContainer.Remove(child);
}
+ Control.ContentContainer.Add(Platform.GetOrCreateRenderer(Element.Content).NativeView);
UpdateContentSize();
}
void UpdateOrientation()
{
- switch (Element.Orientation)
- {
- case ScrollOrientation.Horizontal:
- Control.ScrollBlock = ScrollBlock.Vertical;
- Control.HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Auto;
- Control.VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible;
- break;
- case ScrollOrientation.Vertical:
- Control.ScrollBlock = ScrollBlock.Horizontal;
- Control.HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible;
- Control.VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Auto;
- break;
- default:
- Control.ScrollBlock = ScrollBlock.None;
- Control.HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Auto;
- Control.VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Auto;
- break;
- }
+ Control.ScrollOrientation = (global::Tizen.UIExtensions.Common.ScrollOrientation)Element.Orientation;
+
}
void UpdateContentSize()
{
- _scrollCanvas.MinimumWidth = Forms.ConvertToScaledPixel(Element.ContentSize.Width + Element.Padding.HorizontalThickness);
- _scrollCanvas.MinimumHeight = Forms.ConvertToScaledPixel(Element.ContentSize.Height + Element.Padding.VerticalThickness);
-
- // elm-scroller updates the CurrentRegion after render
- Application.Current.Dispatcher.Dispatch(() =>
+ if (Control.ContentContainer.Children.Count > 0)
{
- if (Control != null)
- {
- OnScrolled(Control, EventArgs.Empty);
- }
- });
+ Control.ContentContainer.Children[0].SizeWidth = Forms.ConvertToScaledPixel(Element.ContentSize.Width + Element.Padding.HorizontalThickness);
+ Control.ContentContainer.Children[0].SizeHeight = Forms.ConvertToScaledPixel(Element.ContentSize.Height + Element.Padding.VerticalThickness);
+ }
}
-
protected void OnScrolled(object sender, EventArgs e)
{
- var region = Control.CurrentRegion.ToDP();
+ var region = Control.ScrollBound.ToDP();
((IScrollViewController)Element).SetScrolledPosition(region.X, region.Y);
}
- async void OnScrollRequested(object sender, ScrollToRequestedEventArgs e)
+ void OnScrollRequested(object sender, ScrollToRequestedEventArgs e)
{
var x = e.ScrollX;
var y = e.ScrollY;
if (e.Mode == ScrollToMode.Element)
{
- Graphics.Point itemPosition = (Element as IScrollViewController).GetScrollPositionForElement(e.Element as VisualElement, e.Position);
+ Point itemPosition = (Element as IScrollViewController).GetScrollPositionForElement(e.Element as VisualElement, e.Position);
x = itemPosition.X;
y = itemPosition.Y;
}
- ERect region = new Graphics.Rect(x, y, Element.Width, Element.Height).ToEFLPixel();
- await Control.ScrollToAsync(region, e.ShouldAnimate);
+ var region = new Rect(x, y, Element.Width, Element.Height).ToPixel();
+ Control.ScrollTo((float)(Element.Orientation == ScrollOrientation.Horizontal ? region.X : region.Y), e.ShouldAnimate);
Element.SendScrollFinished();
}
void UpdateVerticalScrollBarVisibility()
{
- Control.VerticalScrollBarVisiblePolicy = Element.VerticalScrollBarVisibility.ToPlatform();
+ Control.VerticalScrollBarVisibility = (global::Tizen.UIExtensions.Common.ScrollBarVisibility)Element.VerticalScrollBarVisibility;
}
void UpdateHorizontalScrollBarVisibility()
{
var orientation = Element.Orientation;
if (orientation == ScrollOrientation.Horizontal || orientation == ScrollOrientation.Both)
- Control.HorizontalScrollBarVisiblePolicy = Element.HorizontalScrollBarVisibility.ToPlatform();
- }
-
- void UpdateVerticalScrollStep(bool initialize)
- {
- var step = Specific.GetVerticalScrollStep(Element);
- if (initialize && step == -1)
- return;
-
- Control.VerticalStepSize = step != -1 ? Forms.ConvertToScaledPixel(step) : _defaultVerticalStepSize;
- }
-
- void UpdateHorizontalScrollStep(bool initialize)
- {
- var step = Specific.GetHorizontalScrollStep(Element);
- if (initialize && step == -1)
- return;
-
- Control.HorizontalStepSize = step != -1 ? Forms.ConvertToScaledPixel(step) : _defaultHorizontalStepSize;
- }
- }
-
- static class ScrollBarExtensions
- {
- public static ScrollBarVisiblePolicy ToNative(this ScrollBarVisibility visibility)
- {
- switch (visibility)
- {
- case ScrollBarVisibility.Default:
- return ScrollBarVisiblePolicy.Auto;
- case ScrollBarVisibility.Always:
- return ScrollBarVisiblePolicy.Visible;
- case ScrollBarVisibility.Never:
- return ScrollBarVisiblePolicy.Invisible;
- default:
- return ScrollBarVisiblePolicy.Auto;
- }
+ Control.HorizontalScrollBarVisibility = (global::Tizen.UIExtensions.Common.ScrollBarVisibility)Element.HorizontalScrollBarVisibility;
}
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/SearchBarRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/SearchBarRenderer.cs
deleted file mode 100644
index 0c6d0a893caa..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/SearchBarRenderer.cs
+++ /dev/null
@@ -1,219 +0,0 @@
-using System;
-using Microsoft.Maui.Controls.Platform;
-using EColor = ElmSharp.Color;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class SearchBarRenderer : ViewRenderer
- {
-
- ///
- /// Creates a new instance of the class.
- /// Registers handlers for various properties of the SearchBar widget.
- ///
- public SearchBarRenderer()
- {
- RegisterPropertyHandler(SearchBar.CancelButtonColorProperty, CancelButtonColorPropertyHandler);
- RegisterPropertyHandler(SearchBar.FontAttributesProperty, FontAttributesPropertyHandler);
- RegisterPropertyHandler(SearchBar.FontFamilyProperty, FontFamilyPropertyHandler);
- RegisterPropertyHandler(SearchBar.FontSizeProperty, FontSizePropertyHandler);
- RegisterPropertyHandler(SearchBar.HorizontalTextAlignmentProperty, HorizontalTextAlignmentPropertyHandler);
- RegisterPropertyHandler(SearchBar.PlaceholderProperty, PlaceholderPropertyHandler);
- RegisterPropertyHandler(SearchBar.PlaceholderColorProperty, PlaceholderColorPropertyHandler);
- RegisterPropertyHandler(SearchBar.TextProperty, TextPropertyHandler);
- RegisterPropertyHandler(SearchBar.TextColorProperty, TextColorPropertyHandler);
- RegisterPropertyHandler(InputView.KeyboardProperty, UpdateKeyboard);
- RegisterPropertyHandler(InputView.MaxLengthProperty, UpdateMaxLength);
- RegisterPropertyHandler(InputView.IsSpellCheckEnabledProperty, UpdateIsSpellCheckEnabled);
- RegisterPropertyHandler(InputView.IsReadOnlyProperty, UpdateIsReadOnly);
- }
-
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.TextChanged -= OnTextChanged;
- Control.Activated -= OnActivated;
- Control.EntryLayoutFocused -= OnFocused;
- Control.EntryLayoutUnfocused -= OnUnfocused;
- }
- }
- base.Dispose(disposing);
- }
-
- ///
- /// A method called whenever the associated element has changed.
- ///
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new Native.SearchBar(Forms.NativeParent));
- Control.IsSingleLine = true;
- Control.SetInputPanelReturnKeyType(ElmSharp.InputPanelReturnKeyType.Search);
-
- Control.TextChanged += OnTextChanged;
- Control.Activated += OnActivated;
- Control.PrependMarkUpFilter(MaxLengthFilter);
-
- Control.EntryLayoutFocused += OnFocused;
- Control.EntryLayoutUnfocused += OnUnfocused;
- }
- base.OnElementChanged(e);
- }
-
- protected override Graphics.Size MinimumSize()
- {
- return Control.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
- }
-
- ///
- /// Called upon changing of Xamarin widget's cancel button color property.
- /// Converts current Color to ElmSharp.Color instance and sets it in the underlying Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native widget.
- ///
- void CancelButtonColorPropertyHandler(bool initialize)
- {
- if (initialize && Element.CancelButtonColor.IsDefault())
- return;
-
- Control.SetClearButtonColor(Element.CancelButtonColor.ToNative());
- }
-
- ///
- /// Called upon changing of Xamarin widget's font attributes property.
- /// Converts current FontAttributes to ElmSharp.FontAttributes instance
- /// and sets it in the underlying Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.SearchBar widget.
- ///
- void FontAttributesPropertyHandler()
- {
- Control.FontAttributes = Element.FontAttributes;
- }
-
- ///
- /// Called upon changing of Xamarin widget's font family property.
- /// Sets current value of FontFamily property to the underlying Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.SearchBar widget.
- ///
- void FontFamilyPropertyHandler()
- {
- Control.FontFamily = Element.FontFamily.ToNativeFontFamily(Element.RequireFontManager());
- }
-
- ///
- /// Called upon changing of Xamarin widget's font size property.
- /// Sets current value of FontSize property to the underlying Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.SearchBar widget.
- ///
- void FontSizePropertyHandler()
- {
- Control.FontSize = Element.FontSize;
- }
-
- ///
- /// Called upon changing of Xamarin widget's horizontal text alignment property.
- /// Converts current HorizontalTextAlignment property's value to Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.TextAlignment instance
- /// and sets it in the underlying Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.SearchBar widget.
- ///
- void HorizontalTextAlignmentPropertyHandler()
- {
- Control.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative();
- }
-
- ///
- /// Called upon changing of Xamarin widget's placeholder color property.
- /// Converts current PlaceholderColor property value to ElmSharp.Color instance
- /// and sets it in the underlying Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.SearchBar widget.
- ///
- void PlaceholderColorPropertyHandler(bool initialize)
- {
- if (initialize && Element.TextColor.IsDefault())
- return;
-
- Control.PlaceholderColor = Element.PlaceholderColor.ToNative();
- }
-
- ///
- /// Called upon changing of Xamarin widget's placeholder text property.
- ///
- void PlaceholderPropertyHandler()
- {
- Control.Placeholder = Element.Placeholder;
- }
-
- ///
- /// Called on every change of underlying SearchBar's Text property.
- /// Rewrites current underlying Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.SearchBar's Text contents to its Xamarin counterpart.
- ///
- /// Sender.
- /// Event arguments.
- void OnTextChanged(object sender, EventArgs e)
- {
- Element.SetValueFromRenderer(SearchBar.TextProperty, Control.Text);
- }
-
- ///
- /// Called when the user clicks the Search button.
- ///
- /// Sender.
- /// Event arguments.
- void OnActivated(object sender, EventArgs e)
- {
- Control.HideInputPanel();
- (Element as ISearchBarController).OnSearchButtonPressed();
- }
-
- ///
- /// Called upon changing of Xamarin widget's text color property.
- /// Converts current TextColor property value to ElmSharp.Color instance
- /// and sets it in the underlying Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.SearchBar widget.
- ///
- void TextColorPropertyHandler(bool initialize)
- {
- if (initialize && Element.TextColor.IsDefault())
- return;
-
- Control.TextColor = Element.TextColor.ToNative();
- }
-
- ///
- /// Called upon changing of Xamarin widget's text property.
- ///
- void TextPropertyHandler()
- {
- Control.Text = Element.Text ?? "";
- }
-
- void UpdateKeyboard(bool initialize)
- {
- if (initialize && Element.Keyboard == Keyboard.Default)
- return;
- Control.UpdateKeyboard(Element.Keyboard, Element.IsSpellCheckEnabled, true);
- }
-
- void UpdateIsSpellCheckEnabled()
- {
- Control.InputHint = Element.Keyboard.ToInputHints(Element.IsSpellCheckEnabled, true);
- }
-
- void UpdateMaxLength()
- {
- if (Control.Text.Length > Element.MaxLength)
- Control.Text = Control.Text.Substring(0, Element.MaxLength);
- }
-
- string MaxLengthFilter(ElmSharp.Entry entry, string s)
- {
- if (entry.Text.Length < Element.MaxLength)
- return s;
-
- return null;
- }
-
- void UpdateIsReadOnly()
- {
- Control.IsEditable = !Element.IsReadOnly;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/SliderRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/SliderRenderer.cs
deleted file mode 100644
index 8536bc313815..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/SliderRenderer.cs
+++ /dev/null
@@ -1,145 +0,0 @@
-using System;
-using System.ComponentModel;
-using Microsoft.Maui.Controls.Platform;
-using EColor = ElmSharp.Color;
-using ESize = ElmSharp.Size;
-using ESlider = ElmSharp.Slider;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class SliderRenderer : ViewRenderer
- {
- EColor _defaultMinColor;
- EColor _defaultMaxColor;
- EColor _defaultThumbColor;
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(CreateNativeControl());
- Control.ValueChanged += OnValueChanged;
- Control.DragStarted += OnDragStarted;
- Control.DragStopped += OnDragStopped;
- _defaultMinColor = Control.GetBarColor();
- _defaultMaxColor = Control.GetBackgroundColor();
- _defaultThumbColor = Control.GetHandlerColor();
- }
-
- UpdateMinimum();
- UpdateMaximum();
- UpdateValue();
- UpdateSliderColors();
- base.OnElementChanged(e);
- }
-
- protected virtual ESlider CreateNativeControl()
- {
- return new ESlider(Forms.NativeParent);
- }
-
- protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == Slider.MinimumProperty.PropertyName)
- {
- UpdateMinimum();
- }
- else if (e.PropertyName == Slider.MaximumProperty.PropertyName)
- {
- UpdateMaximum();
- }
- else if (e.PropertyName == Slider.ValueProperty.PropertyName)
- {
- UpdateValue();
- }
- else if (e.PropertyName == Slider.MinimumTrackColorProperty.PropertyName)
- {
- UpdateMinimumTrackColor();
- }
- else if (e.PropertyName == Slider.MaximumTrackColorProperty.PropertyName)
- {
- UpdateMaximumTrackColor();
- }
- else if (e.PropertyName == Slider.ThumbColorProperty.PropertyName)
- {
- UpdateThumbColor();
- }
- base.OnElementPropertyChanged(sender, e);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.ValueChanged -= OnValueChanged;
- Control.DragStarted -= OnDragStarted;
- Control.DragStopped -= OnDragStopped;
- }
- }
- base.Dispose(disposing);
- }
-
- protected override ESize Measure(int availableWidth, int availableHeight)
- {
- return new ESize(Math.Min(200, availableWidth), 50);
- }
-
- void OnValueChanged(object sender, EventArgs e)
- {
- Element.SetValueFromRenderer(Slider.ValueProperty, Control.Value);
- }
-
- void OnDragStarted(object sender, EventArgs e)
- {
- ((ISliderController)Element)?.SendDragStarted();
- }
-
- void OnDragStopped(object sender, EventArgs e)
- {
- ((ISliderController)Element)?.SendDragCompleted();
- }
-
- protected void UpdateValue()
- {
- Control.Value = Element.Value;
- }
-
- protected void UpdateMinimum()
- {
- Control.Minimum = Element.Minimum;
- }
-
- protected void UpdateMaximum()
- {
- Control.Maximum = Element.Maximum;
- }
-
- protected virtual void UpdateMinimumTrackColor()
- {
- var color = Element.MinimumTrackColor.IsDefault() ? _defaultMinColor : Element.MinimumTrackColor.ToNative();
- Control.SetBarColor(color);
- }
-
- protected virtual void UpdateMaximumTrackColor()
- {
- Control.SetBackgroundColor(Element.MaximumTrackColor.IsDefault() ? _defaultMaxColor : Element.MaximumTrackColor.ToNative());
- }
-
- protected virtual void UpdateThumbColor()
- {
- var color = Element.ThumbColor.IsDefault() ? _defaultThumbColor : Element.ThumbColor.ToNative();
- Control.SetHandlerColor(color);
- }
-
- protected void UpdateSliderColors()
- {
- // Changing slider color is only available on mobile profile. Otherwise ignored.
- UpdateMinimumTrackColor();
- UpdateMaximum();
- UpdateThumbColor();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/StepperRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/StepperRenderer.cs
deleted file mode 100644
index 5f0fed99290c..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/StepperRenderer.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-using System;
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.Watch;
-using Microsoft.Maui.Devices;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class StepperRenderer : ViewRenderer
- {
-
- public StepperRenderer()
- {
- RegisterPropertyHandler(Stepper.ValueProperty, UpdateValue);
- RegisterPropertyHandler(Stepper.MinimumProperty, UpdateMinimum);
- RegisterPropertyHandler(Stepper.MaximumProperty, UpdateMaximum);
- RegisterPropertyHandler(Stepper.IncrementProperty, UpdateStep);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(CreateNativeControl());
- Control.ValueChanged += OnValueChanged;
- }
- base.OnElementChanged(e);
- }
-
- protected virtual Spinner CreateNativeControl()
- {
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- return new WatchSpinner(Forms.NativeParent, Forms.CircleSurface);
- }
- else
- {
- return new Spinner(Forms.NativeParent)
- {
- IsEditable = false
- };
- }
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.ValueChanged -= OnValueChanged;
- }
- }
- base.Dispose(disposing);
- }
-
- protected virtual void OnValueChanged(object sender, EventArgs e)
- {
- ((IElementController)Element).SetValueFromRenderer(Stepper.ValueProperty, Control.Value);
- }
-
- protected void UpdateValue()
- {
- Control.Value = Element.Value;
- }
-
- protected void UpdateMinimum()
- {
- Control.Minimum = Element.Minimum;
- }
-
- protected void UpdateMaximum()
- {
- Control.Maximum = Element.Maximum;
- }
-
- void UpdateStep()
- {
- Control.LabelFormat = string.Format("%.{0}f", GetRequiredPrecision(Element.Increment));
- Control.Step = Element.Increment;
-
- if (Control is WatchSpinner)
- {
- // Changing maximum value as a workaround to update CircleSpinner's genlist.
- Control.Maximum = Control.Maximum + 1;
- Control.Maximum = Element.Maximum;
- }
- }
-
- int GetRequiredPrecision(double step)
- {
- // Determines how many decimal places are there in current Stepper's value.
- // The 15 pound characters below correspond to the maximum precision of Double type.
- var decimalValue = Decimal.Parse(step.ToString("0.###############"));
-
- // GetBits() method returns an array of four 32-bit integer values.
- // The third (0-indexing) element of an array contains the following information:
- // bits 00-15: unused, required to be 0
- // bits 16-23: an exponent between 0 and 28 indicating the power of 10 to divide the integer number passed as a parameter.
- // Conversely this is the number of decimal digits in the number as well.
- // bits 24-30: unused, required to be 0
- // bit 31: indicates the sign. 0 means positive number, 1 is for negative numbers.
- //
- // The precision information needs to be extracted from bits 16-23 of third element of an array
- // returned by GetBits() call. Right-shifting by 16 bits followed by zeroing anything else results
- // in a nice conversion of this data to integer variable.
- var precision = (Decimal.GetBits(decimalValue)[3] >> 16) & 0x000000FF;
-
- return precision;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/StructuredItemsViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/StructuredItemsViewRenderer.cs
deleted file mode 100644
index fd6e09193b39..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/StructuredItemsViewRenderer.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class StructuredItemsViewRenderer : ItemsViewRenderer
- {
- public StructuredItemsViewRenderer()
- {
- RegisterPropertyHandler(StructuredItemsView.ItemsLayoutProperty, UpdateItemsLayout);
- RegisterPropertyHandler(SelectableItemsView.SelectedItemProperty, UpdateSelectedItem);
- RegisterPropertyHandler(SelectableItemsView.SelectionModeProperty, UpdateSelectionMode);
- RegisterPropertyHandler(StructuredItemsView.ItemSizingStrategyProperty, UpdateSizingStrategy);
- RegisterPropertyHandler(StructuredItemsView.HeaderProperty, UpdateHeaderFooter);
- RegisterPropertyHandler(StructuredItemsView.HeaderTemplateProperty, UpdateHeaderFooter);
- RegisterPropertyHandler(StructuredItemsView.FooterProperty, UpdateHeaderFooter);
- RegisterPropertyHandler(StructuredItemsView.FooterTemplateProperty, UpdateHeaderFooter);
- }
-
- protected override Native.CollectionView CreateNativeControl(ElmSharp.EvasObject parent)
- {
- return new Native.CollectionView(parent);
- }
-
- protected override IItemsLayout GetItemsLayout()
- {
- return Element.ItemsLayout;
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- base.OnElementChanged(e);
- }
-
- protected override void OnItemSelectedFromUI(object sender, SelectedItemChangedEventArgs e)
- {
- if (Element is SelectableItemsView selectableItemsView)
- {
- selectableItemsView.SelectedItem = e.SelectedItem;
- }
- }
-
- protected void UpdateSizingStrategy(bool initialize)
- {
- if (initialize)
- {
- return;
- }
- UpdateItemsLayout();
- }
-
- void UpdateSelectedItem(bool initialize)
- {
- if (initialize)
- return;
-
- if (Element is SelectableItemsView selectable)
- {
- Control?.Adaptor?.RequestItemSelected(selectable.SelectedItem);
- }
- }
-
- void UpdateSelectionMode()
- {
- if (Element is SelectableItemsView selectable)
- {
- Control.SelectionMode = selectable.SelectionMode == SelectionMode.None ? CollectionViewSelectionMode.None : CollectionViewSelectionMode.Single;
- }
- }
-
- void UpdateHeaderFooter(bool init)
- {
- if (!init)
- {
- UpdateAdaptor(false);
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/SwipeViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/SwipeViewRenderer.cs
deleted file mode 100644
index b891670b072e..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/SwipeViewRenderer.cs
+++ /dev/null
@@ -1,433 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using ElmSharp;
-using Microsoft.Maui.Controls.Internals;
-using Microsoft.Maui.Controls.Platform;
-using ERect = ElmSharp.Rect;
-using XStackLayout = Microsoft.Maui.Controls.StackLayout;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- enum SwipeDrawerState
- {
- Opend,
- Closed
- }
-
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class SwipeViewRenderer : LayoutRenderer
- {
- static readonly double SwipeItemWidth = Forms.ConvertToScaledDP(100);
- static readonly double SwipeItemHeight = Forms.ConvertToScaledDP(40);
- static readonly int MovementThreshold = 1000;
- static readonly uint SwipeAnimationDuration = 120;
-
- GestureLayer _gestureLayer;
- IVisualElementRenderer _itemsRenderer;
-
- SwipeView SwipeView => Element as SwipeView;
-
- bool HasLeftItems => SwipeView.LeftItems?.Count > 0;
- bool HasRightItems => SwipeView.RightItems?.Count > 0;
- bool HasTopItems => SwipeView.TopItems?.Count > 0;
- bool HasBottomItems => SwipeView.BottomItems?.Count > 0;
-
- SwipeDirection SwipeDirection { get; set; }
-
- SwipeDrawerState DrawerState { get; set; }
-
- int MaximumSwipeSize { get; set; }
-
- bool IsHorizontalSwipe => SwipeDirection == SwipeDirection.Left || SwipeDirection == SwipeDirection.Right;
- bool IsNegativeDirection => SwipeDirection == SwipeDirection.Left || SwipeDirection == SwipeDirection.Up;
-
- SwipeItems CurrentItems { get; set; }
-
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- base.OnElementChanged(e);
- Initialize();
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- _gestureLayer?.Unrealize();
- _gestureLayer = null;
- _itemsRenderer?.Dispose();
- _itemsRenderer = null;
- }
- base.Dispose(disposing);
- }
-
- void Initialize()
- {
- _gestureLayer?.Unrealize();
- _gestureLayer = new GestureLayer(NativeView);
- _gestureLayer.Attach(NativeView);
-
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Move, OnMoved);
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.End, OnEnd);
- _gestureLayer.SetMomentumCallback(GestureLayer.GestureState.Abort, OnEnd);
- SwipeDirection = 0;
- DrawerState = SwipeDrawerState.Closed;
- Control.AllowFocus(true);
- Control.Unfocused += (s, e) =>
- {
- _ = SwipeCloseAsync();
- };
- }
-
- void OnMoved(GestureLayer.MomentumData moment)
- {
- if (SwipeDirection == 0)
- {
- var direction = SwipeDirectionHelper.GetSwipeDirection(new Graphics.Point(moment.X1, moment.Y1), new Graphics.Point(moment.X2, moment.Y2));
-
- if (HasRightItems && direction == SwipeDirection.Left)
- {
- SwipeDirection = SwipeDirection.Left;
- }
- else if (HasLeftItems && direction == SwipeDirection.Right)
- {
- SwipeDirection = SwipeDirection.Right;
- }
- else if (HasTopItems && direction == SwipeDirection.Down)
- {
- SwipeDirection = SwipeDirection.Down;
- }
- else if (HasBottomItems && direction == SwipeDirection.Up)
- {
- SwipeDirection = SwipeDirection.Up;
- }
- else
- {
- return;
- }
-
- UpdateItems();
- ((ISwipeViewController)Element).SendSwipeStarted(new SwipeStartedEventArgs(SwipeDirection));
- }
-
- var offset = GetSwipeOffset(moment);
-
- if (IsNegativeDirection)
- {
- if (offset > 0)
- offset = 0;
- }
- else
- {
- if (offset < 0)
- offset = 0;
- }
-
- if (Math.Abs(offset) > MaximumSwipeSize)
- {
- offset = MaximumSwipeSize * (offset < 0 ? -1 : 1);
- }
-
- var toDragBound = NativeView.Geometry;
- if (IsHorizontalSwipe)
- {
- toDragBound.X += offset;
- }
- else
- {
- toDragBound.Y += offset;
- }
- Platform.GetRenderer(SwipeView.Content).NativeView.Geometry = toDragBound;
- ((ISwipeViewController)Element).SendSwipeChanging(new SwipeChangingEventArgs(SwipeDirection, Forms.ConvertToScaledDP(offset)));
- }
- async void OnEnd(GestureLayer.MomentumData moment)
- {
- if (SwipeDirection == 0)
- return;
-
- if (ShouldBeOpen(moment))
- {
- await SwipeOpenAsync();
- if (CurrentItems.Mode == SwipeMode.Execute)
- {
- ExecuteItems(CurrentItems);
- _ = SwipeCloseAsync();
- }
- }
- else
- {
- await SwipeCloseAsync();
- }
- }
-
- async Task SwipeOpenAsync()
- {
- var opendBound = NativeView.Geometry;
- if (IsHorizontalSwipe)
- {
- opendBound.X += MaximumSwipeSize * (IsNegativeDirection ? -1 : 1);
- }
- else
- {
- opendBound.Y += MaximumSwipeSize * (IsNegativeDirection ? -1 : 1);
- }
-
- await AnimatedMove(SwipeView.Content, Platform.GetRenderer(SwipeView.Content).NativeView, opendBound, length: SwipeAnimationDuration);
- DrawerState = SwipeDrawerState.Opend;
- }
-
- async Task SwipeCloseAsync()
- {
- if (SwipeDirection == 0)
- return;
-
- await AnimatedMove(SwipeView.Content, Platform.GetRenderer(SwipeView.Content).NativeView, NativeView.Geometry, length: SwipeAnimationDuration);
-
- if (_itemsRenderer != null)
- {
- Control.Children.Remove(_itemsRenderer.NativeView);
- _itemsRenderer.Dispose();
- _itemsRenderer = null;
- }
-
- ((ISwipeViewController)Element).SendSwipeEnded(new SwipeEndedEventArgs(SwipeDirection, DrawerState == SwipeDrawerState.Opend));
- DrawerState = SwipeDrawerState.Closed;
- SwipeDirection = 0;
- }
-
- bool ShouldBeOpen(GestureLayer.MomentumData data)
- {
- var momentum = IsHorizontalSwipe ? data.HorizontalMomentum : data.VerticalMomentum;
-
- if (Math.Abs(momentum) > MovementThreshold)
- {
- return IsNegativeDirection ? momentum < 0 : momentum > 0;
- }
-
- return Math.Abs(GetSwipeOffset(data)) > MaximumSwipeSize / 2.0;
- }
-
- int GetSwipeOffset(GestureLayer.MomentumData data)
- {
- if (IsHorizontalSwipe)
- {
- return DrawerState == SwipeDrawerState.Closed ? (data.X2 - data.X1) :
- (((IsNegativeDirection ? -1 : 1) * MaximumSwipeSize) - (data.X1 - data.X2));
- }
- else
- {
- return DrawerState == SwipeDrawerState.Closed ? (data.Y2 - data.Y1) :
- (((IsNegativeDirection ? -1 : 1) * MaximumSwipeSize) - (data.Y1 - data.Y2));
- }
- }
-
- SwipeItems GetSwipedItems()
- {
- SwipeItems items = SwipeView.LeftItems;
- switch (SwipeDirection)
- {
- case SwipeDirection.Right:
- items = SwipeView.LeftItems;
- break;
- case SwipeDirection.Left:
- items = SwipeView.RightItems;
- break;
- case SwipeDirection.Up:
- items = SwipeView.BottomItems;
- break;
- case SwipeDirection.Down:
- items = SwipeView.TopItems;
- break;
- }
- return items;
- }
-
- void UpdateItems()
- {
- CurrentItems = GetSwipedItems();
- var itemsLayout = new XStackLayout
- {
- Spacing = 0,
- Orientation = IsHorizontalSwipe ? StackOrientation.Horizontal : StackOrientation.Vertical,
- FlowDirection = SwipeDirection == SwipeDirection.Left ? FlowDirection.RightToLeft : FlowDirection.LeftToRight
- };
-
- foreach (var item in CurrentItems)
- {
- View itemView = null;
- if (item is SwipeItem switem)
- {
- itemView = CreateItemView(switem, !IsHorizontalSwipe);
- }
- else if (item is SwipeItemView customItem)
- {
- itemView = CreateItemView(customItem);
- }
- else
- {
- continue;
- }
-
- var tap = new TapGestureRecognizer();
- tap.Command = item.Command;
- tap.CommandParameter = item.CommandParameter;
- tap.Tapped += (s, e) =>
- {
- if (item is ISwipeItem swipeItem)
- swipeItem.OnInvoked();
-
- if (item is SwipeItemView customSwipeItem)
- customSwipeItem.OnInvoked();
-
- if (CurrentItems.SwipeBehaviorOnInvoked != SwipeBehaviorOnInvoked.RemainOpen)
- {
- Application.Current.Dispatcher.Dispatch(() =>
- {
- _ = SwipeCloseAsync();
- });
- }
- };
- itemView.GestureRecognizers.Add(tap);
-
- if (IsHorizontalSwipe)
- {
- itemView.HorizontalOptions = LayoutOptions.Start;
- itemView.VerticalOptions = LayoutOptions.Fill;
- }
- else
- {
- itemView.VerticalOptions = LayoutOptions.Start;
- itemView.HorizontalOptions = LayoutOptions.Fill;
- }
- itemsLayout.Children.Add(itemView);
- }
-
- var itemsRenderer = Platform.GetOrCreateRenderer(itemsLayout);
- (itemsRenderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
- var measured = itemsLayout.Measure(Element.Width, Element.Height);
-
- MaximumSwipeSize = Forms.ConvertToScaledPixel(
- IsHorizontalSwipe ?
- Math.Min(measured.Request.Width, Element.Width) :
- Math.Min(measured.Request.Height, Element.Height));
-
- Control.Children.Add(itemsRenderer.NativeView);
-
- var itemsGeometry = NativeView.Geometry;
- if (SwipeDirection == SwipeDirection.Up)
- {
- itemsGeometry.Y += (itemsGeometry.Height - MaximumSwipeSize);
- }
- itemsRenderer.NativeView.Geometry = itemsGeometry;
- itemsRenderer.NativeView.StackBelow(Platform.GetRenderer(SwipeView.Content).NativeView);
-
- _itemsRenderer = itemsRenderer;
- }
-
- static Task AnimatedMove(IAnimatable animatable, EvasObject target, ERect dest, Easing easing = null, uint length = 120)
- {
- var tcs = new TaskCompletionSource();
-
- var dx = target.Geometry.X - dest.X;
- var dy = target.Geometry.Y - dest.Y;
-
- new Animation((progress) =>
- {
- ERect toMove = dest;
- toMove.X += (int)(dx * (1 - progress));
- toMove.Y += (int)(dy * (1 - progress));
- target.Geometry = toMove;
- }).Commit(animatable, "Move", rate: 60, length: length, easing: easing, finished: (p, e) =>
- {
- tcs.SetResult(true);
- });
- return tcs.Task;
- }
-
- static View CreateItemView(SwipeItemView item)
- {
- return new XStackLayout
- {
- VerticalOptions = LayoutOptions.Fill,
- HorizontalOptions = LayoutOptions.Fill,
- Children =
- {
- item.Content
- }
- };
- }
-
- static View CreateItemView(SwipeItem item, bool horizontal)
- {
- var image = new Image
- {
- Source = item.IconImageSource
- };
- var label = new Label
- {
- Text = item.Text,
- HorizontalTextAlignment = TextAlignment.Center,
-#pragma warning disable CS0612 // Type or member is obsolete
- FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label)),
-#pragma warning disable CS0612 // Type or member is obsolete
- };
-
- if (horizontal)
- {
- image.VerticalOptions = LayoutOptions.Fill;
- image.HorizontalOptions = LayoutOptions.Start;
-
- label.VerticalOptions = LayoutOptions.Center;
- label.HorizontalOptions = LayoutOptions.Center;
- label.VerticalTextAlignment = TextAlignment.Center;
-#pragma warning disable CS0612 // Type or member is obsolete
- label.FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));
-#pragma warning disable CS0612 // Type or member is obsolete
- }
- else
- {
- image.VerticalOptions = LayoutOptions.Fill;
- image.HorizontalOptions = LayoutOptions.Fill;
-
- label.VerticalOptions = LayoutOptions.End;
- label.HorizontalOptions = LayoutOptions.Center;
- label.VerticalTextAlignment = TextAlignment.End;
- }
-
- var layout = new XStackLayout
- {
- Padding = 5,
- BackgroundColor = item.BackgroundColor,
- VerticalOptions = LayoutOptions.Fill,
- Orientation = horizontal ? StackOrientation.Horizontal : StackOrientation.Vertical,
- Children =
- {
- image,
- label
- }
- };
- if (horizontal)
- {
- layout.HeightRequest = SwipeItemHeight;
- }
- else
- {
- layout.WidthRequest = SwipeItemWidth;
- }
- return layout;
- }
-
- static void ExecuteItems(SwipeItems items)
- {
- foreach (var item in items)
- {
- if (item is SwipeItem swipeItem && swipeItem.IsEnabled)
- item.OnInvoked();
- else if (item is SwipeItemView customSwipeItem && customSwipeItem.IsEnabled)
- item.OnInvoked();
- }
- }
-
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/SwitchRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/SwitchRenderer.cs
deleted file mode 100644
index 38973d228e56..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/SwitchRenderer.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using System;
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific;
-using EColor = ElmSharp.Color;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.VisualElement;
-using SpecificSwitch = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.Switch;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class SwitchRenderer : ViewRenderer
- {
- public SwitchRenderer()
- {
- RegisterPropertyHandler(Switch.IsToggledProperty, HandleToggled);
- RegisterPropertyHandler(Switch.OnColorProperty, UpdateOnColor);
- RegisterPropertyHandler(SpecificSwitch.ColorProperty, UpdateColor);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new Check(Forms.NativeParent)
- {
- Style = SwitchStyle.Toggle
- });
- Control.StateChanged += OnStateChanged;
- }
- base.OnElementChanged(e);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.StateChanged -= OnStateChanged;
- }
- }
- base.Dispose(disposing);
- }
-
- protected override void UpdateThemeStyle()
- {
- var style = Specific.GetStyle(Element);
- if (string.IsNullOrEmpty(style))
- {
- return;
- }
- switch (style)
- {
- case SwitchStyle.Toggle:
- case SwitchStyle.Favorite:
- case SwitchStyle.CheckBox:
- case SwitchStyle.OnOff:
- case SwitchStyle.Small:
- Control.Style = style;
- break;
- default:
- Control.Style = SwitchStyle.Toggle;
- break;
- }
- ((IVisualElementController)Element).PlatformSizeChanged();
- UpdateBackgroundColor(false);
- UpdateOnColor(false);
- UpdateColor();
- }
-
- protected virtual void UpdateColor()
- {
- var color = SpecificSwitch.GetColor(Element);
- if (color != null)
- {
- Control.Color = color.ToPlatformEFL();
- }
- }
-
- protected void UpdateOnColor(bool initialize)
- {
- if (initialize && Element.OnColor.IsDefault())
- return;
-
- if (Element.OnColor.IsDefault())
- {
- Control.DeleteOnColors();
- }
- else
- {
- Control.SetOnColors(Element.OnColor.ToPlatformEFL());
- }
- }
-
- void OnStateChanged(object sender, EventArgs e)
- {
- Element.SetValueFromRenderer(Switch.IsToggledProperty, Control.IsChecked);
- }
-
- void HandleToggled()
- {
- Control.IsChecked = Element.IsToggled;
- }
-
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/TabbedPageRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/TabbedPageRenderer.cs
deleted file mode 100644
index 8e0711ecfd47..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/TabbedPageRenderer.cs
+++ /dev/null
@@ -1,499 +0,0 @@
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using System.Linq;
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific;
-using Microsoft.Maui.Devices;
-using EColor = ElmSharp.Color;
-using ERect = ElmSharp.Rect;
-using EToolbar = ElmSharp.Toolbar;
-using EToolbarItem = ElmSharp.ToolbarItem;
-using EToolbarItemEventArgs = ElmSharp.ToolbarItemEventArgs;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class TabbedPageRenderer : VisualElementRenderer
- {
- Box _outterLayout;
- Box _innerBox;
- Scroller _scroller;
- EToolbar _toolbar;
- Dictionary _itemToItemPage = new Dictionary();
- List _toolbarItemList = new List();
- bool _isResettingToolbarItems = false;
- bool _isInitialized = false;
- bool _isUpdateByToolbar = false;
- bool _isUpdateByScroller = false;
- bool _isUpdateByCurrentPage = false;
-
- public TabbedPageRenderer()
- {
- RegisterPropertyHandler(Page.TitleProperty, UpdateTitle);
- RegisterPropertyHandler(nameof(Element.CurrentPage), OnCurrentPageChanged);
- RegisterPropertyHandler(TabbedPage.BarBackgroundColorProperty, UpdateBarBackgroundColor);
- RegisterPropertyHandler(TabbedPage.BarTextColorProperty, UpdateBarTextColor);
- RegisterPropertyHandler(TabbedPage.SelectedTabColorProperty, UpdateSelectedTabColor);
- RegisterPropertyHandler(TabbedPage.UnselectedTabColorProperty, UpdateUnselectedTabColor);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (_toolbar == null)
- {
- //Create box that holds toolbar and selected content
- _outterLayout = new Box(Forms.NativeParent)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
- IsHorizontal = false,
- };
- _outterLayout.Show();
-
- //Create toolbar that is placed inside the _outterLayout
- _toolbar = new EToolbar(Forms.NativeParent)
- {
- AlignmentX = -1,
- WeightX = 1,
- SelectionMode = ToolbarSelectionMode.Always,
- };
-
- if (DeviceInfo.Idiom == DeviceIdiom.Phone)
- {
- //Set ShrinkMode to Expand as defauly only for Mobile profile
- _toolbar.ShrinkMode = ToolbarShrinkMode.Expand;
- }
- else if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- //According to TV UX Guideline, toolbar style should be set to "tabbar_with_title" in case of TabbedPage only for TV profile.
- _toolbar.SetTVTabBarWithTitleStyle();
- }
-
- _toolbar.Show();
- //Add callback for Toolbar item selection
- _toolbar.Selected += OnToolbarItemSelected;
- _outterLayout.PackEnd(_toolbar);
-
- _scroller = new Scroller(_outterLayout)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
- HorizontalPageScrollLimit = 1,
- ScrollBlock = ScrollBlock.Vertical,
- HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible
- };
- _scroller.SetPageSize(1.0, 1.0);
- _scroller.PageScrolled += OnItemPageScrolled;
-
- _innerBox = new Box(Forms.NativeParent)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
- IsHorizontal = true,
- };
-
- _innerBox.SetLayoutCallback(OnInnerLayoutUpdate);
-
- _scroller.SetContent(_innerBox);
- _scroller.Show();
-
- _outterLayout.PackEnd(_scroller);
-
- SetNativeView(_outterLayout);
- UpdateTitle();
- }
-
- if (e.OldElement != null)
- {
- e.OldElement.PagesChanged -= OnElementPagesChanged;
- _isInitialized = false;
- }
- if (e.NewElement != null)
- {
- e.NewElement.PagesChanged += OnElementPagesChanged;
- }
-
- base.OnElementChanged(e);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- Element.PagesChanged -= OnElementPagesChanged;
- if (_outterLayout != null)
- {
- _outterLayout.Unrealize();
- _outterLayout = null;
- }
- if (_toolbar != null)
- {
- _toolbar.Selected -= OnToolbarItemSelected;
- _scroller.PageScrolled -= OnItemPageScrolled;
- _toolbar.Unrealize();
- _toolbar = null;
- }
- }
- base.Dispose(disposing);
- }
-
- protected override void OnElementReady()
- {
- base.OnElementReady();
- _isInitialized = true;
- FillToolbarAndContents();
- Element.UpdateFocusTreePolicy();
- }
-
- protected override void UpdateThemeStyle()
- {
- var style = Element.OnThisPlatform().GetStyle();
- if (!string.IsNullOrEmpty(style))
- {
- _toolbar.Style = style;
- ((IVisualElementController)Element).PlatformSizeChanged();
- UpdateBackgroundColor(false);
- UpdateBarBackgroundColor(false);
- UpdateSelectedTabColor(false);
- UpdateUnselectedTabColor(false);
- }
- }
-
- void OnInnerLayoutUpdate()
- {
- if (!_isInitialized)
- return;
-
- int baseX = _innerBox.Geometry.X;
- ERect bound = _scroller.Geometry;
- int index = 0;
- foreach (var page in Element.Children)
- {
- var nativeView = Platform.GetRenderer(page).NativeView;
- bound.X = baseX + index * bound.Width;
- nativeView.Geometry = bound;
- index++;
- }
- _innerBox.MinimumWidth = Element.Children.Count * bound.Width;
- if (_toolbar.SelectedItem == null)
- return;
- int currentPage = MultiPage.GetIndex(_itemToItemPage[_toolbar.SelectedItem]);
- _scroller.ScrollTo(currentPage, 0, false);
- }
-
- void OnItemPageScrolled(object sender, System.EventArgs e)
- {
- if (_isUpdateByToolbar || _isUpdateByCurrentPage)
- return;
- _isUpdateByScroller = true;
-
- var oldPage = Element.CurrentPage;
- var toBeSelectedItem = _toolbarItemList[_scroller.HorizontalPageIndex];
- var newPage = _itemToItemPage[toBeSelectedItem];
-
- if (oldPage != newPage)
- {
- oldPage?.SendDisappearing();
- newPage.SendAppearing();
-
- toBeSelectedItem.IsSelected = true;
- Element.CurrentPage = newPage;
- Element.UpdateFocusTreePolicy();
- }
-
- _isUpdateByScroller = false;
- }
-
- void UpdateBarBackgroundColor(bool initialize)
- {
- if (initialize && Element.BarBackgroundColor.IsDefault())
- return;
-
- EColor bgColor = Element.BarBackgroundColor.ToPlatformEFL();
- _toolbar.BackgroundColor = bgColor;
- foreach (EToolbarItem item in _itemToItemPage.Keys)
- {
- ApplyBarItemColors(item, BarItemColorType.Background, bgColor);
- }
- }
-
- void UpdateBarTextColor(bool initialize)
- {
- if (initialize && Element.BarTextColor.IsDefault())
- return;
-
- foreach (EToolbarItem item in _itemToItemPage.Keys)
- {
- ApplyBarItemColors(item, BarItemColorType.Text, Element.BarTextColor.ToPlatformEFL());
- }
- }
-
- void UpdateSelectedTabColor(bool initialize)
- {
- if (initialize && Element.SelectedTabColor.IsDefault())
- return;
-
- foreach (EToolbarItem item in _itemToItemPage.Keys)
- {
- ApplyBarItemColors(item, BarItemColorType.SelectedTab, Element.SelectedTabColor.ToPlatformEFL());
- }
- }
-
- void UpdateUnselectedTabColor(bool initialize)
- {
- if (initialize && Element.UnselectedTabColor.IsDefault())
- return;
-
- foreach (EToolbarItem item in _itemToItemPage.Keys)
- {
- ApplyBarItemColors(item, BarItemColorType.UnselectedTab, Element.UnselectedTabColor.ToPlatformEFL());
- }
- }
-
- void UpdateTitle()
- {
- _toolbar.Text = Element.Title;
- }
-
- void UpdateTitle(Page page)
- {
- if (_itemToItemPage.ContainsValue(page))
- {
- var pair = _itemToItemPage.FirstOrDefault(x => x.Value == page);
- pair.Key.SetPartText(null, pair.Value.Title);
- }
- }
-
- void OnPageTitleChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == Page.TitleProperty.PropertyName)
- {
- UpdateTitle(sender as Page);
- }
- }
-
- void OnElementPagesChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- switch (e.Action)
- {
- case NotifyCollectionChangedAction.Add:
- AddToolbarItems(e);
- break;
- case NotifyCollectionChangedAction.Remove:
- RemoveToolbarItems(e);
- break;
- default:
- ResetToolbarItems();
- break;
- }
- Element.UpdateFocusTreePolicy();
- }
-
- void AddToolbarItems(NotifyCollectionChangedEventArgs e)
- {
- int index = e.NewStartingIndex < 0 ? _toolbar.ItemsCount : e.NewStartingIndex;
- foreach (Page item in e.NewItems)
- {
- AddToolbarItem(item, index++);
- }
- }
-
- EToolbarItem AddToolbarItem(Page newItem, int index)
- {
- EToolbarItem toolbarItem;
-
- // TODO: investigate if we can use the other image source types: stream, font, uri
-
- var iconSource = newItem.IconImageSource as FileImageSource;
- var icon = iconSource.IsNullOrEmpty() ? null : ResourcePath.GetPath(iconSource);
-
- if (index == 0)
- {
- toolbarItem = _toolbar.Prepend(newItem.Title, icon);
- }
- else
- {
- toolbarItem = _toolbar.InsertAfter(_toolbarItemList[index - 1], newItem.Title, icon);
- }
- _toolbarItemList.Insert(index, toolbarItem);
- _itemToItemPage.Add(toolbarItem, newItem);
-
- ApplyBarItemColors(toolbarItem, BarItemColorType.Background, Element.BarBackgroundColor.ToPlatformEFL());
- ApplyBarItemColors(toolbarItem, BarItemColorType.Text, Element.BarTextColor.ToPlatformEFL());
- ApplyBarItemColors(toolbarItem, BarItemColorType.SelectedTab, Element.SelectedTabColor.ToPlatformEFL());
- ApplyBarItemColors(toolbarItem, BarItemColorType.UnselectedTab, Element.UnselectedTabColor.ToPlatformEFL());
-
- var childContent = Platform.GetOrCreateRenderer(newItem).NativeView;
- _innerBox.PackEnd(childContent);
-
- newItem.PropertyChanged += OnPageTitleChanged;
-
- return toolbarItem;
- }
-
- void RemoveToolbarItems(NotifyCollectionChangedEventArgs e)
- {
- foreach (Page item in e.OldItems)
- {
- RemoveToolbarItem(item);
- }
- }
-
- void RemoveToolbarItem(Page oldItem)
- {
- foreach (var pair in _itemToItemPage)
- {
- if (pair.Value == oldItem)
- {
- pair.Value.PropertyChanged -= OnPageTitleChanged;
- _toolbarItemList.Remove(pair.Key);
- _itemToItemPage.Remove(pair.Key);
- pair.Key.Delete();
- return;
- }
- }
- }
-
- void ResetToolbarItems()
- {
- _isResettingToolbarItems = true;
- foreach (var pair in _itemToItemPage)
- {
- pair.Value.PropertyChanged -= OnPageTitleChanged;
- pair.Key.Delete();
- }
- _itemToItemPage.Clear();
- _toolbarItemList.Clear();
-
- FillToolbarAndContents();
- _isResettingToolbarItems = false;
- }
-
- void FillToolbarAndContents()
- {
- int index = 0;
- //add items to toolbar
- foreach (Page child in Element.Children)
- {
- EToolbarItem toolbarItem = AddToolbarItem(child, index++);
-
- if (Element.CurrentPage == child)
- {
- //select item on the toolbar and fill content
- toolbarItem.IsSelected = true;
- }
- }
- }
-
- void OnToolbarItemSelected(object sender, EToolbarItemEventArgs e)
- {
- if (_toolbar.SelectedItem == null || _isResettingToolbarItems)
- return;
- if (_isUpdateByCurrentPage || _isUpdateByScroller)
- return;
- _isUpdateByToolbar = true;
-
- var oldPage = Element.CurrentPage;
- var newPage = _itemToItemPage[_toolbar.SelectedItem];
-
- if (oldPage != newPage)
- {
- oldPage?.SendDisappearing();
- Element.CurrentPage = newPage;
- newPage?.SendAppearing();
-
- int index = MultiPage.GetIndex(newPage);
- _scroller.ScrollTo(index, 0, true);
-
- Element.UpdateFocusTreePolicy();
- }
- _isUpdateByToolbar = false;
- }
-
- void OnCurrentPageChanged()
- {
- if (_isUpdateByScroller || _isUpdateByToolbar || !_isInitialized)
- return;
-
- _isUpdateByCurrentPage = true;
- Page oldPage = null;
- if (_toolbar.SelectedItem != null && _itemToItemPage.ContainsKey(_toolbar.SelectedItem))
- oldPage = _itemToItemPage[_toolbar.SelectedItem];
-
- oldPage?.SendDisappearing();
- Element.CurrentPage?.SendAppearing();
-
- int index = MultiPage.GetIndex(Element.CurrentPage);
- _toolbarItemList[index].IsSelected = true;
- _scroller.ScrollTo(index, 0, true);
-
- Element.UpdateFocusTreePolicy();
- _isUpdateByCurrentPage = false;
- }
-
- void ApplyBarItemColors(EToolbarItem item, BarItemColorType type, EColor color)
- {
- if (color.IsDefault)
- {
- ClearBarItemColors(item, type);
- }
- else
- {
- switch (type)
- {
- case BarItemColorType.Background:
- item.SetBackgroundColor(color);
- break;
- case BarItemColorType.Text:
- item.SetTextColor(color);
- break;
- case BarItemColorType.SelectedTab:
- item.SetSelectedTabColor(color);
- break;
- case BarItemColorType.UnselectedTab:
- item.SetUnselectedTabColor(color);
- break;
- default:
- break;
- }
- }
- }
-
- void ClearBarItemColors(EToolbarItem item, BarItemColorType type)
- {
- switch (type)
- {
- case BarItemColorType.Background:
- item.DeleteBackgroundColor();
- break;
- case BarItemColorType.Text:
- item.DeleteTextColor();
- break;
- case BarItemColorType.SelectedTab:
- item.DeleteSelectedTabColor();
- break;
- case BarItemColorType.UnselectedTab:
- item.DeleteUnselectedTabColor();
- break;
- default:
- break;
- }
- }
- }
-
- enum BarItemColorType
- {
- Background,
- Text,
- SelectedTab,
- UnselectedTab
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/TableViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/TableViewRenderer.cs
deleted file mode 100644
index b849441efddb..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/TableViewRenderer.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-using System;
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Microsoft.Maui.Devices;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class TableViewRenderer : ViewRenderer
- {
- internal static BindableProperty PresentationProperty = BindableProperty.Create("Presentation", typeof(View), typeof(TableSectionBase), null, BindingMode.OneWay, null, null, null, null, null as BindableProperty.CreateDefaultValueDelegate);
-
- public TableViewRenderer()
- {
- RegisterPropertyHandler(TableView.HasUnevenRowsProperty, UpdateHasUnevenRows);
- RegisterPropertyHandler(TableView.RowHeightProperty, UpdateRowHeight);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(CreateNativeControl(Forms.NativeParent));
- Control.ItemSelected += OnSelected;
- }
-
- if (e.OldElement != null)
- {
- e.OldElement.ModelChanged -= OnRootPropertyChanged;
- }
-
- if (e.NewElement != null)
- {
- e.NewElement.ModelChanged += OnRootPropertyChanged;
- (Control as ITableView)?.ApplyTableRoot(e.NewElement.Root);
- }
-
- base.OnElementChanged(e);
- }
-
- protected virtual Native.ListView CreateNativeControl(EvasObject parent)
- {
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- return new Native.Watch.WatchTableView(parent, Forms.CircleSurface);
- }
- else
- {
- return new Native.TableView(parent);
- }
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Element != null)
- {
- Element.ModelChanged -= OnRootPropertyChanged;
- }
-
- if (Control != null)
- {
- Control.ItemSelected -= OnSelected;
- }
- }
-
- base.Dispose(disposing);
- }
-
- void OnSelected(object sender, GenListItemEventArgs e)
- {
- var item = e.Item as GenListItem;
-
- if (item != null)
- {
- var clickedCell = item.Data as Native.ListView.ItemContext;
- if (null != clickedCell)
- {
- Element.Model.RowSelected(clickedCell.Cell);
- }
- }
- }
-
- void OnRootPropertyChanged(object sender, EventArgs e)
- {
- if (Element != null)
- {
- (Control as ITableView)?.ApplyTableRoot(Element.Root);
- }
- }
-
- void UpdateHasUnevenRows()
- {
- Control.SetHasUnevenRows(Element.HasUnevenRows);
- }
-
- void UpdateRowHeight()
- {
- Control.UpdateRealizedItems();
- }
-
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/TimePickerRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/TimePickerRenderer.cs
deleted file mode 100644
index b9e91f389816..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/TimePickerRenderer.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-using System;
-using System.Globalization;
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Microsoft.Maui.Devices;
-using Microsoft.Maui.Graphics;
-using EEntry = ElmSharp.Entry;
-using NIEntry = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.IEntry;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.Application;
-using WatchDateTimePickerDialog = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.Watch.WatchDateTimePickerDialog;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class TimePickerRenderer : ViewRenderer
- {
- //TODO need to add internationalization support
- const string DialogTitle = "Choose Time";
- static readonly string s_defaultFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortTimePattern;
-
- Lazy _lazyDialog;
-
- protected TimeSpan Time = DateTime.Now.TimeOfDay;
-
- public TimePickerRenderer()
- {
- RegisterPropertyHandler(TimePicker.FormatProperty, UpdateFormat);
- RegisterPropertyHandler(TimePicker.TimeProperty, UpdateTime);
- RegisterPropertyHandler(TimePicker.TextColorProperty, UpdateTextColor);
- RegisterPropertyHandler(TimePicker.FontAttributesProperty, UpdateFontAttributes);
- RegisterPropertyHandler(TimePicker.FontFamilyProperty, UpdateFontFamily);
- RegisterPropertyHandler(TimePicker.FontSizeProperty, UpdateFontSize);
- }
-
- protected virtual IDateTimeDialog CreateDialog()
- {
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- return new WatchDateTimePickerDialog(Forms.NativeParent);
- }
- else
- {
- return new DateTimePickerDialog(Forms.NativeParent);
- }
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- var entry = CreateNativeControl();
- entry.SetVerticalTextAlignment(0.5);
- SetNativeControl(entry);
-
- if (entry is NIEntry ie)
- {
- ie.TextBlockFocused += OnTextBlockFocused;
- ie.EntryLayoutFocused += OnFocused;
- ie.EntryLayoutUnfocused += OnUnfocused;
- }
-
- _lazyDialog = new Lazy(() =>
- {
- var dialog = CreateDialog();
- dialog.Mode = DateTimePickerMode.Time;
- dialog.Title = DialogTitle;
- dialog.DateTimeChanged += OnDialogTimeChanged;
- dialog.PickerOpened += OnPickerOpened;
- dialog.PickerClosed += OnPickerClosed;
- return dialog;
- });
- }
- base.OnElementChanged(e);
- }
-
- protected virtual EEntry CreateNativeControl()
- {
- return new Native.EditfieldEntry(Forms.NativeParent)
- {
- IsSingleLine = true,
- HorizontalTextAlignment = Native.TextAlignment.Center,
- InputPanelShowByOnDemand = true,
- IsEditable = false
- };
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- if (Control is NIEntry ie)
- {
- ie.TextBlockFocused -= OnTextBlockFocused;
- ie.EntryLayoutFocused -= OnFocused;
- ie.EntryLayoutUnfocused -= OnUnfocused;
- }
- }
- if (_lazyDialog.IsValueCreated)
- {
- _lazyDialog.Value.DateTimeChanged -= OnDialogTimeChanged;
- _lazyDialog.Value.PickerOpened -= OnPickerOpened;
- _lazyDialog.Value.PickerClosed -= OnPickerClosed;
- _lazyDialog.Value.Unrealize();
- }
- }
-
- base.Dispose(disposing);
- }
-
- protected override Size MinimumSize()
- {
- if (Control is IMeasurable im)
- {
- return im.Measure(Control.MinimumWidth, Control.MinimumHeight).ToDP();
- }
- else
- {
- return base.MinimumSize();
- }
- }
-
- void OnTextBlockFocused(object o, EventArgs e)
- {
- // For EFL Entry, the event will occur even if it is currently disabled.
- // If the problem is resolved, no conditional statement is required.
- if (Element.IsEnabled)
- {
- var dialog = _lazyDialog.Value;
- dialog.DateTime -= dialog.DateTime.TimeOfDay;
- dialog.DateTime += Element.Time;
-
- // You need to call Show() after ui thread occupation because of EFL problem.
- // Otherwise, the content of the popup will not receive focus.
- Application.Current.Dispatcher.Dispatch(() => dialog.Show());
- }
- }
-
- void OnDialogTimeChanged(object sender, Native.DateChangedEventArgs dcea)
- {
- Element.SetValueFromRenderer(TimePicker.TimeProperty, dcea.NewDate.TimeOfDay);
- UpdateTime();
- }
-
- void UpdateFormat()
- {
- UpdateTimeAndFormat();
- }
- protected virtual void UpdateTextColor()
- {
- if (Control is NIEntry ie)
- {
- ie.TextColor = Element.TextColor.ToPlatformEFL();
- }
- }
-
- void UpdateTime()
- {
- Time = Element.Time;
- UpdateTimeAndFormat();
- }
-
- void UpdateFontSize()
- {
- if (Control is NIEntry ie)
- {
- ie.FontSize = Element.FontSize;
- }
- }
-
- void UpdateFontFamily()
- {
- if (Control is NIEntry ie)
- {
- ie.FontFamily = Element.FontFamily;
- }
- }
-
- void UpdateFontAttributes()
- {
- if (Control is NIEntry ie)
- {
- ie.FontAttributes = Element.FontAttributes;
- }
- }
- protected virtual void OnPickerOpened(object sender, EventArgs args)
- {
- if (Specific.GetUseBezelInteraction(Application.Current))
- {
- // picker included in WatchDatePickedDialog has been activated, whenever the dialog is opend.
- Forms.RotaryFocusObject = Element;
- Specific.SetActiveBezelInteractionElement(Application.Current, Element);
- }
- }
-
- protected virtual void OnPickerClosed(object sender, EventArgs args)
- {
- if (Specific.GetUseBezelInteraction(Application.Current))
- {
- if (Forms.RotaryFocusObject == Element)
- Forms.RotaryFocusObject = null;
- if (Specific.GetActiveBezelInteractionElement(Application.Current) == Element)
- Specific.SetActiveBezelInteractionElement(Application.Current, null);
- }
- }
-
- protected virtual void UpdateTimeAndFormat()
- {
- // Xamarin using DateTime formatting (https://developer.xamarin.com/api/property/Microsoft.Maui.Controls.Compatibility.TimePicker.Format/)
- Control.Text = new DateTime(Time.Ticks).ToString(Element.Format ?? s_defaultFormat);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/ViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/ViewRenderer.cs
index 2f27c00ec052..f57f3cd0b0b0 100644
--- a/src/Compatibility/Core/src/Tizen/Renderers/ViewRenderer.cs
+++ b/src/Compatibility/Core/src/Tizen/Renderers/ViewRenderer.cs
@@ -3,10 +3,8 @@
using System.Collections.Specialized;
using System.Diagnostics;
using System.Linq;
-using ElmSharp;
-using ElmSharp.Wearable;
using Microsoft.Maui.Controls.Platform;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.Application;
+using NView = Tizen.NUI.BaseComponents.View;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
@@ -16,7 +14,7 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
[Obsolete("Use Microsoft.Maui.Controls.Handlers.Compatibility.ViewRenderer instead")]
public abstract class ViewRenderer : VisualElementRenderer
where TView : View
- where TNativeView : EvasObject
+ where TNativeView : NView
{
ObservableCollection GestureRecognizers => Element.GestureRecognizers as ObservableCollection;
@@ -36,13 +34,6 @@ public TNativeView Control
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
- if (GestureDetector != null)
- {
- GestureRecognizers.CollectionChanged -= OnGestureRecognizerCollectionChanged;
- GestureDetector.Clear();
- GestureDetector = null;
- }
-
GestureRecognizers.CollectionChanged += OnGestureRecognizerCollectionChanged;
if (Element.GestureRecognizers.Count > 0)
{
@@ -98,40 +89,14 @@ void OnGestureRecognizerCollectionChanged(object sender, NotifyCollectionChanged
}
}
- protected override void OnFocused(object sender, EventArgs e)
+ protected override void Dispose(bool disposing)
{
- base.OnFocused(sender, e);
- UpdateRotaryInteraction(true);
- }
-
- protected override void OnUnfocused(object sender, EventArgs e)
- {
- base.OnUnfocused(sender, e);
- UpdateRotaryInteraction(false);
- }
-
- protected virtual void UpdateRotaryInteraction(bool enable)
- {
- if (NativeView is IRotaryInteraction ri)
+ if (disposing)
{
- if (Specific.GetUseBezelInteraction(Application.Current))
- {
- if (enable)
- {
- ri.RotaryWidget?.Activate();
- Forms.RotaryFocusObject = Element;
- Specific.SetActiveBezelInteractionElement(Application.Current, Element);
- }
- else
- {
- ri.RotaryWidget?.Deactivate();
- if (Forms.RotaryFocusObject == Element)
- Forms.RotaryFocusObject = null;
- if (Specific.GetActiveBezelInteractionElement(Application.Current) == Element)
- Specific.SetActiveBezelInteractionElement(Application.Current, null);
- }
- }
+ GestureDetector?.Clear();
}
+ base.Dispose(disposing);
}
+
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs
index 6fa341d20f64..01a64986dfbf 100644
--- a/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs
+++ b/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs
@@ -2,20 +2,18 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
-using ElmSharp;
-using ElmSharp.Accessible;
-using Microsoft.Maui.Controls.Platform;
using Microsoft.Maui.Controls.Internals;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Tizen.UIExtensions.ElmSharp;
using Size = Microsoft.Maui.Graphics.Size;
using Rect = Microsoft.Maui.Graphics.Rect;
using Point = Microsoft.Maui.Graphics.Point;
-using EFocusDirection = ElmSharp.FocusDirection;
-using ERect = ElmSharp.Rect;
-using ESize = ElmSharp.Size;
+using Microsoft.Maui.Controls.Platform;
+using Tizen.NUI;
+using Tizen.UIExtensions.Common;
using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.VisualElement;
using XFocusDirection = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.FocusDirection;
+using NView = Tizen.NUI.BaseComponents.View;
+using TPoint = Tizen.UIExtensions.Common.Point;
+using Tizen.UIExtensions.NUI;
namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
{
@@ -25,7 +23,7 @@ namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
[Obsolete("Use Microsoft.Maui.Controls.Handlers.Compatibility.VisualElementRenderer instead")]
public abstract class VisualElementRenderer : IVisualElementRenderer, IEffectControlProvider where TElement : VisualElement
{
- readonly List> _elementChangedHandlers = new List>();
+ event EventHandler _elementChanged;
readonly Dictionary> _propertyHandlersWithInit = new Dictionary>();
@@ -35,13 +33,6 @@ public abstract class VisualElementRenderer : IVisualElementRenderer,
VisualElementRendererFlags _flags = VisualElementRendererFlags.None;
- bool _movedCallbackEnabled = false;
- string _defaultAccessibilityName;
- string _defaultAccessibilityDescription;
- bool? _defaultIsAccessibilityElement;
-
- Lazy _customFocusManager;
-
///
/// Default constructor.
///
@@ -81,11 +72,6 @@ protected VisualElementRenderer()
RegisterPropertyHandler(AutomationProperties.HelpTextProperty, SetAccessibilityDescription);
RegisterPropertyHandler(AutomationProperties.IsInAccessibleTreeProperty, SetIsAccessibilityElement);
RegisterPropertyHandler(AutomationProperties.LabeledByProperty, SetLabeledBy);
-
- _customFocusManager = new Lazy(() =>
- {
- return new CustomFocusManager(Element, NativeView as Widget);
- });
}
~VisualElementRenderer()
@@ -97,11 +83,11 @@ event EventHandler IVisualElementRenderer.Element
{
add
{
- _elementChangedHandlers.Add(value);
+ _elementChanged += value;
}
remove
{
- _elementChangedHandlers.Remove(value);
+ _elementChanged -= value;
}
}
@@ -122,7 +108,7 @@ VisualElement IVisualElementRenderer.Element
}
}
- public EvasObject NativeView { get; private set; }
+ public NView NativeView { get; private set; }
public event EventHandler> ElementChanged;
@@ -160,14 +146,13 @@ public SizeRequest GetDesiredSize(double widthConstraint, double heightConstrain
availableHeight = int.MaxValue;
Size measured;
- var nativeViewMeasurable = NativeView as Native.IMeasurable;
- if (nativeViewMeasurable != null)
+ if (NativeView is IMeasurable nativeViewMeasurable)
{
measured = nativeViewMeasurable.Measure(availableWidth, availableHeight).ToDP();
}
else
{
- measured = Measure(availableWidth, availableHeight).ToDP();
+ measured = Measure(widthConstraint, heightConstraint);
}
return new SizeRequest(measured, MinimumSize());
@@ -308,15 +293,10 @@ protected virtual void Dispose(bool disposing)
if (NativeView != null)
{
- NativeView.Deleted -= NativeViewDeleted;
- NativeView.Unrealize();
+ NativeView.Unparent();
+ NativeView.Dispose();
NativeView = null;
}
-
- if (_customFocusManager.IsValueCreated)
- {
- _customFocusManager.Value.Dispose();
- }
}
}
@@ -345,8 +325,7 @@ protected virtual void OnElementChanged(ElementChangedEventArgs e)
}
var args = new VisualElementChangedEventArgs(e.OldElement, e.NewElement);
- for (var i = 0; i < _elementChangedHandlers.Count; i++)
- _elementChangedHandlers[i](this, args);
+ _elementChanged?.Invoke(this, args);
ElementChanged?.Invoke(this, e);
@@ -425,38 +404,20 @@ protected virtual void OnElementPropertyChanged(object sender, PropertyChangedEv
///
/// Updates the attached event handlers, sets the native control.
///
- protected void SetNativeView(EvasObject control)
+ protected void SetNativeView(NView control)
{
if (NativeView != null)
{
- if (_movedCallbackEnabled)
- {
- NativeView.Moved -= OnMoved;
- }
- NativeView.Deleted -= NativeViewDeleted;
+ NativeView.FocusGained -= OnFocused;
+ NativeView.FocusLost -= OnUnfocused;
}
- Widget widget = NativeView as Widget;
- if (widget != null)
- {
- widget.Focused -= OnFocused;
- widget.Unfocused -= OnUnfocused;
- }
NativeView = control;
- if (NativeView != null)
- {
- NativeView.Deleted += NativeViewDeleted;
- if (_movedCallbackEnabled)
- {
- NativeView.Moved += OnMoved;
- }
- }
- widget = NativeView as Widget;
- if (widget != null)
+ if (NativeView != null)
{
- widget.Focused += OnFocused;
- widget.Unfocused += OnUnfocused;
+ NativeView.FocusGained += OnFocused;
+ NativeView.FocusLost += OnUnfocused;
}
}
@@ -464,12 +425,7 @@ protected virtual void SetAccessibilityName(bool initialize)
{
if (initialize && (string)Element.GetValue(AutomationProperties.NameProperty) == (default(string)))
return;
-
- var accessibleObject = NativeView as IAccessibleObject;
- if (accessibleObject != null)
- {
- _defaultAccessibilityName = accessibleObject.SetAccessibilityName(Element, _defaultAccessibilityName);
- }
+ // TODO
}
protected virtual void SetAccessibilityDescription(bool initialize)
@@ -477,11 +433,7 @@ protected virtual void SetAccessibilityDescription(bool initialize)
if (initialize && (string)Element.GetValue(AutomationProperties.HelpTextProperty) == (default(string)))
return;
- var accessibleObject = NativeView as IAccessibleObject;
- if (accessibleObject != null)
- {
- _defaultAccessibilityDescription = accessibleObject.SetAccessibilityDescription(Element, _defaultAccessibilityDescription);
- }
+ // TODO
}
protected virtual void SetIsAccessibilityElement(bool initialize)
@@ -489,11 +441,7 @@ protected virtual void SetIsAccessibilityElement(bool initialize)
if (initialize && (bool?)Element.GetValue(AutomationProperties.IsInAccessibleTreeProperty) == default(bool?))
return;
- var accessibleObject = NativeView as IAccessibleObject;
- if (accessibleObject != null)
- {
- _defaultIsAccessibilityElement = accessibleObject.SetIsAccessibilityElement(Element, _defaultIsAccessibilityElement);
- }
+ // TODO
}
protected virtual void SetLabeledBy(bool initialize)
@@ -501,32 +449,18 @@ protected virtual void SetLabeledBy(bool initialize)
if (initialize && (VisualElement)Element.GetValue(AutomationProperties.LabeledByProperty) == default(VisualElement))
return;
- var accessibleObject = NativeView as IAccessibleObject;
- if (accessibleObject != null)
- {
- accessibleObject.SetLabeledBy(Element);
- }
+ // TODO
}
- internal virtual void SendVisualElementInitialized(VisualElement element, EvasObject nativeView)
+ internal virtual void SendVisualElementInitialized(VisualElement element, NView nativeView)
{
element.SendViewInitialized(nativeView);
}
void UpdateNativeGeometry()
{
- var updatedGeometry = new Rect(ComputeAbsolutePoint(Element), new Size(Element.Width, Element.Height)).ToEFLPixel();
-
- if (NativeView.Geometry != updatedGeometry)
- {
- NativeView.Geometry = updatedGeometry;
- ApplyTransformation();
- }
- }
-
- void NativeViewDeleted(object sender, EventArgs e)
- {
- Dispose();
+ NativeView.UpdateBounds(Element.Bounds.ToPixel());
+ ApplyTranslation(true);
}
void OnBatchCommitted(object sender, EventArg e)
@@ -619,16 +553,16 @@ protected virtual void OnElementReady()
protected virtual Size MinimumSize()
{
- return new ESize(NativeView.MinimumWidth, NativeView.MinimumHeight).ToDP();
+ return NativeView.MinimumSize.ToDP();
}
///
/// Calculates how much space this element should take, given how much room there is.
///
/// a desired dimensions of the element
- protected virtual ESize Measure(int availableWidth, int availableHeight)
+ protected virtual Size Measure(double availableWidth, double availableHeight)
{
- return new ESize(NativeView.MinimumWidth, NativeView.MinimumHeight);
+ return MinimumSize();
}
protected virtual void UpdateBackgroundColor(bool initialize)
@@ -636,36 +570,20 @@ protected virtual void UpdateBackgroundColor(bool initialize)
if (initialize && Element.BackgroundColor.IsDefault())
return;
- if (NativeView is Widget)
- {
- (NativeView as Widget).BackgroundColor = Element.BackgroundColor.ToPlatformEFL();
- }
- else
- {
- Log.Warn("{0} uses {1} which does not support background color", this, NativeView);
- }
+ NativeView.UpdateBackgroundColor(Element.BackgroundColor.ToNative());
}
protected virtual void UpdateBackground(bool initialize)
{
- if (!Forms.UseSkiaSharp || (initialize && Element.Background.Equals(Brush.Default)))
+ if (initialize && Element.Background.Equals(Brush.Default))
return;
- if (this is SkiaSharp.IBackgroundCanvas canvasRenderer)
- {
- canvasRenderer.BackgroundCanvas.Invalidate();
- }
+ // TODO
}
protected virtual void UpdateClip(bool initialize)
{
- if (!Forms.UseSkiaSharp || (initialize && Element.Clip == null))
- return;
-
- if (this is SkiaSharp.IClipperCanvas canvasRenderer)
- {
- canvasRenderer.ClipperCanvas.Invalidate();
- }
+ // TODO
}
protected virtual void UpdateOpacity(bool initialize)
@@ -673,73 +591,7 @@ protected virtual void UpdateOpacity(bool initialize)
if (initialize && Element.Opacity == 1d)
return;
- if (NativeView is Widget)
- {
- (NativeView as Widget).Opacity = (int)(Element.Opacity * 255.0);
- }
- else
- {
- Log.Warn("{0} uses {1} which does not support opacity", this, NativeView);
- }
- }
-
- public virtual ERect GetNativeContentGeometry()
- {
- return NativeView.Geometry;
- }
-
- static double ComputeAbsoluteX(VisualElement e)
- {
- var parentX = 0.0;
- if (e.RealParent is VisualElement parent)
- {
- if (CompressedLayout.GetIsHeadless(e.RealParent))
- {
- parentX = ComputeAbsoluteX(parent);
- }
- else
- {
- if (parent.Handler is IPlatformViewHandler nativeHandler)
- {
-
- parentX = nativeHandler.GetPlatformContentGeometry().X.ToScaledDP();
- }
- else
- {
- parentX = Forms.ConvertToScaledDP(Platform.GetRenderer(e.RealParent).GetNativeContentGeometry().X);
- }
- }
- }
- return e.X + parentX;
- }
-
- static double ComputeAbsoluteY(VisualElement e)
- {
- var parentY = 0.0;
- if (e.RealParent is VisualElement parent)
- {
- if (CompressedLayout.GetIsHeadless(e.RealParent))
- {
- parentY = ComputeAbsoluteY(parent);
- }
- else
- {
- if (parent.Handler is IPlatformViewHandler nativeHandler)
- {
- parentY = nativeHandler.GetPlatformContentGeometry().Y.ToScaledDP();
- }
- else
- {
- parentY = Forms.ConvertToScaledDP(Platform.GetRenderer(e.RealParent).GetNativeContentGeometry().Y);
- }
- }
- }
- return e.Y + parentY;
- }
-
- static Point ComputeAbsolutePoint(VisualElement e)
- {
- return new Point(ComputeAbsoluteX(e), ComputeAbsoluteY(e));
+ NativeView.Opacity = (float)Element.Opacity;
}
///
@@ -772,53 +624,24 @@ protected virtual void AddChild(Element child)
{
if (child is VisualElement ve)
{
- if (CompressedLayout.GetIsHeadless(ve) && NativeView is IContainable containerNativeView)
- {
- AddHeadlessChild(ve, containerNativeView);
- ve.IsPlatformEnabled = true;
- }
- else
+ var childRenderer = Platform.GetOrCreateRenderer(ve);
+ // if the native view can have children, attach the new child
+ if (NativeView is IContainable containerView)
{
- var childRenderer = Platform.GetOrCreateRenderer(ve);
- // if the native view can have children, attach the new child
- if (NativeView is IContainable containerView)
- {
- containerView.Children.Add(childRenderer.NativeView);
- }
+ containerView.Children.Add(childRenderer.NativeView);
}
}
}
- protected virtual void AddHeadlessChild(VisualElement element, IContainable parent)
- {
- foreach (var child in (element as IVisualTreeElement).GetVisualChildren())
- {
- if (child is VisualElement visualChild)
- {
- if (CompressedLayout.GetIsHeadless(visualChild))
- {
- AddHeadlessChild(visualChild, parent);
- visualChild.IsPlatformEnabled = true;
- }
- else
- {
- var childRenderer = Platform.GetOrCreateRenderer(visualChild);
- parent.Children.Add(childRenderer.NativeView);
- }
- }
- }
- }
protected virtual void RemoveChild(VisualElement view)
{
var renderer = Platform.GetRenderer(view);
- var containerObject = NativeView as Native.IContainable;
- if (containerObject != null)
+ if (NativeView is IContainable containerObject)
{
containerObject.Children.Remove(renderer.NativeView);
}
-
- renderer.Dispose();
+ renderer?.Dispose();
}
void OnChildAdded(object sender, ElementEventArgs e)
@@ -862,14 +685,7 @@ void OnChildrenReordered(object sender, EventArgs e)
void OnFocusChangeRequested(object sender, VisualElement.FocusRequestArgs e)
{
- Widget widget = NativeView as Widget;
- if (widget == null)
- {
- Log.Warn("{0} is not a widget, it cannot receive focus", NativeView);
- return;
- }
-
- widget.SetFocus(e.Focus);
+ FocusManager.Instance.SetCurrentFocusView(NativeView);
e.Result = true;
}
@@ -883,11 +699,6 @@ void OnRegisterEffect(PlatformEffect effect)
effect.Control = NativeView;
}
- void OnMoved(object sender, EventArgs e)
- {
- ApplyTransformation();
- }
-
void EnsureChildOrder()
{
var logicalChildren = (Element as IElementController).LogicalChildren;
@@ -924,11 +735,7 @@ protected virtual void UpdateIsEnabled(bool initialize)
if (initialize && Element.IsEnabled)
return;
- var widget = NativeView as Widget;
- if (widget != null)
- {
- widget.IsEnabled = Element.IsEnabled;
- }
+ NativeView.SetEnable(Element.IsEnabled);
}
///
@@ -939,7 +746,7 @@ protected virtual void UpdateInputTransparent(bool initialize)
if (initialize && Element.InputTransparent == default(bool))
return;
- NativeView.PassEvents = Element.InputTransparent;
+ NativeView.Sensitive = !Element.InputTransparent;
}
protected virtual void UpdateThemeStyle()
@@ -958,80 +765,25 @@ void UpdateFocusAllowed(bool initialize)
if (initialize && isFocusAllowed == null)
return;
- var widget = NativeView as Widget;
- if (widget != null && isFocusAllowed != null)
+ if (isFocusAllowed != null)
{
- widget.AllowFocus((bool)Specific.IsFocusAllowed(Element));
- }
- else
- {
- Log.Warn("{0} uses {1} which does not support Focus management", this, NativeView);
+ NativeView.Focusable = (bool)isFocusAllowed;
}
}
void UpdateFocusDirection(bool initialize)
{
- var direction = Specific.GetNextFocusDirection(Element);
- if (!initialize && direction != XFocusDirection.None)
- {
- var widget = NativeView as Widget;
- if (widget != null)
- {
- widget.FocusNext(ConvertToNativeFocusDirection(direction));
- }
- else
- {
- Log.Warn("{0} uses {1} which does not support Focus management", this, NativeView);
- }
- }
+ // TODO
}
void UpdateToolTip(bool initialize)
{
- var tooltip = Specific.GetToolTip(Element);
- if (tooltip != null)
- {
- NativeView.SetTooltipText(tooltip);
- }
- else if (!initialize)
- {
- NativeView.UnsetTooltip();
- }
+ // TODO
}
void SetNextFocusViewInternal(string direction)
{
- var widget = NativeView as Widget;
- if (widget != null)
- {
- switch (direction)
- {
- case XFocusDirection.Back:
- _customFocusManager.Value.NextBackward = Specific.GetNextFocusBackView(Element);
- break;
- case XFocusDirection.Forward:
- _customFocusManager.Value.NextForward = Specific.GetNextFocusForwardView(Element);
- break;
- case XFocusDirection.Up:
- _customFocusManager.Value.NextUp = Specific.GetNextFocusUpView(Element);
- break;
- case XFocusDirection.Down:
- _customFocusManager.Value.NextDown = Specific.GetNextFocusDownView(Element);
- break;
- case XFocusDirection.Right:
- _customFocusManager.Value.NextRight = Specific.GetNextFocusRightView(Element);
- break;
- case XFocusDirection.Left:
- _customFocusManager.Value.NextLeft = Specific.GetNextFocusLeftView(Element);
- break;
- default:
- break;
- }
- }
- else
- {
- Log.Warn("{0} uses {1} which does not support Focus management", this, NativeView);
- }
+ // TODO
}
void UpdateFocusUpView()
@@ -1082,129 +834,69 @@ void UpdateFocusForwardView()
}
}
- void ApplyRotation(EvasMap map, ERect geometry, ref bool changed)
+ void ApplyRotation(bool init)
{
var rotationX = Element.RotationX;
var rotationY = Element.RotationY;
var rotationZ = Element.Rotation;
- var anchorX = Element.AnchorX;
- var anchorY = Element.AnchorY;
- // apply rotations
- if (rotationX != 0 || rotationY != 0 || rotationZ != 0)
+ if (init && rotationX == 0 && rotationY == 0 && rotationZ == 0)
+ return;
+
+ var zRotation = new Rotation(new Radian(DegreeToRadian((float)rotationZ)), PositionAxis.Z);
+ var xRotation = new Rotation(new Radian(DegreeToRadian((float)rotationX)), PositionAxis.X);
+ var yRotation = new Rotation(new Radian(DegreeToRadian((float)rotationY)), PositionAxis.Y);
+ var totalRotation = zRotation * xRotation * yRotation;
+ NativeView.Orientation = totalRotation;
+
+ float DegreeToRadian(float degree)
{
- map.Rotate3D(rotationX, rotationY, rotationZ, (int)(geometry.X + geometry.Width * anchorX),
- (int)(geometry.Y + geometry.Height * anchorY), 0);
- // the last argument is focal length, it determine the strength of distortion. We compared it with the Android implementation
- map.Perspective3D(geometry.X + geometry.Width / 2, geometry.Y + geometry.Height / 2, 0, (int)(1.3 * Math.Max(geometry.Height, geometry.Width)));
- // Need to unset clip because perspective 3d rotation is going beyond the container bound
- NativeView.SetClip(null);
- changed = true;
+ return (float)(degree * Math.PI / 180);
}
}
- void ApplyScale(EvasMap map, ERect geometry, ref bool changed)
+ void ApplyScale(bool init)
{
var scale = Element.Scale;
var scaleX = Element.ScaleX * scale;
var scaleY = Element.ScaleY * scale;
+ if (init && scaleX == 1.0 && scaleY == 1.0)
+ return;
- // apply scale factor
- if (scaleX != 1.0 || scaleY != 1.0)
- {
- map.Zoom(scaleX, scaleY,
- geometry.X + (int)(geometry.Width * Element.AnchorX),
- geometry.Y + (int)(geometry.Height * Element.AnchorY));
- changed = true;
- }
+ NativeView.ScaleX = (float)scaleX;
+ NativeView.ScaleY = (float)scaleY;
}
-
- void ApplyTranslation(EvasMap map, ERect geometry, ref bool changed)
+ protected void ApplyTranslation(bool init)
{
var shiftX = Forms.ConvertToScaledPixel(Element.TranslationX);
var shiftY = Forms.ConvertToScaledPixel(Element.TranslationY);
-
- // apply translation, i.e. move/shift the object a little
- if (shiftX != 0 || shiftY != 0)
+ if (init && shiftX == 0 && shiftY == 0)
{
- if (changed)
- {
- // special care is taken to apply the translation last
- Point3D p;
- for (int i = 0; i < 4; i++)
- {
- p = map.GetPointCoordinate(i);
- p.X += shiftX;
- p.Y += shiftY;
- map.SetPointCoordinate(i, p);
- }
- }
- else
- {
- // in case when we only need translation, then construct the map in a simpler way
- geometry.X += shiftX;
- geometry.Y += shiftY;
- map.PopulatePoints(geometry, 0);
-
- changed = true;
- }
+ return;
}
+
+ var pos = Element.Bounds.ToPixel();
+ NativeView.UpdatePosition(new TPoint(pos.X + shiftX, pos.Y + shiftY));
+ }
+ void ApplyAnchor(bool init)
+ {
+ if (init && Element.AnchorX == 0.5 && Element.AnchorY == 0.5)
+ return;
+
+ NativeView.PivotPoint = new Position((float)Element.AnchorX, (float)Element.AnchorY, 0);
}
- protected virtual void ApplyTransformation()
+ protected virtual void ApplyTransformation(bool init = false)
{
if (null == NativeView)
{
Log.Error("Trying to apply transformation to the non-existent native control");
return;
}
-
- // prepare the EFL effect structure
- ERect geometry = NativeView.Geometry;
- EvasMap map = new EvasMap(4);
- map.PopulatePoints(geometry, 0);
-
- bool changed = false;
- ApplyScale(map, geometry, ref changed);
- ApplyRotation(map, geometry, ref changed);
- ApplyTranslation(map, geometry, ref changed);
-
- NativeView.IsMapEnabled = changed;
- if (changed)
- {
- NativeView.EvasMap = map;
- if (!_movedCallbackEnabled)
- {
- _movedCallbackEnabled = true;
- NativeView.Moved += OnMoved;
- }
- }
- else
- {
- if (_movedCallbackEnabled)
- {
- _movedCallbackEnabled = false;
- NativeView.Moved -= OnMoved;
- }
- }
- }
-
- EFocusDirection ConvertToNativeFocusDirection(string direction)
- {
- if (direction == XFocusDirection.Back)
- return EFocusDirection.Previous;
- if (direction == XFocusDirection.Forward)
- return EFocusDirection.Next;
- if (direction == XFocusDirection.Up)
- return EFocusDirection.Up;
- if (direction == XFocusDirection.Down)
- return EFocusDirection.Down;
- if (direction == XFocusDirection.Right)
- return EFocusDirection.Right;
- if (direction == XFocusDirection.Left)
- return EFocusDirection.Left;
-
- return EFocusDirection.Next;
+ ApplyAnchor(init);
+ ApplyScale(init);
+ ApplyRotation(init);
+ ApplyTranslation(init);
}
}
}
diff --git a/src/Compatibility/Core/src/Tizen/Renderers/WebViewRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/WebViewRenderer.cs
deleted file mode 100644
index 97dd1345c29f..000000000000
--- a/src/Compatibility/Core/src/Tizen/Renderers/WebViewRenderer.cs
+++ /dev/null
@@ -1,201 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Threading.Tasks;
-using Microsoft.Maui.Controls.Internals;
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using TChromium = Tizen.WebView.Chromium;
-using TWebView = Tizen.WebView.WebView;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class WebViewRenderer : ViewRenderer, IWebViewDelegate
- {
- bool _isUpdating;
- WebNavigationEvent _eventState;
-
- TWebView NativeWebView => Control.WebView;
-
- IWebViewController ElementController => Element;
-
- void IWebViewDelegate.LoadHtml(string html, string baseUrl)
- {
- NativeWebView.LoadHtml(html, baseUrl);
- }
-
- void IWebViewDelegate.LoadUrl(string url)
- {
- if (!string.IsNullOrEmpty(url))
- {
- NativeWebView.LoadUrl(url);
- }
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- NativeWebView.StopLoading();
- NativeWebView.LoadStarted -= OnLoadStarted;
- NativeWebView.LoadFinished -= OnLoadFinished;
- NativeWebView.LoadError -= OnLoadError;
- }
-
- if (Element != null)
- {
- ((IWebViewController)Element).EvalRequested -= OnEvalRequested;
- ((IWebViewController)Element).EvaluateJavaScriptRequested -= OnEvaluateJavaScriptRequested;
- ((IWebViewController)Element).GoBackRequested -= OnGoBackRequested;
- ((IWebViewController)Element).GoForwardRequested -= OnGoForwardRequested;
- ((IWebViewController)Element).ReloadRequested -= OnReloadRequested;
- }
- }
- base.Dispose(disposing);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- TChromium.Initialize();
- Forms.Context.Terminated += (sender, arg) => TChromium.Shutdown();
- SetNativeControl(new WebViewContainer(Forms.NativeParent));
- NativeWebView.LoadStarted += OnLoadStarted;
- NativeWebView.LoadFinished += OnLoadFinished;
- NativeWebView.LoadError += OnLoadError;
- }
-
- if (e.OldElement != null)
- {
- ((IWebViewController)e.OldElement).EvalRequested -= OnEvalRequested;
- ((IWebViewController)e.OldElement).GoBackRequested -= OnGoBackRequested;
- ((IWebViewController)e.OldElement).GoForwardRequested -= OnGoForwardRequested;
- ((IWebViewController)e.OldElement).ReloadRequested -= OnReloadRequested;
- }
-
- if (e.NewElement != null)
- {
- ((IWebViewController)e.NewElement).EvalRequested += OnEvalRequested;
- ((IWebViewController)e.NewElement).EvaluateJavaScriptRequested += OnEvaluateJavaScriptRequested;
- ((IWebViewController)e.NewElement).GoForwardRequested += OnGoForwardRequested;
- ((IWebViewController)e.NewElement).GoBackRequested += OnGoBackRequested;
- ((IWebViewController)e.NewElement).ReloadRequested += OnReloadRequested;
- Load();
- }
- base.OnElementChanged(e);
- }
-
- protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == WebView.SourceProperty.PropertyName)
- Load();
-
- base.OnElementPropertyChanged(sender, e);
- }
-
- void OnLoadError(object sender, global::Tizen.WebView.SmartCallbackLoadErrorArgs e)
- {
- string url = e.Url;
- if (!string.IsNullOrEmpty(url))
- SendNavigated(new UrlWebViewSource { Url = url }, _eventState, WebNavigationResult.Failure);
- }
-
- void OnLoadStarted(object sender, EventArgs e)
- {
- string url = NativeWebView.Url;
- if (!string.IsNullOrEmpty(url))
- {
- var args = new WebNavigatingEventArgs(_eventState, new UrlWebViewSource { Url = url }, url);
- ElementController.SendNavigating(args);
-
- if (args.Cancel)
- {
- _eventState = WebNavigationEvent.NewPage;
- }
- }
- }
-
- void OnLoadFinished(object sender, EventArgs e)
- {
- string url = NativeWebView.Url;
- if (!string.IsNullOrEmpty(url))
- SendNavigated(new UrlWebViewSource { Url = url }, _eventState, WebNavigationResult.Success);
-
- NativeWebView.SetFocus(true);
- UpdateCanGoBackForward();
- }
-
- void Load()
- {
- if (_isUpdating)
- return;
-
- if (Element.Source != null)
- {
- Element.Source.Load(this);
- }
-
- UpdateCanGoBackForward();
- }
-
- void OnEvalRequested(object sender, EvalRequested eventArg)
- {
- NativeWebView.Eval(eventArg.Script);
- }
-
- Task OnEvaluateJavaScriptRequested(string script)
- {
- NativeWebView.Eval(script);
- return null;
- }
-
- void OnGoBackRequested(object sender, EventArgs eventArgs)
- {
- if (NativeWebView.CanGoBack())
- {
- _eventState = WebNavigationEvent.Back;
- NativeWebView.GoBack();
- }
-
- UpdateCanGoBackForward();
- }
-
- void OnGoForwardRequested(object sender, EventArgs eventArgs)
- {
- if (NativeWebView.CanGoForward())
- {
- _eventState = WebNavigationEvent.Forward;
- NativeWebView.GoForward();
- }
-
- UpdateCanGoBackForward();
- }
-
- void OnReloadRequested(object sender, EventArgs eventArgs)
- {
- NativeWebView.Reload();
- }
-
- void SendNavigated(UrlWebViewSource source, WebNavigationEvent evnt, WebNavigationResult result)
- {
- _isUpdating = true;
- ElementController.SetValueFromRenderer(WebView.SourceProperty, source);
- _isUpdating = false;
-
- ElementController.SendNavigated(new WebNavigatedEventArgs(evnt, source, source.Url, result));
-
- UpdateCanGoBackForward();
- _eventState = WebNavigationEvent.NewPage;
- }
-
- [PortHandler]
- void UpdateCanGoBackForward()
- {
- ElementController.CanGoBack = NativeWebView.CanGoBack();
- ElementController.CanGoForward = NativeWebView.CanGoForward();
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Shapes/EllipseRenderer.cs b/src/Compatibility/Core/src/Tizen/Shapes/EllipseRenderer.cs
deleted file mode 100644
index 4c045d06ba93..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shapes/EllipseRenderer.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-using SkiaSharp;
-using Microsoft.Maui.Controls.Shapes;
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class EllipseRenderer : ShapeRenderer
- {
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new EllipseView());
- }
-
- base.OnElementChanged(e);
- }
- }
-
- public class EllipseView : ShapeView
- {
- public EllipseView() : base()
- {
- UpdateShape();
- }
-
- void UpdateShape()
- {
- var path = new SKPath();
- path.AddCircle(0, 0, 1);
- UpdateShape(path);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Shapes/LineRenderer.cs b/src/Compatibility/Core/src/Tizen/Shapes/LineRenderer.cs
deleted file mode 100644
index c7c42136108a..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shapes/LineRenderer.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using SkiaSharp;
-using Microsoft.Maui.Controls.Shapes;
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class LineRenderer : ShapeRenderer
- {
- public LineRenderer() : base()
- {
- RegisterPropertyHandler(Line.X1Property, UpdateX1);
- RegisterPropertyHandler(Line.Y1Property, UpdateY1);
- RegisterPropertyHandler(Line.X2Property, UpdateX2);
- RegisterPropertyHandler(Line.Y2Property, UpdateY2);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new LineView());
- }
-
- base.OnElementChanged(e);
- }
-
- void UpdateX1()
- {
- Control.UpdateX1((float)Element.X1);
- }
-
- void UpdateY1()
- {
- Control.UpdateY1((float)Element.Y1);
- }
-
- void UpdateX2()
- {
- Control.UpdateX2((float)Element.X2);
- }
-
- void UpdateY2()
- {
- Control.UpdateY2((float)Element.Y2);
- }
- }
-
- public class LineView : ShapeView
- {
- float _x1, _y1, _x2, _y2;
-
- public LineView() : base()
- {
- }
-
- void UpdateShape()
- {
- var path = new SKPath();
- path.MoveTo(_x1, _y1);
- path.LineTo(_x2, _y2);
- UpdateShape(path);
- }
-
- public void UpdateX1(float x1)
- {
- _x1 = Forms.ConvertToScaledPixel(x1);
- UpdateShape();
- }
-
- public void UpdateY1(float y1)
- {
- _y1 = Forms.ConvertToScaledPixel(y1);
- UpdateShape();
- }
-
- public void UpdateX2(float x2)
- {
- _x2 = Forms.ConvertToScaledPixel(x2);
- UpdateShape();
- }
-
- public void UpdateY2(float y2)
- {
- _y2 = Forms.ConvertToScaledPixel(y2);
- UpdateShape();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shapes/PathRenderer.cs b/src/Compatibility/Core/src/Tizen/Shapes/PathRenderer.cs
deleted file mode 100644
index 5655a460e573..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shapes/PathRenderer.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using SkiaSharp;
-using Microsoft.Maui.Controls.Platform;
-using Path = Microsoft.Maui.Controls.Shapes.Path;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class PathRenderer : ShapeRenderer
- {
- public PathRenderer() : base()
- {
- RegisterPropertyHandler(Path.DataProperty, UpdateData);
- RegisterPropertyHandler(Path.RenderTransformProperty, UpdateRenderTransform);
- }
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new PathView());
- }
-
- base.OnElementChanged(e);
- }
-
- void UpdateData()
- {
- Control.UpdateData(Element.Data.ToSKPath());
- }
-
- void UpdateRenderTransform()
- {
- UpdateData();
-
- if (Element.RenderTransform != null)
- {
- Control.UpdateTransform(Element.RenderTransform.ToSkia());
- }
- }
- }
-
- public class PathView : ShapeView
- {
- public PathView() : base()
- {
- }
-
- public void UpdateData(SKPath path)
- {
- UpdateShape(path);
- }
-
- public void UpdateTransform(SKMatrix transform)
- {
- UpdateShapeTransform(transform);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shapes/PolygonRenderer.cs b/src/Compatibility/Core/src/Tizen/Shapes/PolygonRenderer.cs
deleted file mode 100644
index b9e140fdd44e..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shapes/PolygonRenderer.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System.Collections.Specialized;
-using SkiaSharp;
-using Microsoft.Maui.Controls.Shapes;
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class PolygonRenderer : ShapeRenderer
- {
- public PolygonRenderer() : base()
- {
- RegisterPropertyHandler(Polygon.PointsProperty, UpdatePoints);
- RegisterPropertyHandler(Polygon.FillRuleProperty, UpdateFillRule);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new PolygonView());
- }
-
- base.OnElementChanged(e);
-
- if (e.NewElement != null)
- {
- var points = e.NewElement.Points;
- points.CollectionChanged += OnCollectionChanged;
- }
- }
-
- void UpdatePoints()
- {
- Control.UpdatePoints(Element.Points);
- }
-
- void UpdateFillRule()
- {
- Control.UpdateFillMode(Element.FillRule == FillRule.Nonzero);
- }
-
- void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- UpdatePoints();
- }
- }
-
- public class PolygonView : ShapeView
- {
- PointCollection _points;
- bool _fillMode;
-
- public PolygonView() : base()
- {
- }
-
- void UpdateShape()
- {
- if (_points != null && _points.Count > 1)
- {
- SKPath path = new SKPath();
- path.FillType = _fillMode ? SKPathFillType.Winding : SKPathFillType.EvenOdd;
-
- path.MoveTo(Forms.ConvertToScaledPixel(_points[0].X), Forms.ConvertToScaledPixel(_points[0].Y));
- for (int index = 1; index < _points.Count; index++)
- {
- path.LineTo(Forms.ConvertToScaledPixel(_points[index].X), Forms.ConvertToScaledPixel(_points[index].Y));
- }
- path.Close();
-
- UpdateShape(path);
- }
- }
-
- public void UpdatePoints(PointCollection points)
- {
- _points = points;
- UpdateShape();
- }
-
- public void UpdateFillMode(bool fillMode)
- {
- _fillMode = fillMode;
- UpdateShape();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shapes/PolylineRenderer.cs b/src/Compatibility/Core/src/Tizen/Shapes/PolylineRenderer.cs
deleted file mode 100644
index 46766f23028b..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shapes/PolylineRenderer.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-using System.ComponentModel;
-using SkiaSharp;
-using Microsoft.Maui.Controls.Shapes;
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class PolylineRenderer : ShapeRenderer
- {
- public PolylineRenderer() : base()
- {
- RegisterPropertyHandler(Polyline.PointsProperty, UpdatePoints);
- RegisterPropertyHandler(Polyline.FillRuleProperty, UpdateFillRule);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new PolylineView());
- }
-
- base.OnElementChanged(e);
- }
-
- protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- base.OnElementPropertyChanged(sender, e);
-
- if (e.PropertyName == Polyline.PointsProperty.PropertyName)
- UpdatePoints();
- else if (e.PropertyName == Polyline.FillRuleProperty.PropertyName)
- UpdateFillRule();
- }
-
- void UpdatePoints()
- {
- Control.UpdatePoints(Element.Points);
- }
-
- void UpdateFillRule()
- {
- Control.UpdateFillMode(Element.FillRule == FillRule.Nonzero);
- }
- }
-
- public class PolylineView : ShapeView
- {
- PointCollection _points;
- bool _fillMode;
-
- public PolylineView() : base()
- {
- }
-
- void UpdateShape()
- {
- if (_points != null && _points.Count > 1)
- {
- SKPath path = new SKPath();
- path.FillType = _fillMode ? SKPathFillType.Winding : SKPathFillType.EvenOdd;
-
- path.MoveTo(Forms.ConvertToScaledPixel(_points[0].X), Forms.ConvertToScaledPixel(_points[0].Y));
-
- for (int index = 1; index < _points.Count; index++)
- path.LineTo(Forms.ConvertToScaledPixel(_points[index].X), Forms.ConvertToScaledPixel(_points[index].Y));
-
- UpdateShape(path);
- }
- }
-
- public void UpdatePoints(PointCollection points)
- {
- _points = points;
- UpdateShape();
- }
-
- public void UpdateFillMode(bool fillMode)
- {
- _fillMode = fillMode;
- UpdateShape();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shapes/RectangleRenderer.cs b/src/Compatibility/Core/src/Tizen/Shapes/RectangleRenderer.cs
deleted file mode 100644
index 5fc3973d8721..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shapes/RectangleRenderer.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-using SkiaSharp;
-using Microsoft.Maui.Controls.Platform;
-using FormsRectangle = Microsoft.Maui.Controls.Shapes.Rectangle;
-
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class RectangleRenderer : ShapeRenderer
- {
- public RectangleRenderer() : base()
- {
- RegisterPropertyHandler(FormsRectangle.RadiusXProperty, UpdateRadiusX);
- RegisterPropertyHandler(FormsRectangle.RadiusYProperty, UpdateRadiusY);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new RectView());
- }
-
- base.OnElementChanged(e);
- }
-
- void UpdateRadiusX()
- {
- if (Element.Width > 0)
- Control.UpdateRadiusX(Element.RadiusX / Element.Width);
- }
-
- void UpdateRadiusY()
- {
- if (Element.Height > 0)
- Control.UpdateRadiusY(Element.RadiusY / Element.Height);
- }
- }
-
- public class RectView : ShapeView
- {
- public RectView() : base()
- {
- UpdateShape();
- }
-
- public float RadiusX { set; get; }
-
- public float RadiusY { set; get; }
-
- void UpdateShape()
- {
- var path = new SKPath();
- path.AddRoundRect(new SKRect(0, 0, 1, 1), RadiusX, RadiusY, SKPathDirection.Clockwise);
- UpdateShape(path);
- }
-
- public void UpdateRadiusX(double radiusX)
- {
- RadiusX = (float)radiusX;
- UpdateShape();
- }
-
- public void UpdateRadiusY(double radiusY)
- {
- RadiusY = (float)radiusY;
- UpdateShape();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shapes/ShapeRenderer.cs b/src/Compatibility/Core/src/Tizen/Shapes/ShapeRenderer.cs
deleted file mode 100644
index 50f74f6ccf9d..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shapes/ShapeRenderer.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System.Linq;
-using SkiaSharp;
-using Microsoft.Maui.Controls.Shapes;
-using Shape = Microsoft.Maui.Controls.Shapes.Shape;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShapeRenderer : ViewRenderer
- where TShape : Shape
- where TNativeShape : ShapeView
- {
-
- public ShapeRenderer()
- {
- RegisterPropertyHandler(Shape.AspectProperty, UpdateAspect);
- RegisterPropertyHandler(Shape.FillProperty, UpdateFill);
- RegisterPropertyHandler(Shape.StrokeProperty, UpdateStroke);
- RegisterPropertyHandler(Shape.StrokeThicknessProperty, UpdateStrokeThickness);
- RegisterPropertyHandler(Shape.StrokeDashArrayProperty, UpdateStrokeDashArray);
- RegisterPropertyHandler(Shape.StrokeDashOffsetProperty, UpdateStrokeDashOffset);
- RegisterPropertyHandler(Shape.StrokeLineCapProperty, UpdateStrokeLineCap);
- RegisterPropertyHandler(Shape.StrokeLineJoinProperty, UpdateStrokeLineJoin);
- RegisterPropertyHandler(Shape.StrokeMiterLimitProperty, UpdateStrokeMiterLimit);
- }
-
- void UpdateAspect()
- {
- Control.UpdateAspect(Element.Aspect);
- }
-
- void UpdateFill()
- {
- Control.UpdateFill(Element.Fill);
- }
-
- void UpdateStroke()
- {
- Control.UpdateStroke(Element.Stroke);
- }
-
- void UpdateStrokeThickness()
- {
- Control.UpdateStrokeThickness(Element.StrokeThickness);
- }
-
- void UpdateStrokeDashArray()
- {
- Control.UpdateStrokeDashArray(Element.StrokeDashArray.Select(x => (float)x).ToArray());
- }
-
- void UpdateStrokeDashOffset()
- {
- Control.UpdateStrokeDashOffset((float)Element.StrokeDashOffset);
- }
-
- void UpdateStrokeLineCap()
- {
- PenLineCap lineCap = Element.StrokeLineCap;
- SKStrokeCap skStrokeCap = SKStrokeCap.Butt;
- switch (lineCap)
- {
- case PenLineCap.Flat:
- skStrokeCap = SKStrokeCap.Butt;
- break;
- case PenLineCap.Square:
- skStrokeCap = SKStrokeCap.Square;
- break;
- case PenLineCap.Round:
- skStrokeCap = SKStrokeCap.Round;
- break;
- }
- Control.UpdateStrokeLineCap(skStrokeCap);
- }
-
- void UpdateStrokeLineJoin()
- {
- PenLineJoin lineJoin = Element.StrokeLineJoin;
- SKStrokeJoin skStrokeJoin = SKStrokeJoin.Miter;
- switch (lineJoin)
- {
- case PenLineJoin.Miter:
- skStrokeJoin = SKStrokeJoin.Miter;
- break;
- case PenLineJoin.Bevel:
- skStrokeJoin = SKStrokeJoin.Bevel;
- break;
- case PenLineJoin.Round:
- skStrokeJoin = SKStrokeJoin.Round;
- break;
- }
- Control.UpdateStrokeLineJoin(skStrokeJoin);
- }
-
- void UpdateStrokeMiterLimit()
- {
- Control.UpdateStrokeMiterLimit((float)Element.StrokeMiterLimit);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shapes/ShapeView.cs b/src/Compatibility/Core/src/Tizen/Shapes/ShapeView.cs
deleted file mode 100644
index 5f67bb92ca4b..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shapes/ShapeView.cs
+++ /dev/null
@@ -1,290 +0,0 @@
-using System;
-using SkiaSharp;
-using SkiaSharp.Views.Tizen;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- public class ShapeView : Canvas, IMeasurable
- {
- SKCanvasView _skCanvasView;
- SKPath _skPath;
- SKPaint _skPaint;
- SKRect _drawableBounds;
- SKRect _pathFillBounds;
- SKRect _pathStrokeBounds;
- SKMatrix _transform;
-
- Brush _stroke;
- Brush _fill;
- Stretch _stretch;
-
- float _strokeWidth;
- float[] _strokeDash;
- float _strokeDashOffset;
-
- public ShapeView() : base(Forms.NativeParent)
- {
- _skPaint = new SKPaint();
- _skPaint.IsAntialias = true;
- _skCanvasView = new SKCanvasView(Forms.NativeParent);
- _skCanvasView.PaintSurface += OnPaintSurface;
- _skCanvasView.Show();
- Children.Add(_skCanvasView);
- LayoutUpdated += OnLayoutUpdated;
-
- _pathFillBounds = new SKRect();
- _pathStrokeBounds = new SKRect();
-
- _stretch = Stretch.None;
- }
-
- public SKCanvasView SKCanvasView => _skCanvasView;
-
- void OnPaintSurface(object sender, SKPaintSurfaceEventArgs e)
- {
- var canvas = e.Surface.Canvas;
- _drawableBounds = e.Info.Rect;
- canvas.Clear();
-
- if (_skPath == null)
- return;
-
- SKMatrix transformMatrix = CreateMatrix();
- SKPath transformedSkPath = new SKPath();
- _skPath.Transform(transformMatrix, transformedSkPath);
- SKRect fillBounds = transformMatrix.MapRect(_pathFillBounds);
- SKRect strokeBounds;
- using (SKPath strokePath = new SKPath())
- {
- _skPaint.GetFillPath(transformedSkPath, strokePath);
- strokeBounds = strokePath.Bounds;
- }
-
- if (_fill != null)
- {
- _skPaint.Style = SKPaintStyle.Fill;
-
- if (_fill is GradientBrush fillGradientBrush)
- {
- _skPaint.Shader = fillGradientBrush.CreateShader(fillBounds);
- }
- else if (_fill is SolidColorBrush fillSolidColorBrush)
- {
- _skPaint.Color = fillSolidColorBrush.ToSolidColor();
- }
-
- canvas.DrawPath(transformedSkPath, _skPaint);
- _skPaint.Shader = null;
- }
-
- if (_stroke != null)
- {
- _skPaint.Style = SKPaintStyle.Stroke;
-
- if (_stroke is GradientBrush strokeGradientBrush)
- {
- UpdatePathStrokeBounds();
- _skPaint.Shader = strokeGradientBrush.CreateShader(strokeBounds);
- }
- else if (_stroke is SolidColorBrush strokeSolidColorBrush)
- {
- _skPaint.Color = strokeSolidColorBrush.ToSolidColor();
- }
-
- canvas.DrawPath(transformedSkPath, _skPaint);
- _skPaint.Shader = null;
- }
- }
-
- void OnLayoutUpdated(object sender, LayoutEventArgs e)
- {
- _skCanvasView.Geometry = Geometry;
- }
-
- public void UpdateShape(SKPath sKPath)
- {
- _skPath = sKPath;
- UpdatePathShape();
- }
-
- public void UpdateShapeTransform(SKMatrix matrix)
- {
- _transform = matrix;
- _skPath.Transform(_transform);
- _skCanvasView.Invalidate();
- }
-
- public void UpdateAspect(Stretch stretch)
- {
- _stretch = stretch;
- _skCanvasView.Invalidate();
- }
-
- public void UpdateFill(Brush fill)
- {
- _fill = fill;
- _skCanvasView.Invalidate();
- }
-
- public void UpdateStroke(Brush stroke)
- {
- _stroke = stroke;
- _skCanvasView.Invalidate();
- }
-
- public void UpdateStrokeThickness(double strokeWidth)
- {
- _strokeWidth = Forms.ConvertToScaledPixel(strokeWidth);
- _skPaint.StrokeWidth = _strokeWidth;
- UpdateStrokeDash();
- }
-
- public void UpdateStrokeDashArray(float[] dash)
- {
- _strokeDash = dash;
- UpdateStrokeDash();
- }
-
- public void UpdateStrokeDashOffset(float strokeDashOffset)
- {
- _strokeDashOffset = strokeDashOffset;
- UpdateStrokeDash();
- }
-
- public void UpdateStrokeDash()
- {
- if (_strokeDash != null && _strokeDash.Length > 1)
- {
- float[] strokeDash = new float[_strokeDash.Length];
-
- for (int i = 0; i < _strokeDash.Length; i++)
- strokeDash[i] = _strokeDash[i] * _strokeWidth;
- _skPaint.PathEffect = SKPathEffect.CreateDash(strokeDash, _strokeDashOffset * _strokeWidth);
- }
- else
- {
- _skPaint.PathEffect = null;
- }
- UpdatePathStrokeBounds();
- }
-
- public void UpdateStrokeLineCap(SKStrokeCap strokeCap)
- {
- _skPaint.StrokeCap = strokeCap;
- UpdatePathStrokeBounds();
- }
- public void UpdateStrokeLineJoin(SKStrokeJoin strokeJoin)
- {
- _skPaint.StrokeJoin = strokeJoin;
- _skCanvasView.Invalidate();
- }
-
- public void UpdateStrokeMiterLimit(float strokeMiterLimit)
- {
- _skPaint.StrokeMiter = strokeMiterLimit * 2;
- UpdatePathStrokeBounds();
- }
-
- protected void UpdatePathShape()
- {
- if (_skPath != null)
- {
- using (SKPath fillPath = new SKPath())
- {
- _skPaint.StrokeWidth = 0.01f;
- _skPaint.Style = SKPaintStyle.Stroke;
- _skPaint.GetFillPath(_skPath, fillPath);
- _pathFillBounds = fillPath.Bounds;
- _skPaint.StrokeWidth = _strokeWidth;
- }
- }
- else
- {
- _pathFillBounds = SKRect.Empty;
- }
-
- UpdatePathStrokeBounds();
- }
-
- SKMatrix CreateMatrix()
- {
- SKMatrix matrix = SKMatrix.CreateIdentity();
-
- SKRect drawableBounds = _drawableBounds;
- float halfStrokeWidth = _skPaint.StrokeWidth / 2;
-
- drawableBounds.Left += halfStrokeWidth;
- drawableBounds.Top += halfStrokeWidth;
- drawableBounds.Right -= halfStrokeWidth;
- drawableBounds.Bottom -= halfStrokeWidth;
-
- float widthScale = drawableBounds.Width / _pathFillBounds.Width;
- float heightScale = drawableBounds.Height / _pathFillBounds.Height;
-
- switch (_stretch)
- {
- case Stretch.None:
- drawableBounds = _drawableBounds;
- float adjustX = Math.Min(0, _pathStrokeBounds.Left);
- float adjustY = Math.Min(0, _pathStrokeBounds.Top);
- if (adjustX < 0 || adjustY < 0)
- {
- matrix = SKMatrix.CreateTranslation(-adjustX, -adjustY);
- }
- break;
- case Stretch.Fill:
- matrix = SKMatrix.CreateScale(widthScale, heightScale);
- matrix = matrix.PostConcat(
- SKMatrix.CreateTranslation(drawableBounds.Left - widthScale * _pathFillBounds.Left,
- drawableBounds.Top - heightScale * _pathFillBounds.Top));
- break;
- case Stretch.Uniform:
- float minScale = Math.Min(widthScale, heightScale);
- matrix = SKMatrix.CreateScale(minScale, minScale);
- matrix = matrix.PostConcat(
- SKMatrix.CreateTranslation(drawableBounds.Left - (minScale * _pathFillBounds.Left) + (drawableBounds.Width - (minScale * _pathFillBounds.Width)) / 2,
- drawableBounds.Top - (minScale * _pathFillBounds.Top) + (drawableBounds.Height - (minScale * _pathFillBounds.Height)) / 2));
- break;
- case Stretch.UniformToFill:
- float maxScale = Math.Max(widthScale, heightScale);
- matrix = SKMatrix.CreateScale(maxScale, maxScale);
- matrix = matrix.PostConcat(
- SKMatrix.CreateTranslation(drawableBounds.Left - (maxScale * _pathFillBounds.Left),
- drawableBounds.Top - (maxScale * _pathFillBounds.Top)));
- break;
- }
-
- return matrix;
- }
-
- void UpdatePathStrokeBounds()
- {
- if (_skPath != null)
- {
- using (SKPath strokePath = new SKPath())
- {
- _skPaint.Style = SKPaintStyle.Stroke;
- _skPaint.GetFillPath(_skPath, strokePath);
- _pathStrokeBounds = strokePath.Bounds;
- }
- }
- else
- {
- _pathStrokeBounds = SKRect.Empty;
- }
-
- _skCanvasView.Invalidate();
- }
-
- public ElmSharp.Size Measure(int availableWidth, int availableHeight)
- {
- if (_skPath != null)
- {
- return new ElmSharp.Size((int)Math.Max(_pathStrokeBounds.Right - Math.Min(0, _pathStrokeBounds.Left), _strokeWidth),
- (int)Math.Max(_pathStrokeBounds.Bottom - Math.Min(0, _pathStrokeBounds.Top), _strokeWidth));
- }
- return new ElmSharp.Size(MinimumWidth, MinimumHeight);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/IFlyoutController.cs b/src/Compatibility/Core/src/Tizen/Shell/IFlyoutController.cs
deleted file mode 100644
index c7887252f5d1..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/IFlyoutController.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public interface IFlyoutController
- {
- void Open();
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/INavigationDrawer.cs b/src/Compatibility/Core/src/Tizen/Shell/INavigationDrawer.cs
deleted file mode 100644
index cb1a1e83f206..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/INavigationDrawer.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public interface INavigationDrawer
- {
- event EventHandler Toggled;
-
- EvasObject TargetView { get; }
-
- EvasObject NavigationView { get; set; }
-
- EvasObject Main { get; set; }
-
- bool IsOpen { get; set; }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/INavigationView.cs b/src/Compatibility/Core/src/Tizen/Shell/INavigationView.cs
deleted file mode 100644
index 3ce274cb9232..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/INavigationView.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using ElmSharp;
-using EColor = ElmSharp.Color;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public interface INavigationView
- {
-
- EvasObject NativeView { get; }
-
- FlyoutHeaderBehavior HeaderBehavior { get; set; }
-
- View Header { get; set; }
-
- EColor BackgroundColor { get; set; }
-
- ImageSource BackgroundImageSource { get; set; }
-
- Aspect BackgroundImageAspect { get; set; }
-
- void BuildMenu(List> flyout);
-
- event EventHandler SelectedItemChanged;
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/IShellTabs.cs b/src/Compatibility/Core/src/Tizen/Shell/IShellTabs.cs
deleted file mode 100644
index a8f195df619b..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/IShellTabs.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using ElmSharp;
-using EColor = ElmSharp.Color;
-using EToolbarItem = ElmSharp.ToolbarItem;
-using EToolbarItemEventArgs = ElmSharp.ToolbarItemEventArgs;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public interface IShellTabs
- {
- ShellTabsType Scrollable { get; set; }
-
- EvasObject NativeView { get; }
-
- EColor BackgroundColor { get; set; }
-
- EToolbarItem SelectedItem { get; }
-
- event EventHandler Selected;
-
- EToolbarItem Append(string label, string icon);
- EToolbarItem Append(string label);
-
- EToolbarItem InsertBefore(EToolbarItem before, string label, string icon);
- }
-
- public enum ShellTabsType
- {
- Fixed,
- Scrollable
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/NavigationDrawer.cs b/src/Compatibility/Core/src/Tizen/Shell/NavigationDrawer.cs
deleted file mode 100644
index 5963f308c63e..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/NavigationDrawer.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-using EGestureType = ElmSharp.GestureLayer.GestureType;
-using ERect = ElmSharp.Rect;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class NavigationDrawer : EBox, INavigationDrawer, IAnimatable
- {
- EvasObject _navigationView;
- EBox _mainContainer;
- EBox _dimArea;
- EvasObject _main;
- EBox _drawerBox;
-
- GestureLayer _gestureOnDimArea;
-
- bool _isOpen;
-
- public NavigationDrawer(EvasObject parent) : base(parent)
- {
- Initialize(parent);
- }
-
- public event EventHandler Toggled;
-
- public EvasObject TargetView => this;
-
- public EvasObject NavigationView
- {
- get => _navigationView;
- set => UpdateNavigationView(value);
- }
-
- public EvasObject Main
- {
- get
- {
- return _main;
- }
- set
- {
- UpdateMain(value);
- }
- }
-
- public bool IsOpen
- {
- get
- {
- return _isOpen;
- }
- set
- {
- if (_isOpen != value)
- {
- if (value)
- {
- ShowDrawer();
- }
- else
- {
- HideDrawer();
- }
- }
- }
- }
-
- void Initialize(EvasObject parent)
- {
- SetLayoutCallback(OnLayout);
- _mainContainer = new EBox(parent);
- _mainContainer.Show();
- PackEnd(_mainContainer);
-
- _dimArea = new EBox(parent)
- {
- BackgroundColor = ThemeConstants.Shell.ColorClass.DefaultDrawerDimBackgroundColor
- };
- PackEnd(_dimArea);
-
- _gestureOnDimArea = new GestureLayer(_dimArea);
- _gestureOnDimArea.SetTapCallback(EGestureType.Tap, GestureLayer.GestureState.Start, OnTapped);
- _gestureOnDimArea.Attach(_dimArea);
-
- _drawerBox = new EBox(parent);
- PackEnd(_drawerBox);
- }
-
- void UpdateNavigationView(EvasObject navigationView)
- {
- _navigationView?.Hide();
- _navigationView = navigationView;
-
- if (_navigationView != null)
- {
- _navigationView.SetAlignment(-1, -1);
- _navigationView.SetWeight(1, 1);
- _navigationView.Show();
- }
- _drawerBox.PackEnd(_navigationView);
- }
-
- void UpdateMain(EvasObject main)
- {
- if (_main != null)
- {
- _mainContainer.UnPack(_main);
- _main.Hide();
- }
-
- _main = main;
-
- if (_main != null)
- {
- _main.SetAlignment(-1, -1);
- _main.SetWeight(1, 1);
- _main.Show();
- _mainContainer.PackEnd(_main);
- }
- }
-
- void OnLayout()
- {
- if (Geometry.Width == 0 || Geometry.Height == 0)
- return;
-
- _mainContainer.Geometry = Geometry;
- _dimArea.Geometry = Geometry;
- var drawerWidth = (int)(Geometry.Width * this.GetFlyoutRatio(Geometry.Width, Geometry.Height));
- var bound = Geometry;
- bound.Width = drawerWidth;
- bound.X = _isOpen ? bound.X : bound.X - drawerWidth;
- _drawerBox.Geometry = bound;
- }
-
- async void HideDrawer()
- {
- var dest = _drawerBox.Geometry;
- dest.X = Geometry.X - dest.Width;
-
- await MoveDrawerAsync(_drawerBox, dest);
-
- _drawerBox.Hide();
- _dimArea.Hide();
- _mainContainer.IsEnabled = true;
- if (_isOpen)
- {
- _isOpen = false;
- Toggled?.Invoke(this, EventArgs.Empty);
- }
- }
-
- async void ShowDrawer()
- {
- _dimArea.Show();
- _mainContainer.IsEnabled = false;
- _drawerBox.Show();
-
- var dest = _drawerBox.Geometry;
- dest.X = Geometry.X;
-
- await MoveDrawerAsync(_drawerBox, dest);
-
- if (!_isOpen)
- {
- _isOpen = true;
- Toggled?.Invoke(this, EventArgs.Empty);
- }
- }
-
- Task MoveDrawerAsync(EvasObject target, ERect dest, uint length = 200)
- {
- var tcs = new TaskCompletionSource();
-
- var dx = target.Geometry.X - dest.X;
-
- new Animation((progress) =>
- {
- var toMove = dest;
- toMove.X += (int)(dx * (1 - progress));
- target.Geometry = toMove;
-
- }, easing: Easing.Linear).Commit(this, "Move", length: length, finished: (s, e) =>
- {
- target.Geometry = dest;
- tcs.SetResult(true);
- });
- return tcs.Task;
- }
-
- void OnTapped(GestureLayer.TapData data)
- {
- if (_isOpen)
- {
- HideDrawer();
- }
- }
-
- void IAnimatable.BatchBegin()
- {
- }
-
- void IAnimatable.BatchCommit()
- {
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/NavigationView.cs b/src/Compatibility/Core/src/Tizen/Shell/NavigationView.cs
deleted file mode 100644
index 5a127dce5749..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/NavigationView.cs
+++ /dev/null
@@ -1,499 +0,0 @@
-using System;
-using System.Collections.Generic;
-using ElmSharp;
-using Microsoft.Maui.Controls.Internals;
-using EColor = ElmSharp.Color;
-using EImage = ElmSharp.Image;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class NavigationView : Background, INavigationView
- {
- static EColor s_defaultBackgroundColor = EColor.White;
-
- Box _mainLayout;
-
- EImage _backgroundImage;
- Aspect _bgImageAspect;
- ImageSource _bgImageSource;
-
- View _header;
- EvasObject _nativeHeader;
-
- GenList _menu;
- GenItemClass _templateClass;
- GenItemClass _headerClass;
-
- EColor _backgroundColor;
-
- Element _lastSelected;
- Dictionary _cachedView = new Dictionary();
-
- List> _cachedGroups;
-
- public NavigationView(EvasObject parent, Shell shell) : base(parent)
- {
- Shell = shell;
- InitializeComponent(parent);
- }
-
- public event EventHandler SelectedItemChanged;
-
- public EvasObject NativeView => this;
-
- public IShellController ShellController => Shell;
- public Shell Shell { get; }
-
- FlyoutHeaderBehavior _headerBehavior = FlyoutHeaderBehavior.Fixed;
-
- public FlyoutHeaderBehavior HeaderBehavior
- {
- get => _headerBehavior;
- set
- {
- if (_headerBehavior == value)
- return;
- _headerBehavior = value;
- UpdateHeaderBehavior();
- }
- }
-
- public override EColor BackgroundColor
- {
- get
- {
- return _backgroundColor;
- }
- set
- {
- _backgroundColor = value;
- EColor effectiveColor = _backgroundColor.IsDefault ? s_defaultBackgroundColor : _backgroundColor;
- base.BackgroundColor = effectiveColor;
- }
- }
-
- public Aspect BackgroundImageAspect
- {
- get
- {
- return _bgImageAspect;
- }
- set
- {
- _bgImageAspect = value;
- _backgroundImage?.ApplyAspect(_bgImageAspect);
- }
- }
-
- public ImageSource BackgroundImageSource
- {
- get
- {
- return _bgImageSource;
- }
- set
- {
- _bgImageSource = value;
- UpdateBackgroundImage();
- }
- }
-
- public View Header
- {
- get
- {
- return _header;
- }
- set
- {
- UpdateHeader(value);
- }
- }
-
- bool HeaderOnMenu => HeaderBehavior == FlyoutHeaderBehavior.Scroll ||
- HeaderBehavior == FlyoutHeaderBehavior.CollapseOnScroll;
-
- public void BuildMenu(List> flyoutGroups)
- {
- if (!IsMenuItemChanged(flyoutGroups))
- {
- return;
- }
- _cachedGroups = flyoutGroups;
-
- _menu.Clear();
- _cachedView.Clear();
- _lastSelected = null;
- foreach (var group in flyoutGroups)
- {
- bool isFirst = true;
- foreach (var element in group)
- {
- var item = _menu.Append(_templateClass, element);
- if (isFirst)
- {
- isFirst = false;
- }
- else
- {
- item.SetBottomlineColor(EColor.Transparent);
- }
- item.SetBackgroundColor(EColor.Transparent);
- }
- }
- }
-
- void InitializeComponent(EvasObject parent)
- {
- base.BackgroundColor = s_defaultBackgroundColor;
-
- _mainLayout = new Box(parent)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1
- };
- _mainLayout.SetLayoutCallback(OnLayout);
- _mainLayout.Show();
-
- SetContent(_mainLayout);
-
- _menu = new GenList(parent)
- {
- Homogeneous = false,
- SelectionMode = GenItemSelectionMode.Always,
- BackgroundColor = EColor.Transparent,
- Style = "solid/default",
- ListMode = GenListMode.Scroll,
- };
-
- _menu.ItemSelected += (s, e) =>
- {
- if (_lastSelected != null)
- {
- VisualStateManager.GoToState(_cachedView[_lastSelected], "Normal");
- }
- var item = e.Item.Data as Element;
- _lastSelected = item;
- VisualStateManager.GoToState(_cachedView[_lastSelected], "Selected");
- SelectedItemChanged?.Invoke(this, new SelectedItemChangedEventArgs(item, -1));
- };
-
- _menu.Show();
- _mainLayout.PackEnd(_menu);
-
- _templateClass = new GenItemClass(ThemeConstants.GenItemClass.Styles.Full)
- {
- GetContentHandler = GetTemplatedContent,
- };
-
- _headerClass = new GenItemClass(ThemeConstants.GenItemClass.Styles.Full)
- {
- GetContentHandler = GetHeaderContnet
- };
- }
-
- bool IsMenuItemChanged(List> flyoutGroups)
- {
- if (_cachedGroups == null)
- return true;
-
- if (_cachedGroups.Count != flyoutGroups.Count)
- return true;
-
- for (int i = 0; i < flyoutGroups.Count; i++)
- {
- if (_cachedGroups[i].Count != flyoutGroups[i].Count)
- return true;
-
- for (int j = 0; j < flyoutGroups[i].Count; j++)
- {
- if (_cachedGroups[i][j] != flyoutGroups[i][j])
- return true;
- }
- }
- return false;
- }
-
- EvasObject GetHeaderContnet(object data, string part)
- {
- return GetNativeView(data as View);
- }
-
- EvasObject GetTemplatedContent(object data, string part)
- {
- Element item = data as Element;
- View view;
- if (!_cachedView.TryGetValue(item, out view))
- {
- view = (View)GetFlyoutItemDataTemplate(item).CreateContent(item, Shell);
- view.Parent = Shell;
- view.BindingContext = item;
- _cachedView[item] = view;
- }
- if (item == _lastSelected)
- {
- VisualStateManager.GoToState(view, "Selected");
- }
- else
- {
- VisualStateManager.GoToState(view, "Normal");
- }
-
- return GetNativeView(view);
- }
-
- EvasObject GetNativeView(View view)
- {
- var measuredSize = view.Measure(Forms.ConvertToScaledDP(Geometry.Width), Forms.ConvertToScaledDP(Geometry.Height));
- var renderer = Platform.GetOrCreateRenderer(view);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
- renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(measuredSize.Request.Height);
- return renderer.NativeView;
- }
-
- DataTemplate GetFlyoutItemDataTemplate(BindableObject bo)
- {
- string textBinding;
- string iconBinding;
- if (bo is IMenuItemController)
- {
- if (bo is MenuItem mi && mi.Parent != null && mi.Parent.IsSet(Shell.MenuItemTemplateProperty))
- {
- return Shell.GetMenuItemTemplate(mi.Parent);
- }
- else if (bo.IsSet(Shell.MenuItemTemplateProperty))
- {
- return Shell.GetMenuItemTemplate(bo);
- }
-
- if (Shell.MenuItemTemplate != null)
- return Shell.MenuItemTemplate;
-
- textBinding = "Text";
- iconBinding = "Icon";
- }
- else
- {
- if (Shell.GetItemTemplate(bo) != null)
- return Shell.GetItemTemplate(bo);
- else if (Shell.ItemTemplate != null)
- return Shell.ItemTemplate;
-
- textBinding = "Title";
- iconBinding = "FlyoutIcon";
- }
- return new DataTemplate(() =>
- {
- var grid = new Grid
- {
- HeightRequest = this.GetFlyoutItemHeight(),
- };
-
- ColumnDefinitionCollection columnDefinitions = new ColumnDefinitionCollection();
- columnDefinitions.Add(new ColumnDefinition { Width = this.GetFlyoutIconColumnSize() });
- columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star });
- grid.ColumnDefinitions = columnDefinitions;
-
- var image = new Image
- {
- VerticalOptions = LayoutOptions.Center,
- HorizontalOptions = LayoutOptions.Center,
- HeightRequest = this.GetFlyoutIconSize(),
- WidthRequest = this.GetFlyoutIconSize(),
- Margin = new Thickness(this.GetFlyoutMargin(), 0, 0, 0),
- };
- image.SetBinding(Image.SourceProperty, new Binding(iconBinding));
- grid.Children.Add(image);
-
- var label = new Label
- {
- FontSize = this.GetFlyoutItemFontSize(),
- VerticalTextAlignment = TextAlignment.Center,
- TextColor = Graphics.Color.FromRgb(0, 0, 0).MultiplyAlpha(0.87f),
- Margin = new Thickness(this.GetFlyoutMargin(), 0, 0, 0),
- };
- label.SetBinding(Label.TextProperty, new Binding(textBinding));
-
- grid.Children.Add(label, 1, 0);
-
- var groups = new VisualStateGroupList();
-
- var commonGroup = new VisualStateGroup();
- commonGroup.Name = "CommonStates";
- groups.Add(commonGroup);
-
- var normalState = new VisualState();
- normalState.Name = "Normal";
- commonGroup.States.Add(normalState);
-
- var selectedState = new VisualState();
- selectedState.Name = "Selected";
- selectedState.Setters.Add(new Setter
- {
- Property = VisualElement.BackgroundColorProperty,
- Value = new Graphics.Color(0.95f)
- });
-
- commonGroup.States.Add(selectedState);
- VisualStateManager.SetVisualStateGroups(grid, groups);
- return grid;
- });
- }
-
- void UpdateBackgroundImage()
- {
- if (BackgroundImageSource == null)
- {
- if (_backgroundImage != null)
- {
- this.SetBackgroundPart(null);
- _backgroundImage = null;
- }
- }
- else
- {
- if (_backgroundImage == null)
- {
- _backgroundImage = new EImage(this);
- this.SetBackgroundPart(_backgroundImage);
- }
- _backgroundImage.LoadFromImageSourceAsync(BackgroundImageSource).GetAwaiter().OnCompleted(() =>
- {
- _backgroundImage.ApplyAspect(_bgImageAspect);
- });
- }
- }
-
- void UpdateHeader(View header)
- {
- if (_header != null)
- {
- _header.MeasureInvalidated -= OnHeaderSizeChanged;
-
- if (HeaderOnMenu)
- {
- ResetHeaderOnMenu();
- }
- else if (_nativeHeader != null)
- {
- _mainLayout.UnPack(_nativeHeader);
- _nativeHeader.Unrealize();
- _nativeHeader = null;
- }
- }
-
- if (header != null)
- {
- header.MeasureInvalidated += OnHeaderSizeChanged;
-
- if (HeaderOnMenu)
- {
- UpdateHeaderOnMenu(header);
- }
- else
- {
- var renderer = Platform.GetOrCreateRenderer(header);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
- _nativeHeader = renderer.NativeView;
- _mainLayout.PackEnd(_nativeHeader);
- }
- }
- _header = header;
- }
-
- void UpdateHeaderBehavior()
- {
- if (_header == null)
- return;
-
- if (HeaderOnMenu)
- {
- if (_nativeHeader != null)
- {
- _mainLayout.UnPack(_nativeHeader);
- _nativeHeader.Unrealize();
- _nativeHeader = null;
- }
- UpdateHeaderOnMenu(_header);
- }
- else
- {
- ResetHeaderOnMenu();
-
- if (_nativeHeader == null)
- {
- var renderer = Platform.GetOrCreateRenderer(_header);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
- _nativeHeader = renderer.NativeView;
- _mainLayout.PackEnd(_nativeHeader);
- }
- }
- OnLayout();
- }
-
- void UpdateHeaderOnMenu(View header)
- {
- if (_menu.FirstItem != null && _menu.FirstItem.Data == header)
- return;
-
- GenListItem item = null;
- if (_menu.Count > 0)
- {
- item = _menu.InsertBefore(_headerClass, header, _menu.FirstItem);
- }
- else
- {
- item = _menu.Append(_headerClass, header);
- }
- item.SelectionMode = GenItemSelectionMode.None;
- }
-
- void ResetHeaderOnMenu()
- {
- if (_menu.FirstItem != null && _menu.FirstItem.Data == _header)
- {
- _menu.FirstItem.Delete();
- Platform.GetRenderer(_header)?.Dispose();
- }
- }
-
- void OnHeaderSizeChanged(object sender, EventArgs e)
- {
- if (HeaderOnMenu)
- {
- _menu.FirstItem?.Update();
- }
- else
- {
- Application.Current.Dispatcher.Dispatch(OnLayout);
- }
- }
-
- void OnLayout()
- {
- if (Geometry.Width == 0 || Geometry.Height == 0)
- return;
-
- var bound = Geometry;
- int headerHeight = 0;
- if (Header != null)
- {
- if (!HeaderOnMenu)
- {
- var requestSize = Header.Measure(Forms.ConvertToScaledDP(bound.Width), Forms.ConvertToScaledDP(bound.Height));
- headerHeight = Forms.ConvertToScaledPixel(requestSize.Request.Height);
- var headerBound = Geometry;
- headerBound.Height = headerHeight;
- _nativeHeader.Geometry = headerBound;
- }
- }
-
- bound.Y += headerHeight;
- bound.Height -= headerHeight;
- _menu.Geometry = bound;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/SearchHandlerRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/SearchHandlerRenderer.cs
deleted file mode 100644
index a252fa2fbd81..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/SearchHandlerRenderer.cs
+++ /dev/null
@@ -1,300 +0,0 @@
-using System;
-using System.ComponentModel;
-using ElmSharp;
-using EColor = ElmSharp.Color;
-using NSearchBar = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.SearchBar;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class SearchHandlerRenderer : IDisposable
- {
- bool disposedValue;
- SearchResultList _searchResultList;
-
- public SearchHandlerRenderer(SearchHandler searchHandler)
- {
- Element = searchHandler;
- Control = new NSearchBar(Forms.NativeParent)
- {
- IsSingleLine = true,
- };
- Control.Show();
- Control.SetInputPanelReturnKeyType(InputPanelReturnKeyType.Search);
- Control.TextChanged += OnTextChanged;
- Control.Activated += OnActivated;
- Control.Focused += OnFocused;
- Control.Unfocused += OnFocused;
-
- Element.FocusChangeRequested += OnFocusChangedRequested;
- Element.PropertyChanged += OnElementPropertyChanged;
- (Element as ISearchHandlerController).ListProxyChanged += OnSearchResultListChanged;
-
- UpdateKeyboard();
- UpdatePlaceholder();
- UpdatePlaceholderColor();
- UpdateHorizontalTextAlignment();
- UpdateTextColor();
- UpdateFontAttributes();
- UpdateFontFamily();
- UpdateFontSize();
- UpdateBackgroundColor();
- UpdateQuery();
- UpdateIsSearchEnabled();
-
- UpdateSearchResult();
-
- }
-
- public SearchHandler Element { get; }
- public EvasObject NativeView => Control;
- ISearchHandlerController SearchHandlerController => Element;
- NSearchBar Control { get; }
-
- ~SearchHandlerRenderer()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (!disposedValue)
- {
- if (disposing)
- {
- Element.FocusChangeRequested -= OnFocusChangedRequested;
- Element.PropertyChanged -= OnElementPropertyChanged;
- (Element as ISearchHandlerController).ListProxyChanged -= OnSearchResultListChanged;
- Control.TextChanged -= OnTextChanged;
- Control.Activated -= OnActivated;
- Control.Focused -= OnFocused;
- Control.Unfocused -= OnFocused;
- Control.Unrealize();
- }
- disposedValue = true;
- }
- }
-
- void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == nameof(Element.Keyboard))
- {
- UpdateKeyboard();
- }
- else if (e.PropertyName == nameof(Element.Placeholder))
- {
- UpdatePlaceholder();
- }
- else if (e.PropertyName == nameof(Element.PlaceholderColor))
- {
- UpdatePlaceholderColor();
- }
- else if (e.PropertyName == nameof(Element.HorizontalTextAlignment))
- {
- UpdateHorizontalTextAlignment();
- }
- else if (e.PropertyName == nameof(Element.TextColor))
- {
- UpdateTextColor();
- }
- else if (e.PropertyName == nameof(Element.FontAttributes))
- {
- UpdateFontAttributes();
- }
- else if (e.PropertyName == nameof(Element.FontFamily))
- {
- UpdateFontFamily();
- }
- else if (e.PropertyName == nameof(Element.FontSize))
- {
- UpdateFontSize();
- }
- else if (e.PropertyName == nameof(Element.BackgroundColor))
- {
- UpdateBackgroundColor();
- }
- else if (e.PropertyName == nameof(Element.Query))
- {
- UpdateQuery();
- }
- else if (e.PropertyName == nameof(Element.IsSearchEnabled))
- {
- UpdateIsSearchEnabled();
- }
- else if (e.PropertyName == nameof(Element.ShowsResults))
- {
- UpdateSearchResult();
- }
- }
-
- void OnSearchResultListChanged(object sender, ListProxyChangedEventArgs e)
- {
- UpdateSearchResult();
- }
-
- void InitializeSearchResultList()
- {
- if (_searchResultList != null)
- {
- return;
- }
- _searchResultList = new SearchResultList();
- _searchResultList.Show();
- _searchResultList.ItemSelected += OnResultItemSelected;
- }
-
- void OnResultItemSelected(object sender, GenListItemEventArgs e)
- {
- var data = (e.Item.Data as View).BindingContext;
- SearchHandlerController.ItemSelected(data);
- Application.Current.Dispatcher.Dispatch(() =>
- {
- DeinitializeSearchResultList();
- });
- }
-
- void DeinitializeSearchResultList()
- {
- if (_searchResultList == null)
- {
- return;
- }
- _searchResultList.ItemSelected -= OnResultItemSelected;
- _searchResultList.Unrealize();
- _searchResultList = null;
- }
-
- void UpdateSearchResult()
- {
- if (SearchHandlerController == null)
- return;
-
- if (!Element.ShowsResults)
- {
- DeinitializeSearchResultList();
- return;
- }
-
- if (Control.IsFocused && SearchHandlerController.ListProxy != null &&
- SearchHandlerController.ListProxy.Count > 0 &&
- Element.ItemTemplate != null)
- {
- InitializeSearchResultList();
- _searchResultList.ItemTemplate = Element.ItemTemplate;
- _searchResultList.ItemsSource = SearchHandlerController.ListProxy;
- UpdateSearchResultLayout();
- }
- else
- {
- DeinitializeSearchResultList();
- }
- }
-
- void UpdateIsSearchEnabled()
- {
- Control.IsEnabled = Element.IsSearchEnabled;
- }
-
- void UpdateQuery()
- {
- Control.Text = Element.Query;
- }
-
- void UpdateFontAttributes()
- {
- Control.FontAttributes = Element.FontAttributes;
- }
-
- void UpdateFontFamily()
- {
- Control.FontFamily = Element.FontFamily;
- }
-
- void UpdateFontSize()
- {
- Control.FontSize = Element.FontSize;
- }
-
- void UpdateBackgroundColor()
- {
- var color = Element.BackgroundColor.ToNative();
- Control.BackgroundColor = color == EColor.Default ? EColor.White : color;
- }
-
- void UpdateTextColor()
- {
- Control.TextColor = Element.TextColor.ToNative();
- }
-
- void UpdateHorizontalTextAlignment()
- {
- Control.HorizontalTextAlignment = Element.HorizontalTextAlignment.ToNative();
- }
-
- void OnFocusChangedRequested(object sender, VisualElement.FocusRequestArgs e)
- {
- Control.SetFocus(e.Focus);
- e.Result = true;
- }
-
- void UpdateKeyboard()
- {
- Control.Keyboard = Element.Keyboard.ToNative();
- }
-
- void UpdatePlaceholder()
- {
- Control.Placeholder = Element.Placeholder;
- }
- void UpdatePlaceholderColor()
- {
- Control.PlaceholderColor = Element.PlaceholderColor.ToNative();
- }
-
- void OnFocused(object sender, EventArgs e)
- {
- Element.SetIsFocused(Control.IsFocused);
- if (Control.IsFocused)
- {
- UpdateSearchResult();
- }
- else
- {
- if (_searchResultList != null)
- {
- _searchResultList.Hide();
- }
- Application.Current.Dispatcher.DispatchDelayed(TimeSpan.FromMilliseconds(100), () => DeinitializeSearchResultList());
- }
- }
-
- void OnActivated(object sender, EventArgs e)
- {
- Control.HideInputPanel();
- (Element as ISearchHandlerController).QueryConfirmed();
- }
-
- void OnTextChanged(object sender, TextChangedEventArgs e)
- {
- Element.SetValueCore(SearchHandler.QueryProperty, Control.Text);
- }
-
- void UpdateSearchResultLayout()
- {
- if (_searchResultList != null)
- {
- var bound = NativeView.Geometry;
- bound.Y += NativeView.Geometry.Height;
- bound.Height = Math.Min(_searchResultList.Height, bound.Width);
- _searchResultList.Geometry = bound;
- _searchResultList.UpdateLayout();
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/SearchResultList.cs b/src/Compatibility/Core/src/Tizen/Shell/SearchResultList.cs
deleted file mode 100644
index 8f7c70c60b04..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/SearchResultList.cs
+++ /dev/null
@@ -1,73 +0,0 @@
-using System.Collections.Generic;
-using ElmSharp;
-using EColor = ElmSharp.Color;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete]
- public class SearchResultList : GenList
- {
- GenItemClass _defaultClass = null;
-
- public SearchResultList() : base(Forms.NativeParent)
- {
- SetAlignment(-1, -1);
- SetWeight(1, 1);
- Homogeneous = true;
- AllowFocus(true);
- SelectionMode = GenItemSelectionMode.Always;
- BackgroundColor = EColor.White;
- _defaultClass = new GenItemClass(ThemeConstants.GenItemClass.Styles.Full)
- {
- GetContentHandler = GetContent,
- };
- }
-
- public int Height { get; private set; }
-
- IReadOnlyList _itemsSource;
- public IReadOnlyList ItemsSource
- {
- get => _itemsSource;
- set
- {
- _itemsSource = value;
- Clear();
- Height = 0;
- foreach (var item in _itemsSource)
- {
- Append(item);
- }
- }
- }
-
- public void UpdateLayout()
- {
- UpdateRealizedItems();
- }
-
- public DataTemplate ItemTemplate { get; set; }
-
- EvasObject GetContent(object data, string part)
- {
- var view = data as View;
-
- var renderer = Platform.GetOrCreateRenderer(view);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
- var measured = view.Measure(Forms.ConvertToScaledDP(Geometry.Width), Forms.ConvertToScaledDP(Geometry.Width * 3));
- renderer.NativeView.MinimumHeight = Forms.ConvertToScaledPixel(measured.Request.Height);
- return renderer.NativeView;
- }
-
- void Append(object data)
- {
- var view = ItemTemplate.CreateContent() as View;
- view.Parent = Shell.Current;
- view.BindingContext = data;
- var measured = view.Measure(Forms.ConvertToScaledDP(Geometry.Width), Forms.ConvertToScaledDP(Geometry.Width * 3));
- Height += Forms.ConvertToScaledPixel(measured.Request.Height);
- Append(_defaultClass, view);
- }
-
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/ShellItemRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/ShellItemRenderer.cs
deleted file mode 100644
index 95f38abd0ef5..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/ShellItemRenderer.cs
+++ /dev/null
@@ -1,455 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using System.Linq;
-using System.Reflection;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-using EColor = ElmSharp.Color;
-using EImage = ElmSharp.Image;
-using EToolbarItem = ElmSharp.ToolbarItem;
-using EToolbarItemEventArgs = ElmSharp.ToolbarItemEventArgs;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShellItemRenderer : IAppearanceObserver, IDisposable
- {
- // The source of icon resources is https://materialdesignicons.com/
- const string _dotsIcon = ThemeConstants.Shell.Resources.DotsIcon;
-
- IShellTabs _tabs = null;
-
- EBox _mainLayout = null;
- EBox _contentHolder = null;
- Panel _moreItemsDrawer = null;
- ShellMoreToolbar _moreItemsList = null;
- EToolbarItem _moreTabItem = null;
- ShellSectionStack _currentStack = null;
-
- Dictionary _sectionsTable = new Dictionary();
- Dictionary _tabItemsTable = new Dictionary();
- Dictionary _shellSectionStackCache = new Dictionary();
- List _tabsItems = new List();
-
- bool _disposed = false;
- EColor _tabBarBackgroudColor = ShellRenderer.DefaultBackgroundColor.ToNative();
- EColor _tabBarTitleColor = ShellRenderer.DefaultTitleColor.ToNative();
-
- public ShellItemRenderer(ShellItem item)
- {
- Initialize();
- ShellItem = item;
-
- ShellItem.PropertyChanged += OnShellItemPropertyChanged;
- if (ShellItem.Items is INotifyCollectionChanged notifyCollectionChanged)
- {
- notifyCollectionChanged.CollectionChanged += OnShellItemsCollectionChanged;
- }
- ShellController.AddAppearanceObserver(this, ShellItem);
-
- UpdateTabsItems();
- UpdateCurrentItem(ShellItem.CurrentItem);
- }
-
- ~ShellItemRenderer()
- {
- Dispose(false);
- }
-
- public EvasObject NativeView
- {
- get
- {
- return _mainLayout;
- }
- }
-
- public EColor TabBarBackgroundColor
- {
- get
- {
- return _tabBarBackgroudColor;
- }
- set
- {
- _tabBarBackgroudColor = value;
- UpdateTabsBackgroudColor(_tabBarBackgroudColor);
- }
- }
-
- public EColor TabBarTitleColor
- {
- get => _tabBarTitleColor;
- set
- {
- _tabBarTitleColor = value;
- UpdateTabBarTitleColor(value);
- }
- }
-
- ShellItem ShellItem { get; }
- IShellController ShellController => Shell.Current;
- bool HasMoreItems => _moreItemsDrawer != null;
- bool HasTabs => _tabs != null;
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (_disposed)
- return;
-
- if (disposing)
- {
- ShellController.RemoveAppearanceObserver(this);
- if (ShellItem != null)
- {
- ShellItem.PropertyChanged -= OnShellItemPropertyChanged;
- if (ShellItem.Items is INotifyCollectionChanged notifyCollectionChanged)
- {
- notifyCollectionChanged.CollectionChanged -= OnShellItemsCollectionChanged;
- }
-
- foreach (var stack in _shellSectionStackCache.Values)
- {
- stack.Dispose();
- }
-
- DestroyMoreItems();
- DeinitializeTabs();
-
- _sectionsTable.Clear();
- _tabItemsTable.Clear();
- _shellSectionStackCache.Clear();
- _tabsItems.Clear();
- }
- NativeView.Unrealize();
- }
- _disposed = true;
- }
-
- protected virtual void UpdateTabsItems()
- {
- ResetTabs();
- if (ShellItem.Items.Count > 1)
- {
- InitializeTabs();
- foreach (ShellSection section in ShellItem.Items)
- {
- AddTabsItem(section);
- }
- }
- else
- {
- DeinitializeTabs();
- }
- }
-
- protected virtual IShellTabs CreateTabs()
- {
- return new ShellTabs(Forms.NativeParent);
- }
-
- protected virtual ShellSectionStack CreateShellSectionStack(ShellSection section)
- {
- return new ShellSectionStack(section);
- }
-
- bool _disableMoreItemOpen;
-
- void UpdateCurrentItem(ShellSection section)
- {
- UpdateCurrentShellSection(section);
-
- if (HasTabs)
- {
- if (_tabItemsTable.ContainsKey(section))
- {
- _tabItemsTable[section].IsSelected = true;
- }
- else if (HasMoreItems)
- {
- _disableMoreItemOpen = true;
- _moreTabItem.IsSelected = true;
- _disableMoreItemOpen = false;
- }
-
- if (HasMoreItems)
- {
- _moreItemsDrawer.IsOpen = false;
- }
- }
- }
-
- void UpdateCurrentItemFromUI(ShellSection section)
- {
- if (ShellItem.CurrentItem != section)
- {
- ShellItem.SetValueFromRenderer(ShellItem.CurrentItemProperty, section);
- }
- if (HasMoreItems)
- {
- _moreItemsDrawer.IsOpen = false;
- }
- }
-
- void Initialize()
- {
- _mainLayout = new EBox(Forms.NativeParent);
- _mainLayout.SetLayoutCallback(OnLayout);
- _mainLayout.Show();
- _contentHolder = new EBox(Forms.NativeParent);
- _contentHolder.Show();
- _mainLayout.PackEnd(_contentHolder);
- }
-
- void InitializeTabs()
- {
- if (_tabs != null)
- return;
-
- // Create Tabs
- _tabs = CreateTabs();
- _tabs.NativeView.Show();
- _tabs.BackgroundColor = _tabBarBackgroudColor;
- _tabs.Scrollable = ShellTabsType.Fixed;
- _tabs.Selected += OnTabsSelected;
- _mainLayout.PackEnd(_tabs.NativeView);
- }
-
- void DeinitializeTabs()
- {
- if (_tabs == null)
- return;
- _mainLayout.UnPack(_tabs.NativeView);
- _tabs.Selected -= OnTabsSelected;
- _tabs.NativeView.Unrealize();
- _tabs = null;
- }
-
- void CreateMoreItems()
- {
- if (_moreItemsDrawer != null)
- return;
-
- // Create More Tabs
- _moreItemsList = new ShellMoreToolbar(Forms.NativeParent);
- _moreItemsList.Show();
- _moreItemsList.ItemSelected += OnMoreItemSelected;
-
- _moreItemsDrawer = new Panel(Forms.NativeParent);
- _moreItemsDrawer.Show();
-
- _moreItemsDrawer.SetScrollable(true);
- _moreItemsDrawer.SetScrollableArea(1.0);
- _moreItemsDrawer.Direction = PanelDirection.Bottom;
- _moreItemsDrawer.IsOpen = false;
- _moreItemsDrawer.SetContent(_moreItemsList, true);
- _mainLayout.PackEnd(_moreItemsDrawer);
- }
-
- void DestroyMoreItems()
- {
- if (_moreItemsDrawer == null)
- return;
-
- _mainLayout.UnPack(_moreItemsDrawer);
-
- _moreItemsList.Unrealize();
- _moreItemsDrawer.Unrealize();
-
- _moreItemsList = null;
- _moreItemsDrawer = null;
- }
-
- void OnMoreItemSelected(object sender, GenListItemEventArgs e)
- {
- ShellSection section = e.Item.Data as ShellSection;
- UpdateCurrentItemFromUI(section);
- }
-
- void OnShellItemPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == nameof(ShellItem.CurrentItem))
- {
- UpdateCurrentItem(ShellItem.CurrentItem);
- }
- }
-
- void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance)
- {
- var tabBarBackgroudColor = (appearance as IShellAppearanceElement)?.EffectiveTabBarBackgroundColor;
- var tabBarTitleColor = (appearance as IShellAppearanceElement)?.EffectiveTabBarTitleColor;
- TabBarBackgroundColor = tabBarBackgroudColor.IsDefault() ? ShellRenderer.DefaultBackgroundColor.ToNative() : tabBarBackgroudColor.ToNative();
- TabBarTitleColor = tabBarTitleColor.IsDefault() ? ShellRenderer.DefaultTitleColor.ToNative() : tabBarTitleColor.ToNative();
- }
-
- void UpdateTabsBackgroudColor(EColor color)
- {
- foreach (EToolbarItem item in _tabsItems)
- {
- item.SetBackgroundColor(color);
- }
- }
-
- void UpdateTabBarTitleColor(EColor color)
- {
- foreach (EToolbarItem item in _tabsItems)
- {
- item.SetTextColor(color);
- }
- }
-
- void ResetTabs()
- {
- if (!HasTabs)
- return;
-
- foreach (var item in _tabsItems)
- {
- item.Delete();
- }
- _tabsItems.Clear();
- DestroyMoreItems();
- _moreTabItem = null;
- }
-
- void OnShellItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- UpdateTabsItems();
- }
-
- void AddTabsItem(ShellSection section)
- {
- if (_tabsItems.Count < 5)
- {
- var item = AppendTabsItem(section.Title, section.Icon);
- _sectionsTable.Add(item, section);
- _tabItemsTable.Add(section, item);
- _tabsItems.Add(item);
- }
- else if (!HasMoreItems)
- {
- CreateMoreItems();
-
- var last = _tabsItems.Last();
- var lastSection = _sectionsTable[last];
-
- _tabsItems.Remove(last);
- _sectionsTable.Remove(last);
- _tabItemsTable.Remove(lastSection);
- last.Delete();
-
- //The source of icon resources is https://materialdesignicons.com/
- var assembly = typeof(ShellItemRenderer).Assembly;
- var assemblyName = assembly.GetName().Name;
- _moreTabItem = AppendTabsItem("More", ImageSource.FromResource(assemblyName + "." + _dotsIcon, assembly));
- _tabsItems.Add(_moreTabItem);
-
- _moreItemsList.AddItem(lastSection);
- _moreItemsList.AddItem(section);
- }
- else
- {
- _moreItemsList.AddItem(section);
- }
- }
-
- void UpdateCurrentShellSection(ShellSection section)
- {
- if (_currentStack != null)
- {
- _currentStack.Hide();
- _contentHolder.UnPack(_currentStack);
- }
- _currentStack = null;
-
- if (section == null)
- {
- return;
- }
-
- ShellSectionStack native;
- if (_shellSectionStackCache.ContainsKey(section))
- {
- native = _shellSectionStackCache[section];
- }
- else
- {
- native = CreateShellSectionStack(section);
- _shellSectionStackCache[section] = native;
- }
- _currentStack = native;
- _currentStack.Show();
- _contentHolder.PackEnd(_currentStack);
- }
-
- void OnTabsSelected(object sender, EToolbarItemEventArgs e)
- {
- if (_tabs.SelectedItem == null)
- return;
-
- if (HasMoreItems && e.Item == _moreTabItem)
- {
- if (!_disableMoreItemOpen)
- {
- _moreItemsDrawer.IsOpen = !_moreItemsDrawer.IsOpen;
- }
- }
- else
- {
- UpdateCurrentItemFromUI(_sectionsTable[_tabs.SelectedItem]);
- }
- }
-
- void OnLayout()
- {
- if (NativeView.Geometry.Height == 0 || NativeView.Geometry.Width == 0)
- return;
-
- int tabsHeight = 0;
- var bound = _mainLayout.Geometry;
- if (HasTabs)
- {
- tabsHeight = _tabs.NativeView.MinimumHeight;
- var tabsBound = bound;
- tabsBound.Y += (bound.Height - tabsHeight);
- tabsBound.Height = tabsHeight;
- _tabs.NativeView.Geometry = tabsBound;
- if (HasMoreItems)
- {
- int moreItemListHeight = _moreItemsList.HeightRequest;
- moreItemListHeight = Math.Min(moreItemListHeight, bound.Height - tabsHeight);
- var moreItemDrawerBound = bound;
- moreItemDrawerBound.Y += (bound.Height - tabsHeight - moreItemListHeight);
- moreItemDrawerBound.Height = moreItemListHeight;
- _moreItemsDrawer.Geometry = moreItemDrawerBound;
- }
- }
- bound.Height -= tabsHeight;
- _contentHolder.Geometry = bound;
- }
-
- EToolbarItem AppendTabsItem(string text, ImageSource icon)
- {
- var item = _tabs.Append(text);
- if (icon != null)
- {
- EImage image = new EImage(Forms.NativeParent);
- _ = image.LoadFromImageSourceAsync(icon);
- item.SetIconPart(image);
- }
- item.SetBackgroundColor(_tabBarBackgroudColor);
- item.SetUnderlineColor(EColor.Transparent);
- item.SetTextColor(_tabBarTitleColor);
-
- return item;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/ShellMoreToolbar.cs b/src/Compatibility/Core/src/Tizen/Shell/ShellMoreToolbar.cs
deleted file mode 100644
index edee7e2b556d..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/ShellMoreToolbar.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using System;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-using EImage = ElmSharp.Image;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class ShellMoreToolbar : GenList
- {
- GenItemClass _defaultClass = null;
-
- public ShellMoreToolbar(EvasObject parent) : base(parent)
- {
- SetAlignment(-1, -1);
- SetWeight(1, 1);
- Homogeneous = true;
- SelectionMode = GenItemSelectionMode.Always;
- BackgroundColor = ShellRenderer.DefaultBackgroundColor.ToNative();
- _defaultClass = new GenItemClass(ThemeConstants.GenItemClass.Styles.Full)
- {
- GetContentHandler = GetContent,
- };
- }
-
- public void AddItem(ShellSection section)
- {
- Append(_defaultClass, section);
- }
-
- public int HeightRequest
- {
- get
- {
- var cellHeight = this.GetIconSize() * 2 + this.GetIconSize();
- return Forms.ConvertToScaledPixel(cellHeight) * Count;
- }
- }
-
- EvasObject GetContent(object data, string part)
- {
- ShellSection section = data as ShellSection;
-
- var box = new EBox(Forms.NativeParent);
- box.Show();
-
- EImage icon = null;
- if (section.Icon != null)
- {
- icon = new EImage(Forms.NativeParent);
- icon.Show();
- box.PackEnd(icon);
- _ = icon.LoadFromImageSourceAsync(section.Icon);
- }
-
- var title = new Native.Label(Forms.NativeParent)
- {
- Text = section.Title,
- FontSize = Forms.ConvertToEflFontPoint(14),
- HorizontalTextAlignment = Native.TextAlignment.Start,
- VerticalTextAlignment = Native.TextAlignment.Center,
- };
- title.Show();
- box.PackEnd(title);
- int iconPadding = Forms.ConvertToScaledPixel(this.GetIconPadding());
- int iconSize = Forms.ConvertToScaledPixel(this.GetIconSize());
- int cellHeight = iconPadding * 2 + iconSize;
- box.SetLayoutCallback(() =>
- {
- var bound = box.Geometry;
- int leftMargin = iconPadding;
-
- if (icon != null)
- {
- var iconBound = bound;
- iconBound.X += iconPadding;
- iconBound.Y += iconPadding;
- iconBound.Width = iconSize;
- iconBound.Height = iconSize;
- icon.Geometry = iconBound;
- leftMargin = (2 * iconPadding + iconSize);
- }
-
- bound.X += leftMargin;
- bound.Width -= leftMargin;
- title.Geometry = bound;
- });
-
- box.MinimumHeight = cellHeight;
- return box;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/ShellNavBar.cs b/src/Compatibility/Core/src/Tizen/Shell/ShellNavBar.cs
deleted file mode 100644
index 3cceea616903..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/ShellNavBar.cs
+++ /dev/null
@@ -1,374 +0,0 @@
-using System;
-using System.Reflection;
-using Microsoft.Maui.Devices;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-using EButton = ElmSharp.Button;
-using EColor = ElmSharp.Color;
-using EImage = ElmSharp.Image;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class ShellNavBar : EBox, IFlyoutBehaviorObserver, IDisposable
- {
- EImage _menuIcon = null;
- EButton _menuButton = null;
- Native.Label _title = null;
- SearchHandlerRenderer _searchRenderer = null;
- EvasObject _nativeTitleView = null;
-
- SearchHandler _searchHandler = null;
- View _titleView = null;
- Page _page = null;
-
- FlyoutBehavior _flyoutBehavior = FlyoutBehavior.Flyout;
-
- EColor _backgroudColor = ShellRenderer.DefaultBackgroundColor.ToNative();
- EColor _foregroudColor = ShellRenderer.DefaultForegroundColor.ToNative();
- EColor _titleColor = ShellRenderer.DefaultTitleColor.ToNative();
-
- // The source of icon resources is https://materialdesignicons.com/
- const string _menuIconRes = ThemeConstants.Shell.Resources.MenuIcon;
- const string _backIconRes = ThemeConstants.Shell.Resources.BackIcon;
-
- bool _hasBackButton = false;
- private bool disposedValue;
- bool _isTV = DeviceInfo.Idiom == DeviceIdiom.TV;
-
- public ShellNavBar() : base(Forms.NativeParent)
- {
- SetLayoutCallback(OnLayout);
-
- _menuButton = new EButton(Forms.NativeParent);
- _menuButton.Clicked += OnMenuClicked;
-
- _menuIcon = new EImage(Forms.NativeParent);
- UpdateMenuIcon();
-
- _title = new Native.Label(Forms.NativeParent)
- {
- FontSize = this.GetDefaultTitleFontSize(),
- VerticalTextAlignment = Native.TextAlignment.Center,
- TextColor = _titleColor,
- FontAttributes = FontAttributes.Bold,
- };
- _title.Show();
-
- BackgroundColor = _backgroudColor;
- _menuButton.BackgroundColor = _backgroudColor;
- PackEnd(_menuButton);
- PackEnd(_title);
- }
-
- ~ShellNavBar()
- {
- Dispose(false);
- }
-
- public IShellController ShellController => Shell.Current;
-
- public bool HasBackButton
- {
- get
- {
- return _hasBackButton;
- }
- set
- {
- _hasBackButton = value;
- UpdateMenuIcon();
- }
- }
-
- public FlyoutBehavior FlyoutBehavior
- {
- get => _flyoutBehavior;
- set
- {
- if (_flyoutBehavior != value)
- {
- _flyoutBehavior = value;
- UpdateMenuIcon();
- }
- }
- }
-
- public SearchHandler SearchHandler
- {
- get
- {
- return _searchHandler;
- }
- set
- {
- _searchHandler = value;
- UpdateSearchHandler(_searchHandler);
- UpdateChildren();
- }
- }
-
- public View TitleView
- {
- get
- {
- return _titleView;
- }
- set
- {
- _titleView = value;
- UpdateTitleView(_titleView);
- UpdateChildren();
- }
- }
-
- public string Title
- {
- get
- {
- return _title?.Text;
- }
- set
- {
- _title.Text = value;
- }
- }
-
- public override EColor BackgroundColor
- {
- get
- {
- return _backgroudColor;
- }
- set
- {
- _backgroudColor = value;
- _menuButton.BackgroundColor = _backgroudColor;
- base.BackgroundColor = _backgroudColor;
- }
- }
-
- public EColor ForegroundColor
- {
- get
- {
- return _foregroudColor;
- }
- set
- {
- _foregroudColor = value;
- }
- }
-
- public EColor TitleColor
- {
- get
- {
- return _titleColor;
- }
- set
- {
- _titleColor = value;
- _title.TextColor = value;
- }
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- public void SetPage(Page page)
- {
- _page = page;
- Title = page.Title;
- SearchHandler = Shell.GetSearchHandler(page);
- TitleView = Shell.GetTitleView(page);
- UpdateMenuIcon();
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (!disposedValue)
- {
- if (disposing)
- {
- Unrealize();
- }
- disposedValue = true;
- }
- }
-
- void UpdateMenuIcon()
- {
- ImageSource source = null;
- if (HasBackButton)
- {
- if (_isTV)
- {
- _menuButton.Style = ThemeConstants.Button.Styles.Default;
- _menuButton.Text = ThemeConstants.Shell.Resources.TV.BackIconCode;
- _menuIcon = null;
- }
- else
- {
- var assembly = typeof(ShellNavBar).Assembly;
- var assemblyName = assembly.GetName().Name;
- source = ImageSource.FromResource(assemblyName + "." + _backIconRes, assembly);
- }
- }
- else if (_flyoutBehavior != FlyoutBehavior.Flyout)
- {
- _menuButton.Hide();
- }
- else if (ShellController.FlyoutIcon != null)
- {
- if (_isTV)
- {
- _menuButton.Style = ThemeConstants.Button.Styles.Circle;
- _menuIcon = new EImage(Forms.NativeParent);
- }
- source = Shell.Current.FlyoutIcon;
- }
- else
- {
- if (_isTV)
- {
- _menuButton.Style = ThemeConstants.Button.Styles.Default;
- _menuButton.Text = ThemeConstants.Shell.Resources.TV.MenuIconCode;
- _menuIcon = null;
- }
- else
- {
- var assembly = typeof(ShellNavBar).Assembly;
- var assemblyName = assembly.GetName().Name;
- source = ImageSource.FromResource(assemblyName + "." + _menuIconRes, assembly);
- }
- }
-
- if (source != null && _menuIcon != null)
- {
- _menuIcon.Show();
- _ = _menuIcon.LoadFromImageSourceAsync(source);
- }
- _menuButton.SetIconPart(_menuIcon);
- _menuButton.Show();
- }
-
- void OnMenuClicked(object sender, EventArgs e)
- {
- var backButtonHandler = Shell.GetBackButtonBehavior(_page);
- if (backButtonHandler?.Command != null)
- {
- backButtonHandler.Command.Execute(backButtonHandler.CommandParameter);
- }
- else if (_hasBackButton)
- {
- Shell.Current.CurrentItem.Navigation.PopAsync();
- }
- else if (_flyoutBehavior == FlyoutBehavior.Flyout)
- {
- Shell.Current.FlyoutIsPresented = !Shell.Current.FlyoutIsPresented;
- }
- }
-
- void UpdateTitleView(View titleView)
- {
- _nativeTitleView?.Unrealize();
- _nativeTitleView = null;
-
- if (titleView != null)
- {
- var renderer = Platform.GetOrCreateRenderer(titleView);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
- _nativeTitleView = renderer.NativeView;
- _nativeTitleView.Show();
- PackEnd(_nativeTitleView);
- }
- }
-
- void UpdateSearchHandler(SearchHandler handler)
- {
- if (_searchRenderer != null)
- {
- _searchRenderer.Dispose();
- _searchRenderer = null;
- }
-
- if (handler != null)
- {
- _searchRenderer = new SearchHandlerRenderer(handler);
- _searchRenderer.NativeView.Show();
- PackEnd(_searchRenderer.NativeView);
- }
- }
-
- void UpdateChildren()
- {
- if (_searchHandler != null)
- {
- _searchRenderer.NativeView.Show();
- _title?.Hide();
- _nativeTitleView?.Hide();
- }
- else if (_titleView != null)
- {
- _nativeTitleView.Show();
- _title?.Hide();
- _searchRenderer?.NativeView?.Hide();
- }
- else
- {
- _title.Show();
- _nativeTitleView?.Hide();
- _searchRenderer?.NativeView?.Hide();
- }
- }
-
- void OnLayout()
- {
- if (Geometry.Width == 0 || Geometry.Height == 0)
- return;
-
- int menuSize = Forms.ConvertToScaledPixel(this.GetDefaultMenuSize());
- int menuMargin = Forms.ConvertToScaledPixel(this.GetDefaultMargin());
- int titleHMargin = Forms.ConvertToScaledPixel(this.GetDefaultMargin());
- int titleVMargin = Forms.ConvertToScaledPixel(this.GetDefaultMargin());
-
- var bound = Geometry;
-
- var menuBound = bound;
- menuBound.X += menuMargin;
- menuBound.Y += (menuBound.Height - menuSize) / 2;
- menuBound.Width = menuSize;
- menuBound.Height = menuSize;
-
- _menuButton.Geometry = menuBound;
-
- var contentBound = Geometry;
- contentBound.X = menuBound.Right + titleHMargin;
- contentBound.Y += titleVMargin;
- contentBound.Width -= (menuBound.Width + menuMargin + titleHMargin * 2);
- contentBound.Height -= titleVMargin * 2;
-
- if (_searchRenderer != null)
- {
- _searchRenderer.NativeView.Geometry = contentBound;
- }
- else if (_titleView != null)
- {
- _nativeTitleView.Geometry = contentBound;
- }
- else
- {
- _title.Geometry = contentBound;
- }
- }
-
- void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
- {
- FlyoutBehavior = behavior;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/ShellRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/ShellRenderer.cs
deleted file mode 100644
index 3237ad9464e8..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/ShellRenderer.cs
+++ /dev/null
@@ -1,162 +0,0 @@
-using System;
-using Microsoft.Maui.Graphics;
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShellRenderer : VisualElementRenderer, IFlyoutController
- {
- INavigationDrawer _drawer;
- INavigationView _navigationView;
- ShellItemRenderer _currentShellItem;
-
- public static readonly Color DefaultBackgroundColor = ThemeConstants.Shell.ColorClass.DefaultBackgroundColor;
- public static readonly Color DefaultForegroundColor = ThemeConstants.Shell.ColorClass.DefaultForegroundColor;
- public static readonly Color DefaultTitleColor = ThemeConstants.Shell.ColorClass.DefaultTitleColor;
-
- public ShellRenderer()
- {
- RegisterPropertyHandler(Shell.CurrentItemProperty, UpdateCurrentItem);
- RegisterPropertyHandler(Shell.FlyoutBackgroundColorProperty, UpdateFlyoutBackgroundColor);
- RegisterPropertyHandler(Shell.FlyoutBackgroundImageProperty, UpdateFlyoutBackgroundImage);
- RegisterPropertyHandler(Shell.FlyoutBackgroundImageAspectProperty, UpdateFlyoutBackgroundImageAspect);
- RegisterPropertyHandler(Shell.FlyoutIsPresentedProperty, UpdateFlyoutIsPresented);
- RegisterPropertyHandler(Shell.FlyoutHeaderProperty, UpdateFlyoutHeader);
- RegisterPropertyHandler(Shell.FlyoutHeaderTemplateProperty, UpdateFlyoutHeader);
- RegisterPropertyHandler(Shell.FlyoutHeaderBehaviorProperty, UpdateFlyoutHeaderBehavior);
- }
-
- protected INavigationDrawer NavigationDrawer => _drawer;
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (_drawer == null)
- {
- _drawer = CreateNavigationDrawer();
- _navigationView = CreateNavigationView();
- _drawer.NavigationView = _navigationView.NativeView;
- _drawer.Toggled += OnFlyoutIsPresentedChanged;
- SetNativeView(_drawer.TargetView);
-
- InitializeFlyout();
- }
- base.OnElementChanged(e);
- UpdateFlyoutHeader(false);
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- ((IShellController)Element).StructureChanged -= OnShellStructureChanged;
- if (_drawer != null)
- {
- _drawer.Toggled -= OnFlyoutIsPresentedChanged;
- _navigationView.SelectedItemChanged -= OnItemSelected;
- }
- }
- base.Dispose(disposing);
- }
-
- protected void InitializeFlyout()
- {
- ((IShellController)Element).StructureChanged += OnShellStructureChanged;
- _navigationView.BuildMenu(((IShellController)Element).GenerateFlyoutGrouping());
- _navigationView.SelectedItemChanged += OnItemSelected;
- }
-
- protected void OnFlyoutIsPresentedChanged(object sender, EventArgs e)
- {
- Element.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, _drawer.IsOpen);
- }
-
- protected virtual ShellItemRenderer CreateShellItemRenderer(ShellItem item)
- {
- return new ShellItemRenderer(item);
- }
-
- protected virtual INavigationDrawer CreateNavigationDrawer()
- {
- return new NavigationDrawer(Forms.NativeParent);
- }
-
- protected virtual INavigationView CreateNavigationView()
- {
- return new NavigationView(Forms.NativeParent, Element);
- }
-
- void UpdateFlyoutHeader(bool init)
- {
- if (init)
- return;
-
- if ((Element as IShellController).FlyoutHeader != null)
- {
- _navigationView.Header = (Element as IShellController).FlyoutHeader;
- }
- else
- {
- _navigationView.Header = null;
- }
- }
-
- void UpdateFlyoutHeaderBehavior()
- {
- _navigationView.HeaderBehavior = Element.FlyoutHeaderBehavior;
- }
-
- void UpdateCurrentItem()
- {
- _currentShellItem?.Dispose();
- if (Element.CurrentItem != null)
- {
- _currentShellItem = CreateShellItemRenderer(Element.CurrentItem);
- _drawer.Main = _currentShellItem.NativeView;
- }
- else
- {
- _drawer.Main = null;
- }
- }
-
- void UpdateFlyoutBackgroundColor()
- {
- _navigationView.BackgroundColor = Element.FlyoutBackgroundColor.ToPlatformEFL();
- }
-
- void UpdateFlyoutBackgroundImageAspect()
- {
- _navigationView.BackgroundImageAspect = Element.FlyoutBackgroundImageAspect;
- }
-
- void UpdateFlyoutBackgroundImage()
- {
- _navigationView.BackgroundImageSource = Element.FlyoutBackgroundImage;
- }
-
- protected virtual void UpdateFlyoutIsPresented()
- {
- // It is workaround of Panel.IsOpen bug, Panel.IsOpen property is not working when layouting was triggered
- Application.Current.Dispatcher.Dispatch(() =>
- {
- _drawer.IsOpen = Element.FlyoutIsPresented;
- });
- }
-
- void OnShellStructureChanged(object sender, EventArgs e)
- {
- _navigationView.BuildMenu(((IShellController)Element).GenerateFlyoutGrouping());
- }
-
- void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
- {
- ((IShellController)Element).OnFlyoutItemSelected(e.SelectedItem as Element);
- }
-
- void IFlyoutController.Open()
- {
- _drawer.IsOpen = true;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Shell/ShellSectionRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/ShellSectionRenderer.cs
deleted file mode 100644
index 3cc160c23086..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/ShellSectionRenderer.cs
+++ /dev/null
@@ -1,372 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-using EColor = ElmSharp.Color;
-using EToolbarItem = ElmSharp.ToolbarItem;
-using EToolbarItemEventArgs = ElmSharp.ToolbarItemEventArgs;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public interface IShellSectionRenderer : IDisposable
- {
- EvasObject NativeView { get; }
- }
-
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShellSectionRenderer : IAppearanceObserver, IShellSectionRenderer
- {
- EBox _mainLayout = null;
- EBox _contentArea = null;
- IShellTabs _tabs = null;
- EvasObject _currentContent = null;
- Page _displayedPage;
-
- Dictionary _contentCache = new Dictionary();
- Dictionary _contentToTabsItem = new Dictionary();
- Dictionary _itemToContent = new Dictionary();
- List _tabsItems = new List();
-
- EColor _backgroundColor = ShellRenderer.DefaultBackgroundColor.ToNative();
- EColor _foregroundColor = ShellRenderer.DefaultForegroundColor.ToNative();
-
- bool _disposed = false;
-
- public ShellSectionRenderer(ShellSection section)
- {
- ShellSection = section;
- ShellSection.PropertyChanged += OnSectionPropertyChanged;
- (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnShellSectionCollectionChanged;
-
- _mainLayout = new EBox(Forms.NativeParent);
- _mainLayout.SetLayoutCallback(OnLayout);
-
- _contentArea = new EBox(Forms.NativeParent);
- _contentArea.Show();
- _mainLayout.PackEnd(_contentArea);
-
- UpdateTabsItem();
- UpdateCurrentItem(ShellSection.CurrentItem);
-
- ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection);
- (ShellSection as IShellSectionController).AddDisplayedPageObserver(this, UpdateDisplayedPage);
- }
-
- bool HasTabs => _tabs != null;
-
- bool _tabBarIsVisible = true;
-
- protected virtual bool TabBarIsVisible
- {
- get => _tabBarIsVisible;
- set
- {
- if (_tabBarIsVisible != value)
- {
- _tabBarIsVisible = value;
- _mainLayout.MarkChanged();
-
- if (value)
- {
- _tabs?.NativeView.Show();
- }
- else
- {
- _tabs?.NativeView.Hide();
- }
- }
- }
- }
-
- public ShellSection ShellSection { get; }
-
- public EvasObject NativeView
- {
- get
- {
- return _mainLayout;
- }
- }
-
- public EColor ToolbarBackgroundColor
- {
- get
- {
- return _backgroundColor;
- }
- set
- {
- _backgroundColor = value;
- UpdateToolbarBackgroudColor(_backgroundColor);
- }
- }
-
- public EColor ToolbarForegroundColor
- {
- get
- {
- return _foregroundColor;
- }
- set
- {
- _foregroundColor = value;
- UpdateToolbarForegroundColor(_foregroundColor);
- }
- }
-
- ~ShellSectionRenderer()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance)
- {
- var backgroundColor = (appearance as IShellAppearanceElement)?.EffectiveTabBarBackgroundColor;
- var foregroundColor = appearance?.ForegroundColor;
- ToolbarBackgroundColor = backgroundColor.IsDefault() ? ShellRenderer.DefaultBackgroundColor.ToNative() : backgroundColor.ToNative();
- ToolbarForegroundColor = foregroundColor.IsDefault() ? ShellRenderer.DefaultForegroundColor.ToNative() : foregroundColor.ToNative();
- }
-
- void UpdateDisplayedPage(Page page)
- {
- if (_displayedPage != null)
- {
- _displayedPage.PropertyChanged -= OnDisplayedPagePropertyChanged;
- }
-
- if (page == null)
- {
- TabBarIsVisible = true;
- return;
- }
- _displayedPage = page;
- _displayedPage.PropertyChanged += OnDisplayedPagePropertyChanged;
- TabBarIsVisible = Shell.GetTabBarIsVisible(page);
- }
-
- void OnDisplayedPagePropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == Shell.TabBarIsVisibleProperty.PropertyName)
- {
- TabBarIsVisible = Shell.GetTabBarIsVisible(_displayedPage);
- }
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (_disposed)
- return;
-
- if (disposing)
- {
- ((IShellController)Shell.Current).RemoveAppearanceObserver(this);
- if (ShellSection != null)
- {
- (ShellSection as IShellSectionController).RemoveDisplayedPageObserver(this);
- ShellSection.PropertyChanged -= OnSectionPropertyChanged;
- DeinitializeTabs();
-
- foreach (var native in _contentCache.Values)
- {
- native.Unrealize();
- }
- _contentCache.Clear();
- _contentToTabsItem.Clear();
- _itemToContent.Clear();
- }
- NativeView.Unrealize();
- }
- _disposed = true;
- }
-
- protected virtual IShellTabs CreateToolbar()
- {
- return new ShellTabs(Forms.NativeParent);
- }
-
- void InitializeTabs()
- {
- if (_tabs != null)
- {
- return;
- }
- _tabs = CreateToolbar();
- _tabs.NativeView.Show();
- _tabs.BackgroundColor = _backgroundColor;
- _tabs.Scrollable = ShellTabsType.Fixed;
- _tabs.Selected += OnTabsSelected;
- _mainLayout.PackEnd(_tabs.NativeView);
- }
-
- void ClearTabsItem()
- {
- if (!HasTabs)
- return;
-
- foreach (var item in _tabsItems)
- {
- item.Delete();
- }
- _tabsItems.Clear();
- _contentToTabsItem.Clear();
- _itemToContent.Clear();
- }
-
- void DeinitializeTabs()
- {
- if (_tabs == null)
- {
- return;
- }
- ClearTabsItem();
- _tabs.NativeView.Unrealize();
- _tabs = null;
- }
-
- void OnSectionPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == "CurrentItem")
- {
- UpdateCurrentItem(ShellSection.CurrentItem);
- }
- }
-
- void UpdateCurrentItem(ShellContent content)
- {
- UpdateCurrentShellContent(content);
- if (_contentToTabsItem.ContainsKey(content))
- {
- _contentToTabsItem[content].IsSelected = true;
- }
- }
-
- void UpdateToolbarBackgroudColor(EColor color)
- {
- foreach (EToolbarItem item in _tabsItems)
- {
- item.SetBackgroundColor(color);
- }
- }
-
- void UpdateToolbarForegroundColor(EColor color)
- {
- foreach (EToolbarItem item in _tabsItems)
- {
- item.SetUnderlineColor(color);
- }
- }
-
- void UpdateTabsItem()
- {
- if (ShellSection.Items.Count <= 1)
- {
- DeinitializeTabs();
- return;
- }
-
- InitializeTabs();
- ClearTabsItem();
- foreach (ShellContent content in ShellSection.Items)
- {
- InsertTabsItem(content);
- }
- _tabs.Scrollable = ShellSection.Items.Count > 3 ? ShellTabsType.Scrollable : ShellTabsType.Fixed;
- }
-
- EToolbarItem InsertTabsItem(ShellContent content)
- {
- EToolbarItem item = _tabs.Append(content.Title, null);
- item.SetBackgroundColor(_backgroundColor);
- item.SetUnderlineColor(_foregroundColor);
-
- _tabsItems.Add(item);
- _itemToContent[item] = content;
- _contentToTabsItem[content] = item;
- return item;
- }
-
- void OnShellSectionCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- UpdateTabsItem();
- }
-
- void OnTabsSelected(object sender, EToolbarItemEventArgs e)
- {
- if (_tabs.SelectedItem == null)
- {
- return;
- }
-
- ShellContent content = _itemToContent[_tabs.SelectedItem];
- if (ShellSection.CurrentItem != content)
- {
- ShellSection.SetValueFromRenderer(ShellSection.CurrentItemProperty, content);
- }
- }
-
- void UpdateCurrentShellContent(ShellContent content)
- {
- if (_currentContent != null)
- {
- _currentContent.Hide();
- _contentArea.UnPack(_currentContent);
- _currentContent = null;
- }
-
- if (content == null)
- {
- return;
- }
-
- if (!_contentCache.ContainsKey(content))
- {
- var native = CreateShellContent(content);
- native.SetAlignment(-1, -1);
- native.SetWeight(1, 1);
- _contentCache[content] = native;
- }
- _currentContent = _contentCache[content];
- _currentContent.Show();
- _contentArea.PackEnd(_currentContent);
- }
-
- EvasObject CreateShellContent(ShellContent content)
- {
- Page xpage = ((IShellContentController)content).GetOrCreateContent();
- return Platform.GetOrCreateRenderer(xpage).NativeView;
- }
-
- void OnLayout()
- {
- if (NativeView.Geometry.Width == 0 || NativeView.Geometry.Height == 0)
- return;
- var bound = NativeView.Geometry;
-
- int tabsHeight;
- if (HasTabs && TabBarIsVisible)
- {
- var tabsBound = bound;
- tabsHeight = _tabs.NativeView.MinimumHeight;
- tabsBound.Height = tabsHeight;
- _tabs.NativeView.Geometry = tabsBound;
- }
- else
- {
- tabsHeight = 0;
- }
-
- var contentBound = bound;
- contentBound.Y += tabsHeight;
- contentBound.Height -= tabsHeight;
- _contentArea.Geometry = contentBound;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/ShellSectionStack.cs b/src/Compatibility/Core/src/Tizen/Shell/ShellSectionStack.cs
deleted file mode 100644
index ecd126a3ec01..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/ShellSectionStack.cs
+++ /dev/null
@@ -1,281 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Threading.Tasks;
-using Microsoft.Maui.Devices;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class ShellSectionStack : EBox, IAppearanceObserver, IDisposable
- {
- ShellNavBar _navBar = null;
- Page _currentPage = null;
- SimpleViewStack _viewStack = null;
- IShellSectionRenderer _shellSectionRenderer;
-
- bool _disposed = false;
- bool _navBarIsVisible = true;
-
- public ShellSectionStack(ShellSection section) : base(Forms.NativeParent)
- {
- ShellSection = section;
- InitializeComponent();
- }
-
- public virtual bool NavBarIsVisible
- {
- get
- {
- return _navBarIsVisible;
- }
- set
- {
- _navBarIsVisible = value;
- OnLayout();
- }
- }
-
- ShellSection ShellSection { get; }
-
- ~ShellSectionStack()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (_disposed)
- return;
-
- if (disposing)
- {
- (Shell.Current as IShellController).RemoveAppearanceObserver(this);
- (Shell.Current as IShellController).RemoveFlyoutBehaviorObserver(_navBar);
- if (ShellSection != null)
- {
- IShellSectionController controller = ShellSection;
- controller.NavigationRequested -= OnNavigationRequested;
- controller.RemoveDisplayedPageObserver(this);
- }
- if (_currentPage != null)
- {
- _currentPage.PropertyChanged -= OnPagePropertyChanged;
- }
- if (_navBar != null)
- {
- _navBar.Dispose();
- _navBar = null;
- }
- Unrealize();
- }
- _disposed = true;
- }
-
- protected virtual IShellSectionRenderer CreateShellSectionRenderer(ShellSection section)
- {
- return new ShellSectionRenderer(section);
- }
-
- void InitializeComponent()
- {
- SetAlignment(-1, -1);
- SetWeight(1, 1);
- SetLayoutCallback(OnLayout);
-
- _viewStack = new SimpleViewStack(Forms.NativeParent);
- if (DeviceInfo.Idiom == DeviceIdiom.Phone)
- {
- _viewStack.BackgroundColor = ElmSharp.Color.White;
- }
- _viewStack.Show();
- PackEnd(_viewStack);
-
- _navBar = new ShellNavBar();
- _navBar.Show();
- PackEnd(_navBar);
-
- IShellSectionController controller = ShellSection;
- controller.NavigationRequested += OnNavigationRequested;
- controller.AddDisplayedPageObserver(this, UpdateDisplayedPage);
- ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection);
- ((IShellController)Shell.Current).AddFlyoutBehaviorObserver(_navBar);
-
- _shellSectionRenderer = CreateShellSectionRenderer(ShellSection);
- _shellSectionRenderer.NativeView.Show();
- _viewStack.Push(_shellSectionRenderer.NativeView);
-
- Application.Current.Dispatcher.Dispatch(() =>
- {
- (_shellSectionRenderer.NativeView as Widget)?.SetFocus(true);
- });
- }
-
- void UpdateDisplayedPage(Page page)
- {
- // this callback is raised when DisplayPage was updated and it is raised ahead of push NavigationRequesed event
- if (_currentPage != null)
- {
- _currentPage.PropertyChanged -= OnPagePropertyChanged;
- }
- if (page == null)
- return;
-
- _currentPage = page;
- _currentPage.PropertyChanged += OnPagePropertyChanged;
- NavBarIsVisible = Shell.GetNavBarIsVisible(page);
- _navBar.SetPage(page);
- }
-
- void IAppearanceObserver.OnAppearanceChanged(ShellAppearance appearance)
- {
- if (_navBar == null)
- return;
-
- var titleColor = (appearance as IShellAppearanceElement)?.EffectiveTabBarTitleColor;
- var backgroundColor = appearance?.BackgroundColor;
- var foregroundColor = appearance?.ForegroundColor;
-
- _navBar.TitleColor = titleColor.IsDefault() ? ShellRenderer.DefaultTitleColor.ToPlatformEFL() : titleColor.ToPlatformEFL();
- _navBar.BackgroundColor = backgroundColor.IsDefault() ? ShellRenderer.DefaultBackgroundColor.ToPlatformEFL() : backgroundColor.ToPlatformEFL();
- _navBar.ForegroundColor = foregroundColor.IsDefault() ? ShellRenderer.DefaultForegroundColor.ToPlatformEFL() : foregroundColor.ToPlatformEFL();
- }
-
-
- protected virtual void OnPagePropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == Page.TitleProperty.PropertyName)
- {
- _navBar.Title = (sender as Page)?.Title;
- }
- else if (e.PropertyName == Shell.SearchHandlerProperty.PropertyName)
- {
- _navBar.SearchHandler = Shell.GetSearchHandler(sender as Page);
- }
- else if (e.PropertyName == Shell.NavBarIsVisibleProperty.PropertyName)
- {
- NavBarIsVisible = Shell.GetNavBarIsVisible(sender as Page);
- }
- else if (e.PropertyName == Shell.TitleViewProperty.PropertyName)
- {
- _navBar.TitleView = Shell.GetTitleView(sender as Page);
- }
- }
-
- void OnNavigationRequested(object sender, Internals.NavigationRequestedEventArgs e)
- {
- if (e.RequestType == Internals.NavigationRequestType.Push)
- {
- PushRequest(sender, e);
- }
- else if (e.RequestType == Internals.NavigationRequestType.Insert)
- {
- InsertRequest(sender, e);
- }
- else if (e.RequestType == Internals.NavigationRequestType.Pop)
- {
- PopRequest(sender, e);
- }
- else if (e.RequestType == Internals.NavigationRequestType.PopToRoot)
- {
- PopToRootRequest(sender, e);
- }
- else if (e.RequestType == Internals.NavigationRequestType.Remove)
- {
- RemoveRequest(sender, e);
- }
- UpdateHasBackButton();
- }
-
- void RemoveRequest(object sender, Internals.NavigationRequestedEventArgs request)
- {
- var renderer = Platform.GetRenderer(request.Page);
- if (renderer == null)
- {
- request.Task = Task.FromException(new ArgumentException("Can't found page on stack", nameof(request.Page)));
- return;
- }
- _viewStack.Remove(renderer.NativeView);
- request.Task = Task.FromResult(true);
- }
-
- void PopRequest(object sender, Internals.NavigationRequestedEventArgs request)
- {
- _viewStack.Pop();
- request.Task = Task.FromResult(true);
- }
-
- void PopToRootRequest(object sender, Internals.NavigationRequestedEventArgs request)
- {
- _viewStack.PopToRoot();
- request.Task = Task.FromResult(true);
- }
-
- void PushRequest(object sender, Internals.NavigationRequestedEventArgs request)
- {
- var renderer = Platform.GetOrCreateRenderer(request.Page);
- _viewStack.Push(renderer.NativeView);
- request.Task = Task.FromResult(true);
- Application.Current.Dispatcher.Dispatch(() =>
- {
- (renderer.NativeView as Widget)?.SetFocus(true);
- });
- }
-
- void InsertRequest(object sender, Internals.NavigationRequestedEventArgs request)
- {
- var before = Platform.GetRenderer(request.BeforePage)?.NativeView ?? null;
- if (before == null)
- {
- request.Task = Task.FromException(new ArgumentException("Can't found page on stack", nameof(request.BeforePage)));
- return;
- }
- var renderer = Platform.GetOrCreateRenderer(request.Page);
- _viewStack.Insert(before, renderer.NativeView);
- request.Task = Task.FromResult(true);
- }
-
- void UpdateHasBackButton()
- {
- if (_viewStack.Stack.Count > 1)
- _navBar.HasBackButton = true;
- else
- _navBar.HasBackButton = false;
- }
-
- void OnLayout()
- {
- if (Geometry.Width == 0 || Geometry.Height == 0)
- return;
-
- var bound = Geometry;
- int navBarHeight;
- if (NavBarIsVisible)
- {
- var navBound = bound;
- navBarHeight = Forms.ConvertToScaledPixel(_navBar.GetDefaultHeight());
- navBound.Height = navBarHeight;
-
- _navBar.Show();
- _navBar.Geometry = navBound;
- _navBar.RaiseTop();
- }
- else
- {
- navBarHeight = 0;
- _navBar.Hide();
- }
-
- bound.Y += navBarHeight;
- bound.Height -= navBarHeight;
- _viewStack.Geometry = bound;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/ShellTabs.cs b/src/Compatibility/Core/src/Tizen/Shell/ShellTabs.cs
deleted file mode 100644
index 7626804c9b5d..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/ShellTabs.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using ElmSharp;
-using EToolbar = ElmSharp.Toolbar;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public class ShellTabs : EToolbar, IShellTabs
- {
-
- ShellTabsType _type;
- public ShellTabs(EvasObject parent) : base(parent)
- {
- Style = ThemeConstants.Toolbar.Styles.Material;
- SelectionMode = ToolbarSelectionMode.Always;
- }
-
- public ShellTabsType Scrollable
- {
- get => _type;
- set
- {
- switch (value)
- {
- case ShellTabsType.Fixed:
- this.ShrinkMode = ToolbarShrinkMode.Expand;
- break;
- case ShellTabsType.Scrollable:
- this.ShrinkMode = ToolbarShrinkMode.Scroll;
- break;
- }
- _type = value;
- }
- }
-
- public EvasObject NativeView
- {
- get
- {
- return this;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/SimpleViewStack.cs b/src/Compatibility/Core/src/Tizen/Shell/SimpleViewStack.cs
deleted file mode 100644
index 1245231cb15b..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/SimpleViewStack.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public class SimpleViewStack : EBox
- {
- EvasObject _lastTop;
-
- public SimpleViewStack(EvasObject parent) : base(parent)
- {
- InternalStack = new List();
- SetLayoutCallback(OnLayout);
- }
-
- List InternalStack { get; set; }
-
- public IReadOnlyList Stack => InternalStack;
-
- public void Push(EvasObject view)
- {
- InternalStack.Add(view);
- PackEnd(view);
- UpdateTopView();
- }
-
- public void Pop()
- {
- if (_lastTop != null)
- {
- var tobeRemoved = _lastTop;
- InternalStack.Remove(tobeRemoved);
- UnPack(tobeRemoved);
- UpdateTopView();
- // if Pop was called by removed page,
- // Unrealize cause deletation of NativeCallback, it could be a cause of crash
- Application.Current.Dispatcher.Dispatch(() =>
- {
- tobeRemoved.Unrealize();
- });
- }
- }
-
- public void PopToRoot()
- {
- while (InternalStack.Count > 1)
- {
- Pop();
- }
- }
-
- public void Insert(EvasObject before, EvasObject view)
- {
- view.Hide();
- var idx = InternalStack.IndexOf(before);
- InternalStack.Insert(idx, view);
- PackEnd(view);
- UpdateTopView();
- }
-
- public void Remove(EvasObject view)
- {
- InternalStack.Remove(view);
- UnPack(view);
- UpdateTopView();
- Application.Current.Dispatcher.Dispatch(() =>
- {
- view?.Unrealize();
- });
- }
-
- void UpdateTopView()
- {
- if (_lastTop != InternalStack.LastOrDefault())
- {
- _lastTop?.Hide();
- _lastTop = InternalStack.LastOrDefault();
- _lastTop.Show();
- (_lastTop as Widget)?.SetFocus(true);
- }
- }
-
- void OnLayout()
- {
- foreach (var view in Stack)
- {
- view.Geometry = Geometry;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/TV/FlyoutItemTemplateAdaptor.cs b/src/Compatibility/Core/src/Tizen/Shell/TV/FlyoutItemTemplateAdaptor.cs
deleted file mode 100644
index a6f7cc5c1484..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/TV/FlyoutItemTemplateAdaptor.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System.Collections;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.TV
-{
- [System.Obsolete]
- public class FlyoutItemTemplateAdaptor : ItemTemplateAdaptor
- {
- public FlyoutItemTemplateAdaptor(Element itemsView, IEnumerable items, DataTemplate template, bool hasHeader)
- : base(itemsView, items, template)
- {
- HasHeader = hasHeader;
- }
-
- public bool HasHeader { get; set; }
-
- protected override bool IsSelectable => true;
-
- protected override View CreateHeaderView()
- {
- if (!HasHeader)
- return null;
-
- View header = null;
- if (Element is IShellController shell)
- {
- header = shell.FlyoutHeader;
- }
- return header;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/TV/FlyoutItemTemplateSelector.cs b/src/Compatibility/Core/src/Tizen/Shell/TV/FlyoutItemTemplateSelector.cs
deleted file mode 100644
index ede79b5c20d0..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/TV/FlyoutItemTemplateSelector.cs
+++ /dev/null
@@ -1,165 +0,0 @@
-using System;
-using System.Globalization;
-using Microsoft.Maui.Graphics;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.TV
-{
- public class FlyoutItemTemplateSelector : DataTemplateSelector
- {
- public DataTemplate DefaultTemplate { get; private set; }
- public DataTemplate FlyoutItemTemplate { get; private set; }
- public DataTemplate MenuItemTemplate { get; private set; }
-
- public FlyoutItemTemplateSelector(INavigationView nv)
- {
- DefaultTemplate = new DataTemplate(() =>
- {
- var grid = new Grid
- {
- HeightRequest = nv.GetFlyoutItemHeight(),
- WidthRequest = nv.GetFlyoutItemWidth()
- };
-
- ColumnDefinitionCollection columnDefinitions = new ColumnDefinitionCollection();
- columnDefinitions.Add(new ColumnDefinition { Width = nv.GetFlyoutIconColumnSize() });
- columnDefinitions.Add(new ColumnDefinition { Width = GridLength.Star });
- grid.ColumnDefinitions = columnDefinitions;
-
- var image = new Image
- {
- VerticalOptions = LayoutOptions.Center,
- HorizontalOptions = LayoutOptions.Center,
- HeightRequest = nv.GetFlyoutIconSize(),
- WidthRequest = nv.GetFlyoutIconSize(),
- Margin = new Thickness(nv.GetFlyoutMargin(), 0, 0, 0),
- };
- image.SetBinding(Image.SourceProperty, new Binding("FlyoutIcon"));
- grid.Children.Add(image);
-
- var label = new Label
- {
- FontSize = nv.GetFlyoutItemFontSize(),
- VerticalTextAlignment = TextAlignment.Center,
- Margin = new Thickness(nv.GetFlyoutMargin(), 0, 0, 0),
- };
- label.SetBinding(Label.TextProperty, new Binding("Title"));
- label.SetBinding(Label.TextColorProperty, new Binding("BackgroundColor", converter: new TextColorConverter(), source: grid));
-
- grid.Children.Add(label, 1, 0);
-
- var groups = new VisualStateGroupList();
-
- var commonGroup = new VisualStateGroup();
- commonGroup.Name = "CommonStates";
- groups.Add(commonGroup);
-
- var normalState = new VisualState();
- normalState.Name = "Normal";
- normalState.Setters.Add(new Setter
- {
- Property = VisualElement.BackgroundColorProperty,
- Value = nv.GetTvFlyoutItemDefaultColor()
- });
-
- var focusedState = new VisualState();
- focusedState.Name = "Focused";
- focusedState.Setters.Add(new Setter
- {
- Property = VisualElement.BackgroundColorProperty,
- Value = nv.GetTvFlyoutItemFocusedColor()
- });
-
- var selectedState = new VisualState();
- selectedState.Name = "Selected";
- selectedState.Setters.Add(new Setter
- {
- Property = VisualElement.BackgroundColorProperty,
- Value = nv.GetTvFlyoutItemDefaultColor()
- });
-
- commonGroup.States.Add(normalState);
- commonGroup.States.Add(focusedState);
- commonGroup.States.Add(selectedState);
-
- VisualStateManager.SetVisualStateGroups(grid, groups);
- return grid;
- });
- }
-
- public FlyoutItemTemplateSelector(INavigationView nv, DataTemplate flyoutItemTemplate, DataTemplate menuItemTemplate) : this(nv)
- {
- FlyoutItemTemplate = flyoutItemTemplate;
- MenuItemTemplate = menuItemTemplate;
- }
-
- protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
- {
- var bo = item as BindableObject;
- if (bo == null)
- return DefaultTemplate;
-
- if (item is IMenuItemController)
- {
- if (item is MenuItem mi && mi.Parent != null && mi.Parent.IsSet(Shell.MenuItemTemplateProperty))
- {
- return Shell.GetMenuItemTemplate(mi.Parent);
- }
- else if (bo.IsSet(Shell.MenuItemTemplateProperty))
- {
- return Shell.GetMenuItemTemplate(bo);
- }
-
- if (MenuItemTemplate != null)
- {
- return MenuItemTemplate;
- }
- else
- {
- return DefaultTemplate;
- }
- }
- else
- {
- if (Shell.GetItemTemplate(bo) != null)
- {
- return Shell.GetItemTemplate(bo);
- }
-
- if (FlyoutItemTemplate != null)
- {
- return FlyoutItemTemplate;
- }
- else
- {
- return DefaultTemplate;
- }
- }
- }
- class TextColorConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is Color c && c == KnownColor.Transparent)
- {
- return Color.FromRgb(255, 255, 255);
- }
- else
- {
- return Color.FromRgb(0, 0, 0);
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is Color c && c.Equals(Color.FromRgb(255, 255, 255)))
- {
- return KnownColor.Transparent;
- }
- else
- {
- return Color.FromRgb(0, 0, 0);
- }
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/TV/TVNavigationDrawer.cs b/src/Compatibility/Core/src/Tizen/Shell/TV/TVNavigationDrawer.cs
deleted file mode 100644
index 68bc76c832a7..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/TV/TVNavigationDrawer.cs
+++ /dev/null
@@ -1,274 +0,0 @@
-using System;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-using EButton = ElmSharp.Button;
-using EColor = ElmSharp.Color;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.TV
-{
- [Obsolete]
- public class TVNavigationDrawer : EBox, INavigationDrawer, IAnimatable, IFlyoutBehaviorObserver
- {
- EBox _drawerBox;
- EBox _mainBox;
- EvasObject _main;
- TVNavigationView _drawer;
- EButton _focusControlArea;
-
- FlyoutBehavior _behavior;
- bool _isOpen;
-
- double _openRatio;
-
- public TVNavigationDrawer(EvasObject parent) : base(parent)
- {
- Initialize(parent);
- }
-
- public event EventHandler Toggled;
-
- public EvasObject TargetView => this;
-
- public EvasObject NavigationView
- {
- get => _drawer;
- set => UpdateNavigationView(value);
- }
-
- public EvasObject Main
- {
- get => _main;
- set => UpdateMain(value);
- }
-
- public bool IsOpen
- {
- get => _isOpen;
- set => UpdateOpenState(value);
- }
-
- void Initialize(EvasObject parent)
- {
- SetLayoutCallback(OnLayout);
-
- _drawerBox = new EBox(parent);
- _drawerBox.Show();
- PackEnd(_drawerBox);
-
- _mainBox = new EBox(parent);
- _mainBox.SetLayoutCallback(OnMainBoxLayout);
- _mainBox.Show();
- PackEnd(_mainBox);
-
- _focusControlArea = new EButton(parent);
- _focusControlArea.Color = EColor.Transparent;
- _focusControlArea.BackgroundColor = EColor.Transparent;
- _focusControlArea.SetEffectColor(EColor.Transparent);
- _focusControlArea.Show();
- _mainBox.PackEnd(_focusControlArea);
-
- _drawerBox.KeyUp += (s, e) =>
- {
- if (e.KeyName == "Return" || e.KeyName == "Right")
- {
- IsOpen = false;
- }
- };
-
- _mainBox.KeyUp += (s, e) =>
- {
- if (e.KeyName == "Left")
- {
- if (_focusControlArea.IsFocused)
- IsOpen = true;
- }
- else
- {
- // Workaround to prevent unexpected movement of the focus to drawer during page pushing.
- if (_behavior == FlyoutBehavior.Locked)
- _drawerBox.AllowTreeFocus = true;
- }
- };
-
- _mainBox.KeyDown += (s, e) =>
- {
- if (e.KeyName != "Left")
- {
- // Workaround to prevent unexpected movement of the focus to drawer during page pushing.
- if (_behavior == FlyoutBehavior.Locked)
- _drawerBox.AllowTreeFocus = false;
- }
- };
-
- UpdateFocusPolicy();
- }
-
- void UpdateNavigationView(EvasObject navigationView)
- {
- if (_drawer != null)
- {
- _drawer.ContentFocused -= OnNavigationViewItemFocused;
- _drawer.ContentUnfocused -= OnNavigationViewItemUnfocused;
- _drawerBox.UnPack(_drawer);
- _drawer.Hide();
- }
-
- _drawer = navigationView as TVNavigationView;
-
- if (_drawer != null)
- {
- _drawer.SetAlignment(-1, -1);
- _drawer.SetWeight(1, 1);
- _drawer.Show();
- _drawerBox.PackEnd(_drawer);
-
- _drawer.ContentFocused += OnNavigationViewItemFocused;
- _drawer.ContentUnfocused += OnNavigationViewItemUnfocused;
- }
- }
-
- void OnNavigationViewItemFocused(object sender, EventArgs args)
- {
- IsOpen = true;
- }
-
- void OnNavigationViewItemUnfocused(object sender, EventArgs args)
- {
- IsOpen = false;
- }
-
- void UpdateMain(EvasObject main)
- {
- if (_main != null)
- {
- _mainBox.UnPack(_main);
- _main.Hide();
- }
- _main = main;
-
- if (_main != null)
- {
- _main.SetAlignment(-1, -1);
- _main.SetWeight(1, 1);
- _main.Show();
- _mainBox.PackStart(_main);
- }
- }
-
- void UpdateBehavior(FlyoutBehavior behavior)
- {
- _behavior = behavior;
- _focusControlArea.IsEnabled = _behavior == FlyoutBehavior.Flyout;
-
- var open = false;
-
- if (_behavior == FlyoutBehavior.Locked)
- open = true;
- else if (_behavior == FlyoutBehavior.Disabled)
- open = false;
- else
- open = _drawerBox.IsFocused;
-
- UpdateOpenState(open);
- }
-
- void OnMainBoxLayout()
- {
- if (_main != null)
- {
- _main.Geometry = _mainBox.Geometry;
- }
-
- var focusedButtonGeometry = _mainBox.Geometry;
- focusedButtonGeometry.X = focusedButtonGeometry.X - 100;
- focusedButtonGeometry.Width = 0;
- _focusControlArea.Geometry = focusedButtonGeometry;
- }
-
- void OnLayout()
- {
- if (Geometry.Width == 0 || Geometry.Height == 0)
- return;
-
- var bound = Geometry;
-
- var ratio = this.GetFlyoutRatio(Geometry.Width, Geometry.Height);
- var collapseRatio = (_behavior == FlyoutBehavior.Disabled) ? 0 : this.GetFlyoutCollapseRatio();
- var drawerWidthMax = (int)(bound.Width * ratio);
- var drawerWidthMin = (int)(bound.Width * collapseRatio);
-
- var drawerWidthOutBound = (int)((drawerWidthMax - drawerWidthMin) * (1 - _openRatio));
- var drawerWidthInBound = drawerWidthMax - drawerWidthOutBound;
-
- var drawerGeometry = bound;
- drawerGeometry.Width = drawerWidthInBound;
- _drawerBox.Geometry = drawerGeometry;
-
- var containerGeometry = bound;
- containerGeometry.X = drawerWidthInBound;
- containerGeometry.Width = (_behavior == FlyoutBehavior.Locked) ? (bound.Width - drawerWidthInBound) : (bound.Width - drawerWidthMin);
- _mainBox.Geometry = containerGeometry;
- }
-
- void UpdateOpenState(bool isOpen)
- {
- if (_behavior == FlyoutBehavior.Locked && !isOpen)
- return;
-
- double endState = ((_behavior != FlyoutBehavior.Disabled) && isOpen) ? 1 : 0;
- new Animation((r) =>
- {
- _openRatio = r;
- OnLayout();
- }, _openRatio, endState, Easing.SinOut).Commit(this, "DrawerMove", finished: (f, aborted) =>
- {
- if (!aborted)
- {
- if (_isOpen != isOpen)
- {
- _isOpen = isOpen;
- UpdateFocusPolicy();
- Toggled?.Invoke(this, EventArgs.Empty);
- }
- }
- });
- }
-
- void UpdateFocusPolicy()
- {
- if (_isOpen)
- {
- if (_behavior == FlyoutBehavior.Locked)
- {
- _drawerBox.AllowTreeFocus = true;
- _mainBox.AllowTreeFocus = true;
- }
- else
- {
- _mainBox.AllowTreeFocus = false;
- _drawerBox.AllowTreeFocus = true;
- _drawerBox.SetFocus(true);
- }
- }
- else
- {
- _mainBox.AllowTreeFocus = true;
- _drawerBox.AllowTreeFocus = false;
- _mainBox.SetFocus(true);
- }
- }
-
- void IFlyoutBehaviorObserver.OnFlyoutBehaviorChanged(FlyoutBehavior behavior)
- {
- UpdateBehavior(behavior);
- }
-
- void IAnimatable.BatchBegin()
- {
- }
-
- void IAnimatable.BatchCommit()
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Shell/TV/TVNavigationView.cs b/src/Compatibility/Core/src/Tizen/Shell/TV/TVNavigationView.cs
deleted file mode 100644
index 80cdd7bd070a..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/TV/TVNavigationView.cs
+++ /dev/null
@@ -1,380 +0,0 @@
-using System;
-using System.Collections.Generic;
-using ElmSharp;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.TV;
-using EBox = ElmSharp.Box;
-using EColor = ElmSharp.Color;
-using EImage = ElmSharp.Image;
-using NCollectionView = Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.CollectionView;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class TVNavigationView : Background, INavigationView
- {
- static EColor s_defaultBackgroundColor = EColor.Black;
-
- EBox _mainLayout;
-
- EImage _backgroundImage;
- Aspect _bgImageAspect;
- ImageSource _bgImageSource;
-
- View _header;
- EvasObject _nativeHeader;
-
- NCollectionView _list;
-
- EColor _backgroundColor;
-
- List> _cachedGroups;
-
- IEnumerable _cacheditems;
-
- public TVNavigationView(EvasObject parent) : base(parent)
- {
- InitializeComponent(parent);
- }
-
- public TVNavigationView(EvasObject parent, Element element) : this(parent)
- {
- Element = element;
- }
-
- public event EventHandler SelectedItemChanged;
-
- public event EventHandler ContentFocused;
-
- public event EventHandler ContentUnfocused;
-
- public EvasObject NativeView => this;
-
- public Element Element { get; }
-
- FlyoutHeaderBehavior _headerBehavior = FlyoutHeaderBehavior.Fixed;
-
- public View Header
- {
- get
- {
- return _header;
- }
- set
- {
- UpdateHeader(value);
- }
- }
-
- public FlyoutHeaderBehavior HeaderBehavior
- {
- get => _headerBehavior;
- set
- {
- if (_headerBehavior == value)
- return;
- _headerBehavior = value;
- UpdateHeaderBehavior();
- }
- }
-
- public override EColor BackgroundColor
- {
- get
- {
- return _backgroundColor;
- }
- set
- {
- _backgroundColor = value;
- EColor effectiveColor = _backgroundColor.IsDefault ? s_defaultBackgroundColor : _backgroundColor;
- base.BackgroundColor = effectiveColor;
- }
- }
-
- public Aspect BackgroundImageAspect
- {
- get
- {
- return _bgImageAspect;
- }
- set
- {
- _bgImageAspect = value;
- _backgroundImage?.ApplyAspect(_bgImageAspect);
- }
- }
-
- public ImageSource BackgroundImageSource
- {
- get
- {
- return _bgImageSource;
- }
- set
- {
- _bgImageSource = value;
- UpdateBackgroundImage();
- }
- }
-
- bool HeaderOnMenu => _headerBehavior == FlyoutHeaderBehavior.Scroll ||
- _headerBehavior == FlyoutHeaderBehavior.CollapseOnScroll;
-
- public void BuildMenu(List> flyoutGroups)
- {
- if (!IsMenuItemChanged(flyoutGroups))
- {
- return;
- }
- _cachedGroups = flyoutGroups;
-
- var items = new List();
- foreach (var group in flyoutGroups)
- {
- foreach (var element in group)
- {
- items.Add(element);
- }
- }
-
- BuildMenu(items);
- }
-
- public void BuildMenu(IEnumerable items, DataTemplate itemTemplate = null)
- {
- var datatemplate = new FlyoutItemTemplateSelector(this, itemTemplate, null);
- if (Element is Shell shell)
- {
- datatemplate = new FlyoutItemTemplateSelector(this, shell.ItemTemplate, shell.MenuItemTemplate);
- }
-
- _cacheditems = items;
- _list.Adaptor = new FlyoutItemTemplateAdaptor(Element, items, datatemplate, HeaderOnMenu);
- _list.Adaptor.ItemSelected += OnItemSelected;
- }
-
- public int GetDrawerWidth()
- {
- if (_list is ICollectionViewController controller)
- return controller.GetItemSize(Forms.NativeParent.Geometry.Width / 2, Forms.NativeParent.Geometry.Height).Width;
- else
- return 0;
- }
-
- void OnItemSelected(object sender, SelectedItemChangedEventArgs e)
- {
- SelectedItemChanged?.Invoke(this, new SelectedItemChangedEventArgs(e.SelectedItem, -1));
- }
-
- void InitializeComponent(EvasObject parent)
- {
- base.BackgroundColor = s_defaultBackgroundColor;
-
- _mainLayout = new EBox(parent)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
- };
- _mainLayout.SetLayoutCallback(OnLayout);
- _mainLayout.Show();
-
- SetContent(_mainLayout);
- CreateMenu();
- }
-
- void CreateMenu()
- {
- _list = new NCollectionView(Forms.NativeParent)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
- SelectionMode = Native.CollectionViewSelectionMode.Single,
- HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible,
- VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible,
- LayoutManager = new Native.LinearLayoutManager(false, ItemSizingStrategy.MeasureFirstItem)
- };
-
- _list.Show();
- _mainLayout.PackEnd(_list);
-
- _list.Focused += OnListFocused;
- _list.Unfocused += OnListUnfocused;
-
- }
-
- void OnListFocused(object sender, EventArgs args)
- {
- ContentFocused?.Invoke(this, EventArgs.Empty);
- }
-
- void OnListUnfocused(object sender, EventArgs args)
- {
- ContentUnfocused?.Invoke(this, EventArgs.Empty);
- }
-
- bool IsMenuItemChanged(List> flyoutGroups)
- {
- if (_cachedGroups == null)
- return true;
-
- if (_cachedGroups.Count != flyoutGroups.Count)
- return true;
-
- for (int i = 0; i < flyoutGroups.Count; i++)
- {
- if (_cachedGroups[i].Count != flyoutGroups[i].Count)
- return true;
-
- for (int j = 0; j < flyoutGroups[i].Count; j++)
- {
- if (_cachedGroups[i][j] != flyoutGroups[i][j])
- return true;
- }
- }
- return false;
- }
-
- void UpdateBackgroundImage()
- {
- if (BackgroundImageSource == null)
- {
- if (_backgroundImage != null)
- {
- this.SetBackgroundPart(null);
- _backgroundImage = null;
- }
- }
- else
- {
- if (_backgroundImage == null)
- {
- _backgroundImage = new EImage(this);
- this.SetBackgroundPart(_backgroundImage);
- }
- _backgroundImage.LoadFromImageSourceAsync(BackgroundImageSource).GetAwaiter().OnCompleted(() =>
- {
- _backgroundImage.ApplyAspect(_bgImageAspect);
- });
- }
- }
-
- void UpdateHeader(View header)
- {
- if (_header != null)
- {
- _header.MeasureInvalidated -= OnHeaderSizeChanged;
-
- if (HeaderOnMenu)
- {
- ResetHeader();
- }
-
- if (_nativeHeader != null)
- {
- _mainLayout.UnPack(_nativeHeader);
- _nativeHeader.Unrealize();
- _nativeHeader = null;
- }
- }
-
- if (header != null)
- {
- header.MeasureInvalidated += OnHeaderSizeChanged;
-
- if (HeaderOnMenu)
- {
- UpdateHeaderOnMenu();
- }
- else
- {
- var renderer = Platform.GetOrCreateRenderer(header);
- (renderer as ILayoutRenderer)?.RegisterOnLayoutUpdated();
- _nativeHeader = renderer.NativeView;
- _mainLayout.PackEnd(_nativeHeader);
- }
- }
-
- _header = header;
- }
-
- void UpdateHeaderBehavior()
- {
- if (_header == null)
- return;
-
- if (HeaderOnMenu)
- {
- if (_nativeHeader != null)
- {
- _mainLayout.UnPack(_nativeHeader);
- _nativeHeader.Unrealize();
- _nativeHeader = null;
- }
- }
- else
- {
- ResetHeader();
- if (_nativeHeader == null)
- {
- var renderer = Platform.GetOrCreateRenderer(_header);
- (renderer as LayoutRenderer)?.RegisterOnLayoutUpdated();
- _nativeHeader = renderer.NativeView;
- _mainLayout.PackEnd(_nativeHeader);
- }
- }
- UpdateHeaderOnMenu();
- OnLayout();
- }
-
- void UpdateHeaderOnMenu()
- {
- if (_list.Adaptor != null)
- _list.Adaptor.ItemSelected -= OnItemSelected;
-
- BuildMenu(_cacheditems);
- }
-
- void ResetHeader()
- {
- if (_header != null)
- {
- Platform.GetRenderer(_header)?.Dispose();
- _nativeHeader = null;
- }
- }
-
- void OnHeaderSizeChanged(object sender, EventArgs e)
- {
- Application.Current.Dispatcher.Dispatch(OnLayout);
- }
-
- void OnLayout()
- {
- if (Geometry.Width == 0 || Geometry.Height == 0)
- return;
-
- var bound = Geometry;
- int headerHeight = 0;
- if (Header != null)
- {
- if (!HeaderOnMenu)
- {
- var requestSize = Header.Measure(Forms.ConvertToScaledDP(bound.Width), Forms.ConvertToScaledDP(bound.Height));
- headerHeight = Forms.ConvertToScaledPixel(requestSize.Request.Height);
- var headerBound = Geometry;
- headerBound.Height = headerHeight;
- _nativeHeader.Geometry = headerBound;
- }
- }
- bound.Y += headerHeight;
- bound.Height -= headerHeight;
-
- _list.Geometry = bound;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellItemRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellItemRenderer.cs
deleted file mode 100644
index 2ab47af82984..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellItemRenderer.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.TV
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class TVShellItemRenderer : ShellItemRenderer
- {
- public TVShellItemRenderer(ShellItem item) : base(item)
- {
- }
-
- protected override ShellSectionStack CreateShellSectionStack(ShellSection section)
- {
- return new TVShellSectionStack(section);
- }
-
- protected override void UpdateTabsItems()
- {
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellRenderer.cs
deleted file mode 100644
index a94c5343d585..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellRenderer.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.TV
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class TVShellRenderer : ShellRenderer
- {
- protected override INavigationDrawer CreateNavigationDrawer()
- {
- var drawer = new TVNavigationDrawer(Forms.NativeParent);
- ((IShellController)Element).AddFlyoutBehaviorObserver(drawer);
- return drawer;
- }
-
- protected override ShellItemRenderer CreateShellItemRenderer(ShellItem item)
- {
- return new TVShellItemRenderer(item);
- }
-
- protected override INavigationView CreateNavigationView()
- {
- return new TVNavigationView(Forms.NativeParent, Element);
- }
-
- protected override void UpdateFlyoutIsPresented()
- {
- NavigationDrawer.IsOpen = Element.FlyoutIsPresented;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellSectionRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellSectionRenderer.cs
deleted file mode 100644
index ff1838fa4b47..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellSectionRenderer.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using ElmSharp;
-using EBox = ElmSharp.Box;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class TVShellSectionRenderer : IShellSectionRenderer, IDisposable
- {
- EBox _mainLayout = null;
- EBox _contentArea = null;
-
- EvasObject _currentContent = null;
- TVNavigationView _navigationView;
-
- Dictionary _contentCache = new Dictionary();
-
- bool _disposed = false;
- bool _drawerIsVisible => (ShellSection != null) ? (ShellSection.Items.Count > 1) : false;
-
- public TVShellSectionRenderer(ShellSection section)
- {
- ShellSection = section;
- ShellSection.PropertyChanged += OnSectionPropertyChanged;
- (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnShellSectionCollectionChanged;
-
- _mainLayout = new EBox(Forms.NativeParent);
- _mainLayout.SetLayoutCallback(OnLayout);
-
- _contentArea = new EBox(Forms.NativeParent);
- _contentArea.Show();
- _mainLayout.PackEnd(_contentArea);
-
- UpdateSectionItems();
- UpdateCurrentItem(ShellSection.CurrentItem);
- }
-
- public ShellSection ShellSection { get; }
-
- public EvasObject NativeView
- {
- get
- {
- return _mainLayout;
- }
- }
-
- ~TVShellSectionRenderer()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (_disposed)
- return;
-
- if (disposing)
- {
- if (ShellSection != null)
- {
- ShellSection.PropertyChanged -= OnSectionPropertyChanged;
- }
-
- NativeView.Unrealize();
- }
- _disposed = true;
- }
-
- void OnNavigationViewSelectedItemChanged(object sender, SelectedItemChangedEventArgs e)
- {
- if (e.SelectedItem == null)
- return;
-
- var content = e.SelectedItem;
- if (ShellSection.CurrentItem != content)
- {
- ShellSection.SetValueFromRenderer(ShellSection.CurrentItemProperty, content);
- }
- }
-
- void OnSectionPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == "CurrentItem")
- {
- UpdateCurrentItem(ShellSection.CurrentItem);
- }
- }
-
- void UpdateSectionItems()
- {
- if (!_drawerIsVisible)
- {
- return;
- }
-
- if (_navigationView == null)
- {
- _navigationView = new TVNavigationView(Forms.NativeParent, ShellSection);
- _navigationView.SetAlignment(-1, -1);
- _navigationView.SetWeight(1, 1);
- _navigationView.Show();
- _mainLayout.PackStart(_navigationView);
-
- _navigationView.SelectedItemChanged += OnNavigationViewSelectedItemChanged;
- }
-
- (_navigationView as TVNavigationView).BuildMenu(ShellSection.Items, Shell.GetItemTemplate(ShellSection));
- }
-
- void UpdateCurrentItem(ShellContent content)
- {
- if (_currentContent != null)
- {
- _currentContent.Hide();
- _contentArea.UnPack(_currentContent);
- _currentContent = null;
- }
-
- if (content == null)
- {
- return;
- }
-
- if (!_contentCache.ContainsKey(content))
- {
- var native = CreateShellContent(content);
- native.SetAlignment(-1, -1);
- native.SetWeight(1, 1);
- _contentCache[content] = native;
- }
- _currentContent = _contentCache[content];
- _currentContent.Show();
- _contentArea.PackEnd(_currentContent);
- }
-
- EvasObject CreateShellContent(ShellContent content)
- {
- Page xpage = ((IShellContentController)content).GetOrCreateContent();
- return Platform.GetOrCreateRenderer(xpage).NativeView;
- }
-
- void OnLayout()
- {
- if (NativeView.Geometry.Width == 0 || NativeView.Geometry.Height == 0)
- return;
-
- var bound = NativeView.Geometry;
- var drawerWidth = 0;
-
- if (_drawerIsVisible && _navigationView != null)
- {
- var drawerBound = bound;
- drawerWidth = _navigationView.GetDrawerWidth();
- drawerBound.Width = drawerWidth;
-
- _navigationView.Geometry = drawerBound;
- }
-
- var contentBound = bound;
-
- contentBound.X += drawerWidth;
- contentBound.Width -= drawerWidth;
- _contentArea.Geometry = contentBound;
- }
-
- void OnShellSectionCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- UpdateSectionItems();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellSectionStack.cs b/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellSectionStack.cs
deleted file mode 100644
index 784244db9137..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/TV/TVShellSectionStack.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.ComponentModel;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.TV
-{
- [System.Obsolete]
- public class TVShellSectionStack : ShellSectionStack
- {
-
- public TVShellSectionStack(ShellSection section) : base(section)
- {
- }
-
- public override bool NavBarIsVisible => false;
-
- protected override IShellSectionRenderer CreateShellSectionRenderer(ShellSection section)
- {
- return new TVShellSectionRenderer(section);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/IShellItemRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/IShellItemRenderer.cs
deleted file mode 100644
index 2feafa79c5e8..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/IShellItemRenderer.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- public interface IShellItemRenderer : IDisposable
- {
- BaseShellItem Item { get; }
- EvasObject NativeView { get; }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/NavigationDrawer.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/NavigationDrawer.cs
deleted file mode 100644
index 8e0ee7841278..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/NavigationDrawer.cs
+++ /dev/null
@@ -1,542 +0,0 @@
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-using ElmSharp;
-using ElmSharp.Wearable;
-using EButton = ElmSharp.Button;
-using EColor = ElmSharp.Color;
-using EImage = ElmSharp.Image;
-using ELayout = ElmSharp.Layout;
-using ERect = ElmSharp.Rect;
-using EWidget = ElmSharp.Widget;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- [Obsolete]
- public class NavigationDrawer : ELayout, IAnimatable
- {
- static readonly int TouchWidth = ThemeConstants.Shell.Resources.Watch.DefaultDrawerTouchWidth;
- static readonly int IconSize = ThemeConstants.Shell.Resources.Watch.DefaultDrawerIconSize;
- static readonly string DefaultIcon = ThemeConstants.Shell.Resources.Watch.DefaultDrawerIcon;
-
- Box _mainLayout;
- Box _contentGestureBox;
- Box _contentBox;
- Box _drawerBox;
- Box _drawerContentBox;
- Box _drawerIconBox;
-
- EvasObject _content;
- EvasObject _drawerContent;
-
- EImage _drawerIcon;
- EButton _touchArea;
-
- GestureLayer _gestureOnContent;
- GestureLayer _gestureOnDrawer;
-
- ImageSource _drawerIconSource;
-
- bool _isOpen;
- bool _isDefaultIcon;
-
- CancellationTokenSource _fadeInCancelTokenSource = null;
-
- bool HasDrawer => _drawerBox != null;
-
- public NavigationDrawer(EvasObject parent) : base(parent)
- {
- Initialize();
- }
-
- public int HandlerHeight { get; set; } = 40;
-
- public bool IsOpen
- {
- get
- {
- return _isOpen;
- }
- set
- {
- if (_isOpen != value)
- {
- if (value)
- {
- Open();
- }
- else
- {
- Close();
- }
- }
- }
- }
-
- EColor _handlerBackgroundColor = EColor.Transparent;
- public EColor HandlerBackgroundColor
- {
- get => _handlerBackgroundColor;
- set
- {
- _handlerBackgroundColor = value;
- UpdateHandlerBackgroundColor();
- }
- }
-
- public event EventHandler Toggled;
-
- public void SetMainContent(EvasObject content)
- {
- if (content == null)
- {
- UnsetMainContent();
- return;
- }
-
- _content = content;
- _content.Show();
- _contentBox.PackEnd(_content);
- _content.Geometry = _contentBox.Geometry;
- }
-
- public void SetDrawerContent(EvasObject content)
- {
- InitializeDrawerBox();
-
- if (content == null)
- {
- UnsetDrawerContent();
- return;
- }
-
- _drawerContent = content;
- _drawerContent.Show();
- _drawerContentBox.PackEnd(_drawerContent);
-
- _drawerContentBox.Show();
- _drawerIconBox.Show();
-
- if (_drawerContent is NavigationView nv)
- {
- nv.Dragged += (s, e) =>
- {
- if (e.State == DraggedState.EdgeTop)
- {
- Close();
- }
- };
- }
- }
-
- public void UpdateDrawerIcon(ImageSource source)
- {
- _drawerIconSource = source;
- if (HasDrawer)
- {
- SetDrawerIcon(_drawerIconSource);
- }
- }
-
- public async void Open(uint length = 300)
- {
- if (!HasDrawer)
- return;
-
- var toMove = _drawerBox.Geometry;
- toMove.Y = 0;
-
- await RunMoveAnimation(_drawerBox, toMove, length);
-
- if (!_isOpen)
- {
- _isOpen = true;
- Toggled?.Invoke(this, EventArgs.Empty);
- }
- OnLayout();
- OnDrawerLayout();
- FlipIcon();
- }
-
- public async void Close(uint length = 300)
- {
- if (!HasDrawer)
- return;
-
- var toMove = _drawerBox.Geometry;
- toMove.Y = Geometry.Height - HandlerHeight;
-
- await RunMoveAnimation(_drawerBox, toMove, length);
-
- if (_isOpen)
- {
- _isOpen = false;
- Toggled?.Invoke(this, EventArgs.Empty);
- }
- OnLayout();
- OnDrawerLayout();
- ResetIcon();
- StartHighlightAnimation(_drawerIcon);
- }
-
- void IAnimatable.BatchBegin()
- {
- }
-
- void IAnimatable.BatchCommit()
- {
- }
-
- protected override IntPtr CreateHandle(EvasObject parent)
- {
- _mainLayout = new Box(parent);
- return _mainLayout.Handle;
- }
-
- void Initialize()
- {
- _mainLayout.SetLayoutCallback(OnLayout);
-
- _contentGestureBox = new Box(_mainLayout);
- _contentGestureBox.Show();
- _mainLayout.PackEnd(_contentGestureBox);
-
- _contentBox = new Box(_mainLayout);
- _contentBox.SetLayoutCallback(OnContentLayout);
- _contentBox.Show();
- _mainLayout.PackEnd(_contentBox);
- }
-
- void InitializeDrawerBox()
- {
- if (_drawerBox != null)
- return;
-
- _drawerBox = new Box(_mainLayout);
- _drawerBox.SetLayoutCallback(OnDrawerLayout);
- _drawerBox.Show();
- _mainLayout.PackEnd(_drawerBox);
-
- _drawerContentBox = new Box(_drawerBox);
- _drawerBox.PackEnd(_drawerContentBox);
-
- _drawerIconBox = new Box(_drawerBox)
- {
- BackgroundColor = _handlerBackgroundColor
- };
- _drawerBox.PackEnd(_drawerIconBox);
-
- _drawerIcon = new EImage(_drawerIconBox)
- {
- AlignmentY = 0.5,
- AlignmentX = 0.5,
- MinimumHeight = IconSize,
- MinimumWidth = IconSize,
- };
- _drawerIcon.Show();
- _drawerIconBox.PackEnd(_drawerIcon);
- SetDrawerIcon(_drawerIconSource);
-
- _touchArea = new EButton(_drawerBox)
- {
- Color = EColor.Transparent,
- BackgroundColor = EColor.Transparent,
- };
- _touchArea.SetEffectColor(EColor.Transparent);
- _touchArea.Show();
- _touchArea.RepeatEvents = true;
- _touchArea.Clicked += OnIconClicked;
-
- _drawerBox.PackEnd(_touchArea);
-
- _gestureOnContent = new GestureLayer(_contentGestureBox);
- _gestureOnContent.SetMomentumCallback(GestureLayer.GestureState.Start, OnContentDragStarted);
- _gestureOnContent.SetMomentumCallback(GestureLayer.GestureState.End, OnContentDragEnded);
- _gestureOnContent.SetMomentumCallback(GestureLayer.GestureState.Abort, OnContentDragEnded);
- _gestureOnContent.Attach(_contentGestureBox);
- _contentBox.RepeatEvents = true;
-
- _gestureOnDrawer = new GestureLayer(_drawerIconBox);
- _gestureOnDrawer.SetMomentumCallback(GestureLayer.GestureState.Move, OnDrawerDragged);
- _gestureOnDrawer.SetMomentumCallback(GestureLayer.GestureState.End, OnDrawerDragEnded);
- _gestureOnDrawer.SetMomentumCallback(GestureLayer.GestureState.Abort, OnDrawerDragEnded);
- _gestureOnDrawer.Attach(_drawerIconBox);
-
- RotaryEventManager.Rotated += OnRotateEventReceived;
- }
-
- void SetDrawerIcon(ImageSource source)
- {
- if (source == null)
- {
- _ = _drawerIcon.LoadFromImageSourceAsync(ImageSource.FromResource(DefaultIcon, GetType().Assembly));
- _isDefaultIcon = true;
- }
- else
- {
- _isDefaultIcon = false;
- if (source is FileImageSource fsource)
- {
- _drawerIcon.Load(fsource.ToAbsPath());
- }
- else
- {
- _ = _drawerIcon.LoadFromImageSourceAsync(source);
- }
- }
- }
-
- void UpdateHandlerBackgroundColor()
- {
- if (_drawerIconBox != null)
- {
- _drawerIconBox.BackgroundColor = _handlerBackgroundColor;
- }
- }
-
- void OnIconClicked(object sender, EventArgs e)
- {
- if (IsOpen)
- Close();
- else
- Open();
- }
-
- async Task ShowAsync(EWidget target, Easing easing = null, uint length = 300, CancellationToken cancelltaionToken = default(CancellationToken))
- {
- var tcs = new TaskCompletionSource();
-
- await Task.Delay(1000);
-
- if (cancelltaionToken.IsCancellationRequested)
- {
- cancelltaionToken.ThrowIfCancellationRequested();
- }
-
- target.Show();
- var opacity = target.Opacity;
-
- if (opacity == 255 || opacity == -1)
- return true;
-
- new Animation((progress) =>
- {
- target.Opacity = opacity + (int)((255 - opacity) * progress);
-
- }).Commit(this, "FadeIn", length: length, finished: (p, e) =>
- {
- target.Opacity = 255;
- tcs.SetResult(true);
- StartHighlightAnimation(_drawerIcon);
- });
-
- return await tcs.Task;
- }
-
- void OnLayout()
- {
- var bound = Geometry;
- _contentGestureBox.Geometry = bound;
- _contentBox.Geometry = bound;
- if (_drawerBox != null)
- {
- bound.Y = _isOpen ? 0 : (bound.Height - HandlerHeight);
- _drawerBox.Geometry = bound;
- }
- }
-
- void OnContentLayout()
- {
- if (_content != null)
- {
- _content.Geometry = _contentBox.Geometry;
- }
- }
-
- void OnDrawerLayout()
- {
- this.AbortAnimation("HighlightAnimation");
-
- var bound = _drawerBox.Geometry;
-
- var currentY = bound.Y;
- var ratio = currentY / (double)(Geometry.Height - HandlerHeight);
-
- var contentBound = bound;
- contentBound.Y += (int)(HandlerHeight * ratio);
- _drawerContentBox.Geometry = contentBound;
-
- var drawerHandleBound = bound;
- drawerHandleBound.Height = HandlerHeight;
- _drawerIconBox.Geometry = drawerHandleBound;
-
- var drawerTouchBound = drawerHandleBound;
- drawerTouchBound.Width = TouchWidth;
- drawerTouchBound.X = drawerHandleBound.X + (drawerHandleBound.Width - TouchWidth) / 2;
- _touchArea.Geometry = drawerTouchBound;
- }
-
- async Task HideAsync(EWidget target, Easing easing = null, uint length = 300)
- {
- var tcs = new TaskCompletionSource();
-
- var opacity = target.Opacity;
- if (opacity == -1)
- opacity = 255;
-
- new Animation((progress) =>
- {
- target.Opacity = opacity - (int)(progress * opacity);
-
- }).Commit(this, "FadeOut", length: length, finished: (p, e) =>
- {
- target.Opacity = 0;
- target.Hide();
- tcs.SetResult(true);
- });
-
- return await tcs.Task;
- }
-
- void StartHighlightAnimation(EWidget target)
- {
- if (!_isDefaultIcon || this.AnimationIsRunning("HighlightAnimation"))
- return;
-
- int count = 2;
- var bound = target.Geometry;
- var y = bound.Y;
- var dy = bound.Y - bound.Height / 3;
-
- var anim = new Animation();
-
- var transfAnim = new Animation((f) =>
- {
- bound.Y = (int)f;
- var map = new EvasMap(4);
- map.PopulatePoints(bound, 0);
- target.IsMapEnabled = true;
- target.EvasMap = map;
- }, y, dy);
-
- var opacityAnim = new Animation(f => target.Opacity = (int)f, 255, 40);
-
- anim.Add(0, 1, opacityAnim);
- anim.Add(0, 1, transfAnim);
-
- anim.Commit(this, "HighlightAnimation", 16, 800, finished: (f, b) =>
- {
- target.Opacity = 255;
- target.IsMapEnabled = false;
- }, repeat: () => --count > 0);
- }
-
- async void OnRotateEventReceived(EventArgs args)
- {
- _fadeInCancelTokenSource?.Cancel();
- _fadeInCancelTokenSource = new CancellationTokenSource();
-
- if (!_isOpen)
- {
- var token = _fadeInCancelTokenSource.Token;
- await HideAsync(_drawerBox);
- _ = ShowAsync(_drawerBox, cancelltaionToken: token);
- }
- }
-
- void OnContentDragStarted(GestureLayer.MomentumData moment)
- {
- _fadeInCancelTokenSource?.Cancel();
- _fadeInCancelTokenSource = null;
-
- if (!_isOpen)
- {
- _ = HideAsync(_drawerBox);
- }
- }
-
- void OnContentDragEnded(GestureLayer.MomentumData moment)
- {
- _fadeInCancelTokenSource = new CancellationTokenSource();
- _ = ShowAsync(_drawerBox, cancelltaionToken: _fadeInCancelTokenSource.Token);
- }
-
- void OnDrawerDragged(GestureLayer.MomentumData moment)
- {
- var toMove = _drawerBox.Geometry;
- toMove.Y = (moment.Y2 < 0) ? 0 : moment.Y2;
- _drawerBox.Geometry = toMove;
- OnDrawerLayout();
- }
-
- void OnDrawerDragEnded(GestureLayer.MomentumData moment)
- {
- if (_drawerBox.Geometry.Y < (_mainLayout.Geometry.Height / 2))
- {
- Open();
- }
- else
- {
- Close();
- }
- }
-
- void FlipIcon()
- {
- if (_isDefaultIcon)
- {
- _drawerIcon.Orientation = ImageOrientation.FlipVertical;
- }
- }
-
- void ResetIcon()
- {
- _drawerIcon.Orientation = ImageOrientation.None;
- }
-
- Task RunMoveAnimation(EvasObject target, ERect dest, uint length, Easing easing = null)
- {
- var tcs = new TaskCompletionSource();
-
- var dx = target.Geometry.X - dest.X;
- var dy = target.Geometry.Y - dest.Y;
-
- new Animation((progress) =>
- {
- var toMove = dest;
- toMove.X += (int)(dx * (1 - progress));
- toMove.Y += (int)(dy * (1 - progress));
- target.Geometry = toMove;
- OnDrawerLayout();
- }).Commit(this, "Move", length: length, finished: (s, e) =>
- {
- target.Geometry = dest;
- tcs.SetResult(true);
- });
- return tcs.Task;
- }
-
- void UnsetMainContent()
- {
- if (_content != null)
- {
- _contentBox.UnPack(_content);
- _content.Hide();
- _content = null;
- }
- }
-
- void UnsetDrawerContent()
- {
- if (_drawerContent != null)
- {
- _drawerContentBox.UnPack(_drawerContent);
- _drawerContent.Hide();
- _drawerContent = null;
-
- _drawerContentBox.Hide();
- _drawerIconBox.Hide();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/NavigationView.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/NavigationView.cs
deleted file mode 100644
index efba6fe375b5..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/NavigationView.cs
+++ /dev/null
@@ -1,359 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using ElmSharp;
-using ElmSharp.Wearable;
-using EColor = ElmSharp.Color;
-using ELayout = ElmSharp.Layout;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- [Obsolete]
- public class NavigationView : ELayout
- {
- readonly int _defaultIconSize = ThemeConstants.Shell.Resources.Watch.DefaultNavigationViewIconSize;
-
- class Item : INotifyPropertyChanged
- {
- Element _source;
- public Element Source
- {
- get
- {
- return _source;
- }
- set
- {
- if (_source != null)
- {
- _source.PropertyChanged -= OnElementPropertyChanged;
- }
- _source = value;
- _source.PropertyChanged += OnElementPropertyChanged;
- UpdateContent();
- }
- }
-
- public string Text { get; set; }
- public string Icon { get; set; }
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- void UpdateContent()
- {
- if (Source is BaseShellItem shellItem)
- {
- Text = shellItem.Title;
- Icon = (shellItem.Icon as FileImageSource)?.ToAbsPath();
- }
- else if (Source is MenuItem menuItem)
- {
- Text = menuItem.Text;
- Icon = (menuItem.IconImageSource as FileImageSource)?.ToAbsPath();
- }
- else
- {
- Text = null;
- Icon = null;
- }
- SendPropertyChanged();
- }
-
- void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- UpdateContent();
- }
-
- void SendPropertyChanged([CallerMemberName] string propertyName = "")
- {
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
- }
- }
-
- Box _outterBox;
- ELayout _surfaceLayout;
- CircleSurface _surface;
- CircleGenList _naviMenu;
-
- GenItemClass _defaultClass;
- SmartEvent _draggedUpCallback;
- SmartEvent _draggedDownCallback;
-
- GenListItem _header;
- GenListItem _footer;
-
- List> _itemCache;
- List _items = new List();
-
- public NavigationView(EvasObject parent) : base(parent)
- {
- InitializeComponent();
- }
-
- public event EventHandler ItemSelected;
-
- public event EventHandler Dragged;
-
-
- EColor _backgroundColor = ThemeConstants.Shell.ColorClass.Watch.DefaultNavigationViewBackgroundColor;
- public override EColor BackgroundColor
- {
- get => _backgroundColor;
- set
- {
- _backgroundColor = value.IsDefault ? ThemeConstants.Shell.ColorClass.Watch.DefaultNavigationViewBackgroundColor : value;
- UpdateBackgroundColor();
- }
- }
-
- EColor _foregroundColor = ThemeConstants.Shell.ColorClass.Watch.DefaultNavigationViewForegroundColor;
- public EColor ForegroundColor
- {
- get => _foregroundColor;
- set
- {
- _foregroundColor = value;
- UpdateForegroundColor();
- }
- }
-
-
- public void Build(List> items)
- {
- // Only update when items was changed
- if (!IsUpdated(items))
- {
- return;
- }
- _itemCache = items;
-
- ClearItemPropertyChangedHandler();
- _naviMenu.Clear();
- _items.Clear();
- // header
- _header = _naviMenu.Append(_defaultClass, new Item { Text = "" });
-
- // TODO. need to improve, need to support group
- foreach (var group in items)
- {
- foreach (var item in group)
- {
- var data = new Item
- {
- Source = item
- };
- if (item is BaseShellItem shellItem)
- {
- data.Text = shellItem.Title;
- data.Icon = (shellItem.Icon as FileImageSource)?.ToAbsPath();
- }
- else if (item is MenuItem menuItem)
- {
- data.Text = menuItem.Text;
- data.Icon = (menuItem.IconImageSource as FileImageSource)?.ToAbsPath();
- }
- var genitem = _naviMenu.Append(_defaultClass, data, GenListItemType.Normal);
- _items.Add(genitem);
- data.PropertyChanged += OnItemPropertyChanged;
- }
- }
- _footer = _naviMenu.Append(_defaultClass, new Item { Text = "" });
- }
-
- public void Activate()
- {
- (_naviMenu as IRotaryActionWidget)?.Activate();
- }
- public void Deactivate()
- {
- (_naviMenu as IRotaryActionWidget)?.Deactivate();
- }
-
- protected override IntPtr CreateHandle(EvasObject parent)
- {
- _outterBox = new Box(parent);
- return _outterBox.Handle;
- }
-
- void InitializeComponent()
- {
- _outterBox.SetLayoutCallback(OnLayout);
-
- _surfaceLayout = new ELayout(this);
- _surfaceLayout.Show();
- _surface = new CircleSurface(_surfaceLayout);
-
- _naviMenu = new CircleGenList(this, _surface)
- {
- Homogeneous = true,
- BackgroundColor = _backgroundColor
- };
- _naviMenu.Show();
-
- _draggedUpCallback = new SmartEvent(_naviMenu, "drag,start,up");
- _draggedUpCallback.On += (s, e) =>
- {
- if (_footer.TrackObject.IsVisible)
- {
- Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.EdgeBottom));
- }
- else
- {
- Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.Up));
- }
- };
-
- _draggedDownCallback = new SmartEvent(_naviMenu, "drag,start,down");
- _draggedDownCallback.On += (s, e) =>
- {
- if (_header.TrackObject.IsVisible)
- {
- Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.EdgeTop));
- }
- else
- {
- Dragged?.Invoke(this, new DraggedEventArgs(DraggedState.Down));
- }
- };
-
- _outterBox.PackEnd(_naviMenu);
- _outterBox.PackEnd(_surfaceLayout);
-
- _surfaceLayout.StackAbove(_naviMenu);
-
- _defaultClass = new GenItemClass(ThemeConstants.GenItemClass.Styles.Watch.Text1Icon1)
- {
- GetTextHandler = (obj, part) =>
- {
- if (part == ThemeConstants.GenItemClass.Parts.Text)
- {
- var text = (obj as Item).Text;
- if (_foregroundColor != EColor.Default)
- return $"{text}";
- else
- return text;
- }
- return null;
- },
- GetContentHandler = (obj, part) =>
- {
- if (part == ThemeConstants.GenItemClass.Parts.Watch.Icon && obj is Item menuItem && !string.IsNullOrEmpty(menuItem.Icon))
- {
- var icon = new ElmSharp.Image(Microsoft.Maui.Controls.Compatibility.Forms.NativeParent)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1.0,
- WeightY = 1.0,
- MinimumWidth = _defaultIconSize,
- MinimumHeight = _defaultIconSize,
- };
- icon.Show();
- icon.Load(menuItem.Icon);
- return icon;
- }
- return null;
- }
- };
-
- _naviMenu.ItemSelected += OnItemSelected;
-
- }
-
- void OnItemSelected(object sender, GenListItemEventArgs e)
- {
- ItemSelected?.Invoke(this, new SelectedItemChangedEventArgs((e.Item.Data as Item).Source, -1));
- }
-
- void OnLayout()
- {
- _surfaceLayout.Geometry = Geometry;
- _naviMenu.Geometry = Geometry;
- }
-
- void UpdateBackgroundColor()
- {
- _naviMenu.BackgroundColor = _backgroundColor;
- }
-
- void UpdateForegroundColor()
- {
- foreach (var item in _items)
- {
- item.Update();
- }
- }
-
- bool IsUpdated(List> items)
- {
- if (_itemCache == null)
- return true;
-
- if (_itemCache.Count != items.Count)
- return true;
-
- for (int i = 0; i < items.Count; i++)
- {
- if (_itemCache[i].Count != items[i].Count)
- return true;
-
- for (int j = 0; j < items[i].Count; j++)
- {
- if (_itemCache[i][j] != items[i][j])
- return true;
- }
- }
- return false;
- }
-
- void ClearItemPropertyChangedHandler()
- {
- foreach (var item in _items)
- {
- (item.Data as Item).PropertyChanged -= OnItemPropertyChanged;
- }
- }
-
- void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- var item = _items.Where((d) => d.Data == sender).FirstOrDefault();
- item?.Update();
- }
-
- }
- public enum DraggedState
- {
- EdgeTop,
- Up,
- Down,
- EdgeBottom,
- }
-
- public class DraggedEventArgs
- {
- public DraggedState State { get; private set; }
-
- public DraggedEventArgs(DraggedState state)
- {
- State = state;
- }
- }
-
- static class FileImageSourceEX
- {
- public static string ToAbsPath(this FileImageSource source)
- {
- return ResourcePath.GetPath(source.File);
- }
- }
-
- static class ColorEX
- {
- public static string ToHex(this EColor c)
- {
- return string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", c.R, c.G, c.B, c.A);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellContentRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellContentRenderer.cs
deleted file mode 100644
index a6ccb674aa77..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellContentRenderer.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShellContentRenderer : IShellItemRenderer
- {
- public ShellContentRenderer(ShellContent content)
- {
- ShellContent = content;
- NativeView = GetNativeView(content);
- }
-
- public ShellContent ShellContent { get; protected set; }
-
- public BaseShellItem Item => ShellContent;
-
- public EvasObject NativeView { get; protected set; }
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- NativeView?.Unrealize();
- }
- }
-
- static EvasObject GetNativeView(ShellContent content)
- {
- var page = (content as IShellContentController).GetOrCreateContent();
- return Platform.GetOrCreateRenderer(page).NativeView;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellItemRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellItemRenderer.cs
deleted file mode 100644
index 11db455ffb54..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellItemRenderer.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System.Collections.Generic;
-using System.ComponentModel;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShellItemRenderer : IShellItemRenderer
- {
- Box _mainLayout;
- EvasObject _currentItem;
- Dictionary _rendererCache = new Dictionary();
-
- public ShellItemRenderer(ShellItem item)
- {
- ShellItem = item;
- ShellItem.PropertyChanged += OnItemPropertyChanged;
- InitializeComponent();
- UpdateCurrentItem();
- }
-
- public ShellItem ShellItem { get; protected set; }
-
- public BaseShellItem Item => ShellItem;
-
- public EvasObject NativeView => _mainLayout;
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- ResetCurrentItem();
- ShellItem.PropertyChanged -= OnItemPropertyChanged;
- }
- }
-
- void InitializeComponent()
- {
- _mainLayout = new Box(Forms.NativeParent);
- _mainLayout.SetLayoutCallback(OnLayout);
- }
-
- void UpdateCurrentItem()
- {
- ResetCurrentItem();
- var currentItem = ShellItem.CurrentItem;
- if (currentItem != null)
- {
- if (!_rendererCache.TryGetValue(currentItem, out IShellItemRenderer renderer))
- {
- renderer = ShellRendererFactory.Default.CreateShellNavigationRenderer(currentItem);
- _rendererCache[currentItem] = renderer;
- }
- SetCurrentItem(renderer.NativeView);
- }
- }
-
- void SetCurrentItem(EvasObject item)
- {
- _currentItem = item;
- _currentItem.Show();
- _mainLayout.PackEnd(_currentItem);
- }
-
- void ResetCurrentItem()
- {
- if (_currentItem != null)
- {
- _mainLayout.UnPack(_currentItem);
- _currentItem.Hide();
- _currentItem = null;
- }
- }
-
- void OnItemPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == nameof(ShellItem.CurrentItem))
- {
- UpdateCurrentItem();
- }
- }
-
- void OnLayout()
- {
- if (_currentItem != null)
- {
- _currentItem.Geometry = _mainLayout.Geometry;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellRenderer.cs
deleted file mode 100644
index b54cba9647f8..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellRenderer.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-using System;
-using System.Collections.Generic;
-using ElmSharp;
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShellRenderer : VisualElementRenderer
- {
- NavigationDrawer _drawer;
- NavigationView _navigationView;
-
- Dictionary _rendererCache = new Dictionary();
-
- public ShellRenderer()
- {
- RegisterPropertyHandler(Shell.CurrentItemProperty, UpdateCurrentItem);
- RegisterPropertyHandler(Shell.FlyoutIsPresentedProperty, UpdateFlyoutIsPresented);
- RegisterPropertyHandler(Shell.FlyoutBehaviorProperty, UpdateFlyoutBehavior);
- RegisterPropertyHandler(Shell.FlyoutIconProperty, UpdateFlyoutIcon);
- RegisterPropertyHandler(Shell.FlyoutBackgroundColorProperty, UpdateFlyoutBackgroundColor);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- InitializeComponent();
- base.OnElementChanged(e);
- }
-
- protected override void OnElementReady()
- {
- base.OnElementReady();
- UpdateFlyoutMenu();
- (Element as IShellController).StructureChanged += OnNavigationStructureChanged;
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- foreach (var renderer in _rendererCache.Values)
- {
- renderer.Dispose();
- }
- (Element as IShellController).StructureChanged -= OnNavigationStructureChanged;
- }
- base.Dispose(disposing);
- }
-
- protected virtual NavigationView CreateNavigationView(EvasObject parent)
- {
- return new NavigationView(parent);
- }
-
- protected virtual NavigationDrawer CreateNavigationDrawer(EvasObject parent)
- {
- return new NavigationDrawer(parent);
- }
-
- void InitializeComponent()
- {
- if (_drawer == null)
- {
- _drawer = CreateNavigationDrawer(Forms.NativeParent);
- _drawer.IsOpen = Element.FlyoutIsPresented;
- _drawer.Toggled += OnNavigationDrawerToggled;
- SetNativeView(_drawer);
- }
- }
-
- void OnNavigationStructureChanged(object sender, EventArgs e)
- {
- UpdateFlyoutMenu();
- }
-
- void UpdateFlyoutMenu()
- {
- if (Element.FlyoutBehavior == FlyoutBehavior.Disabled)
- return;
-
- var flyoutItems = (Element as IShellController).GenerateFlyoutGrouping();
- int itemCount = 0;
- foreach (var item in flyoutItems)
- {
- itemCount += item.Count;
- }
-
- if (itemCount > 1)
- {
- InitializeNavigationDrawer();
- _navigationView.Build(flyoutItems);
- }
- else
- {
- DeinitializeNavigationView();
- }
- }
-
- void InitializeNavigationDrawer()
- {
- if (_navigationView != null)
- {
- return;
- }
-
- _navigationView = CreateNavigationView(Forms.NativeParent);
- _navigationView.AlignmentX = -1;
- _navigationView.AlignmentY = -1;
- _navigationView.WeightX = 1;
- _navigationView.WeightY = 1;
-
- _navigationView.Show();
- _navigationView.ItemSelected += OnMenuItemSelected;
-
- _drawer.SetDrawerContent(_navigationView);
- }
-
- protected virtual void OnNavigationDrawerToggled(object sender, EventArgs e)
- {
- if (_drawer.IsOpen)
- {
- _navigationView.Activate();
- }
- else
- {
- _navigationView.Deactivate();
- }
-
- Element.SetValueFromRenderer(Shell.FlyoutIsPresentedProperty, _drawer.IsOpen);
- }
-
- void DeinitializeNavigationView()
- {
- if (_navigationView == null)
- return;
- _drawer.SetDrawerContent(null);
- _navigationView.Unrealize();
- _navigationView = null;
- }
-
- void OnMenuItemSelected(object sender, SelectedItemChangedEventArgs e)
- {
- ((IShellController)Element).OnFlyoutItemSelected(e.SelectedItem as Element);
- }
-
- void UpdateCurrentItem()
- {
- ResetCurrentItem();
- if (Element.CurrentItem != null)
- {
- if (!_rendererCache.TryGetValue(Element.CurrentItem, out IShellItemRenderer renderer))
- {
- renderer = ShellRendererFactory.Default.CreateItemRenderer(Element.CurrentItem);
- _rendererCache[Element.CurrentItem] = renderer;
- }
- SetCurrentItem(renderer.NativeView);
- }
- }
-
- void UpdateFlyoutBehavior(bool init)
- {
- if (init)
- return;
-
- if (Element.FlyoutBehavior == FlyoutBehavior.Disabled)
- {
- DeinitializeNavigationView();
- }
- else if (Element.FlyoutBehavior == FlyoutBehavior.Flyout)
- {
- UpdateFlyoutMenu();
- }
- else if (Element.FlyoutBehavior == FlyoutBehavior.Locked)
- {
- // Locked behavior is not supported on circularshell
- }
- }
-
- void UpdateFlyoutIcon(bool init)
- {
- if (init && Element.FlyoutIcon == null)
- return;
-
- _drawer.UpdateDrawerIcon(Element.FlyoutIcon);
- }
-
- void UpdateFlyoutBackgroundColor(bool init)
- {
- if (init && Element.FlyoutBackgroundColor.IsDefault())
- return;
-
- if (_navigationView != null)
- {
- _navigationView.BackgroundColor = Element.FlyoutBackgroundColor.ToNative();
- }
- }
-
- void UpdateFlyoutIsPresented()
- {
- _drawer.IsOpen = Element.FlyoutIsPresented;
- }
-
- void SetCurrentItem(EvasObject item)
- {
- _drawer.SetMainContent(item);
- }
-
- void ResetCurrentItem()
- {
- _drawer.SetMainContent(null);
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellRendererFactory.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellRendererFactory.cs
deleted file mode 100644
index 820c90d03c03..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellRendererFactory.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- [System.Obsolete]
- public class ShellRendererFactory
- {
- static ShellRendererFactory _instance;
- public static ShellRendererFactory Default
- {
- get
- {
- if (_instance == null)
- {
- _instance = new ShellRendererFactory();
- }
- return _instance;
- }
- set
- {
- _instance = value;
- }
-
- }
-
- public virtual IShellItemRenderer CreateItemRenderer(ShellItem item)
- {
- if (item.Items.Count == 1)
- {
- return CreateShellNavigationRenderer(item.CurrentItem);
- }
- return new ShellItemRenderer(item);
- }
-
- public virtual IShellItemRenderer CreateShellNavigationRenderer(ShellSection item)
- {
- return new ShellSectionNavigationRenderer(item);
- }
-
- public virtual IShellItemRenderer CreateItemRenderer(ShellSection item)
- {
- if (item.Items.Count == 1)
- {
- return CreateItemRenderer(item.CurrentItem);
- }
- return new ShellSectionItemsRenderer(item);
- }
-
- public virtual IShellItemRenderer CreateItemRenderer(ShellContent item)
- {
- return new ShellContentRenderer(item);
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellSectionItemsRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellSectionItemsRenderer.cs
deleted file mode 100644
index 21d3fb523c85..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellSectionItemsRenderer.cs
+++ /dev/null
@@ -1,324 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Collections.Specialized;
-using System.ComponentModel;
-using ElmSharp;
-using ElmSharp.Wearable;
-using ERect = ElmSharp.Rect;
-using Index = ElmSharp.Index;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShellSectionItemsRenderer : IShellItemRenderer
- {
- const int ItemMaxCount = 20;
- const int OddMiddleItem = 10;
- const int EvenMiddleItem = 11;
-
- Box _mainBox;
- Index _indexIndicator;
- Scroller _scroller;
- Box _innerContainer;
- List _items = new List();
-
- int _currentIndex = -1;
- ERect _lastLayoutBound;
- int _updateByCode;
- bool _isScrolling;
-
- public ShellSectionItemsRenderer(ShellSection shellSection)
- {
- ShellSection = shellSection;
- ShellSection.PropertyChanged += OnSectionPropertyChanged;
- (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnItemsChanged;
- InitializeComponent();
- UpdateItems();
- }
-
- public ShellSection ShellSection { get; protected set; }
-
- public BaseShellItem Item => ShellSection;
-
- public EvasObject NativeView => _mainBox;
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- _mainBox?.Unrealize();
- (ShellSection.Items as INotifyCollectionChanged).CollectionChanged -= OnItemsChanged;
- ShellSection.PropertyChanged -= OnSectionPropertyChanged;
- }
- }
-
- void InitializeComponent()
- {
- _mainBox = new Box(Forms.NativeParent)
- {
- AlignmentX = -1,
- AlignmentY = -1,
- WeightX = 1,
- WeightY = 1,
- };
- _mainBox.Show();
- _mainBox.SetLayoutCallback(OnLayout);
-
- _indexIndicator = new Index(_mainBox)
- {
- IsHorizontal = true,
- AutoHide = false,
- }.SetStyledIndex();
- _indexIndicator.Show();
-
- _scroller = new Scroller(_mainBox);
- _scroller.Scrolled += OnScrolled;
- _scroller.PageScrolled += OnScrollStop;
-
- //PageScrolled event is not invoked when a user scrolls beyond the end using bezel
- var scrollAnimationStop = new SmartEvent(_scroller, ThemeConstants.Scroller.Signals.StopScrollAnimation);
- scrollAnimationStop.On += OnScrollStop;
-
- _scroller.Focused += OnFocused;
- _scroller.Unfocused += OnUnfocused;
-
- // Disables the visibility of the scrollbar in both directions:
- _scroller.HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible;
- _scroller.VerticalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible;
-
- // Sets the limit of scroll to one page maximum:
- _scroller.HorizontalPageScrollLimit = 1;
- _scroller.SetPageSize(1.0, 1.0);
- _scroller.SetAlignment(-1, -1);
- _scroller.SetWeight(1.0, 1.0);
- _scroller.Show();
-
- _innerContainer = new Box(_mainBox);
- _innerContainer.SetLayoutCallback(OnInnerLayoutUpdate);
- _innerContainer.SetAlignment(-1, -1);
- _innerContainer.SetWeight(1.0, 1.0);
- _innerContainer.Show();
- _scroller.SetContent(_innerContainer);
-
- _mainBox.PackEnd(_indexIndicator);
- _mainBox.PackEnd(_scroller);
- _indexIndicator.StackAbove(_scroller);
- }
-
- void UpdateItems()
- {
- _items.Clear();
- _indexIndicator.Clear();
- _innerContainer.UnPackAll();
- _lastLayoutBound = default(ERect);
-
- foreach (var item in ShellSection.Items)
- {
- var indexItem = _indexIndicator.Append(null);
- indexItem.SetIndexItemStyle(ShellSection.Items.Count, _items.Count, EvenMiddleItem, OddMiddleItem);
- _items.Add(new ItemHolder
- {
- IsRealized = false,
- IndexItem = indexItem,
- Item = item
- });
- }
- _indexIndicator.Update(0);
- UpdateCurrentPage(ShellSection.Items.IndexOf(ShellSection.CurrentItem));
- }
-
- void RealizeItem(int index)
- {
- if (index < 0 || _items.Count <= index)
- return;
-
- if (!_items[index].IsRealized)
- RealizeItem(_items[index]);
- }
-
- void RealizeItem(ItemHolder item)
- {
- var renderer = ShellRendererFactory.Default.CreateItemRenderer(item.Item);
- renderer.NativeView.Show();
-
- item.NativeView = renderer.NativeView;
- item.IsRealized = true;
- _innerContainer.PackEnd(item.NativeView);
- item.NativeView.StackBelow(_indexIndicator);
- item.NativeView.Geometry = item.Bound;
- }
-
- void UpdateCurrentPage(int index)
- {
- RealizeItem(index - 1);
- RealizeItem(index);
- RealizeItem(index + 1);
-
- UpdateCurrentIndex(index);
- UpdateFocusPolicy();
- }
-
- void UpdateFocusPolicy()
- {
- foreach (var item in _items)
- {
- if (item.IsRealized)
- {
- if (item.NativeView is ElmSharp.Widget widget)
- {
- widget.AllowTreeFocus = (_items[_currentIndex] == item);
- }
- }
- }
- }
-
- void UpdateCurrentIndex(int index)
- {
- if (index >= 0 && index < _items.Count)
- {
- _currentIndex = index;
- _items[index].IndexItem.Select(true);
- }
- }
-
- void OnItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
- {
- UpdateItems();
- }
-
- void OnFocused(object sender, EventArgs e)
- {
- RotaryEventManager.Rotated += OnRotated;
- var item = _items[_currentIndex].NativeView as Widget;
- item?.SetFocus(true);
- }
-
- void OnUnfocused(object sender, EventArgs e)
- {
- RotaryEventManager.Rotated -= OnRotated;
- }
-
- void OnScrollStop(object sender, EventArgs e)
- {
- if (_updateByCode > 0)
- return;
-
- UpdateCurrentPage(_currentIndex);
- var currentItem = ShellSection.Items[_currentIndex];
- ShellSection.SetValueFromRenderer(ShellSection.CurrentItemProperty, currentItem);
- _isScrolling = false;
-
- var item = _items[_currentIndex].NativeView as Widget;
- item?.SetFocus(true);
- }
-
- protected void OnRotated(RotaryEventArgs args)
- {
- OnRotated(args.IsClockwise);
- }
-
- protected virtual bool OnRotated(bool isClockwise)
- {
- if (Forms.RotaryFocusObject != null)
- return false;
-
- MoveNextPage(isClockwise);
- return true;
- }
-
- protected void MoveNextPage(bool isClockwise)
- {
- var index = _currentIndex;
- _isScrolling = true;
-
- if (isClockwise)
- {
- RealizeItem(index + 2);
- _scroller.ScrollTo(index + 1, 0, true);
- }
- else
- {
- RealizeItem(index - 2);
- _scroller.ScrollTo(index - 1, 0, true);
- }
- }
-
- void OnScrolled(object sender, EventArgs e)
- {
- _isScrolling = true;
- if (_currentIndex != _scroller.HorizontalPageIndex)
- {
- UpdateCurrentIndex(_scroller.HorizontalPageIndex);
- }
- }
-
- void OnSectionPropertyChanged(object sender, PropertyChangedEventArgs e)
- {
- if (e.PropertyName == nameof(ShellSection.CurrentItem))
- {
- var newIndex = ShellSection.Items.IndexOf(ShellSection.CurrentItem);
- if (_currentIndex != newIndex)
- {
- UpdateCurrentPage(newIndex);
- _updateByCode++;
- _scroller.ScrollTo(newIndex, 0, false);
- _updateByCode--;
- }
- }
- }
-
- void OnLayout()
- {
- _indexIndicator.Geometry = _mainBox.Geometry;
- _scroller.Geometry = _mainBox.Geometry;
- }
-
- void OnInnerLayoutUpdate()
- {
- if (_lastLayoutBound == _innerContainer.Geometry)
- {
- return;
- }
- _lastLayoutBound = _innerContainer.Geometry;
-
- var layoutBound = _innerContainer.Geometry.Size;
- int baseX = _innerContainer.Geometry.X;
-
- ERect bound = _scroller.Geometry;
- int index = 0;
- foreach (var item in _items)
- {
- bound.X = baseX + index * bound.Width;
- item.Bound = bound;
- if (item.IsRealized)
- {
- item.NativeView.Geometry = bound;
- }
- index++;
- }
- _innerContainer.MinimumWidth = _items.Count * bound.Width;
-
-
- if (_items.Count > _currentIndex && _currentIndex >= 0 && !_isScrolling)
- {
- _updateByCode++;
- _scroller.ScrollTo(_currentIndex, 0, false);
- _updateByCode--;
- }
- }
-
- class ItemHolder
- {
- public bool IsRealized { get; set; }
- public ERect Bound { get; set; }
- public EvasObject NativeView { get; set; }
- public IndexItem IndexItem { get; set; }
- public ShellContent Item { get; set; }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellSectionNavigationRenderer.cs b/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellSectionNavigationRenderer.cs
deleted file mode 100644
index 6cd67841ac88..000000000000
--- a/src/Compatibility/Core/src/Tizen/Shell/Watch/ShellSectionNavigationRenderer.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using ElmSharp;
-using Microsoft.Maui.Controls.Internals;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Watch
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ShellSectionNavigationRenderer : IShellItemRenderer
- {
- SimpleViewStack _viewStack;
- IShellItemRenderer _rootPageRenderer;
-
- public ShellSectionNavigationRenderer(ShellSection item)
- {
- ShellSection = item;
- (ShellSection as IShellSectionController).NavigationRequested += OnNavigationRequested;
- InitializeComponent();
- }
-
- public ShellSection ShellSection { get; protected set; }
-
- public BaseShellItem Item => ShellSection;
-
- public EvasObject NativeView => _viewStack;
-
- public void Dispose()
- {
- Dispose(true);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (disposing)
- {
- _rootPageRenderer?.Dispose();
- _viewStack?.Unrealize();
- (ShellSection as IShellSectionController).NavigationRequested -= OnNavigationRequested;
- }
- }
-
- void InitializeComponent()
- {
- _viewStack = new SimpleViewStack(Forms.NativeParent);
- _viewStack.Show();
-
- _rootPageRenderer = ShellRendererFactory.Default.CreateItemRenderer(ShellSection);
- _viewStack.Push(_rootPageRenderer.NativeView);
-
- Application.Current.Dispatcher.Dispatch(() =>
- {
- (_rootPageRenderer.NativeView as Widget)?.SetFocus(true);
- });
- }
-
- void OnInsertRequest(NavigationRequestedEventArgs request)
- {
- var before = Platform.GetRenderer(request.BeforePage)?.NativeView ?? null;
- if (before == null)
- {
- request.Task = Task.FromException(new ArgumentException("Can't found page on stack", nameof(request.BeforePage)));
- return;
- }
- var renderer = Platform.GetOrCreateRenderer(request.Page);
- _viewStack.Insert(before, renderer.NativeView);
- request.Task = Task.FromResult(true);
- }
-
- void OnPushRequest(NavigationRequestedEventArgs request)
- {
- var renderer = Platform.GetOrCreateRenderer(request.Page);
- _viewStack.Push(renderer.NativeView);
- request.Task = Task.FromResult(true);
- Application.Current.Dispatcher.Dispatch(() =>
- {
- (renderer.NativeView as Widget)?.SetFocus(true);
- });
- }
-
- void OnPopRequest(NavigationRequestedEventArgs request)
- {
- _viewStack.Pop();
- request.Task = Task.FromResult(true);
- }
-
- void OnPopToRootRequest(NavigationRequestedEventArgs request)
- {
- _viewStack.PopToRoot();
- request.Task = Task.FromResult(true);
- }
-
- void OnRemoveRequest(NavigationRequestedEventArgs request)
- {
- var renderer = Platform.GetRenderer(request.Page);
- if (renderer == null)
- {
- request.Task = Task.FromException(new ArgumentException("Can't found page on stack", nameof(request.Page)));
- return;
- }
- _viewStack.Remove(renderer.NativeView);
- request.Task = Task.FromResult(true);
- }
-
- void OnNavigationRequested(object sender, NavigationRequestedEventArgs e)
- {
- switch (e.RequestType)
- {
- case NavigationRequestType.Insert:
- OnInsertRequest(e);
- break;
- case NavigationRequestType.Push:
- OnPushRequest(e);
- break;
- case NavigationRequestType.Pop:
- OnPopRequest(e);
- break;
- case NavigationRequestType.PopToRoot:
- OnPopToRootRequest(e);
- break;
- case NavigationRequestType.Remove:
- OnRemoveRequest(e);
- break;
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/SkiaSharp/BoxViewRenderer.cs b/src/Compatibility/Core/src/Tizen/SkiaSharp/BoxViewRenderer.cs
deleted file mode 100644
index afcc8f21674b..000000000000
--- a/src/Compatibility/Core/src/Tizen/SkiaSharp/BoxViewRenderer.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using Microsoft.Maui.Controls.Platform;
-using Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native;
-using EColor = ElmSharp.Color;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class BoxViewRenderer : CanvasViewRenderer
- {
- public BoxViewRenderer()
- {
- RegisterPropertyHandler(BoxView.ColorProperty, UpdateColor);
- RegisterPropertyHandler(BoxView.CornerRadiusProperty, UpdateRadius);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (RealControl == null)
- {
- SetRealNativeControl(new RoundRectangle(Forms.NativeParent));
- }
- base.OnElementChanged(e);
-
- }
-
- protected override void UpdateBackgroundColor(bool initialize)
- {
- if (initialize && Element.BackgroundColor.IsDefault())
- return;
-
- if (Element.Color.IsDefault())
- {
- UpdateColor();
- }
- }
-
- protected override void UpdateLayout()
- {
- base.UpdateLayout();
- RealControl.Draw(Control.Geometry);
- }
-
- protected override void UpdateOpacity(bool initialize)
- {
- if (initialize && Element.Opacity == 1d)
- return;
-
- UpdateColor();
- }
-
- void UpdateRadius(bool init)
- {
- CornerRadius = Element.CornerRadius;
- int topLeft = Forms.ConvertToScaledPixel(Element.CornerRadius.TopLeft);
- int topRight = Forms.ConvertToScaledPixel(Element.CornerRadius.TopRight);
- int bottomLeft = Forms.ConvertToScaledPixel(Element.CornerRadius.BottomLeft);
- int bottomRight = Forms.ConvertToScaledPixel(Element.CornerRadius.BottomRight);
-
- if (!init)
- {
- RealControl.Draw();
- }
- }
-
- void UpdateColor()
- {
- if (Element.Color.IsDefault())
- {
- if (Element.BackgroundColor.IsDefault())
- {
- // Set to default color. (Transparent)
- RealControl.Color = EColor.Transparent;
- }
- else
- {
- // Use BackgroundColor only if color is default and background color is not default.
- RealControl.Color = Element.BackgroundColor.MultiplyAlpha((float)Element.Opacity).ToNative();
- }
- }
- else
- {
- // Color has higer priority than BackgroundColor.
- RealControl.Color = Element.Color.MultiplyAlpha((float)Element.Opacity).ToNative();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/SkiaSharp/CanvasViewRenderer.cs b/src/Compatibility/Core/src/Tizen/SkiaSharp/CanvasViewRenderer.cs
deleted file mode 100644
index ff079661bd9b..000000000000
--- a/src/Compatibility/Core/src/Tizen/SkiaSharp/CanvasViewRenderer.cs
+++ /dev/null
@@ -1,179 +0,0 @@
-using System;
-using System.Diagnostics;
-using ElmSharp;
-using SkiaSharp;
-using SkiaSharp.Views.Tizen;
-using Microsoft.Maui.Controls.Shapes;
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public abstract class CanvasViewRenderer : ViewRenderer, IBackgroundCanvas, IClipperCanvas, ICanvasRenderer
- where TView : View
- where TNativeView : EvasObject
- {
- public TNativeView RealControl
- {
- get
- {
- return (TNativeView)RealNativeView;
- }
- }
-
- Lazy _backgroundCanvas;
-
- Lazy _clipper;
-
- public SKCanvasView BackgroundCanvas => _backgroundCanvas.Value;
-
- public SKClipperView ClipperCanvas => _clipper.Value;
-
- public EvasObject RealNativeView { get; private set; }
-
- public CornerRadius CornerRadius { get; set; }
-
- public Geometry ClippingGeometry { get; set; }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (Control == null)
- {
- SetNativeControl(new Native.Canvas(Forms.NativeParent));
- Control.Show();
- Control.LayoutUpdated += OnLayout;
- Control.Children.Add(RealNativeView);
- }
-
- _backgroundCanvas = new Lazy(() =>
- {
- var canvas = new SKCanvasView(Forms.NativeParent);
- canvas.PassEvents = true;
- canvas.PaintSurface += OnBackgroundPaint;
- canvas.Show();
- Control.Children.Add(canvas);
- canvas.Lower();
- RealNativeView?.RaiseTop();
- return canvas;
- });
-
- _clipper = new Lazy(() =>
- {
- var clipper = new SKClipperView(Forms.NativeParent);
- clipper.PassEvents = true;
- clipper.PaintSurface += OnClipperPaint;
- clipper.Show();
- Control.Children.Add(clipper);
- clipper.Lower();
- RealNativeView?.RaiseTop();
- return clipper;
- });
-
- base.OnElementChanged(e);
- }
-
- protected override void UpdateLayout()
- {
- base.UpdateLayout();
- if (_backgroundCanvas.IsValueCreated)
- {
- BackgroundCanvas.Geometry = Control.Geometry;
- }
- if (_clipper.IsValueCreated)
- {
- ClipperCanvas.Geometry = Control.Geometry;
- ClipperCanvas.Invalidate();
- }
- }
-
- protected void SetRealNativeControl(TNativeView control)
- {
- Debug.Assert(control != null);
- RealNativeView = control;
- RealNativeView.Show();
- }
-
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- if (Control != null)
- {
- Control.LayoutUpdated -= OnLayout;
- }
- if (_backgroundCanvas.IsValueCreated)
- {
- BackgroundCanvas.PaintSurface -= OnBackgroundPaint;
- BackgroundCanvas.Unrealize();
- _backgroundCanvas = null;
- }
-
- if (_clipper.IsValueCreated)
- {
- ClipperCanvas.PaintSurface -= OnClipperPaint;
- ClipperCanvas.Unrealize();
- _clipper = null;
- }
- }
- base.Dispose(disposing);
- }
-
- protected virtual void OnLayout(object sender, Native.LayoutEventArgs e)
- {
- RealControl.Geometry = Control.Geometry;
- if (_backgroundCanvas.IsValueCreated)
- {
- BackgroundCanvas.Geometry = Control.Geometry;
- }
- if (_clipper.IsValueCreated)
- {
- ClipperCanvas.Geometry = Control.Geometry;
- ClipperCanvas.Invalidate();
- }
- }
-
- protected virtual void OnBackgroundPaint(object sender, SKPaintSurfaceEventArgs e)
- {
- var canvas = e.Surface.Canvas;
- canvas.Clear();
-
- var bounds = e.Info.Rect;
- var paint = Element.GetBackgroundPaint(bounds);
-
- if (paint != null)
- {
- using (paint)
- using (var path = bounds.ToRoundedRectPath(CornerRadius))
- {
- canvas.DrawPath(path, paint);
- }
- }
- }
-
- protected virtual void OnClipperPaint(object sender, SKPaintSurfaceEventArgs e)
- {
- var canvas = e.Surface.Canvas;
- canvas.Clear();
-
- ClippingGeometry = Element.Clip;
- if (ClippingGeometry == null)
- return;
-
- using (var paint = new SKPaint
- {
- IsAntialias = true,
- Style = SKPaintStyle.Fill,
- Color = SKColors.White
- })
- {
- canvas.DrawPath(ClippingGeometry.ToSKPath(), paint);
- RealControl?.SetClipperCanvas(ClipperCanvas);
-
- if (_backgroundCanvas.IsValueCreated)
- {
- BackgroundCanvas.SetClipperCanvas(ClipperCanvas);
- }
- }
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/SkiaSharp/FrameRenderer.cs b/src/Compatibility/Core/src/Tizen/SkiaSharp/FrameRenderer.cs
deleted file mode 100644
index 1f13ba5a9058..000000000000
--- a/src/Compatibility/Core/src/Tizen/SkiaSharp/FrameRenderer.cs
+++ /dev/null
@@ -1,151 +0,0 @@
-using SkiaSharp;
-using SkiaSharp.Views.Tizen;
-using Microsoft.Maui.Controls.Platform;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class FrameRenderer : LayoutRenderer
- {
- static float s_borderWidth = 1.0f;
- static SKColor s_defaultColor = SKColors.Transparent;
-
- SKClipperView _clipper;
- new Frame Element => base.Element as Frame;
-
- public FrameRenderer()
- {
- RegisterPropertyHandler(Frame.CornerRadiusProperty, UpdateCornerRadius);
- RegisterPropertyHandler(Frame.BorderColorProperty, UpdateBorderColor);
- RegisterPropertyHandler(Frame.HasShadowProperty, UpdateHasShadow);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- base.OnElementChanged(e);
- _clipper = new SKClipperView(Forms.NativeParent);
- _clipper.Show();
- _clipper.PassEvents = true;
- _clipper.PaintSurface += OnCliperPaint;
-
- Control.Children.Add(_clipper);
- BackgroundCanvas?.StackAbove(_clipper);
- }
-
- protected override void UpdateBackgroundColor(bool initialize)
- {
- if (initialize && Element.BackgroundColor.IsDefault())
- return;
- else
- BackgroundCanvas.Invalidate();
- }
-
- protected override void OnBackgroundLayoutUpdated(object sender, Native.LayoutEventArgs e)
- {
- base.OnBackgroundLayoutUpdated(sender, e);
- _clipper.Geometry = Control.Geometry;
- _clipper.Invalidate();
- }
-
- protected override void OnBackgroundPaint(object sender, SKPaintSurfaceEventArgs e)
- {
- var canvas = e.Surface.Canvas;
- var bound = e.Info.Rect;
- canvas.Clear();
- var bgColor = Element.BackgroundColor.IsDefault() ? s_defaultColor : SKColor.Parse(Element.BackgroundColor.ToHex());
- var borderColor = Element.BorderColor.IsDefault() ? s_defaultColor : SKColor.Parse(Element.BorderColor.ToHex());
- var roundRect = CreateRoundRect(bound);
-
- using (var paint = new SKPaint
- {
- IsAntialias = true,
- })
- {
- if (Element.HasShadow)
- {
- paint.Color = SKColors.White;
- paint.Style = SKPaintStyle.Stroke;
- // Draw shadow
- paint.ImageFilter = SKImageFilter.CreateDropShadowOnly(
- Forms.ConvertToScaledPixel(0),
- Forms.ConvertToScaledPixel(0),
- Forms.ConvertToScaledPixel(s_borderWidth * 2),
- Forms.ConvertToScaledPixel(s_borderWidth * 2),
- SKColors.Black);
- canvas.DrawRoundRect(roundRect, paint);
- }
-
- paint.ImageFilter = null;
- paint.Style = SKPaintStyle.Fill;
- paint.Color = bgColor;
-
- // Draw background color
- canvas.DrawRoundRect(roundRect, paint);
-
- paint.Style = SKPaintStyle.Stroke;
- paint.StrokeWidth = Forms.ConvertToScaledPixel(s_borderWidth);
- paint.Color = borderColor;
-
- // Draw Background (Brush)
- using (var brushPaint = Element.GetBackgroundPaint(bound))
- {
- if (brushPaint != null)
- canvas.DrawRoundRect(roundRect, brushPaint);
- }
-
- // Draw border
- canvas.DrawRoundRect(roundRect, paint);
- }
- }
-
- void OnCliperPaint(object sender, SKPaintSurfaceEventArgs e)
- {
- if (Element.Content == null)
- return;
-
- var canvas = e.Surface.Canvas;
- var bound = e.Info.Rect;
- canvas.Clear();
-
- var roundRect = CreateRoundRect(bound);
-
- using (var paint = new SKPaint
- {
- IsAntialias = true,
- Style = SKPaintStyle.Fill,
- Color = SKColors.White,
- })
- {
- canvas.DrawRoundRect(roundRect, paint);
- }
-
- Element.Content.SetClipperCanvas(_clipper);
- }
-
- void UpdateCornerRadius()
- {
- BackgroundCanvas.Invalidate();
- _clipper?.Invalidate();
- }
-
- void UpdateBorderColor()
- {
- BackgroundCanvas.Invalidate();
- }
-
- void UpdateHasShadow()
- {
- BackgroundCanvas.Invalidate();
- _clipper?.Invalidate();
- }
-
- SKRoundRect CreateRoundRect(SKRect bounds)
- {
- var border = Forms.ConvertToScaledPixel(s_borderWidth) * (Element.HasShadow ? 4 : 2);
- var radius = Forms.ConvertToScaledPixel(Element.CornerRadius);
- var roundRect = new SKRoundRect(bounds, radius);
- roundRect.Deflate(border, border);
- return roundRect;
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/SkiaSharp/IBackgroundCanvas.cs b/src/Compatibility/Core/src/Tizen/SkiaSharp/IBackgroundCanvas.cs
deleted file mode 100644
index 366c68c15938..000000000000
--- a/src/Compatibility/Core/src/Tizen/SkiaSharp/IBackgroundCanvas.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using SkiaSharp.Views.Tizen;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- public interface IBackgroundCanvas
- {
- public SKCanvasView BackgroundCanvas { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/SkiaSharp/ICanvasRenderer.cs b/src/Compatibility/Core/src/Tizen/SkiaSharp/ICanvasRenderer.cs
deleted file mode 100644
index b579a762e333..000000000000
--- a/src/Compatibility/Core/src/Tizen/SkiaSharp/ICanvasRenderer.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using ElmSharp;
-using SkiaSharp.Views.Tizen;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- public interface ICanvasRenderer
- {
- public EvasObject RealNativeView { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/SkiaSharp/IClipperCanvas.cs b/src/Compatibility/Core/src/Tizen/SkiaSharp/IClipperCanvas.cs
deleted file mode 100644
index 6ff8f23bedf5..000000000000
--- a/src/Compatibility/Core/src/Tizen/SkiaSharp/IClipperCanvas.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using SkiaSharp.Views.Tizen;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- public interface IClipperCanvas
- {
- public SKClipperView ClipperCanvas { get; }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/SkiaSharp/ImageRenderer.cs b/src/Compatibility/Core/src/Tizen/SkiaSharp/ImageRenderer.cs
deleted file mode 100644
index b38057ea0f24..000000000000
--- a/src/Compatibility/Core/src/Tizen/SkiaSharp/ImageRenderer.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-using Microsoft.Maui.Controls.Platform;
-using ESize = ElmSharp.Size;
-using Specific = Microsoft.Maui.Controls.PlatformConfiguration.TizenSpecific.Image;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- [System.Obsolete(Compatibility.Hosting.MauiAppBuilderExtensions.UseMapperInstead)]
- public class ImageRenderer : CanvasViewRenderer
- {
- public ImageRenderer()
- {
- RegisterPropertyHandler(Image.SourceProperty, UpdateSource);
- RegisterPropertyHandler(Image.AspectProperty, UpdateAspect);
- RegisterPropertyHandler(Image.IsOpaqueProperty, UpdateIsOpaque);
- RegisterPropertyHandler(Image.IsAnimationPlayingProperty, UpdateIsAnimationPlaying);
- RegisterPropertyHandler(Specific.BlendColorProperty, UpdateBlendColor);
- RegisterPropertyHandler(Specific.FileProperty, UpdateFile);
- }
-
- protected override void OnElementChanged(ElementChangedEventArgs e)
- {
- if (RealControl == null)
- {
- SetRealNativeControl(new Native.Image(Forms.NativeParent));
- }
- base.OnElementChanged(e);
- }
-
- protected override ESize Measure(int availableWidth, int availableHeight)
- {
- return RealControl != null ? RealControl.Measure(availableWidth, availableHeight) : base.Measure(availableHeight, availableHeight);
- }
-
- async void UpdateSource(bool initialize)
- {
- if (initialize && Element.Source == default(ImageSource))
- return;
-
- ImageSource source = Element.Source;
- ((IImageController)Element).SetIsLoading(true);
-
- if (RealControl != null)
- {
- bool success = await RealControl.LoadFromImageSourceAsync(source);
- if (!IsDisposed && success)
- {
- ((IVisualElementController)Element).PlatformSizeChanged();
- UpdateAfterLoading(initialize);
- }
- }
-
- if (!IsDisposed)
- ((IImageController)Element).SetIsLoading(false);
- }
-
- void UpdateFile(bool initialize)
- {
- if (initialize && Specific.GetFile(Element) == default || Element.Source != default(ImageSource))
- return;
-
- if (RealControl != null)
- {
- bool success = RealControl.LoadFromFile(Specific.GetFile(Element));
- if (!IsDisposed && success)
- {
- ((IVisualElementController)Element).PlatformSizeChanged();
- UpdateAfterLoading(initialize);
- }
- }
- }
-
- protected virtual void UpdateAfterLoading(bool initialize)
- {
- UpdateIsOpaque(initialize);
- UpdateBlendColor(initialize);
- UpdateIsAnimationPlaying(initialize);
- }
-
- void UpdateAspect(bool initialize)
- {
- if (initialize && Element.Aspect == Aspect.AspectFit)
- return;
-
- RealControl.ApplyAspect(Element.Aspect);
- }
-
- void UpdateIsOpaque(bool initialize)
- {
- if (initialize && !Element.IsOpaque)
- return;
-
- RealControl.IsOpaque = Element.IsOpaque;
- }
-
- void UpdateIsAnimationPlaying(bool initialize)
- {
- if (initialize && !Element.IsAnimationPlaying)
- return;
-
- RealControl.IsAnimated = Element.IsAnimationPlaying;
- RealControl.IsAnimationPlaying = Element.IsAnimationPlaying;
- }
-
- void UpdateBlendColor(bool initialize)
- {
- if (initialize && Specific.GetBlendColor(Element) == null)
- return;
-
- RealControl.Color = Specific.GetBlendColor(Element).ToPlatformEFL();
- }
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/SkiaSharp/SKClipperView.cs b/src/Compatibility/Core/src/Tizen/SkiaSharp/SKClipperView.cs
deleted file mode 100644
index f664466e45bf..000000000000
--- a/src/Compatibility/Core/src/Tizen/SkiaSharp/SKClipperView.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-using ElmSharp;
-using SkiaSharp.Views.Tizen;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen.SkiaSharp
-{
- public class SKClipperView : SKCanvasView
- {
- public SKClipperView(EvasObject parent) : base(parent) { }
-
- public bool ClippingRequired { get; set; }
-
- public new void Invalidate()
- {
- ClippingRequired = true;
- OnDrawFrame();
- ClippingRequired = false;
- }
- }
-
- public static class ClipperExtension
- {
- public static void SetClipperCanvas(this VisualElement target, SKClipperView clipper)
- {
- if (target != null && clipper.ClippingRequired)
- {
-#pragma warning disable CS0612 // Type or member is obsolete
- var nativeView = Platform.GetOrCreateRenderer(target)?.NativeView;
-#pragma warning disable CS0612 // Type or member is obsolete
- var realHandle = elm_object_part_content_get(clipper, "elm.swallow.content");
-
- nativeView?.SetClip(null); // To restore original image
- evas_object_clip_set(nativeView, realHandle);
- }
- }
-
- public static void SetClipperCanvas(this EvasObject target, SKClipperView clipper)
- {
- if (target != null && clipper.ClippingRequired)
- {
- var realHandle = elm_object_part_content_get(clipper, "elm.swallow.content");
-
- target.SetClip(null); // To restore original image
- evas_object_clip_set(target, realHandle);
- }
- }
-
- [DllImport("libevas.so.1")]
- internal static extern void evas_object_clip_set(IntPtr obj, IntPtr clip);
-
- [DllImport("libelementary.so.1")]
- internal static extern IntPtr elm_object_part_content_get(IntPtr obj, string part);
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/StaticRegistrar.cs b/src/Compatibility/Core/src/Tizen/StaticRegistrar.cs
index 53480c968765..99da0c307f16 100644
--- a/src/Compatibility/Core/src/Tizen/StaticRegistrar.cs
+++ b/src/Compatibility/Core/src/Tizen/StaticRegistrar.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Reflection;
using Microsoft.Maui.Controls.Internals;
-using Microsoft.Maui.Controls.Shapes;
using Microsoft.Maui.Controls.Xaml.Internals;
using Microsoft.Maui.Devices;
@@ -71,74 +70,18 @@ static StaticRegistrar()
public static void RegisterHandlers(Dictionary> customHandlers)
{
//Renderers
- if (Forms.UseFastLayout)
- {
- Registered.Register(typeof(Layout), () => new FastLayoutRenderer());
- }
- else
- {
- Registered.Register(typeof(Layout), () => new LayoutRenderer());
- }
+ Registered.Register(typeof(Layout), () => new LayoutRenderer());
Registered.Register(typeof(ScrollView), () => new ScrollViewRenderer());
- Registered.Register(typeof(CarouselPage), () => new CarouselPageRenderer());
Registered.Register(typeof(Page), () => new PageRenderer());
Registered.Register(typeof(NavigationPage), () => new NavigationPageRenderer());
- Registered.Register(typeof(FlyoutPage), () => new FlyoutPageRenderer());
- Registered.Register(typeof(TabbedPage), () => new TabbedPageRenderer());
Registered.Register(typeof(Label), () => new LabelRenderer());
- Registered.Register(typeof(Button), () => new ButtonRenderer());
Registered.Register(typeof(Image), () => new ImageRenderer());
- Registered.Register(typeof(Slider), () => new SliderRenderer());
- Registered.Register(typeof(Picker), () => new PickerRenderer());
- Registered.Register(typeof(Frame), () => new FrameRenderer());
- Registered.Register(typeof(Stepper), () => new StepperRenderer());
- Registered.Register(typeof(DatePicker), () => new DatePickerRenderer());
- Registered.Register(typeof(TimePicker), () => new TimePickerRenderer());
- Registered.Register(typeof(ProgressBar), () => new ProgressBarRenderer());
- Registered.Register(typeof(Switch), () => new SwitchRenderer());
- Registered.Register(typeof(CheckBox), () => new CheckBoxRenderer());
- Registered.Register(typeof(ListView), () => new ListViewRenderer());
- Registered.Register(typeof(BoxView), () => new BoxViewRenderer());
- Registered.Register(typeof(ActivityIndicator), () => new ActivityIndicatorRenderer());
- Registered.Register(typeof(SearchBar), () => new SearchBarRenderer());
- Registered.Register(typeof(Entry), () => new EntryRenderer());
- Registered.Register(typeof(Editor), () => new EditorRenderer());
- Registered.Register(typeof(TableView), () => new TableViewRenderer());
- Registered.Register(typeof(NativeViewWrapper), () => new NativeViewWrapperRenderer());
- Registered.Register(typeof(WebView), () => new WebViewRenderer());
- Registered.Register(typeof(ImageButton), () => new ImageButtonRenderer());
- Registered.Register(typeof(StructuredItemsView), () => new StructuredItemsViewRenderer());
- Registered.Register(typeof(CarouselView), () => new CarouselViewRenderer());
- Registered.Register(typeof(SwipeView), () => new SwipeViewRenderer());
- Registered.Register(typeof(RefreshView), () => new RefreshViewRenderer());
- Registered.Register(typeof(IndicatorView), () => new IndicatorViewRenderer());
- Registered.Register(typeof(RadioButton), () => new RadioButtonRenderer());
-
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- Registered.Register(typeof(Shell), () => new Watch.ShellRenderer());
- }
- else if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- Registered.Register(typeof(Shell), () => new TV.TVShellRenderer());
- }
- else
- {
- Registered.Register(typeof(Shell), () => new ShellRenderer());
- }
//ImageSourceHandlers
Registered.Register(typeof(FileImageSource), () => new FileImageSourceHandler());
Registered.Register(typeof(StreamImageSource), () => new StreamImageSourceHandler());
Registered.Register(typeof(UriImageSource), () => new UriImageSourceHandler());
- //Cell Renderers
- Registered.Register(typeof(TextCell), () => new TextCellRenderer());
- Registered.Register(typeof(ImageCell), () => new ImageCellRenderer());
- Registered.Register(typeof(SwitchCell), () => new SwitchCellRenderer());
- Registered.Register(typeof(EntryCell), () => new EntryCellRenderer());
- Registered.Register(typeof(ViewCell), () => new ViewCellRenderer());
-
//Font Loaders
Registered.Register(typeof(EmbeddedFont), () => new CompatibilityEmbeddedFontLoader());
@@ -147,23 +90,6 @@ public static void RegisterHandlers(Dictionary> custom
DependencyService.Register();
#pragma warning disable CS0612 // Type or member is obsolete
DependencyService.Register();
- DependencyService.Register();
-
- //SkiaSharp Renderers
- if (Forms.UseSkiaSharp)
- {
- // Register all skiasharp-based rednerers here for StaticRegistrar
- Registered.Register(typeof(Frame), () => new SkiaSharp.FrameRenderer());
- Registered.Register(typeof(BoxView), () => new SkiaSharp.BoxViewRenderer());
- Registered.Register(typeof(Image), () => new SkiaSharp.ImageRenderer());
-
- Registered.Register(typeof(Ellipse), () => new SkiaSharp.EllipseRenderer());
- Registered.Register(typeof(Line), () => new SkiaSharp.LineRenderer());
- Registered.Register(typeof(Path), () => new SkiaSharp.PathRenderer());
- Registered.Register(typeof(Polygon), () => new SkiaSharp.PolygonRenderer());
- Registered.Register(typeof(Polyline), () => new SkiaSharp.PolylineRenderer());
- Registered.Register(typeof(Shapes.Rectangle), () => new SkiaSharp.RectangleRenderer());
- }
//Custom Handlers
if (customHandlers != null)
diff --git a/src/Compatibility/Core/src/Tizen/SwipeGestureHandler.cs b/src/Compatibility/Core/src/Tizen/SwipeGestureHandler.cs
deleted file mode 100644
index e34d3b6f7204..000000000000
--- a/src/Compatibility/Core/src/Tizen/SwipeGestureHandler.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [System.Obsolete]
- public class SwipeGestureHandler : GestureHandler
- {
- public SwipeGestureHandler(IGestureRecognizer recognizer) : base(recognizer)
- {
- }
-
- public override GestureLayer.GestureType Type => GestureLayer.GestureType.Flick;
-
- protected override void OnStarted(View sender, object data) { }
-
- protected override void OnMoved(View sender, object data) { }
-
- protected override void OnCompleted(View sender, object data)
- {
- if (Recognizer is SwipeGestureRecognizer swipeGesture)
- {
- var lineData = (GestureLayer.LineData)data;
- (swipeGesture as ISwipeGestureController)?.SendSwipe(sender, Forms.ConvertToScaledDP(lineData.X2 - lineData.X1), Forms.ConvertToScaledDP(lineData.Y2 - lineData.Y1));
- (swipeGesture as ISwipeGestureController)?.DetectSwipe(sender, swipeGesture.Direction);
- }
- }
-
- protected override void OnCanceled(View sender, object data) { }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/TapGestureHandler.cs b/src/Compatibility/Core/src/Tizen/TapGestureHandler.cs
deleted file mode 100644
index 5d23d8370cc6..000000000000
--- a/src/Compatibility/Core/src/Tizen/TapGestureHandler.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System;
-using System.ComponentModel;
-using ElmSharp;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public class TapGestureHandler : GestureHandler
- {
- public TapGestureHandler(IGestureRecognizer recognizer) : base(recognizer)
- {
- }
-
- public override GestureLayer.GestureType Type
- {
- get
- {
- var recognizer = Recognizer as TapGestureRecognizer;
- if (recognizer != null)
- {
- int numberOfTaps = recognizer.NumberOfTapsRequired;
-
- if (numberOfTaps > 2)
- return GestureLayer.GestureType.TripleTap;
- else if (numberOfTaps > 1)
- return GestureLayer.GestureType.DoubleTap;
- }
- return GestureLayer.GestureType.Tap;
- }
- }
-
- protected override void OnStarted(View sender, object data)
- {
- }
-
- protected override void OnMoved(View sender, object data)
- {
- }
-
- protected override void OnCompleted(View sender, object data)
- {
- (Recognizer as TapGestureRecognizer)?.SendTapped(sender);
- }
-
- protected override void OnCanceled(View sender, object data)
- {
- }
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/ThemeConstants.cs b/src/Compatibility/Core/src/Tizen/ThemeConstants.cs
deleted file mode 100644
index 95b1cd15915e..000000000000
--- a/src/Compatibility/Core/src/Tizen/ThemeConstants.cs
+++ /dev/null
@@ -1,637 +0,0 @@
-using Microsoft.Maui.Devices;
-using Tizen.Common;
-using EColor = ElmSharp.Color;
-using Color = Microsoft.Maui.Graphics.Color;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- public class ThemeConstants
- {
- #region Common
- public class Common
- {
- public class Parts
- {
- public const string Text = "elm.text";
- public const string Content = "elm.swallow.content";
- }
-
- public class ColorClass
- {
- public const string BackGround = "bg";
- public const string Opacity = "opacity";
- }
-
- public class Resource
- {
- public class Mobile
- {
- public const double BaseScale = 2.6;
- }
- public class TV
- {
- public const double BaseScale = 2.0;
- }
- public class Watch
- {
- public const double BaseScale = 1.3;
- }
- public class Refrigerator
- {
- public const double BaseScale = 1.0;
- }
- public class Iot
- {
- public const double BaseScale = 1.8;
- }
- }
- }
- #endregion
-
- #region Layout
- public class Layout
- {
- public class Parts
- {
- public const string Text = Common.Parts.Text;
- public const string Content = Common.Parts.Content;
- public const string Background = "elm.swallow.background";
- public const string Overlay = "elm.swallow.overlay";
- }
- }
- #endregion
-
- #region Button
- public class Button
- {
- public class Styles
- {
- public const string Default = "default";
- public const string Circle = "circle";
- public const string Bottom = "bottom";
- public const string Text = "textbutton";
- public const string SelectMode = "select_mode";
- public const string EditFieldClear = "editfield_clear";
- public const string Transparent = "transparent";
- public const string Popup = "popup";
- public const string NavigationTitleLeft = "naviframe/title_left";
- public const string NavigationTitleRight = "naviframe/title_right";
- public const string NavigationBack = "naviframe/back_btn/default";
- public const string NavigationDrawers = "naviframe/drawers";
-
- public class Watch
- {
- public const string PopupLeft = "popup/circle/left_delete";
- public const string PopupRight = "popup/circle/right_check";
- public const string Text = "textbutton";
- }
- }
-
- public class Parts
- {
- public const string Icon = "elm.swallow.content";
- public const string Button = "elm.swallow.button";
- }
-
- public class ColorClass
- {
- public const string Icon = "icon";
- public const string IconPressed = "icon_pressed";
- public const string Effect = "effect";
- public const string EffectPressed = "effect_pressed";
- }
-
- public class Signals
- {
- public const string ElementaryCode = "elm";
- public const string TextVisibleState = "elm,state,text,visible";
- public const string TextHiddenState = "elm,state,text,hidden";
- }
- }
- #endregion
-
- #region Entry
- public class Entry
- {
- public class Parts
- {
- public const string PlaceHolderText = "elm.guide";
- }
-
- public class Signals
- {
- public const string SelectionChanged = "selection,changed";
- public const string SelectionCleared = "selection,cleared";
- }
- }
- #endregion
-
- #region GenListItem
- public class GenListItem
- {
- public class ColorClass
- {
- public const string BottomLine = "bottomline";
- public const string Background = Common.ColorClass.BackGround;
- }
-
- public class Signals
- {
- public class TV
- {
- public const string SinglelineIconTextTheme = "theme,singleline,icon,text";
- public const string SinglelineTextIconTheme = "theme,singleline,text,1icon";
- }
- }
- }
- #endregion
-
- #region NaviItem
- public class NaviItem
- {
- public class Styles
- {
- public const string Default = "default";
- public const string NavigationBar = "navigationbar";
-
- public class TV
- {
- public const string TabBar = "tabbar";
- }
- }
-
- public class Parts
- {
- public const string Title = "default";
- public const string BackButton = "elm.swallow.prev_btn";
- public const string LeftToolbarButton = "title_left_btn";
- public const string RightToolbarButton = "title_right_btn";
- public const string NavigationBar = "navigationbar";
- }
-
- public class ColorClass
- {
- public const string TextUnderIconPressed = "text_under_icon_pressed";
- public const string TextUnderIconSelected = "text_under_icon_selected";
- }
- }
- #endregion
-
- #region GenList
- public static class GenList
- {
- public class Styles
- {
- public const string Solid = "solid/default";
- }
- }
- #endregion
-
- #region GenItemClass
- public static class GenItemClass
- {
- public class Styles
- {
- public const string Default = "default";
- public const string Full = "full";
- public const string DoubleLabel = "double_label";
- public const string GroupIndex = "group_index";
-
- public class Watch
- {
- public const string Padding = "padding";
- public const string SingleText = "1text";
- public const string Text1Icon1 = "1text.1icon.1";
- public const string TwoText1Icon1 = "2text.1icon.1";
- public const string Icon2Text = "2text.1icon";//"1icon_2text"
- public const string FullEffectOff = "full_effect_off";
- public const string FullOff = "full_off";
- }
- }
-
- public class Parts
- {
- public const string Text = Common.Parts.Text;
- public const string Content = Common.Parts.Content;
- public const string Icon = "elm.swallow.icon";
- public const string End = "elm.swallow.end";
- public const string SubText = "elm.text.sub";
- public const string EndText = "elm.text.end";
- public const string Ignore = "null";
-
- public class Watch
- {
- public const string Icon = "elm.icon";
- public const string Text = "elm.text.1";
- }
- }
- }
- #endregion
-
- #region Popup
- public class Popup
- {
- public class Styles
- {
- public class Watch
- {
- public const string Circle = "circle";
- public const string ToastCircle = "toast/circle";
- }
- }
-
- public class Parts
- {
- public const string Title = "title,text";
- public const string Button1 = "button1";
- public const string Button2 = "button2";
- public const string Button3 = "button3";
-
- public class Watch
- {
- public const string ToastIcon = "toast,icon";
- }
- }
-
- public class ColorClass
- {
- public const string Title = "text_maintitle";
- public const string TitleBackground = "bg_title";
- public const string ContentBackground = "bg_content";
-
- public class TV
- {
- public const string Title = "text_title";
- }
- }
- }
- #endregion
-
- #region ContextPopup
- public class ContextPopup
- {
- public class Styles
- {
- public const string SelectMode = "select_mode";
- }
- }
- #endregion
-
- #region DateTimeSelector
- public class DateTimeSelector
- {
- public class Styles
- {
- public const string TimeLayout = "time_layout";
- public const string DateLayout = "date_layout";
- }
- }
- #endregion
-
- #region CircleDateTimeSelector
- public class CircleDateTimeSelector
- {
- public class Styles
- {
- public const string CircleDatePicker = "datepicker/circle";
- public const string CircleTimePicker = "timepicker/circle";
- }
- }
- #endregion
-
- #region CircleSpinner
- public class CircleSpinner
- {
- public class Styles
- {
- public const string Circle = "circle";
- }
-
- public class Signals
- {
- public static readonly string ShowList = DotnetUtil.TizenAPIVersion == 4 ? "genlist,show" : "list,show";
- public static readonly string HideList = DotnetUtil.TizenAPIVersion == 4 ? "genlist,hide" : "list,hide";
- }
- }
- #endregion
-
- #region Toolbar
- public class Toolbar
- {
- public class Styles
- {
- public const string Default = "default";
- public const string NavigationBar = "navigationbar";
- public const string Tabbar = "tabbar";
- public const string Material = "material";
-
- public class TV
- {
- public const string TabbarWithTitle = "tabbar_with_title";
- }
- }
- }
- #endregion
-
- #region ToolbarItem
- public class ToolbarItem
- {
- public class Parts
- {
- public const string Icon = "elm.swallow.icon";
- }
-
- public class ColorClass
- {
- public const string Background = Common.ColorClass.BackGround;
- public const string Icon = "icon";
- public const string IconPressed = "icon_pressed";
- public const string IconSelected = "icon_selected";
- public const string Text = "text";
- public const string TextPressed = "text_pressed";
- public const string TextSelected = "text_selected";
- public const string TextUnderIcon = "text_under_icon";
- public const string TextUnderIconPressed = "text_under_icon_pressed";
- public const string TextUnderIconSelected = "text_under_icon_selected";
- public const string Underline = "underline";
- }
- }
- #endregion
-
- #region ProgressBar
- public class ProgressBar
- {
- public class Styles
- {
- public const string Default = "default";
- public const string Pending = "pending";
- public const string Small = "process_small";
- public const string Large = "process_large";
-
- public class Watch
- {
- public const string PopupSmall = "process/popup/small";
- }
- }
-
- public class ColorClass
- {
- public static readonly EColor Default = new EColor(129, 198, 255);
- }
- }
- #endregion
-
- #region Frame
- public class Frame
- {
- public class ColorClass
- {
- public static readonly EColor DefaultBorderColor = DeviceInfo.Idiom == DeviceIdiom.TV || DeviceInfo.Idiom == DeviceIdiom.Watch ? EColor.Gray : EColor.Black;
- public static readonly EColor DefaultShadowColor = EColor.FromRgba(80, 80, 80, 50);
- }
- }
- #endregion
-
- #region Panes
- public class Panes
- {
- public class Parts
- {
- public const string Left = "left";
- public const string Right = "right";
- }
- }
- #endregion
-
- #region Scroller
- public class Scroller
- {
- public class Signals
- {
- public const string StartScrollAnimation = "scroll,anim,start";
- public const string StopScrollAnimation = "scroll,anim,stop";
- }
- }
- #endregion
-
- #region Background
- public class Background
- {
- public class Parts
- {
- public const string Overlay = "overlay";
- }
- }
- #endregion
-
- #region Check
- public class Check
- {
- public class Styles
- {
- public const string Default = "default";
- public const string Toggle = "toggle";
- public const string Favorite = "favorite";
- public const string OnOff = "on&off";
- public const string Small = "small";
-
- public class Watch
- {
- public const string ListSelectMode = "genlist/select_mode";
- }
- }
-
- public class ColorClass
- {
- public const string BackgroundOn = "bg_on";
- public const string Stroke = "stroke";
-
- public class TV
- {
- public const string SliderOn = "slider_on";
- public const string SliderFocusedOn = "slider_focused_on";
- }
-
- public class Watch
- {
- public const string OuterBackgroundOn = "outer_bg_on";
- public const string OuterBackgroundOnPressed = "outer_bg_on_pressed";
- public const string CheckOn = "check_on";
- public const string CheckOnPressed = "check_on_pressed";
- }
- }
- }
- #endregion
-
- #region Radio
- public class Radio
- {
- public class Signals
- {
- public const string ElementaryCode = "elm";
- public const string TextVisibleState = "elm,state,text,visible";
- public const string TextHiddenState = "elm,state,text,hidden";
- }
- }
- #endregion
-
- #region Index
- public class Index
- {
- public class Styles
- {
- public const string PageControl = "pagecontrol";
- public const string Circle = "circle";
- public const string Thumbnail = "thumbnail";
- }
- }
- #endregion
-
- #region IndexItem
- public class IndexItem
- {
- public class Styles
- {
- public const string EvenItemPrefix = "item/even_";
- public const string OddItemPrefix = "item/odd_";
- }
- }
- #endregion
-
- #region Slider
- public class Slider
- {
- public class ColorClass
- {
- public const string Bar = "bar";
- public const string Background = "bg";
- public const string Handler = "handler";
- public const string BarPressed = "bar_pressed";
- public const string HandlerPressed = "handler_pressed";
- }
- }
- #endregion
-
- #region RefreshView
- public class RefreshView
- {
- public class Resources
- {
- public const int IconSize = 48;
- public const string IconPath = "Microsoft.Maui.Controls.Compatibility.Tizen.Resources.refresh_48dp.png";
- }
-
- public class ColorClass
- {
- public static readonly Color DefaultColor = Color.FromArgb("#6200EE");
- }
- }
- #endregion
-
- #region Span
- public class Span
- {
- public class ColorClass
- {
- public static readonly EColor DefaultUnderLineColor = EColor.Black;
- }
- }
- #endregion
-
- #region Cell
- public class EntryCell
- {
- public class Resources
- {
- public const double DefaultHeight = 65;
- }
-
- public class ColorClass
- {
- public static readonly EColor DefaultLabelColor = EColor.Black;
- }
- }
-
- public class ImageCell
- {
- public class Resources
- {
- public const double DefaultHeight = 55;
- }
- }
- #endregion
-
- #region Shell
- public class Shell
- {
- public class Resources
- {
- // The source of icon resources is https://materialdesignicons.com/
- public const string MenuIcon = "Resources.menu.png";
- public const string BackIcon = "Resources.arrow_left.png";
- public const string DotsIcon = "Resources.dots_horizontal.png";
-
- public class Watch
- {
- public const int DefaultNavigationViewIconSize = 60;
- public const int DefaultDrawerTouchWidth = 50;
- public const int DefaultDrawerIconSize = 40;
- public const string DefaultDrawerIcon = "Microsoft.Maui.Controls.Compatibility.Tizen.Resources.wc_visual_cue.png";
- }
-
- public class TV
- {
- public const string MenuIconCode = "\u2630";
- public const string BackIconCode = "\u2190";
- public const string DotsIconCode = "\u2026";
- }
- }
-
- public class ColorClass
- {
- public static readonly Color DefaultBackgroundColor = Color.FromRgb(33, 150, 243);
- public static readonly Color DefaultForegroundColor = Color.FromRgb(255, 255, 255);
- public static readonly Color DefaultTitleColor = Color.FromRgb(0, 0, 0);
- public static readonly EColor DefaultNavigationViewBackgroundColor = EColor.White;
- public static readonly EColor DefaultDrawerDimBackgroundColor = new EColor(0, 0, 0, 82);
-
- public class Watch
- {
- public static readonly EColor DefaultNavigationViewForegroundColor = EColor.Default;
- public static readonly EColor DefaultNavigationViewBackgroundColor = EColor.Black;
- }
- }
- }
- #endregion
-
- #region CarouselView
- public class CarouselView
- {
- public class ColorClass
- {
- public static readonly EColor DefaultFocusedColor = EColor.Transparent;
- public static readonly EColor DefaultSelectedColor = EColor.Transparent;
- }
- }
- #endregion
-
- #region MediaPlayer
- public class MediaPlayer
- {
- public class Resources
- {
- public const string PlayImagePath = "Microsoft.Maui.Controls.Compatibility.Tizen.Resources.img_button_play.png";
- public const string PauseImagePath = "Microsoft.Maui.Controls.Compatibility.Tizen.Resources.img_button_pause.png";
- }
-
- public class ColorClass
- {
- public static readonly Color DefaultProgressLabelColor = Color.FromArgb("#eeeeeeee");
- public static readonly Color DefaultProgressBarColor = Color.FromArgb($"#4286f4");
- public static readonly Color DefaultProgressAreaColor = Color.FromArgb("#80000000");
- public static readonly Color DefaultProgressAreaBackgroundColor = Color.FromArgb("#50000000");
- }
- }
- #endregion
- }
-}
diff --git a/src/Compatibility/Core/src/Tizen/ThemeManager.cs b/src/Compatibility/Core/src/Tizen/ThemeManager.cs
deleted file mode 100644
index ae51278f367c..000000000000
--- a/src/Compatibility/Core/src/Tizen/ThemeManager.cs
+++ /dev/null
@@ -1,1048 +0,0 @@
-using System;
-using Microsoft.Maui.Devices;
-using ElmSharp;
-using ElmSharp.Wearable;
-#pragma warning disable CS0612 // Type or member is obsolete
-using static Microsoft.Maui.Controls.Compatibility.Platform.Tizen.Native.TableView;
-#pragma warning disable CS0612 // Type or member is obsolete
-using EButton = ElmSharp.Button;
-using EColor = ElmSharp.Color;
-using EEntry = ElmSharp.Entry;
-using ELabel = ElmSharp.Label;
-using ELayout = ElmSharp.Layout;
-using EProgressBar = ElmSharp.ProgressBar;
-using ESize = ElmSharp.Size;
-using ESlider = ElmSharp.Slider;
-using EToolbar = ElmSharp.Toolbar;
-using EToolbarItem = ElmSharp.ToolbarItem;
-using Index = ElmSharp.Index;
-
-namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen
-{
- [Obsolete]
- public static class ThemeManager
- {
- #region Layout
- public static EdjeTextPartObject GetContentPartEdjeObject(this ELayout layout)
- {
- return layout?.EdjeObject[ThemeConstants.Layout.Parts.Content];
- }
-
- public static EdjeTextPartObject GetTextPartEdjeObject(this ELayout layout)
- {
- return layout?.EdjeObject[ThemeConstants.Layout.Parts.Text];
- }
-
- public static bool SetTextPart(this ELayout layout, string text)
- {
- return layout.SetPartText(ThemeConstants.Layout.Parts.Text, text);
- }
-
- public static bool SetContentPart(this ELayout layout, EvasObject content, bool preserveOldContent = false)
- {
- var ret = layout.SetPartContent(ThemeConstants.Layout.Parts.Content, content, preserveOldContent);
- if (!ret)
- {
- // Restore theme to default if given layout is not available
- layout.SetTheme("layout", "application", "default");
- ret = layout.SetPartContent(ThemeConstants.Layout.Parts.Content, content, preserveOldContent);
- }
- return ret;
- }
-
- public static bool SetBackgroundPart(this ELayout layout, EvasObject content, bool preserveOldContent = false)
- {
- return layout.SetPartContent(ThemeConstants.Layout.Parts.Background, content, preserveOldContent);
- }
-
- public static bool SetOverlayPart(this ELayout layout, EvasObject content, bool preserveOldContent = false)
- {
- return layout.SetPartContent(ThemeConstants.Layout.Parts.Overlay, content, preserveOldContent);
- }
- #endregion
-
- #region Entry
- public static bool SetPlaceHolderTextPart(this EEntry entry, string text)
- {
- return entry.SetPartText(ThemeConstants.Entry.Parts.PlaceHolderText, text);
- }
-
- public static void SetVerticalTextAlignment(this EEntry entry, double valign)
- {
- entry.SetVerticalTextAlignment(ThemeConstants.Common.Parts.Text, valign);
- }
-
- public static void SetVerticalPlaceHolderTextAlignment(this EEntry entry, double valign)
- {
- entry.SetVerticalTextAlignment(ThemeConstants.Entry.Parts.PlaceHolderText, valign);
- }
-
- public static ESize GetTextBlockFormattedSize(this EEntry entry)
- {
- var textPart = entry.EdjeObject[ThemeConstants.Common.Parts.Text];
- if (textPart == null)
- {
- Log.Error("There is no elm.text part");
- return new ESize(0, 0);
- }
- return textPart.TextBlockFormattedSize;
- }
-
- public static ESize GetTextBlockNativeSize(this EEntry entry)
- {
- var textPart = entry.EdjeObject[ThemeConstants.Common.Parts.Text];
- if (textPart == null)
- {
- Log.Error("There is no elm.text part");
- return new ESize(0, 0);
- }
- return textPart.TextBlockNativeSize;
- }
-
- public static ESize GetPlaceHolderTextBlockFormattedSize(this EEntry entry)
- {
- var textPart = entry.EdjeObject[ThemeConstants.Entry.Parts.PlaceHolderText];
- if (textPart == null)
- {
- Log.Error("There is no elm.guide part");
- return new ESize(0, 0);
- }
- return textPart.TextBlockFormattedSize;
- }
-
- public static ESize GetPlaceHolderTextBlockNativeSize(this EEntry entry)
- {
- var textPart = entry.EdjeObject[ThemeConstants.Entry.Parts.PlaceHolderText];
- if (textPart == null)
- {
- Log.Error("There is no elm.guide part");
- return new ESize(0, 0);
- }
- return textPart.TextBlockNativeSize;
- }
- #endregion
-
- #region Label
- public static void SetVerticalTextAlignment(this ELabel label, double valign)
- {
- label.SetVerticalTextAlignment(ThemeConstants.Common.Parts.Text, valign);
- }
-
- public static double GetVerticalTextAlignment(this ELabel label)
- {
- return label.GetVerticalTextAlignment(ThemeConstants.Common.Parts.Text);
- }
-
- public static ESize GetTextBlockFormattedSize(this ELabel label)
- {
- var textPart = label.EdjeObject[ThemeConstants.Common.Parts.Text];
- if (textPart == null)
- {
- Log.Error("There is no elm.text part");
- return new ESize(0, 0);
- }
- return textPart.TextBlockFormattedSize;
- }
- #endregion
-
- #region Button
- public static ESize GetTextBlockNativeSize(this EButton button)
- {
- var textPart = button.EdjeObject[ThemeConstants.Common.Parts.Text];
- if (textPart == null)
- {
- Log.Error("There is no elm.text part");
- return new ESize(0, 0);
- }
- return textPart.TextBlockNativeSize;
- }
-
- public static void SetTextBlockStyle(this EButton button, string style)
- {
- var textBlock = button.EdjeObject[ThemeConstants.Common.Parts.Text];
- if (textBlock != null)
- {
- textBlock.TextStyle = style;
- }
- }
-
- public static void SendTextVisibleSignal(this EButton button, bool isVisible)
- {
- button.SignalEmit(isVisible ? ThemeConstants.Button.Signals.TextVisibleState : ThemeConstants.Button.Signals.TextHiddenState, ThemeConstants.Button.Signals.ElementaryCode);
- }
-
- public static EButton SetDefaultStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.Default;
- return button;
- }
-
- public static EButton SetBottomStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.Bottom;
- return button;
- }
-
- public static EButton SetPopupStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.Popup;
- return button;
- }
-
- public static EButton SetNavigationTitleRightStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.NavigationTitleRight;
- return button;
- }
-
- public static EButton SetNavigationTitleLeftStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.NavigationTitleLeft;
- return button;
- }
-
- public static EButton SetNavigationBackStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.NavigationBack;
- return button;
- }
-
- public static EButton SetNavigationDrawerStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.NavigationDrawers;
- return button;
- }
-
- public static EButton SetTransparentStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.Transparent;
- return button;
- }
-
- public static EButton SetWatchPopupRightStyle(this EButton button)
- {
- if (DeviceInfo.Idiom != DeviceIdiom.Watch)
- {
- Log.Error($"ToWatchPopupRightStyleButton is only supported on DeviceIdiom.Watch : {0}", DeviceInfo.Idiom);
- return button;
- }
- button.Style = ThemeConstants.Button.Styles.Watch.PopupRight;
- return button;
- }
-
- public static EButton SetWatchPopupLeftStyle(this EButton button)
- {
- if (DeviceInfo.Idiom != DeviceIdiom.Watch)
- {
- Log.Error($"WatchPopupLeftStyleButton is only supported on DeviceIdiom.Watch : {0}", DeviceInfo.Idiom);
- return button;
- }
- button.Style = ThemeConstants.Button.Styles.Watch.PopupLeft;
- return button;
- }
-
- public static EButton SetWatchTextStyle(this EButton button)
- {
- if (DeviceInfo.Idiom != DeviceIdiom.Watch)
- {
- Log.Error($"ToWatchPopupRightStyleButton is only supported on DeviceIdiom.Watch : {0}", DeviceInfo.Idiom);
- return button;
- }
- button.Style = ThemeConstants.Button.Styles.Watch.Text;
- return button;
- }
-
- public static bool SetIconPart(this EButton button, EvasObject content, bool preserveOldContent = false)
- {
- return button.SetPartContent(ThemeConstants.Button.Parts.Icon, content, preserveOldContent);
- }
-
- public static EButton SetEditFieldClearStyle(this EButton button)
- {
- button.Style = ThemeConstants.Button.Styles.EditFieldClear;
- return button;
- }
-
- public static EColor GetIconColor(this EButton button)
- {
- var ret = EColor.Default;
- if (button == null)
- return ret;
-
- ret = button.GetPartColor(ThemeConstants.Button.ColorClass.Icon);
- return ret;
- }
-
- public static void SetIconColor(this EButton button, EColor color)
- {
- if (button == null)
- return;
-
- button.SetPartColor(ThemeConstants.Button.ColorClass.Icon, color);
- button.SetPartColor(ThemeConstants.Button.ColorClass.IconPressed, color);
- }
-
- public static void SetEffectColor(this EButton button, EColor color)
- {
- if (button == null)
- return;
-
- button.SetPartColor(ThemeConstants.Button.ColorClass.Effect, color);
- button.SetPartColor(ThemeConstants.Button.ColorClass.EffectPressed, color);
- }
-
- #endregion
-
- #region Popup
- public static Popup SetWatchCircleStyle(this Popup popup)
- {
- if (DeviceInfo.Idiom != DeviceIdiom.Watch)
- {
- Log.Error($"WatchCircleStylePopup is only supported on DeviceIdiom.Watch : {0}", DeviceInfo.Idiom);
- return popup;
- }
- popup.Style = ThemeConstants.Popup.Styles.Watch.Circle;
- return popup;
- }
-
- public static void SetTitleColor(this Popup popup, EColor color)
- {
- popup.SetPartColor(DeviceInfo.Idiom == DeviceIdiom.TV ? ThemeConstants.Popup.ColorClass.TV.Title : ThemeConstants.Popup.ColorClass.Title, color);
- }
-
- public static void SetTitleBackgroundColor(this Popup popup, EColor color)
- {
- popup.SetPartColor(ThemeConstants.Popup.ColorClass.TitleBackground, color);
- }
-
- public static void SetContentBackgroundColor(this Popup popup, EColor color)
- {
- popup.SetPartColor(ThemeConstants.Popup.ColorClass.ContentBackground, color);
- }
-
- public static bool SetTitleTextPart(this Popup popup, string title)
- {
- return popup.SetPartText(ThemeConstants.Popup.Parts.Title, title);
- }
-
- public static bool SetButton1Part(this Popup popup, EvasObject content, bool preserveOldContent = false)
- {
- return popup.SetPartContent(ThemeConstants.Popup.Parts.Button1, content, preserveOldContent);
- }
-
- public static bool SetButton2Part(this Popup popup, EvasObject content, bool preserveOldContent = false)
- {
- return popup.SetPartContent(ThemeConstants.Popup.Parts.Button2, content, preserveOldContent);
- }
-
- public static bool SetButton3Part(this Popup popup, EvasObject content, bool preserveOldContent = false)
- {
- return popup.SetPartContent(ThemeConstants.Popup.Parts.Button3, content, preserveOldContent);
- }
- #endregion
-
- #region ProgressBar
- public static EProgressBar SetSmallStyle(this EProgressBar progressBar)
- {
- progressBar.Style = ThemeConstants.ProgressBar.Styles.Small;
- return progressBar;
- }
-
- public static EProgressBar SetLargeStyle(this EProgressBar progressBar)
- {
- progressBar.Style = ThemeConstants.ProgressBar.Styles.Large;
- return progressBar;
- }
- #endregion
-
- #region Check
-
- public static void SetOnColors(this Check check, EColor color)
- {
- foreach (string s in check.GetColorParts())
- {
- check.SetPartColor(s, color);
- }
- }
-
- public static void DeleteOnColors(this Check check)
- {
- foreach (string s in check.GetColorEdjeParts())
- {
- check.EdjeObject.DeleteColorClass(s);
- }
- }
-
- public static string[] GetColorParts(this Check check)
- {
- if (DeviceInfo.Idiom == DeviceIdiom.Watch)
- {
- if (check.Style == ThemeConstants.Check.Styles.Toggle)
- {
- return new string[] { ThemeConstants.Check.ColorClass.Watch.OuterBackgroundOn };
- }
- else
- {
- return new string[] {
- ThemeConstants.Check.ColorClass.Watch.OuterBackgroundOn,
- ThemeConstants.Check.ColorClass.Watch.OuterBackgroundOnPressed,
- ThemeConstants.Check.ColorClass.Watch.CheckOn,
- ThemeConstants.Check.ColorClass.Watch.CheckOnPressed
- };
- }
- }
- else if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- if (check.Style == ThemeConstants.Check.Styles.Toggle)
- {
- return new string[] { ThemeConstants.Check.ColorClass.TV.SliderOn, ThemeConstants.Check.ColorClass.TV.SliderFocusedOn };
- }
- else
- {
- return new string[] {
- ThemeConstants.Check.ColorClass.TV.SliderOn,
- ThemeConstants.Check.ColorClass.TV.SliderFocusedOn,
- };
- }
- }
- else
- {
- if (check.Style == ThemeConstants.Check.Styles.Toggle)
- {
- return new string[] { ThemeConstants.Check.ColorClass.BackgroundOn };
- }
- else
- {
- return new string[] { ThemeConstants.Check.ColorClass.BackgroundOn, ThemeConstants.Check.ColorClass.Stroke };
- }
- }
- }
-
- public static string[] GetColorEdjeParts(this Check check)
- {
- string[] ret = check.GetColorParts();
-
- for (int i = 0; i < ret.Length; i++)
- {
- ret[i] = check.ClassName.ToLower().Replace("elm_", "", StringComparison.Ordinal) + "/" + ret[i];
- }
- return ret;
- }
- #endregion
-
- #region NaviItem
- public static void SetTitle(this NaviItem item, string text)
- {
- item.SetPartText(ThemeConstants.NaviItem.Parts.Title, text);
- }
-
- public static void SetBackButton(this NaviItem item, EvasObject content, bool preserveOldContent = false)
- {
- item.SetPartContent(ThemeConstants.NaviItem.Parts.BackButton, content, preserveOldContent);
- }
-
- public static void SetLeftToolbarButton(this NaviItem item, EvasObject content, bool preserveOldContent = false)
- {
- item.SetPartContent(ThemeConstants.NaviItem.Parts.LeftToolbarButton, content, preserveOldContent);
- }
-
- public static void SetRightToolbarButton(this NaviItem item, EvasObject content, bool preserveOldContent = false)
- {
- item.SetPartContent(ThemeConstants.NaviItem.Parts.RightToolbarButton, content, preserveOldContent);
- }
-
- public static void SetNavigationBar(this NaviItem item, EvasObject content, bool preserveOldContent = false)
- {
- item.SetPartContent(ThemeConstants.NaviItem.Parts.NavigationBar, content, preserveOldContent);
- }
-
- public static NaviItem SetNavigationBarStyle(this NaviItem item)
- {
- item.Style = ThemeConstants.NaviItem.Styles.NavigationBar;
- return item;
- }
-
- public static NaviItem SetTabBarStyle(this NaviItem item)
- {
- if (DeviceInfo.Idiom == DeviceIdiom.TV)
- {
- //According to TV UX Guideline, item style should be set to "tabbar" in case of TabbedPage only for TV profile.
- item.Style = ThemeConstants.NaviItem.Styles.TV.TabBar;
- }
- else
- {
- item.Style = ThemeConstants.NaviItem.Styles.Default;
- }
- return item;
- }
- #endregion
-
- #region Toolbar
- public static EToolbar SetNavigationBarStyle(this EToolbar toolbar)
- {
- toolbar.Style = ThemeConstants.Toolbar.Styles.NavigationBar;
- return toolbar;
- }
-
- public static EToolbar SetTVTabBarWithTitleStyle(this EToolbar toolbar)
- {
- if (DeviceInfo.Idiom != DeviceIdiom.TV)
- {
- Log.Error($"TabBarWithTitleStyle is only supported on DeviceIdiom.TV : {0}", DeviceInfo.Idiom);
- return toolbar;
- }
- toolbar.Style = ThemeConstants.Toolbar.Styles.TV.TabbarWithTitle;
- return toolbar;
- }
- #endregion
-
- #region ToolbarItem
- public static void SetIconPart(this EToolbarItem item, EvasObject content, bool preserveOldContent = false)
- {
- item.SetPartContent(ThemeConstants.ToolbarItem.Parts.Icon, content, preserveOldContent);
- }
-
- public static void SetBackgroundColor(this EToolbarItem item, EColor color)
- {
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Background, color);
- }
-
- public static void SetUnderlineColor(this EToolbarItem item, EColor color)
- {
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Underline, color);
- }
-
- public static void SetTextColor(this EToolbarItem item, EColor color)
- {
- if (string.IsNullOrEmpty(item.Icon))
- {
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Text, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextPressed, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextSelected, color);
- }
- else
- {
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIcon, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconPressed, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconSelected, color);
- }
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Underline, color);
- }
-
- public static void SetSelectedTabColor(this EToolbarItem item, EColor color)
- {
- if (string.IsNullOrEmpty(item.Icon))
- {
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextSelected, color);
- }
- else
- {
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconSelected, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.IconSelected, color);
- }
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Underline, color);
- }
-
- public static void SetUnselectedTabColor(this EToolbarItem item, EColor color)
- {
- if (string.IsNullOrEmpty(item.Icon))
- {
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Text, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextPressed, color);
- }
- else
- {
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIcon, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconPressed, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.Icon, color);
- item.SetPartColor(ThemeConstants.ToolbarItem.ColorClass.IconPressed, color);
- }
- }
-
- public static void DeleteBackgroundColor(this EToolbarItem item)
- {
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Background);
- }
-
- public static void DeleteUnderlineColor(this EToolbarItem item)
- {
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Underline);
- }
-
- public static void DeleteTextColor(this EToolbarItem item)
- {
- if (string.IsNullOrEmpty(item.Icon))
- {
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Text);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextPressed);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextSelected);
- }
- else
- {
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIcon);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconPressed);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconSelected);
- }
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Underline);
- }
-
- public static void DeleteSelectedTabColor(this EToolbarItem item)
- {
- if (string.IsNullOrEmpty(item.Icon))
- {
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextSelected);
- }
- else
- {
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconSelected);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.IconSelected);
- }
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Underline);
- }
-
- public static void DeleteUnselectedTabColor(this EToolbarItem item)
- {
- if (string.IsNullOrEmpty(item.Icon))
- {
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Text);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextPressed);
- }
- else
- {
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIcon);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.TextUnderIconPressed);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.Icon);
- item.DeletePartColor(ThemeConstants.ToolbarItem.ColorClass.IconPressed);
- }
- }
-
- #endregion
-
- #region Background
- public static bool SetOverlayPart(this Background bg, EvasObject content, bool preserveOldContent = false)
- {
- return bg.SetPartContent(ThemeConstants.Background.Parts.Overlay, content, preserveOldContent);
- }
- #endregion
-
- #region Panes
- public static bool SetLeftPart(this Panes panes, EvasObject content, bool preserveOldContent = false)
- {
- return panes.SetPartContent(ThemeConstants.Panes.Parts.Left, content, preserveOldContent);
- }
-
- public static bool SetRightPart(this Panes panes, EvasObject content, bool preserveOldContent = false)
- {
- return panes.SetPartContent(ThemeConstants.Panes.Parts.Right, content, preserveOldContent);
- }
- #endregion
-
- #region Cell
- public static void SendSignalToItem(this Cell cell, GenListItem item)
- {
- // This is only required for TV profile.
- if (DeviceInfo.Idiom != DeviceIdiom.TV)
- return;
-
- if (cell is ImageCell)
- {
- item.EmitSignal(ThemeConstants.GenListItem.Signals.TV.SinglelineIconTextTheme, "");
- }
- else if (cell is SwitchCell)
- {
- item.EmitSignal(ThemeConstants.GenListItem.Signals.TV.SinglelineTextIconTheme, "");
- }
- }
- #endregion
-
- #region CellRenderer
- public static string GetTextCellRendererStyle()
- {
- return DeviceInfo.Idiom == DeviceIdiom.TV ? ThemeConstants.GenItemClass.Styles.Default : ThemeConstants.GenItemClass.Styles.DoubleLabel;
- }
-
- public static string GetTextCellGroupModeStyle(bool isGroupMode)
- {
- return isGroupMode ? ThemeConstants.GenItemClass.Styles.GroupIndex : GetTextCellRendererStyle();
- }
-
- public static string GetMainPart(this CellRenderer cell)
- {
- switch (cell.Style)
- {
- default:
- return ThemeConstants.GenItemClass.Parts.Text;
- }
- }
-
- public static string GetDetailPart(this TextCellRenderer textCell)
- {
- // TextCell.Detail property is not supported on TV profile due to UX limitation.
- switch (textCell.Style)
- {
- case ThemeConstants.GenItemClass.Styles.Watch.TwoText1Icon1:
- case ThemeConstants.GenItemClass.Styles.Watch.Icon2Text:
- return ThemeConstants.GenItemClass.Parts.Watch.Text;
- case ThemeConstants.GenItemClass.Styles.GroupIndex:
- return textCell is SectionCellRenderer ? ThemeConstants.GenItemClass.Parts.Ignore : ThemeConstants.GenItemClass.Parts.EndText;
- default:
- return ThemeConstants.GenItemClass.Parts.SubText;
- }
- }
-
- public static string GetSwitchCellRendererStyle()
- {
- return DeviceInfo.Idiom == DeviceIdiom.Watch ? ThemeConstants.GenItemClass.Styles.Watch.Text1Icon1 : ThemeConstants.GenItemClass.Styles.Default;
- }
-
- public static string GetSwitchPart(this SwitchCellRenderer switchCell)
- {
- return DeviceInfo.Idiom == DeviceIdiom.Watch ? ThemeConstants.GenItemClass.Parts.Watch.Icon : ThemeConstants.GenItemClass.Parts.End;
- }
-
- public static int GetDefaultHeightPixel(this EntryCellRenderer entryCell)
- {
- return Forms.ConvertToScaledPixel(ThemeConstants.EntryCell.Resources.DefaultHeight);
- }
-
- public static string GetImageCellRendererStyle()
- {
- return DeviceInfo.Idiom == DeviceIdiom.Watch ? ThemeConstants.GenItemClass.Styles.Watch.Icon2Text : DeviceInfo.Idiom == DeviceIdiom.TV ? ThemeConstants.GenItemClass.Styles.Default : ThemeConstants.GenItemClass.Styles.DoubleLabel;
- }
-
- public static string GetImagePart(this ImageCellRenderer imageCell)
- {
- return DeviceInfo.Idiom == DeviceIdiom.Watch ? ThemeConstants.GenItemClass.Parts.Watch.Icon : ThemeConstants.GenItemClass.Parts.Icon;
- }
-
- public static int GetDefaultHeightPixel(this ImageCellRenderer imageCell)
- {
- return Forms.ConvertToScaledPixel(ThemeConstants.ImageCell.Resources.DefaultHeight);
- }
-
- public static string GetViewCellRendererStyle()
- {
- return ThemeConstants.GenItemClass.Styles.Full;
- }
-
- public static string GetMainContentPart(this ViewCellRenderer viewCell)
- {
- return ThemeConstants.GenItemClass.Parts.Content;
- }
- #endregion
-
- #region GenItemClass
- //public static string GetMainPart()
- #endregion
-
- #region GenList
- public static GenList SetSolidStyle(this GenList list)
- {
- list.Style = ThemeConstants.GenList.Styles.Solid;
- return list;
- }
- #endregion
-
- #region GenListItem
- public static void SetBottomlineColor(this GenListItem item, EColor color)
- {
- item.SetPartColor(ThemeConstants.GenListItem.ColorClass.BottomLine, color);
- }
-
- public static void SetBackgroundColor(this GenListItem item, EColor color)
- {
- item.SetPartColor(ThemeConstants.GenListItem.ColorClass.Background, color);
- }
-
- public static void DeleteBottomlineColor(this GenListItem item)
- {
- item.DeletePartColor(ThemeConstants.GenListItem.ColorClass.BottomLine);
- }
-
- public static void DeleteBackgroundColor(this GenListItem item)
- {
- item.DeletePartColor(ThemeConstants.GenListItem.ColorClass.Background);
- }
- #endregion
-
- #region Radio
- public static ESize GetTextBlockFormattedSize(this Radio radio)
- {
- return radio.EdjeObject[ThemeConstants.Common.Parts.Text].TextBlockFormattedSize;
- }
-
- public static void SetTextBlockStyle(this Radio radio, string style)
- {
- var textBlock = radio.EdjeObject[ThemeConstants.Common.Parts.Text];
- if (textBlock != null)
- {
- textBlock.TextStyle = style;
- }
- }
-
- public static void SendTextVisibleSignal(this Radio radio, bool isVisible)
- {
- radio.SignalEmit(isVisible ? ThemeConstants.Radio.Signals.TextVisibleState : ThemeConstants.Radio.Signals.TextHiddenState, ThemeConstants.Radio.Signals.ElementaryCode);
- }
- #endregion
-
- #region Slider
- public static EColor GetBarColor(this ESlider slider)
- {
- return slider.GetPartColor(ThemeConstants.Slider.ColorClass.Bar);
- }
-
- public static void SetBarColor(this ESlider slider, EColor color)
- {
- slider.SetPartColor(ThemeConstants.Slider.ColorClass.Bar, color);
- slider.SetPartColor(ThemeConstants.Slider.ColorClass.BarPressed, color);
- }
-
- public static EColor GetBackgroundColor(this ESlider slider)
- {
- return slider.GetPartColor(ThemeConstants.Slider.ColorClass.Background);
- }
-
- public static void SetBackgroundColor(this ESlider slider, EColor color)
- {
- slider.SetPartColor(ThemeConstants.Slider.ColorClass.Background, color);
- }
-
- public static EColor GetHandlerColor(this ESlider slider)
- {
- return slider.GetPartColor(ThemeConstants.Slider.ColorClass.Handler);
- }
-
- public static void SetHandlerColor(this ESlider slider, EColor color)
- {
- slider.SetPartColor(ThemeConstants.Slider.ColorClass.Handler, color);
- slider.SetPartColor(ThemeConstants.Slider.ColorClass.HandlerPressed, color);
- }
- #endregion
-
- #region Index
- public static Index SetStyledIndex(this Index index)
- {
- index.Style = DeviceInfo.Idiom == DeviceIdiom.Watch ? ThemeConstants.Index.Styles.Circle : ThemeConstants.Index.Styles.PageControl;
- return index;
- }
- #endregion
-
- #region IndexItem
- public static void SetIndexItemStyle(this IndexItem item, int itemCount, int offset, int evenMiddleItem, int oddMiddleItem)
- {
- string style;
- int position;
-
- if (itemCount % 2 == 0) //Item count is even.
- {
- position = evenMiddleItem - itemCount / 2 + offset;
- style = ThemeConstants.IndexItem.Styles.EvenItemPrefix + position;
- }
- else //Item count is odd.
- {
- position = oddMiddleItem - itemCount / 2 + offset;
- style = ThemeConstants.IndexItem.Styles.OddItemPrefix + position;
- }
- item.Style = style;
- }
- #endregion
-
- #region CircleSpinner
- public static bool SetTitleTextPart(this CircleSpinner spinner, string title)
- {
- return spinner.SetPartText(ThemeConstants.Common.Parts.Text, title);
- }
- #endregion
-
- #region BaseScale
- public static double GetBaseScale(string deviceType)
- {
- if (deviceType.StartsWith("Mobile"))
- {
- return ThemeConstants.Common.Resource.Mobile.BaseScale;
- }
- else if (deviceType.StartsWith("TV"))
- {
- return ThemeConstants.Common.Resource.TV.BaseScale;
- }
- else if (deviceType.StartsWith("Wearable"))
- {
- return ThemeConstants.Common.Resource.Watch.BaseScale;
- }
- else if (deviceType.StartsWith("Refrigerator"))
- {
- return ThemeConstants.Common.Resource.Refrigerator.BaseScale;
- }
- else if (deviceType.StartsWith("TizenIOT"))
- {
- return ThemeConstants.Common.Resource.Iot.BaseScale;
- }
- return 1.0;
- }
- #endregion
-
- #region ShellNavBar
- static double s_shellNavBarDefaultHeight = -1;
- public static double GetDefaultHeight(this ShellNavBar navBar)
- {
- if (s_shellNavBarDefaultHeight > 0)
- return s_shellNavBarDefaultHeight;
- return s_shellNavBarDefaultHeight = CalculateDoubleScaledSizeInLargeScreen(70);
- }
-
- static double s_shellNavBarDefaultMenuSize = -1;
- public static double GetDefaultMenuSize(this ShellNavBar navBar)
- {
- if (s_shellNavBarDefaultMenuSize > 0)
- return s_shellNavBarDefaultMenuSize;
- return s_shellNavBarDefaultMenuSize = CalculateDoubleScaledSizeInLargeScreen(DeviceInfo.Idiom == DeviceIdiom.TV ? 70 : 40);
- }
-
- static double s_shellNavBarDefaultMargin = -1;
- public static double GetDefaultMargin(this ShellNavBar navBar)
- {
- if (s_shellNavBarDefaultMargin > 0)
- return s_shellNavBarDefaultMargin;
- return s_shellNavBarDefaultMargin = CalculateDoubleScaledSizeInLargeScreen(10);
- }
- static double s_shellNavBarTitleFontSize = -1;
- public static double GetDefaultTitleFontSize(this ShellNavBar navBar)
- {
- if (s_shellNavBarTitleFontSize > 0)
- return s_shellNavBarTitleFontSize;
- return s_shellNavBarTitleFontSize = CalculateDoubleScaledSizeInLargeScreen(23);
- }
- #endregion
-
- #region INavigationView
-
- static double s_navigationViewFlyoutItemHeight = -1;
- public static double GetFlyoutItemHeight(this INavigationView nav)
- {
- if (s_navigationViewFlyoutItemHeight > 0)
- return s_navigationViewFlyoutItemHeight;
- return s_navigationViewFlyoutItemHeight = CalculateDoubleScaledSizeInLargeScreen(60);
- }
-
- static double s_navigationViewFlyoutItemWidth = -1;
- public static double GetFlyoutItemWidth(this INavigationView nav)
- {
- if (s_navigationViewFlyoutItemWidth > 0)
- return s_navigationViewFlyoutItemWidth;
- return s_navigationViewFlyoutItemWidth = CalculateDoubleScaledSizeInLargeScreen(200);
- }
-
- static double s_navigationViewFlyoutIconColumnSize = -1;
- public static double GetFlyoutIconColumnSize(this INavigationView nav)
- {
- if (s_navigationViewFlyoutIconColumnSize > 0)
- return s_navigationViewFlyoutIconColumnSize;
- return s_navigationViewFlyoutIconColumnSize = CalculateDoubleScaledSizeInLargeScreen(40);
- }
-
- static double s_navigationViewFlyoutIconSize = -1;
- public static double GetFlyoutIconSize(this INavigationView nav)
- {
- if (s_navigationViewFlyoutIconSize > 0)
- return s_navigationViewFlyoutIconSize;
- return s_navigationViewFlyoutIconSize = CalculateDoubleScaledSizeInLargeScreen(25);
- }
-
- static double s_navigationViewFlyoutMargin = -1;
- public static double GetFlyoutMargin(this INavigationView nav)
- {
- if (s_navigationViewFlyoutMargin > 0)
- return s_navigationViewFlyoutMargin;
- return s_navigationViewFlyoutMargin = CalculateDoubleScaledSizeInLargeScreen(10);
- }
-
- static double s_navigationViewFlyoutItemFontSize = -1;
- public static double GetFlyoutItemFontSize(this INavigationView nav)
- {
- if (s_navigationViewFlyoutItemFontSize > 0)
- return s_navigationViewFlyoutItemFontSize;
- return s_navigationViewFlyoutItemFontSize = CalculateDoubleScaledSizeInLargeScreen(25);
- }
-
- public static Graphics.Color GetTvFlyoutItemDefaultColor(this INavigationView nav)
- {
- return new Graphics.Color(0f);
- }
-
- public static Graphics.Color GetTvFlyoutItemFocusedColor(this INavigationView nav)
- {
- return new Graphics.Color(0.95f);
- }
-
- public static Graphics.Color GetTvFlyoutItemTextDefaultColor(this INavigationView nav)
- {
- return Graphics.Color.FromRgb(255, 255, 255);
- }
-
- public static Graphics.Color GetTvFlyoutItemTextFocusedColor(this INavigationView nav)
- {
- return Graphics.Color.FromRgb(0, 0, 0);
- }
-
- #endregion
-
- #region INavigationDrawer
-
- static double s_navigationDrawerRatio = -1;
- public static double GetFlyoutRatio(this INavigationDrawer drawer, int width, int height)
- {
- return s_navigationDrawerRatio = (width > height) ? 0.4 : 0.83;
- }
-
- public static double GetFlyoutCollapseRatio(this INavigationDrawer drawer)
- {
- return 0.05;
- }
- #endregion
-
- #region ShellMoreToolbar
-
- static double s_shellMoreToolBarIconPadding = -1;
- public static double GetIconPadding(this ShellMoreToolbar self)
- {
- if (s_shellMoreToolBarIconPadding > 0)
- return s_shellMoreToolBarIconPadding;
- return s_shellMoreToolBarIconPadding = CalculateDoubleScaledSizeInLargeScreen(15);
- }
-
- static double s_shellMoreToolBarIconSize = -1;
- public static double GetIconSize(this ShellMoreToolbar self)
- {
- if (s_shellMoreToolBarIconSize > 0)
- return s_shellMoreToolBarIconSize;
- return s_shellMoreToolBarIconSize = CalculateDoubleScaledSizeInLargeScreen(30);
- }
-
- #endregion
-
- public static double GetPhysicalPortraitSizeInDP()
- {
- var screenSize = Forms.PhysicalScreenSize;
- return Math.Min(screenSize.Width, screenSize.Height);
- }
-
- static double CalculateDoubleScaledSizeInLargeScreen(double size)
- {
- if (Forms.DisplayResolutionUnit.UseVP)
- return size;
-
- if (!Forms.DisplayResolutionUnit.UseDeviceScale && GetPhysicalPortraitSizeInDP() > 1000)
- {
- size *= 2.5;
- }
-
- if (!Forms.DisplayResolutionUnit.UseDP)
- {
- size = Forms.ConvertToPixel(size);
- }
- return size;
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/Compatibility/Core/src/Tizen/ViewInitializedEventArgs.cs b/src/Compatibility/Core/src/Tizen/ViewInitializedEventArgs.cs
index ad3fb1ecd10e..e5a9b48cdc5f 100644
--- a/src/Compatibility/Core/src/Tizen/ViewInitializedEventArgs.cs
+++ b/src/Compatibility/Core/src/Tizen/ViewInitializedEventArgs.cs
@@ -1,11 +1,11 @@
using System;
-using ElmSharp;
+using NView = Tizen.NUI.BaseComponents.View;
namespace Microsoft.Maui.Controls.Compatibility
{
public class ViewInitializedEventArgs : EventArgs
{
- public EvasObject NativeView
+ public NView NativeView
{
get;
internal set;
diff --git a/src/Controls/samples/Controls.Sample/Controls/FocusEffect/FocusPlatformEffect.cs b/src/Controls/samples/Controls.Sample/Controls/FocusEffect/FocusPlatformEffect.cs
index 5af77c22fb7b..382dc7ca6270 100644
--- a/src/Controls/samples/Controls.Sample/Controls/FocusEffect/FocusPlatformEffect.cs
+++ b/src/Controls/samples/Controls.Sample/Controls/FocusEffect/FocusPlatformEffect.cs
@@ -16,7 +16,7 @@ public class FocusPlatformEffect : PlatformEffect
#elif __IOS__
UIKit.UIColor backgroundColor;
#elif TIZEN
- ElmSharp.Color backgroundColor;
+ Tizen.NUI.Color backgroundColor;
#endif
public FocusPlatformEffect()
@@ -36,7 +36,7 @@ protected override void OnAttached()
#elif __IOS__
Control.BackgroundColor = backgroundColor = UIKit.UIColor.FromRGB(204, 153, 255);
#elif TIZEN
- (Control as ElmSharp.Widget).BackgroundColor = backgroundColor = ElmSharp.Color.FromRgb(204, 153, 255);
+ (Control as Tizen.NUI.BaseComponents.View).BackgroundColor = backgroundColor = Tizen.NUI.Color.LightGreen;
#endif
}
catch (Exception ex)
@@ -82,16 +82,13 @@ protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
#elif TIZEN
if (args.PropertyName == "IsFocused")
{
- if (Control is ElmSharp.Widget widget)
+ if (Control.BackgroundColor == backgroundColor)
{
- if (widget.BackgroundColor == backgroundColor)
- {
- widget.BackgroundColor = ElmSharp.Color.White;
- }
- else
- {
- widget.BackgroundColor = backgroundColor;
- }
+ Control.BackgroundColor = Tizen.NUI.Color.White;
+ }
+ else
+ {
+ Control.BackgroundColor = backgroundColor;
}
}
#endif
diff --git a/src/Controls/samples/Controls.Sample/Controls/SkiaSharpHandlers/SkiaGraphicsViewHandler.cs b/src/Controls/samples/Controls.Sample/Controls/SkiaSharpHandlers/SkiaGraphicsViewHandler.cs
index e68bc29ac096..91aea05027f9 100644
--- a/src/Controls/samples/Controls.Sample/Controls/SkiaSharpHandlers/SkiaGraphicsViewHandler.cs
+++ b/src/Controls/samples/Controls.Sample/Controls/SkiaSharpHandlers/SkiaGraphicsViewHandler.cs
@@ -2,7 +2,9 @@
using Microsoft.Maui;
using Microsoft.Maui.Handlers;
-#if !(NETSTANDARD || !PLATFORM)
+#if TIZEN
+using Tizen.UIExtensions.NUI.GraphicsView;
+#elif !(NETSTANDARD || !PLATFORM)
using Microsoft.Maui.Graphics.Skia.Views;
#else
using SkiaGraphicsView = System.Object;
@@ -27,8 +29,6 @@ protected override SkiaGraphicsView CreatePlatformView()
{
#if __ANDROID__
return new SkiaGraphicsView(Context);
-#elif TIZEN
- return new SkiaGraphicsView(NativeParent);
#else
return new SkiaGraphicsView();
#endif
diff --git a/src/Controls/samples/Controls.Sample/Controls/SkiaSharpHandlers/SkiaShapeViewHandler.cs b/src/Controls/samples/Controls.Sample/Controls/SkiaSharpHandlers/SkiaShapeViewHandler.cs
index 8af2d51fed57..70a5ecac6b94 100644
--- a/src/Controls/samples/Controls.Sample/Controls/SkiaSharpHandlers/SkiaShapeViewHandler.cs
+++ b/src/Controls/samples/Controls.Sample/Controls/SkiaSharpHandlers/SkiaShapeViewHandler.cs
@@ -3,7 +3,9 @@
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Graphics;
-#if !(NETSTANDARD || !PLATFORM)
+#if TIZEN
+using Tizen.UIExtensions.NUI.GraphicsView;
+#elif !(NETSTANDARD || !PLATFORM)
using Microsoft.Maui.Graphics.Skia.Views;
#else
using SkiaGraphicsView = System.Object;
@@ -36,8 +38,6 @@ protected override SkiaGraphicsView CreatePlatformView()
{
#if __ANDROID__
return new SkiaGraphicsView(Context);
-#elif TIZEN
- return new SkiaGraphicsView(NativeParent);
#else
return new SkiaGraphicsView();
#endif
diff --git a/src/Controls/samples/Controls.Sample/MauiProgram.cs b/src/Controls/samples/Controls.Sample/MauiProgram.cs
index f759d00e285e..b58fcfc8d6d0 100644
--- a/src/Controls/samples/Controls.Sample/MauiProgram.cs
+++ b/src/Controls/samples/Controls.Sample/MauiProgram.cs
@@ -39,9 +39,6 @@ public static MauiApp CreateMauiApp()
var appBuilder = MauiApp.CreateBuilder();
appBuilder.UseMauiApp();
-#if TIZEN
- appBuilder.UseMauiCompatibility();
-#endif
var services = appBuilder.Services;
if (UseMauiGraphicsSkia)
diff --git a/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/CellContentFactory.cs b/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/CellContentFactory.cs
new file mode 100644
index 000000000000..1fe3e97fd78f
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/CellContentFactory.cs
@@ -0,0 +1,332 @@
+using Microsoft.Maui.Graphics;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public class SectionCell : TextCell { }
+
+ public class CellContentFactory
+ {
+ public static View CreateContent(object data, BindableObject container = null)
+ {
+ if (data is ImageCell imageCell)
+ {
+ return new CellContentView(imageCell, container)
+ {
+ Content = CreateContent(imageCell)
+ };
+ }
+ else if (data is SectionCell sectionCell)
+ {
+ return new CellContentView(sectionCell, container, false, false)
+ {
+ Content = CreateContent(sectionCell)
+ };
+ }
+ else if (data is EntryCell entryCell)
+ {
+ return new CellContentView(entryCell, container)
+ {
+ Content = CreateContent(entryCell)
+ };
+ }
+ else if (data is TextCell textCell)
+ {
+ return new CellContentView(textCell, container)
+ {
+ Content = CreateContent(textCell)
+ };
+ }
+ else if (data is ViewCell viewCell)
+ {
+ return new CellContentView(viewCell, container, false)
+ {
+ Content = CreateContent(viewCell)
+ };
+ }
+ else if (data is SwitchCell switchCell)
+ {
+ return new CellContentView(switchCell, container)
+ {
+ Content = CreateContent(switchCell)
+ };
+ }
+ else
+ {
+ return new Controls.StackLayout
+ {
+ BackgroundColor = Colors.Red
+ };
+ }
+ }
+
+ static View CreateContent(SectionCell sectionCell)
+ {
+ var text = new Label
+ {
+ HorizontalOptions = LayoutOptions.Fill,
+ VerticalOptions = LayoutOptions.Fill,
+ FontAttributes = FontAttributes.Bold,
+ Margin = new Thickness(10, 0),
+#pragma warning disable CS0612 // Type or member is obsolete
+ FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label))
+#pragma warning restore CS0612 // Type or member is obsolete
+ };
+
+ text.SetBinding(Label.TextProperty, new Binding("Text", source: sectionCell));
+ text.SetBinding(Label.TextColorProperty, new Binding("TextColor", source: sectionCell));
+
+ var layout = new Controls.StackLayout
+ {
+ HorizontalOptions = LayoutOptions.Fill,
+ BackgroundColor = Color.FromArgb("#e3f2fd"),
+ Padding = 5,
+ Children =
+ {
+ text,
+ }
+ };
+ return layout;
+ }
+
+ static View CreateContent(TextCell textcell)
+ {
+ var text = new Label();
+ text.SetBinding(Label.TextProperty, new Binding("Text", source: textcell));
+ text.SetBinding(Label.TextColorProperty, new Binding("TextColor", source: textcell));
+#pragma warning disable CS0612 // Type or member is obsolete
+ text.FontSize = Device.GetNamedSize(NamedSize.Default, typeof(Label));
+#pragma warning restore CS0612 // Type or member is obsolete
+
+ var detail = new Label();
+ detail.SetBinding(Label.TextProperty, new Binding("Detail", source: textcell));
+ detail.SetBinding(Label.TextColorProperty, new Binding("DetailColor", source: textcell));
+#pragma warning disable CS0612 // Type or member is obsolete
+ detail.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
+#pragma warning restore CS0612 // Type or member is obsolete
+ detail.Margin = new Thickness(10, 0, 0, 0);
+
+ var layout = new Controls.StackLayout
+ {
+ Spacing = 0,
+ HorizontalOptions = LayoutOptions.Fill,
+ Margin = new Thickness(10, 5),
+ Children =
+ {
+ text,
+ detail,
+ }
+ };
+ return layout;
+ }
+
+ static View CreateContent(ImageCell imageCell)
+ {
+ var textcell = CreateContent((TextCell)imageCell);
+ textcell.HorizontalOptions = LayoutOptions.Fill;
+ var layout = new Controls.Grid
+ {
+ HorizontalOptions = LayoutOptions.Fill,
+ ColumnDefinitions =
+ {
+ new ColumnDefinition(GridLength.Auto),
+ new ColumnDefinition(GridLength.Star)
+ },
+ Margin = new Thickness(10, 5),
+ };
+ var img = new Image
+ {
+ Aspect = Aspect.AspectFit,
+ };
+ img.SetBinding(Image.SourceProperty, new Binding("ImageSource", source: imageCell));
+ layout.Add(img, 0, 0);
+ layout.Add(textcell, 1, 0);
+ return layout;
+ }
+
+ static View CreateContent(EntryCell entryCell)
+ {
+ var entry = new Entry();
+ entry.SetBinding(Entry.TextProperty, new Binding("Text", BindingMode.TwoWay, source: entryCell));
+ entry.SetBinding(Entry.PlaceholderProperty, new Binding("Placeholder", source: entryCell));
+ entry.SetBinding(InputView.KeyboardProperty, new Binding("Keyboard", source: entryCell));
+ entry.SetBinding(Entry.HorizontalTextAlignmentProperty, new Binding("HorizontalTextAlignment", source: entryCell));
+ entry.SetBinding(Entry.VerticalTextAlignmentProperty, new Binding("VerticalTextAlignment", source: entryCell));
+
+ var label = new Label();
+ label.SetBinding(Label.TextProperty, new Binding("Label", source: entryCell));
+ label.SetBinding(Label.TextColorProperty, new Binding("LabelColor", source: entryCell));
+#pragma warning disable CS0612 // Type or member is obsolete
+ label.FontSize = Device.GetNamedSize(NamedSize.Micro, typeof(Label));
+#pragma warning restore CS0612 // Type or member is obsolete
+ var layout = new Controls.StackLayout
+ {
+ Margin = new Thickness(10, 5),
+ HorizontalOptions = LayoutOptions.Fill,
+ Children =
+ {
+ label,
+ entry,
+ }
+ };
+
+ return layout;
+ }
+
+ static View CreateContent(SwitchCell switchCell)
+ {
+#pragma warning disable CS0618
+ var text = new Label
+ {
+ VerticalTextAlignment = TextAlignment.Center,
+ HorizontalOptions = LayoutOptions.StartAndExpand,
+ };
+#pragma warning restore CS0618
+ text.SetBinding(Label.TextProperty, new Binding("Text", source: switchCell));
+
+ var sw = new Switch
+ {
+ HorizontalOptions = LayoutOptions.End
+ };
+ sw.SetBinding(Switch.IsToggledProperty, new Binding("On", BindingMode.TwoWay, source: switchCell));
+ sw.SetBinding(Switch.OnColorProperty, new Binding("OnColor", source: switchCell));
+
+ var layout = new Controls.StackLayout
+ {
+ Margin = new Thickness(10, 5),
+ HorizontalOptions = LayoutOptions.Fill,
+ Orientation = StackOrientation.Horizontal,
+ Children =
+ {
+ text,
+ sw
+ }
+ };
+ return layout;
+ }
+
+ static View CreateContent(ViewCell viewCell)
+ {
+ return viewCell.View;
+ }
+
+ class CellContentView : ContentView
+ {
+ BindableObject _target;
+ public CellContentView(BindableObject target, BindableObject container = null, bool hasVisualState = true, bool hasSeparator = true)
+ {
+ BackgroundColor = Colors.Transparent;
+ var separator = new BoxView
+ {
+ Margin = new Thickness(10, 0),
+ Color = Color.FromRgb(120, 120, 120),
+ HeightRequest = 1,
+ };
+
+ var content = new ContentPresenter
+ {
+ VerticalOptions = LayoutOptions.Fill,
+ HorizontalOptions = LayoutOptions.Fill
+ };
+
+
+ if (container is ListView listview)
+ {
+ if (listview.SeparatorVisibility == SeparatorVisibility.None)
+ {
+ separator.IsVisible = false;
+ }
+ if (!listview.SeparatorColor.IsDefault())
+ {
+ separator.Color = listview.SeparatorColor;
+ }
+ if (listview.RowHeight > 0 && !listview.HasUnevenRows)
+ {
+ content.HeightRequest = listview.RowHeight;
+ }
+ }
+
+ if (separator.IsVisible && !hasSeparator)
+ {
+ separator.IsVisible = false;
+ }
+
+
+ ControlTemplate = new ControlTemplate(() =>
+ {
+ var layout = new Controls.StackLayout
+ {
+ Spacing = 0,
+ VerticalOptions = LayoutOptions.Fill,
+ HorizontalOptions = LayoutOptions.Fill,
+ Children =
+ {
+ content,
+ separator
+ }
+ };
+ return layout;
+ });
+ _target = target;
+ if (hasVisualState)
+ SetupVisualState();
+ }
+
+ void SetupVisualState()
+ {
+ VisualStateGroup stateGroup = new VisualStateGroup();
+
+ var selected = new VisualState
+ {
+ Name = VisualStateManager.CommonStates.Selected,
+ TargetType = typeof(View),
+ Setters =
+ {
+ new Setter
+ {
+ Property = View.BackgroundColorProperty,
+ Value = Color.FromArgb("#f9fbe7"),
+ }
+ }
+ };
+
+ var normal = new VisualState
+ {
+ Name = VisualStateManager.CommonStates.Normal,
+ TargetType = typeof(View),
+ Setters =
+ {
+ new Setter
+ {
+ Property = View.BackgroundColorProperty,
+ Value = Colors.Transparent
+ }
+ }
+ };
+ var focused = new VisualState
+ {
+ Name = VisualStateManager.CommonStates.Focused,
+ TargetType = typeof(View),
+ Setters =
+ {
+ new Setter
+ {
+ Property = View.BackgroundColorProperty,
+ Value = Color.FromArgb("#eeeeeeee")
+ }
+ }
+ };
+
+ stateGroup.States.Add(normal);
+ stateGroup.States.Add(focused);
+ stateGroup.States.Add(selected);
+ VisualStateManager.GetVisualStateGroups(this).Add(stateGroup);
+ }
+
+ protected override void OnBindingContextChanged()
+ {
+ base.OnBindingContextChanged();
+ _target.BindingContext = BindingContext;
+ }
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/CellWrapperTemplate.cs b/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/CellWrapperTemplate.cs
new file mode 100644
index 000000000000..e04a854b0743
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/CellWrapperTemplate.cs
@@ -0,0 +1,40 @@
+using System.Collections.Generic;
+using Microsoft.Maui.Controls.Internals;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public class CellWrapperTemplateSelector : DataTemplateSelector
+ {
+ Dictionary _cache = new Dictionary();
+ DataTemplateSelector _selector;
+ public CellWrapperTemplateSelector(DataTemplateSelector selector)
+ {
+ _selector = selector;
+ }
+ protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
+ {
+ var template = _selector.SelectTemplate(item, container);
+ if (_cache.ContainsKey(template))
+ {
+ return _cache[template];
+ }
+ var wrapper = new CellWrapperTemplate(template, container);
+ _cache[template] = wrapper;
+ return wrapper;
+ }
+ }
+
+ public class CellWrapperTemplate : DataTemplate
+ {
+ BindableObject _container;
+ DataTemplate _sourceTemplate;
+
+ public CellWrapperTemplate(DataTemplate source, BindableObject container = null)
+ {
+ _container = container;
+ _sourceTemplate = source;
+
+ LoadTemplate = () => CellContentFactory.CreateContent(_sourceTemplate.CreateContent(), _container);
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/ListViewAdaptor.cs b/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/ListViewAdaptor.cs
new file mode 100644
index 000000000000..584736c32c34
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/ListViewAdaptor.cs
@@ -0,0 +1,50 @@
+using System.Collections;
+using Microsoft.Maui.Controls.Handlers.Items;
+using TSize = Tizen.UIExtensions.Common.Size;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public class ListViewAdaptor : ItemTemplateAdaptor
+ {
+ new ListView Element { get; set; }
+
+ public ListViewAdaptor(ListView listview, IEnumerable items, DataTemplate template) : base(listview, items, template)
+ {
+ Element = listview;
+ }
+
+ protected override bool IsSelectable => (Element?.SelectionMode ?? ListViewSelectionMode.None) == ListViewSelectionMode.Single;
+
+ public override TSize MeasureItem(double widthConstraint, double heightConstraint)
+ {
+ if (Element.RowHeight > 0)
+ {
+ return new TSize(widthConstraint, Element.RowHeight);
+ }
+ return MeasureItem(0, widthConstraint, heightConstraint);
+ }
+
+ public override TSize MeasureItem(int index, double widthConstraint, double heightConstraint)
+ {
+ if (index < 0 || index >= Element.TemplatedItems.Count)
+ return new TSize(0, 0);
+
+ var cell = Element.TemplatedItems[index];
+ if (cell.RenderHeight > 0)
+ {
+ return new TSize(widthConstraint, cell.RenderHeight);
+ }
+ return base.MeasureItem(index, widthConstraint, heightConstraint);
+ }
+
+ protected override View CreateHeaderView()
+ {
+ return Element.HeaderElement as View;
+ }
+
+ protected override View CreateFooterView()
+ {
+ return Element.FooterElement as View;
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/ListViewRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/ListViewRenderer.cs
new file mode 100644
index 000000000000..89af3c821017
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/ListView/Tizen/ListViewRenderer.cs
@@ -0,0 +1,170 @@
+using System.ComponentModel;
+using System.Linq;
+using Microsoft.Maui.Controls.Handlers.Items;
+using Microsoft.Maui.Controls.Platform;
+using Tizen.NUI;
+using Tizen.UIExtensions.NUI;
+using TCollectionView = Tizen.UIExtensions.NUI.CollectionView;
+using TItemSizingStrategy = Tizen.UIExtensions.NUI.ItemSizingStrategy;
+using TScrollToPosition = Tizen.UIExtensions.Common.ScrollToPosition;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public class ListViewRenderer : ViewRenderer
+ {
+ public static PropertyMapper Mapper =
+ new PropertyMapper(VisualElementRendererMapper);
+
+ public static CommandMapper CommandMapper =
+ new CommandMapper(VisualElementRendererCommandMapper);
+
+ bool _isUpdateFromUI;
+
+ public ListViewRenderer() : base(Mapper, CommandMapper)
+ {
+ AutoPackage = false;
+ }
+
+ protected override void OnElementChanged(ElementChangedEventArgs e)
+ {
+ if (Control == null)
+ {
+ SetNativeControl(new TCollectionView());
+ Control.Scrolled += OnScrolled;
+ }
+ Element.ScrollToRequested += OnScrollToRequested;
+ base.OnElementChanged(e);
+ UpdateLayoutManager(false);
+ UpdateAdaptor(false);
+ }
+
+ protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
+ {
+ base.OnElementPropertyChanged(sender, e);
+ if (e.PropertyName == ListView.ItemsSourceProperty.PropertyName)
+ UpdateItemsSource(false);
+ else if (e.PropertyName == ListView.ItemTemplateProperty.PropertyName)
+ UpdateAdaptor(false);
+ else if (e.PropertyName == ListView.RowHeightProperty.PropertyName)
+ UpdateAdaptor(false);
+ else if (e.PropertyName == ListView.SelectedItemProperty.PropertyName)
+ UpdateSelectedItem();
+ else if (e.PropertyName == ListView.HasUnevenRowsProperty.PropertyName)
+ UpdateLayoutManager(false);
+ else if (e.PropertyName == ListView.SelectionModeProperty.PropertyName)
+ UpdateSelectionMode();
+ else if (e.PropertyName == "HeaderElement")
+ UpdateAdaptor(false);
+ else if (e.PropertyName == "FooterElement")
+ UpdateAdaptor(false);
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ Control.Scrolled -= OnScrolled;
+ Element.ScrollToRequested -= OnScrollToRequested;
+ if (Control.Adaptor is ItemTemplateAdaptor old)
+ {
+ old.SelectionChanged -= OnItemSelectedFromUI;
+ }
+ }
+ base.Dispose(disposing);
+ }
+
+ protected void UpdateAdaptor(bool initialize)
+ {
+ if (!initialize)
+ {
+ if (Control.Adaptor is ItemTemplateAdaptor old)
+ {
+ old.SelectionChanged -= OnItemSelectedFromUI;
+ }
+
+ DataTemplate template;
+ if (Element.ItemTemplate is DataTemplateSelector selector)
+ {
+ template = new CellWrapperTemplateSelector(selector);
+ }
+ else if (Element.ItemTemplate != null)
+ {
+ template = new CellWrapperTemplate(Element.ItemTemplate, Element);
+ }
+ else
+ {
+ template = new CellWrapperTemplate(new DataTemplate(() =>
+ {
+ var label = new TextCell();
+ label.SetBinding(TextCell.TextProperty, new Binding("."));
+ return label;
+ }), Element);
+ }
+ var adaptor = new ListViewAdaptor(Element, Element.ItemsSource, template);
+ Control.Adaptor = adaptor;
+
+ adaptor.SelectionChanged += OnItemSelectedFromUI;
+ }
+ }
+
+ void OnItemSelectedFromUI(object sender, CollectionViewSelectionChangedEventArgs e)
+ {
+ if (e.SelectedItems.Count > 0)
+ {
+ _isUpdateFromUI = true;
+ Element.NotifyRowTapped(Control.Adaptor.GetItemIndex(e.SelectedItems[0]));
+ _isUpdateFromUI = false;
+ }
+ }
+
+ void UpdateItemsSource(bool init)
+ {
+ UpdateAdaptor(init);
+ }
+
+ void UpdateLayoutManager(bool init)
+ {
+ if (init)
+ return;
+ Control.LayoutManager = new LinearLayoutManager(false, Element.HasUnevenRows ? TItemSizingStrategy.MeasureAllItems : TItemSizingStrategy.MeasureFirstItem, 2);
+ }
+
+ void UpdateSelectionMode()
+ {
+ Control.SelectionMode = Element.SelectionMode == ListViewSelectionMode.Single ? CollectionViewSelectionMode.SingleAlways : CollectionViewSelectionMode.None;
+ }
+
+ void UpdateSelectedItem()
+ {
+ if (_isUpdateFromUI)
+ return;
+
+ if (Element.SelectedItem == null)
+ {
+ foreach (var item in Control.SelectedItems.ToList())
+ {
+ Control.RequestItemUnselect(Control.Adaptor.GetItemIndex(item));
+ }
+ }
+ else
+ {
+ Control.RequestItemSelect(Control.Adaptor.GetItemIndex(Element.SelectedItem));
+ }
+ }
+
+ void OnScrolled(object sender, CollectionViewScrolledEventArgs e)
+ {
+ var x = DPExtensions.ConvertToScaledDP(e.HorizontalOffset);
+ var y = DPExtensions.ConvertToScaledDP(e.VerticalOffset);
+ Element.SendScrolled(new ScrolledEventArgs(x, y));
+ }
+
+ void OnScrollToRequested(object sender, ScrollToRequestedEventArgs e)
+ {
+ var scrollArgs = (ITemplatedItemsListScrollToRequestedEventArgs)e;
+
+ var index = Control.Adaptor.GetItemIndex(scrollArgs.Item);
+ Control.ScrollTo(index, (TScrollToPosition)e.Position, e.ShouldAnimate);
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Compatibility/Handlers/TableView/Tizen/TableViewAdaptor.cs b/src/Controls/src/Core/Compatibility/Handlers/TableView/Tizen/TableViewAdaptor.cs
new file mode 100644
index 000000000000..e17c4bcdcec6
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/TableView/Tizen/TableViewAdaptor.cs
@@ -0,0 +1,35 @@
+using System.Collections;
+using Microsoft.Maui.Controls.Handlers.Items;
+using TSize = Tizen.UIExtensions.Common.Size;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public class TableViewAdaptor : ItemTemplateAdaptor
+ {
+ new TableView Element { get; set; }
+
+ public TableViewAdaptor(TableView tableView, IEnumerable items, DataTemplate template) : base(tableView, items, template)
+ {
+ Element = tableView;
+ }
+
+ protected override bool IsSelectable => true;
+
+ public override TSize MeasureItem(double widthConstraint, double heightConstraint)
+ {
+ if (Element.RowHeight > 0)
+ {
+ return new TSize(widthConstraint, Element.RowHeight);
+ }
+ return MeasureItem(0, widthConstraint, heightConstraint);
+ }
+
+ public override TSize MeasureItem(int index, double widthConstraint, double heightConstraint)
+ {
+ if (index < 0 || index >= Count)
+ return new TSize(0, 0);
+
+ return base.MeasureItem(index, widthConstraint, heightConstraint);
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Compatibility/Handlers/TableView/Tizen/TableViewRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/TableView/Tizen/TableViewRenderer.cs
new file mode 100644
index 000000000000..47852e54e772
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/TableView/Tizen/TableViewRenderer.cs
@@ -0,0 +1,122 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.Maui.Controls.Handlers.Items;
+using Microsoft.Maui.Controls.Platform;
+using Tizen.UIExtensions.NUI;
+using Size = Microsoft.Maui.Graphics.Size;
+using TCollectionView = Tizen.UIExtensions.NUI.CollectionView;
+using TItemSizingStrategy = Tizen.UIExtensions.NUI.ItemSizingStrategy;
+using IMeasurable = Tizen.UIExtensions.Common.IMeasurable;
+using TSize = Tizen.UIExtensions.Common.Size;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public class TableViewRenderer : ViewRenderer, IMeasurable
+ {
+ List _items = new List();
+ DataTemplateSelector _dataTemplateSelector = new TableViewTemplateSelector();
+
+ protected override void OnElementChanged(ElementChangedEventArgs e)
+ {
+ if (Control == null)
+ {
+ SetNativeControl(new TCollectionView());
+ Control.SelectionMode = CollectionViewSelectionMode.SingleAlways;
+ }
+
+ if (e.OldElement != null)
+ {
+ e.OldElement.ModelChanged -= OnRootPropertyChanged;
+ }
+
+ if (e.NewElement != null)
+ {
+ e.NewElement.ModelChanged += OnRootPropertyChanged;
+ }
+ base.OnElementChanged(e);
+ Control.LayoutManager = new LinearLayoutManager(false, TItemSizingStrategy.MeasureAllItems);
+ ApplyTableRoot();
+ }
+
+ TSize IMeasurable.Measure(double availableWidth, double availableHeight)
+ {
+ if (Control.Adaptor == null || Control.LayoutManager == null || Control.LayoutManager.GetScrollCanvasSize().Height == 0 || Control.LayoutManager.GetScrollCanvasSize().Width == 0)
+ {
+ var scaled = Devices.DeviceDisplay.MainDisplayInfo.GetScaledScreenSize();
+ var size = new Size(availableWidth, availableHeight);
+ if (size.Width == double.PositiveInfinity)
+ size.Width = scaled.Width;
+ if (size.Height == double.PositiveInfinity)
+ size.Height = scaled.Height;
+ return size.ToPixel();
+ }
+
+ var canvasSize = Control.LayoutManager.GetScrollCanvasSize();
+ canvasSize.Width = Math.Min(canvasSize.Width, availableWidth.ToScaledPixel());
+ canvasSize.Height = Math.Min(canvasSize.Height, availableHeight.ToScaledPixel());
+ return canvasSize;
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ if (Element != null)
+ {
+ Element.ModelChanged -= OnRootPropertyChanged;
+ }
+ }
+
+ base.Dispose(disposing);
+ }
+
+ void ApplyTableRoot()
+ {
+ _items.Clear();
+ foreach (TableSection ts in Element.Root)
+ {
+ if (!string.IsNullOrEmpty(ts.Title))
+ {
+ _items.Add(new SectionCell
+ {
+ Text = ts.Title,
+ TextColor = ts.TextColor,
+ });
+ }
+ foreach (var cell in ts)
+ {
+ _items.Add(cell);
+ }
+ }
+
+ var adaptor = new TableViewAdaptor(Element, _items, _dataTemplateSelector);
+
+ adaptor.SelectionChanged += OnSelected;
+
+ Control.Adaptor = adaptor;
+ }
+
+ void OnSelected(object sender, CollectionViewSelectionChangedEventArgs e)
+ {
+ var selected = e.SelectedItems.FirstOrDefault();
+ if (selected != null && !(selected is SectionCell))
+ {
+ Element.Model.RowSelected(selected);
+ }
+ }
+
+ void OnRootPropertyChanged(object sender, EventArgs e)
+ {
+ ApplyTableRoot();
+ }
+
+ class TableViewTemplateSelector : DataTemplateSelector
+ {
+ protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
+ {
+ return new DataTemplate(() => CellContentFactory.CreateContent(item));
+ }
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Compatibility/Handlers/Tizen/FrameRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Tizen/FrameRenderer.cs
new file mode 100644
index 000000000000..37ac305b95c9
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/Tizen/FrameRenderer.cs
@@ -0,0 +1,294 @@
+#nullable enable
+
+using System.ComponentModel;
+using Microsoft.Maui.Controls.Platform;
+using Microsoft.Maui.Graphics;
+using SkiaSharp;
+using Tizen.UIExtensions.NUI;
+using IMeasurable = Tizen.UIExtensions.Common.IMeasurable;
+using NColor = Tizen.NUI.Color;
+using TColor = Tizen.UIExtensions.Common.Color;
+using TLayoutParamPolicies = Tizen.NUI.BaseComponents.LayoutParamPolicies;
+using TShadow = Tizen.NUI.Shadow;
+using TSize = Tizen.UIExtensions.Common.Size;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public class FrameRenderer : ContentViewGroup, IPlatformViewHandler, IMeasurable
+ {
+ public static IPropertyMapper Mapper
+ = new PropertyMapper(ViewRenderer.VisualElementRendererMapper)
+ {
+ [Frame.HasShadowProperty.PropertyName] = (h, _) => h.UpdateShadow(),
+ [VisualElement.BackgroundColorProperty.PropertyName] = (h, _) => h.UpdateBackgroundColor(),
+ [VisualElement.BackgroundProperty.PropertyName] = (h, _) => h.UpdateBackground(),
+ [Frame.CornerRadiusProperty.PropertyName] = (h, _) => h.UpdateCornerRadius(),
+ [Frame.BorderColorProperty.PropertyName] = (h, _) => h.UpdateBorderColor(),
+ [Microsoft.Maui.Controls.Compatibility.Layout.IsClippedToBoundsProperty.PropertyName] = (h, _) => h.UpdateClippedToBounds(),
+ [Frame.ContentProperty.PropertyName] = (h, _) => h.UpdateContent()
+ };
+
+ public static CommandMapper CommandMapper
+ = new CommandMapper(ViewRenderer.VisualElementRendererCommandMapper);
+
+ bool _disposed;
+
+ SKClipperView _clipperView;
+
+ IMauiContext? _mauiContext;
+ ViewHandlerDelegator _viewHandlerWrapper;
+ IPlatformViewHandler? _contentHandler;
+
+
+ public FrameRenderer() : base(null)
+ {
+ _clipperView = new SKClipperView()
+ {
+ WidthSpecification = TLayoutParamPolicies.MatchParent,
+ HeightSpecification = TLayoutParamPolicies.MatchParent
+ };
+ _clipperView.DrawClippingArea += OnDrawClippingArea;
+
+ Children.Add(_clipperView);
+
+ BorderlineColor = NColor.Transparent;
+ BorderlineWidth = 1.0.ToScaledPixel();
+ _viewHandlerWrapper = new ViewHandlerDelegator(Mapper, CommandMapper, this);
+ }
+
+ protected Frame? Element
+ {
+ get { return _viewHandlerWrapper.Element; }
+ set
+ {
+ if (value != null)
+ (this as IPlatformViewHandler).SetVirtualView(value);
+ }
+ }
+
+ protected override void Dispose(bool disposing)
+ {
+ if (_disposed)
+ return;
+
+ _disposed = true;
+
+ if (disposing)
+ {
+ if (Element != null)
+ {
+ Element.PropertyChanged -= OnElementPropertyChanged;
+ }
+
+ Element?.Handler?.DisconnectHandler();
+ }
+
+ base.Dispose(disposing);
+ }
+
+ protected virtual void OnElementChanged(ElementChangedEventArgs e)
+ {
+ if (e.NewElement != null)
+ {
+ CrossPlatformArrange = e.NewElement.CrossPlatformArrange;
+ CrossPlatformMeasure = e.NewElement.CrossPlatformMeasure;
+ }
+ }
+
+ protected virtual void OnElementPropertyChanged(object? sender, PropertyChangedEventArgs e)
+ {
+ if (_disposed)
+ {
+ return;
+ }
+
+ if (Element != null && e.PropertyName != null)
+ _viewHandlerWrapper.UpdateProperty(e.PropertyName);
+ }
+
+ void OnDrawClippingArea(object? sender, SkiaSharp.Views.Tizen.SKPaintSurfaceEventArgs e)
+ {
+ if (Element == null || _disposed)
+ return;
+
+ var canvas = e.Surface.Canvas;
+ var directRect = e.Info.Rect;
+ canvas.Clear();
+
+ if (!Element.IsClippedToBounds)
+ {
+ canvas.Clear(SKColors.White);
+ return;
+ }
+ var radius = ((double)Element.CornerRadius).ToScaledPixel();
+ using var paint = new SKPaint
+ {
+ Color = SKColors.White,
+ };
+ canvas.DrawRoundRect(directRect, new SKSize(radius, radius), paint);
+ }
+
+ void UpdateClippedToBounds()
+ {
+ if (Element == null || _disposed)
+ return;
+
+ _clipperView.Invalidate();
+ }
+
+ void UpdateBackgroundColor()
+ {
+ if (Element == null || _disposed)
+ return;
+
+ if (Element.BackgroundColor.IsNotDefault())
+ BackgroundColor = Element.BackgroundColor.ToNUIColor();
+ else
+ BackgroundColor = Colors.White.ToNUIColor();
+ }
+
+ void UpdateBackground()
+ {
+ if (Element == null || _disposed)
+ return;
+
+ // If BackgroundColor is valid, do not update Background
+ if (Element.BackgroundColor.IsNotDefault())
+ return;
+
+ var color = ((Paint)Element.Background)?.ToColor();
+
+ if (color != null)
+ BackgroundColor = color.ToNUIColor();
+ else
+ BackgroundColor = Colors.White.ToNUIColor();
+ }
+
+ void UpdateBorderColor()
+ {
+ if (Element == null || _disposed)
+ return;
+
+ if (Element.BorderColor.IsNotDefault())
+ BorderlineColor = Element.BorderColor.ToNUIColor();
+ else
+ BorderlineColor = NColor.Transparent;
+ }
+
+ void UpdateShadow()
+ {
+ if (Element == null || _disposed)
+ return;
+
+ if (Element.HasShadow)
+ {
+ BoxShadow = new TShadow(2.0.ToScaledPixel(), TColor.FromHex("#111111").ToNative());
+ }
+ else
+ {
+ BoxShadow = null;
+ }
+ }
+
+ void UpdateCornerRadius()
+ {
+ if (Element == null || _disposed)
+ return;
+
+ CornerRadius = ((double)Element.CornerRadius).ToScaledPixel();
+ }
+
+ void UpdateContent()
+ {
+ var content = Element?.Content;
+
+ if (_contentHandler != null)
+ {
+ if (_contentHandler.PlatformView != null)
+ {
+ _clipperView.Remove(_contentHandler.PlatformView);
+ }
+ _contentHandler?.Dispose();
+ _contentHandler = null;
+ }
+
+
+ if (content == null || _mauiContext == null || _disposed)
+ {
+ return;
+ }
+
+ var platformView = content.ToPlatform(_mauiContext);
+ platformView.WidthSpecification = TLayoutParamPolicies.MatchParent;
+ platformView.HeightSpecification = TLayoutParamPolicies.MatchParent;
+ _clipperView.Add(platformView);
+ if (content.Handler is IPlatformViewHandler thandler)
+ {
+ _contentHandler = thandler;
+ }
+ }
+
+
+ TSize IMeasurable.Measure(double availableWidth, double availableHeight)
+ {
+ if (Element?.Handler is IPlatformViewHandler pvh && Element is IContentView cv)
+ {
+ return pvh.MeasureVirtualView(availableWidth.ToScaledDP(), availableHeight.ToScaledDP(), cv.CrossPlatformMeasure).ToPixel();
+ }
+ else
+ {
+ return NaturalSize2D.ToCommon();
+ }
+ }
+
+ #region IPlatformViewHandler
+ Size IViewHandler.GetDesiredSize(double widthConstraint, double heightConstraint)
+ {
+ return this.GetDesiredSizeFromHandler(widthConstraint, heightConstraint);
+ }
+
+ bool IViewHandler.HasContainer { get => false; set { } }
+
+ object? IViewHandler.ContainerView => null;
+
+ IView? IViewHandler.VirtualView => Element;
+
+ object IElementHandler.PlatformView => this;
+
+ Maui.IElement? IElementHandler.VirtualView => Element;
+
+ IMauiContext? IElementHandler.MauiContext => _mauiContext;
+
+ Tizen.NUI.BaseComponents.View? IPlatformViewHandler.PlatformView => this;
+
+ Tizen.NUI.BaseComponents.View? IPlatformViewHandler.ContainerView => this;
+
+ void IViewHandler.PlatformArrange(Graphics.Rect rect) =>
+ this.PlatformArrangeHandler(rect);
+
+ void IElementHandler.SetMauiContext(IMauiContext mauiContext) =>
+ _mauiContext = mauiContext;
+
+ void IElementHandler.SetVirtualView(Maui.IElement view) =>
+ _viewHandlerWrapper.SetVirtualView(view, OnElementChanged, false);
+
+ void IElementHandler.UpdateValue(string property)
+ {
+ if (Element != null)
+ {
+ OnElementPropertyChanged(Element, new PropertyChangedEventArgs(property));
+ }
+ }
+
+ void IElementHandler.Invoke(string command, object? args)
+ {
+ _viewHandlerWrapper.Invoke(command, args);
+ }
+
+ void IElementHandler.DisconnectHandler()
+ {
+ _viewHandlerWrapper.DisconnectHandler();
+ }
+ #endregion
+ }
+}
diff --git a/src/Controls/src/Core/Compatibility/Handlers/Tizen/ViewRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Tizen/ViewRenderer.cs
new file mode 100644
index 000000000000..1021adbb00a3
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/Tizen/ViewRenderer.cs
@@ -0,0 +1,77 @@
+#nullable enable
+using Tizen.UIExtensions.NUI;
+using PlatformView = Tizen.NUI.BaseComponents.View;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public abstract partial class ViewRenderer : ViewRenderer
+ {
+ }
+
+ public abstract partial class ViewRenderer : VisualElementRenderer, IPlatformViewHandler
+ where TElement : View, IView
+ where TPlatformView : PlatformView
+ {
+ TPlatformView? _platformView;
+ ViewGroup? _container;
+
+ public TPlatformView? Control => ((IElementHandler)this).PlatformView as TPlatformView ?? _platformView;
+ object? IElementHandler.PlatformView => _platformView;
+
+ public ViewRenderer() : this(VisualElementRendererMapper, VisualElementRendererCommandMapper)
+ {
+ }
+
+ internal ViewRenderer(IPropertyMapper mapper, CommandMapper? commandMapper = null)
+ : base(mapper, commandMapper)
+ {
+ }
+
+ protected virtual TPlatformView CreateNativeControl()
+ {
+ return default(TPlatformView)!;
+ }
+
+ protected void SetNativeControl(TPlatformView control)
+ {
+ SetNativeControl(control, this);
+ }
+
+ internal void SetNativeControl(TPlatformView control, ViewGroup container)
+ {
+ if (Control != null)
+ {
+ Children.Remove(Control);
+ }
+
+ _container = container;
+ _platformView = control;
+
+ var toAdd = container == this ? control : (PlatformView)container;
+ toAdd.WidthSpecification = Tizen.NUI.BaseComponents.LayoutParamPolicies.MatchParent;
+ toAdd.HeightSpecification = Tizen.NUI.BaseComponents.LayoutParamPolicies.MatchParent;
+ Children.Add(toAdd);
+ }
+
+ private protected override void DisconnectHandlerCore()
+ {
+ if (_platformView != null && Element != null)
+ {
+ // We set the PlatformView to null so no one outside of this handler tries to access
+ // PlatformView. PlatformView access should be isolated to the instance passed into
+ // DisconnectHandler
+ var oldPlatformView = _platformView;
+ _platformView = null;
+ DisconnectHandler(oldPlatformView);
+ }
+
+ base.DisconnectHandlerCore();
+ }
+
+ protected virtual void DisconnectHandler(TPlatformView oldPlatformView)
+ {
+ }
+
+ PlatformView? IPlatformViewHandler.ContainerView => _container;
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Compatibility/Handlers/Tizen/VisualElementRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/Tizen/VisualElementRenderer.cs
new file mode 100644
index 000000000000..29872ddefbe4
--- /dev/null
+++ b/src/Controls/src/Core/Compatibility/Handlers/Tizen/VisualElementRenderer.cs
@@ -0,0 +1,54 @@
+#nullable enable
+using Microsoft.Maui.Controls.Platform;
+using Microsoft.Maui.Graphics;
+using Tizen.UIExtensions.NUI;
+using IMeasurable = Tizen.UIExtensions.Common.IMeasurable;
+using TSize = Tizen.UIExtensions.Common.Size;
+
+namespace Microsoft.Maui.Controls.Handlers.Compatibility
+{
+ public abstract partial class VisualElementRenderer : ViewGroup, IPlatformViewHandler, IMeasurable
+ where TElement : Element, IView
+ {
+ object? IElementHandler.PlatformView => Children.Count > 0 ? Children[0] : null;
+
+ static partial void ProcessAutoPackage(IElement element)
+ {
+ if (element?.Handler?.PlatformView is not ViewGroup viewGroup)
+ return;
+
+ viewGroup.Children.Clear();
+
+ if (element is not IVisualTreeElement vte)
+ return;
+
+ var mauiContext = element?.Handler?.MauiContext;
+ if (mauiContext == null)
+ return;
+
+ foreach (var child in vte.GetVisualChildren())
+ {
+ if (child is IElement childElement)
+ viewGroup.Children.Add(childElement.ToPlatform(mauiContext));
+ }
+ }
+
+ public void UpdateLayout()
+ {
+ if (Element != null)
+ this.InvalidateMeasure(Element);
+ }
+
+ TSize IMeasurable.Measure(double availableWidth, double availableHeight)
+ {
+ if (Children.Count > 0 && Children[0] is IMeasurable measurable)
+ {
+ return measurable.Measure(availableWidth, availableHeight);
+ }
+ else
+ {
+ return NaturalSize2D.ToCommon();
+ }
+ }
+ }
+}
diff --git a/src/Controls/src/Core/Compatibility/Handlers/ViewHandlerDelegator.cs b/src/Controls/src/Core/Compatibility/Handlers/ViewHandlerDelegator.cs
index d38d53dc7cb1..da8ededfc58d 100644
--- a/src/Controls/src/Core/Compatibility/Handlers/ViewHandlerDelegator.cs
+++ b/src/Controls/src/Core/Compatibility/Handlers/ViewHandlerDelegator.cs
@@ -1,6 +1,6 @@
#nullable enable
-#if WINDOWS || IOS || ANDROID
+#if WINDOWS || IOS || ANDROID || TIZEN
using System;
using System.Collections.Generic;
using System.Text;
diff --git a/src/Controls/src/Core/Compatibility/Handlers/VisualElementRenderer.cs b/src/Controls/src/Core/Compatibility/Handlers/VisualElementRenderer.cs
index 70829f5f4161..789187f086fb 100644
--- a/src/Controls/src/Core/Compatibility/Handlers/VisualElementRenderer.cs
+++ b/src/Controls/src/Core/Compatibility/Handlers/VisualElementRenderer.cs
@@ -1,5 +1,5 @@
#nullable enable
-#if WINDOWS || ANDROID || IOS
+#if WINDOWS || ANDROID || IOS || TIZEN
using System;
using System.Collections.Generic;
@@ -13,6 +13,8 @@
using PlatformView = Android.Views.View;
#elif IOS
using PlatformView = UIKit.UIView;
+#elif TIZEN
+using PlatformView = Tizen.NUI.BaseComponents.View;
#endif
namespace Microsoft.Maui.Controls.Handlers.Compatibility
@@ -153,7 +155,11 @@ public virtual SizeRequest GetDesiredSize(double widthConstraint, double heightC
return new SizeRequest(size, minSize);
}
+#if TIZEN
+ protected new virtual Size MinimumSize()
+#else
protected virtual Size MinimumSize()
+#endif
{
return new Size();
}
diff --git a/src/Controls/src/Core/Compatibility/Tizen/FontNamedSizeService.cs b/src/Controls/src/Core/Compatibility/Tizen/FontNamedSizeService.cs
index b182ce2c0667..772b65912ce8 100644
--- a/src/Controls/src/Core/Compatibility/Tizen/FontNamedSizeService.cs
+++ b/src/Controls/src/Core/Compatibility/Tizen/FontNamedSizeService.cs
@@ -1,6 +1,6 @@
using System;
using Microsoft.Maui.Controls.Internals;
-using Microsoft.Maui.Devices;
+using Tizen.UIExtensions.Common;
#pragma warning disable CS0612 // Type or member is obsolete
[assembly: Microsoft.Maui.Controls.Dependency(typeof(Microsoft.Maui.Controls.Compatibility.Platform.Tizen.FontNamedSizeService))]
@@ -13,42 +13,40 @@ class FontNamedSizeService : IFontNamedSizeService
{
public double GetNamedSize(NamedSize size, Type targetElementType, bool useOldSizes)
{
- int pt;
- // Actual font size depends on the target idiom.
- switch (size)
+ if (DeviceInfo.IsTV || DeviceInfo.IsIoT)
{
- case NamedSize.Micro:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV || DeviceInfo.Idiom == DeviceIdiom.Watch ? 24 : 19;
- break;
- case NamedSize.Small:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV ? 26 : (DeviceInfo.Idiom == DeviceIdiom.Watch ? 30 : 22);
- break;
- case NamedSize.Default:
- case NamedSize.Medium:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV ? 28 : (DeviceInfo.Idiom == DeviceIdiom.Watch ? 32 : 25);
- break;
- case NamedSize.Large:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV ? 32 : (DeviceInfo.Idiom == DeviceIdiom.Watch ? 36 : 31);
- break;
- case NamedSize.Body:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV ? 30 : (DeviceInfo.Idiom == DeviceIdiom.Watch ? 32 : 28);
- break;
- case NamedSize.Caption:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV ? 26 : (DeviceInfo.Idiom == DeviceIdiom.Watch ? 24 : 22);
- break;
- case NamedSize.Header:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV ? 84 : (DeviceInfo.Idiom == DeviceIdiom.Watch ? 36 : 138);
- break;
- case NamedSize.Subtitle:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV ? 30 : (DeviceInfo.Idiom == DeviceIdiom.Watch ? 30 : 28);
- break;
- case NamedSize.Title:
- pt = DeviceInfo.Idiom == DeviceIdiom.TV ? 42 : (DeviceInfo.Idiom == DeviceIdiom.Watch ? 36 : 40);
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(size));
+ return size switch
+ {
+ NamedSize.Default => 22,
+ NamedSize.Micro => 18,
+ NamedSize.Small => 20,
+ NamedSize.Medium => 22,
+ NamedSize.Large => 26,
+ NamedSize.Body => 24,
+ NamedSize.Caption => 20,
+ NamedSize.Header => 42,
+ NamedSize.Subtitle => 24,
+ NamedSize.Title => 32,
+ _ => throw new ArgumentOutOfRangeException(nameof(size)),
+ };
+ }
+ else
+ {
+ return size switch
+ {
+ NamedSize.Default => 14,
+ NamedSize.Micro => 10,
+ NamedSize.Small => 12,
+ NamedSize.Medium => 14,
+ NamedSize.Large => 18,
+ NamedSize.Body => 16,
+ NamedSize.Caption => 12,
+ NamedSize.Header => 14,
+ NamedSize.Subtitle => 16,
+ NamedSize.Title => 24,
+ _ => throw new ArgumentOutOfRangeException(nameof(size)),
+ };
}
- return DPExtensions.ConvertToDPFont(pt);
}
}
}
\ No newline at end of file
diff --git a/src/Controls/src/Core/HandlerImpl/Application/Application.Tizen.cs b/src/Controls/src/Core/HandlerImpl/Application/Application.Tizen.cs
new file mode 100644
index 000000000000..261b6771c807
--- /dev/null
+++ b/src/Controls/src/Core/HandlerImpl/Application/Application.Tizen.cs
@@ -0,0 +1,6 @@
+namespace Microsoft.Maui.Controls
+{
+ public partial class Application
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/HandlerImpl/Button/Button.Tizen.cs b/src/Controls/src/Core/HandlerImpl/Button/Button.Tizen.cs
index 781e0f865107..0fc2d45c534f 100644
--- a/src/Controls/src/Core/HandlerImpl/Button/Button.Tizen.cs
+++ b/src/Controls/src/Core/HandlerImpl/Button/Button.Tizen.cs
@@ -1,7 +1,5 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Microsoft.Maui.Controls.Platform;
+using Microsoft.Maui.Controls.Platform;
+using Tizen.NUI;
namespace Microsoft.Maui.Controls
{
@@ -12,7 +10,31 @@ public static void MapText(ButtonHandler handler, Button button)
handler.PlatformView?.UpdateText(button);
}
- [MissingMapper]
- public static void MapLineBreakMode(IButtonHandler handler, Button button) { }
+ public static void MapLineBreakMode(IButtonHandler handler, Button button)
+ {
+ switch (button.LineBreakMode)
+ {
+ case LineBreakMode.NoWrap:
+ handler.PlatformView.TextLabel.MultiLine = false;
+ handler.PlatformView.TextLabel.Ellipsis = false;
+ break;
+ case LineBreakMode.WordWrap:
+ handler.PlatformView.TextLabel.MultiLine = true;
+ handler.PlatformView.TextLabel.Ellipsis = false;
+ handler.PlatformView.TextLabel.LineWrapMode = LineWrapMode.Word;
+ break;
+ case LineBreakMode.CharacterWrap:
+ handler.PlatformView.TextLabel.MultiLine = true;
+ handler.PlatformView.TextLabel.Ellipsis = false;
+ handler.PlatformView.TextLabel.LineWrapMode = LineWrapMode.Character;
+ break;
+ case LineBreakMode.HeadTruncation:
+ case LineBreakMode.TailTruncation:
+ case LineBreakMode.MiddleTruncation:
+ handler.PlatformView.TextLabel.MultiLine = false;
+ handler.PlatformView.TextLabel.Ellipsis = true;
+ break;
+ }
+ }
}
}
diff --git a/src/Controls/src/Core/HandlerImpl/Label/Label.Tizen.cs b/src/Controls/src/Core/HandlerImpl/Label/Label.Tizen.cs
index 37c0f6347a30..083d7525524b 100644
--- a/src/Controls/src/Core/HandlerImpl/Label/Label.Tizen.cs
+++ b/src/Controls/src/Core/HandlerImpl/Label/Label.Tizen.cs
@@ -1,4 +1,4 @@
-using Microsoft.Maui;
+using Microsoft.Maui;
using Microsoft.Maui.Handlers;
using Microsoft.Maui.Controls.Platform;
@@ -8,42 +8,12 @@ public partial class Label
{
public static void MapTextType(LabelHandler handler, Label label)
{
- handler.PlatformView?.UpdateText(label);
+ Platform.TextExtensions.UpdateText(handler.PlatformView, label);
}
public static void MapText(LabelHandler handler, Label label)
{
- handler.PlatformView?.UpdateText(label);
- }
-
- public static void MapTextDecorations(LabelHandler handler, Label label)
- {
- if (label?.TextType == TextType.Html)
- {
- return;
- }
-
- LabelHandler.MapTextDecorations(handler, label);
- }
-
- public static void MapFont(LabelHandler handler, Label label)
- {
- if (label?.TextType == TextType.Html)
- {
- return;
- }
-
- LabelHandler.MapFont(handler, label);
- }
-
- public static void MapTextColor(LabelHandler handler, Label label)
- {
- if (label?.TextType == TextType.Html)
- {
- return;
- }
-
- LabelHandler.MapTextColor(handler, label);
+ Platform.TextExtensions.UpdateText(handler.PlatformView, label);
}
public static void MapLineBreakMode(ILabelHandler handler, Label label)
diff --git a/src/Controls/src/Core/HandlerImpl/Layout/Layout.Tizen.cs b/src/Controls/src/Core/HandlerImpl/Layout/Layout.Tizen.cs
index 18df92e58048..1e7a050af2d2 100644
--- a/src/Controls/src/Core/HandlerImpl/Layout/Layout.Tizen.cs
+++ b/src/Controls/src/Core/HandlerImpl/Layout/Layout.Tizen.cs
@@ -4,8 +4,22 @@ public partial class Layout
{
public static void MapInputTransparent(LayoutHandler handler, Layout layout)
{
- handler.PlatformView?.UpdateInputTransparent(handler, layout);
- layout.UpdateDescendantInputTransparent();
+ if (handler.PlatformView == null)
+ return;
+
+ if (layout.CascadeInputTransparent)
+ {
+ // Sensitive property on NUI View was false, disabled all touch event including children
+ handler.PlatformView.Sensitive = !layout.InputTransparent;
+ handler.PlatformView.InputTransparent = false;
+ }
+ else
+ {
+ // InputTransparent property on LayoutViewGroup was false,
+ // Only LayoutViewGroup event was disabled but children are allowed
+ handler.PlatformView.InputTransparent = layout.InputTransparent;
+ handler.PlatformView.Sensitive = true;
+ }
}
}
}
diff --git a/src/Controls/src/Core/HandlerImpl/RadioButton/RadioButton.Tizen.cs b/src/Controls/src/Core/HandlerImpl/RadioButton/RadioButton.Tizen.cs
new file mode 100644
index 000000000000..0dd21e9a377b
--- /dev/null
+++ b/src/Controls/src/Core/HandlerImpl/RadioButton/RadioButton.Tizen.cs
@@ -0,0 +1,117 @@
+using Microsoft.Maui.Controls.Internals;
+using Microsoft.Maui.Controls.Shapes;
+
+namespace Microsoft.Maui.Controls
+{
+ public partial class RadioButton
+ {
+ static ControlTemplate s_tizenDefaultTemplate;
+
+ public static void MapContent(RadioButtonHandler handler, RadioButton radioButton)
+ {
+ if (radioButton.ResolveControlTemplate() == null)
+ radioButton.ControlTemplate = s_tizenDefaultTemplate ?? (s_tizenDefaultTemplate = new ControlTemplate(() => BuildTizenDefaultTemplate()));
+
+ RadioButtonHandler.MapContent(handler, radioButton);
+ }
+
+ static View BuildTizenDefaultTemplate()
+ {
+ var frame = new Frame
+ {
+ HasShadow = false,
+ Padding = 6
+ };
+
+ BindToTemplatedParent(frame, BackgroundColorProperty, Controls.Frame.BorderColorProperty, Controls.Frame.CornerRadiusProperty, HorizontalOptionsProperty,
+ MarginProperty, OpacityProperty, RotationProperty, ScaleProperty, ScaleXProperty, ScaleYProperty,
+ TranslationYProperty, TranslationXProperty, VerticalOptionsProperty);
+
+ var grid = new Grid
+ {
+ ColumnSpacing = 6,
+ RowSpacing = 0,
+ ColumnDefinitions = new ColumnDefinitionCollection {
+ new ColumnDefinition { Width = GridLength.Auto },
+ new ColumnDefinition { Width = GridLength.Star }
+ },
+ RowDefinitions = new RowDefinitionCollection {
+ new RowDefinition { Height = GridLength.Auto }
+ }
+ };
+
+ var normalEllipse = new Ellipse
+ {
+ Fill = Brush.Transparent,
+ Aspect = Stretch.Uniform,
+ HorizontalOptions = LayoutOptions.Center,
+ VerticalOptions = LayoutOptions.Center,
+ HeightRequest = 21,
+ WidthRequest = 21,
+ StrokeThickness = 2,
+ Stroke = RadioButtonThemeColor,
+ InputTransparent = true
+ };
+
+ var checkMark = new Ellipse
+ {
+ Fill = RadioButtonCheckMarkThemeColor,
+ Aspect = Stretch.Uniform,
+ HorizontalOptions = LayoutOptions.Center,
+ VerticalOptions = LayoutOptions.Center,
+ HeightRequest = 11,
+ WidthRequest = 11,
+ Opacity = 0,
+ InputTransparent = true
+ };
+
+ var contentPresenter = new ContentPresenter
+ {
+ HorizontalOptions = LayoutOptions.Fill,
+ VerticalOptions = LayoutOptions.Center
+ };
+
+ contentPresenter.SetBinding(BackgroundColorProperty, new Binding(BackgroundColorProperty.PropertyName,
+ source: RelativeBindingSource.TemplatedParent));
+
+ grid.Add(normalEllipse);
+ grid.Add(checkMark);
+ grid.Add(contentPresenter, 1, 0);
+
+ frame.Content = grid;
+
+ INameScope nameScope = new NameScope();
+ NameScope.SetNameScope(frame, nameScope);
+ nameScope.RegisterName(TemplateRootName, frame);
+ nameScope.RegisterName(UncheckedButton, normalEllipse);
+ nameScope.RegisterName(CheckedIndicator, checkMark);
+ nameScope.RegisterName("ContentPresenter", contentPresenter);
+
+ VisualStateGroupList visualStateGroups = new VisualStateGroupList();
+
+ var common = new VisualStateGroup() { Name = "Common" };
+ common.States.Add(new VisualState() { Name = VisualStateManager.CommonStates.Normal });
+ common.States.Add(new VisualState() { Name = VisualStateManager.CommonStates.Disabled });
+
+ visualStateGroups.Add(common);
+
+ var checkedStates = new VisualStateGroup() { Name = "CheckedStates" };
+
+ VisualState checkedVisualState = new VisualState() { Name = CheckedVisualState };
+ checkedVisualState.Setters.Add(new Setter() { Property = OpacityProperty, TargetName = CheckedIndicator, Value = 1 });
+ checkedVisualState.Setters.Add(new Setter() { Property = Shape.StrokeProperty, TargetName = UncheckedButton, Value = RadioButtonCheckMarkThemeColor });
+ checkedStates.States.Add(checkedVisualState);
+
+ VisualState uncheckedVisualState = new VisualState() { Name = UncheckedVisualState };
+ uncheckedVisualState.Setters.Add(new Setter() { Property = OpacityProperty, TargetName = CheckedIndicator, Value = 0 });
+ uncheckedVisualState.Setters.Add(new Setter() { Property = Shape.StrokeProperty, TargetName = UncheckedButton, Value = RadioButtonThemeColor });
+ checkedStates.States.Add(uncheckedVisualState);
+
+ visualStateGroups.Add(checkedStates);
+
+ VisualStateManager.SetVisualStateGroups(frame, visualStateGroups);
+
+ return frame;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/HandlerImpl/RadioButton/RadioButton.cs b/src/Controls/src/Core/HandlerImpl/RadioButton/RadioButton.cs
index 4a735de52802..20ee54b1d2e3 100644
--- a/src/Controls/src/Core/HandlerImpl/RadioButton/RadioButton.cs
+++ b/src/Controls/src/Core/HandlerImpl/RadioButton/RadioButton.cs
@@ -11,7 +11,7 @@ public partial class RadioButton
public static IPropertyMapper ControlsRadioButtonMapper =
new PropertyMapper(RadioButtonHandler.Mapper)
{
-#if IOS || ANDROID || WINDOWS
+#if IOS || ANDROID || WINDOWS || TIZEN
[nameof(IRadioButton.Content)] = MapContent
#endif
};
diff --git a/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.Tizen.cs b/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.Tizen.cs
index 75c3c615bdf1..eb3f2a6ae97e 100644
--- a/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.Tizen.cs
+++ b/src/Controls/src/Core/HandlerImpl/SearchBar/SearchBar.Tizen.cs
@@ -4,7 +4,7 @@ public partial class SearchBar
{
public static void MapText(SearchBarHandler handler, SearchBar searchBar)
{
- Platform.TextExtensions.UpdateText(handler.PlatformView, searchBar);
+ Platform.TextExtensions.UpdateText(handler.PlatformView.Entry, searchBar);
}
}
}
diff --git a/src/Controls/src/Core/HandlerImpl/TabbedPage/TabbedPage.Tizen.cs b/src/Controls/src/Core/HandlerImpl/TabbedPage/TabbedPage.Tizen.cs
index 2f8b57ca02d4..2d8787e955d9 100644
--- a/src/Controls/src/Core/HandlerImpl/TabbedPage/TabbedPage.Tizen.cs
+++ b/src/Controls/src/Core/HandlerImpl/TabbedPage/TabbedPage.Tizen.cs
@@ -1,12 +1,102 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Microsoft.Maui.Handlers;
+#nullable enable
+using System;
+using System.Linq;
+using Microsoft.Maui.Controls.Handlers.Items;
+using Tizen.NUI;
+using Tizen.UIExtensions.NUI;
+using GColor = Microsoft.Maui.Graphics.Color;
+using GColors = Microsoft.Maui.Graphics.Colors;
+using NCollectionView = Tizen.UIExtensions.NUI.CollectionView;
+using NLayoutParamPolicies = Tizen.NUI.BaseComponents.LayoutParamPolicies;
+using NItemSizingStrategy = Tizen.UIExtensions.NUI.ItemSizingStrategy;
+using NView = Tizen.NUI.BaseComponents.View;
+using XLabel = Microsoft.Maui.Controls.Label;
namespace Microsoft.Maui.Controls
{
public partial class TabbedPage
{
+ NCollectionView _tabbedView;
+ TabbedPageAdaptor _adaptor;
+ ViewGroup _content;
+ IMauiContext MauiContext => this.Handler?.MauiContext ?? throw new InvalidOperationException("MauiContext cannot be null here");
+
+ NView CreatePlatformView(TabbedPage tabbedPage)
+ {
+ var view = new NView
+ {
+ HeightSpecification = NLayoutParamPolicies.MatchParent,
+ WidthSpecification = NLayoutParamPolicies.MatchParent,
+ Layout = new LinearLayout
+ {
+ LinearOrientation = LinearLayout.Orientation.Vertical
+ }
+ };
+
+ _tabbedView = new NCollectionView
+ {
+ SizeHeight = 40d.ToScaledPixel(),
+ WidthSpecification = NLayoutParamPolicies.MatchParent,
+ LayoutManager = new GridLayoutManager(true, 1, NItemSizingStrategy.MeasureAllItems),
+ SelectionMode = CollectionViewSelectionMode.SingleAlways,
+ };
+ _tabbedView.Adaptor = _adaptor = new TabbedPageAdaptor(tabbedPage);
+
+ _content = new ViewGroup
+ {
+ WidthSpecification = NLayoutParamPolicies.MatchParent,
+ HeightSpecification = NLayoutParamPolicies.MatchParent
+ };
+
+ view.Add(_tabbedView);
+ view.Add(_content);
+ _adaptor.SelectionChanged += OnTabItemSelected;
+ var currentPageIndex = tabbedPage.InternalChildren.IndexOf(tabbedPage.CurrentPage);
+ if (currentPageIndex != -1)
+ _tabbedView!.RequestItemSelect(currentPageIndex);
+ return view;
+ }
+
+ static NView? OnCreatePlatformView(ViewHandler arg)
+ {
+ if (arg.VirtualView is TabbedPage tabbedPage)
+ {
+ return tabbedPage.CreatePlatformView(tabbedPage);
+ }
+
+ return null;
+ }
+
+ partial void OnHandlerChangingPartial(HandlerChangingEventArgs args)
+ {
+ if (args.OldHandler != null && args.NewHandler == null)
+ DisconnectHandler();
+ }
+
+ void DisconnectHandler()
+ {
+ foreach (var child in InternalChildren)
+ {
+ var handler = child.ToHandler(MauiContext);
+ handler?.DisconnectHandler();
+ }
+ _tabbedView?.Dispose();
+ _content?.Dispose();
+ }
+
+ void OnTabItemSelected(object? sender, CollectionViewSelectionChangedEventArgs e)
+ {
+ if (e.SelectedItems is null || e.SelectedItems.Count == 0)
+ return;
+
+ Page? current = e.SelectedItems[0] as Page;
+ if (CurrentPage != current)
+ {
+ CurrentPage?.SendDisappearing();
+ CurrentPage = current;
+ }
+ }
+
internal static void MapBarBackground(ITabbedViewHandler handler, TabbedPage view)
{
}
@@ -34,7 +124,171 @@ internal static void MapSelectedItem(ITabbedViewHandler handler, TabbedPage view
}
internal static void MapCurrentPage(ITabbedViewHandler handler, TabbedPage view)
{
+ if (view.MauiContext == null)
+ return;
+
+ var currentHandler = view.CurrentPage.ToHandler(view.MauiContext);
+ if (currentHandler != null && currentHandler.ToPlatform() is NView current)
+ {
+ current.WidthSpecification = NLayoutParamPolicies.MatchParent;
+ current.HeightSpecification = NLayoutParamPolicies.MatchParent;
+ var old = view._content.Children.FirstOrDefault();
+ if (current != old)
+ {
+ if (old != null)
+ {
+ view._content.Remove(old);
+ }
+ view._content.Add(current);
+ view.CurrentPage?.SendAppearing();
+ }
+ }
+ }
+
+ class TabbedPageAdaptor : ItemTemplateAdaptor
+ {
+ public TabbedPageAdaptor(TabbedPage page) : base(page, page.InternalChildren, GetTemplate(page)) { }
+
+ protected override bool IsSelectable => true;
+
+ static DataTemplate GetTemplate(TabbedPage page)
+ {
+ return new DataTemplate(() =>
+ {
+ return new TabbedItem(page);
+ });
+ }
+ }
+
+ class TabbedItem : Frame
+ {
+ static readonly BindableProperty SelectedStateProperty = BindableProperty.Create(nameof(IsSelected), typeof(bool), typeof(TabbedItem), false, propertyChanged: (b, o, n) => ((TabbedItem)b).UpdateSelectedState());
+ static readonly BindableProperty SelectedTabColorProperty = BindableProperty.Create(nameof(SelectedTabColor), typeof(GColor), typeof(TabbedItem), default(Color), propertyChanged: (b, o, n) => ((TabbedItem)b).UpdateSelectedState());
+ static readonly BindableProperty UnselectedTabColorProperty = BindableProperty.Create(nameof(UnselectedTabColor), typeof(GColor), typeof(TabbedItem), default(Color), propertyChanged: (b, o, n) => ((TabbedItem)b).UpdateSelectedState());
+
+ TabbedPage _page;
+ BoxView _bar;
+
+ public bool IsSelected
+ {
+ get => (bool)GetValue(SelectedStateProperty);
+ set => SetValue(SelectedStateProperty, value);
+ }
+
+ public GColor SelectedTabColor
+ {
+ get => (GColor)GetValue(SelectedTabColorProperty);
+ set => SetValue(SelectedTabColorProperty, value);
+ }
+
+ public GColor UnselectedTabColor
+ {
+ get => (GColor)GetValue(UnselectedTabColorProperty);
+ set => SetValue(UnselectedTabColorProperty, value);
+ }
+
+#pragma warning disable CS8618
+ public TabbedItem(TabbedPage page)
+#pragma warning restore CS8618
+ {
+ _page = page;
+ InitializeComponent();
+ }
+
+ void InitializeComponent()
+ {
+ Padding = new Thickness(0);
+ HasShadow = false;
+ BorderColor = GColors.DarkGray;
+ SetBinding(BackgroundProperty, new Binding("BarBackground", source: _page));
+ SetBinding(BackgroundColorProperty, new Binding("BarBackgroundColor", source: _page));
+ SetBinding(SelectedTabColorProperty, new Binding("SelectedTabColor", source: _page));
+ SetBinding(UnselectedTabColorProperty, new Binding("UnselectedTabColor", source: _page));
+
+ var label = new XLabel
+ {
+ Margin = new Thickness(20, 0),
+ FontSize = 16,
+ HorizontalTextAlignment = TextAlignment.Center,
+ VerticalTextAlignment = TextAlignment.Center,
+ };
+ label.SetBinding(XLabel.TextProperty, new Binding("Title"));
+ label.SetBinding(XLabel.TextColorProperty, new Binding("BarTextColor", source: _page));
+
+ _bar = new BoxView
+ {
+ Color = GColors.Transparent,
+ };
+
+ var grid = new Grid
+ {
+ RowDefinitions =
+ {
+ new RowDefinition
+ {
+ Height = GridLength.Star,
+ },
+ new RowDefinition
+ {
+ Height = 5,
+ }
+ }
+ };
+ grid.Add(label, 0, 0);
+ grid.Add(_bar, 0, 1);
+ Content = grid;
+
+ var groups = new VisualStateGroupList();
+
+ VisualStateGroup group = new VisualStateGroup()
+ {
+ Name = "CommonStates",
+ };
+
+ VisualState selected = new VisualState()
+ {
+ Name = VisualStateManager.CommonStates.Selected,
+ TargetType = typeof(TabbedItem),
+ Setters =
+ {
+ new Setter
+ {
+ Property = SelectedStateProperty,
+ Value = true,
+ },
+ },
+ };
+
+ VisualState normal = new VisualState()
+ {
+ Name = VisualStateManager.CommonStates.Normal,
+ TargetType = typeof(TabbedItem),
+ Setters =
+ {
+ new Setter
+ {
+ Property = SelectedStateProperty,
+ Value = false,
+ },
+ }
+ };
+ group.States.Add(normal);
+ group.States.Add(selected);
+ groups.Add(group);
+ VisualStateManager.SetVisualStateGroups(this, groups);
+ }
+ void UpdateSelectedState()
+ {
+ if (IsSelected)
+ {
+ _bar.Color = _page.SelectedTabColor.IsNotDefault() ? _page.SelectedTabColor : GColors.DarkGray;
+ }
+ else
+ {
+ _bar.Color = _page.UnselectedTabColor.IsNotDefault() ? _page.UnselectedTabColor : GColors.Transparent;
+ }
+ }
}
}
}
diff --git a/src/Controls/src/Core/HandlerImpl/TabbedPage/TabbedPage.cs b/src/Controls/src/Core/HandlerImpl/TabbedPage/TabbedPage.cs
index 2cd00f1dee5b..3c15544a5a9c 100644
--- a/src/Controls/src/Core/HandlerImpl/TabbedPage/TabbedPage.cs
+++ b/src/Controls/src/Core/HandlerImpl/TabbedPage/TabbedPage.cs
@@ -26,7 +26,7 @@ public partial class TabbedPage
{
TabbedViewHandler.Mapper = ControlsTabbedPageMapper;
-#if WINDOWS || ANDROID
+#if WINDOWS || ANDROID || TIZEN
TabbedViewHandler.PlatformViewFactory = OnCreatePlatformView;
#endif
}
diff --git a/src/Controls/src/Core/HandlerImpl/Toolbar/Toolbar.Tizen.cs b/src/Controls/src/Core/HandlerImpl/Toolbar/Toolbar.Tizen.cs
new file mode 100644
index 000000000000..bf5d0a4cda5e
--- /dev/null
+++ b/src/Controls/src/Core/HandlerImpl/Toolbar/Toolbar.Tizen.cs
@@ -0,0 +1,97 @@
+#nullable enable
+
+using System;
+using Microsoft.Maui.Controls.Platform;
+
+namespace Microsoft.Maui.Controls
+{
+ public partial class Toolbar
+ {
+ IPlatformViewHandler? _nativeTitleViewHandler;
+ MauiToolbar PlatformView => Handler?.PlatformView as MauiToolbar ?? throw new InvalidOperationException("Native View not set");
+
+ public static void MapBarTextColor(ToolbarHandler handler, Toolbar toolbar)
+ {
+ handler.PlatformView.UpdateBarTextColor(toolbar);
+ }
+
+ public static void MapBarBackgroundColor(ToolbarHandler handler, Toolbar toolbar)
+ {
+ handler.PlatformView.UpdateBarBackgroundColor(toolbar);
+ }
+
+ public static void MapBackButtonTitle(ToolbarHandler handler, Toolbar toolbar)
+ {
+ handler.PlatformView.UpdateBackButton(toolbar);
+ }
+
+ public static void MapToolbarItems(ToolbarHandler handler, Toolbar toolbar)
+ {
+ toolbar.UpdateMenu();
+ }
+
+ public static void MapTitle(ToolbarHandler handler, Toolbar toolbar)
+ {
+ handler.PlatformView.UpdateTitle(toolbar);
+ }
+
+ public static void MapTitleView(ToolbarHandler handler, Toolbar toolbar)
+ {
+ toolbar.UpdateTitleView();
+ }
+
+ public static void MapTitleIcon(ToolbarHandler handler, Toolbar toolbar)
+ {
+ handler.PlatformView.UpdateTitleIcon(toolbar);
+ }
+
+ public static void MapBackButtonVisible(ToolbarHandler handler, Toolbar toolbar)
+ {
+ handler.PlatformView.UpdateBackButton(toolbar);
+ }
+
+ public static void MapIsVisible(ToolbarHandler handler, Toolbar toolbar)
+ {
+ handler.PlatformView.UpdateIsVisible(toolbar);
+ }
+
+ public static void MapBarBackground(ToolbarHandler handler, Toolbar toolbar)
+ {
+ handler.PlatformView.UpdateBarBackgroundColor(toolbar);
+ }
+
+ [MissingMapper]
+ public static void MapIconColor(ToolbarHandler handler, Toolbar toolbar) { }
+
+ void UpdateTitleView()
+ {
+ _ = MauiContext ?? throw new ArgumentNullException(nameof(MauiContext));
+
+ VisualElement titleView = TitleView;
+ if (_nativeTitleViewHandler != null)
+ {
+ PlatformView.Content = null;
+ _nativeTitleViewHandler.Dispose();
+ _nativeTitleViewHandler = null;
+ }
+
+ if (titleView == null)
+ {
+ PlatformView.UpdateTitle(this);
+ return;
+ }
+
+ var nativeTitleView = titleView.ToPlatform(MauiContext);
+ _nativeTitleViewHandler = titleView.Handler as IPlatformViewHandler;
+
+ PlatformView.Title = string.Empty;
+ PlatformView.Content = nativeTitleView;
+ }
+
+ void UpdateMenu()
+ {
+ _ = MauiContext ?? throw new ArgumentNullException(nameof(MauiContext));
+ PlatformView.UpdateMenuItems(this);
+ }
+ }
+}
diff --git a/src/Controls/src/Core/HandlerImpl/Toolbar/Toolbar.cs b/src/Controls/src/Core/HandlerImpl/Toolbar/Toolbar.cs
index c159a00fad7e..d5bed1cca6e6 100644
--- a/src/Controls/src/Core/HandlerImpl/Toolbar/Toolbar.cs
+++ b/src/Controls/src/Core/HandlerImpl/Toolbar/Toolbar.cs
@@ -17,9 +17,9 @@ public partial class Toolbar
public static IPropertyMapper ControlsToolbarMapper =
new PropertyMapper(ToolbarHandler.Mapper)
{
-#if ANDROID || WINDOWS
+#if ANDROID || WINDOWS || TIZEN
[nameof(IToolbar.IsVisible)] = MapIsVisible,
- [nameof(IToolbar.BackButtonVisible)] = MapBackButtonVisible,
+ [nameof(IToolbar.BackButtonVisible)] = MapBackButtonVisible,
[nameof(Toolbar.TitleIcon)] = MapTitleIcon,
[nameof(Toolbar.TitleView)] = MapTitleView,
[nameof(Toolbar.IconColor)] = MapIconColor,
diff --git a/src/Controls/src/Core/HandlerImpl/VisualElement/VisualElement.Platform.cs b/src/Controls/src/Core/HandlerImpl/VisualElement/VisualElement.Platform.cs
index 88058852a141..6b94d274b238 100644
--- a/src/Controls/src/Core/HandlerImpl/VisualElement/VisualElement.Platform.cs
+++ b/src/Controls/src/Core/HandlerImpl/VisualElement/VisualElement.Platform.cs
@@ -9,7 +9,7 @@
#elif WINDOWS
using PlatformView = Microsoft.UI.Xaml.FrameworkElement;
#elif TIZEN
-using PlatformView = ElmSharp.EvasObject;
+using PlatformView = Tizen.NUI.BaseComponents.View;
#endif
namespace Microsoft.Maui.Controls
diff --git a/src/Controls/src/Core/HandlerImpl/VisualElement/VisualElement.Tizen.cs b/src/Controls/src/Core/HandlerImpl/VisualElement/VisualElement.Tizen.cs
new file mode 100644
index 000000000000..5195d1ae8978
--- /dev/null
+++ b/src/Controls/src/Core/HandlerImpl/VisualElement/VisualElement.Tizen.cs
@@ -0,0 +1,7 @@
+namespace Microsoft.Maui.Controls
+{
+ public partial class VisualElement
+ {
+
+ }
+}
\ No newline at end of file
diff --git a/src/Controls/src/Core/HandlerImpl/Window/Window.Tizen.cs b/src/Controls/src/Core/HandlerImpl/Window/Window.Tizen.cs
index 8c27288b79d9..d4fc5795d39a 100644
--- a/src/Controls/src/Core/HandlerImpl/Window/Window.Tizen.cs
+++ b/src/Controls/src/Core/HandlerImpl/Window/Window.Tizen.cs
@@ -1,12 +1,12 @@
#nullable enable
using System;
-using EWindow = ElmSharp.Window;
+using NWindow = Tizen.NUI.Window;
namespace Microsoft.Maui.Controls
{
public partial class Window
{
- internal EWindow NativeWindow =>
- (Handler?.PlatformView as EWindow) ?? throw new InvalidOperationException("Window should have a ElmSharp.Window set.");
+ internal NWindow NativeWindow =>
+ (Handler?.PlatformView as NWindow) ?? throw new InvalidOperationException("Window should have a Tizen.NUI.Window set.");
}
}
\ No newline at end of file
diff --git a/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.Tizen.cs b/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.Tizen.cs
index 73542dc5b865..15c3fc085d00 100644
--- a/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.Tizen.cs
+++ b/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.Tizen.cs
@@ -1,18 +1,41 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Microsoft.Maui.Handlers;
+using TCollectionView = Tizen.UIExtensions.NUI.CollectionView;
namespace Microsoft.Maui.Controls.Handlers.Items
{
public partial class CarouselViewHandler : ItemsViewHandler
{
- //TODO : Need to impl
- public static void MapCurrentItem(CarouselViewHandler handler, CarouselView carouselView) { }
- public static void MapPosition(CarouselViewHandler handler, CarouselView carouselView) { }
+ protected override TCollectionView CreatePlatformView()
+ {
+ return new MauiCarouselView();
+ }
+
+ public static void MapCurrentItem(CarouselViewHandler handler, CarouselView carouselView)
+ {
+ (handler.PlatformView as MauiCarouselView)?.UpdateCurrentItem();
+ }
+
+ public static void MapPosition(CarouselViewHandler handler, CarouselView carouselView)
+ {
+ (handler.PlatformView as MauiCarouselView)?.UpdatePosition();
+ }
+
+ [MissingMapper]
public static void MapIsBounceEnabled(CarouselViewHandler handler, CarouselView carouselView) { }
- public static void MapIsSwipeEnabled(CarouselViewHandler handler, CarouselView carouselView) { }
+
+ public static void MapIsSwipeEnabled(CarouselViewHandler handler, CarouselView carouselView)
+ {
+ (handler.PlatformView as MauiCarouselView)?.UpdateIsSwipeEnabled();
+ }
+
+ [MissingMapper]
public static void MapPeekAreaInsets(CarouselViewHandler handler, CarouselView carouselView) { }
+
+ [MissingMapper]
public static void MapLoop(CarouselViewHandler handler, CarouselView carouselView) { }
+
+ public static void MapItemsLayout(CarouselViewHandler handler, CarouselView itemsView)
+ {
+ (handler.PlatformView as MauiCarouselView)?.UpdateLayoutManager();
+ }
}
}
diff --git a/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs b/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs
index 1376a44bc70d..658448d1029e 100644
--- a/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs
+++ b/src/Controls/src/Core/Handlers/Items/CarouselViewHandler.cs
@@ -13,6 +13,9 @@ public CarouselViewHandler(PropertyMapper mapper = null) : base(mapper ?? Mapper
public static PropertyMapper Mapper = new PropertyMapper | |