diff --git a/src/Compatibility/Core/src/Forms.cs b/src/Compatibility/Core/src/Forms.cs index d1060efe372a..9b4c24ec1a45 100644 --- a/src/Compatibility/Core/src/Forms.cs +++ b/src/Compatibility/Core/src/Forms.cs @@ -1,4 +1,4 @@ -#if !(__ANDROID__ || __IOS__ || WINDOWS || (__TIZEN__ || TIZEN)) +#if !(__ANDROID__ || __IOS__ || WINDOWS || TIZEN) using System; using System.Collections.Generic; using System.Text; diff --git a/src/Compatibility/Core/src/Tizen/Forms.cs b/src/Compatibility/Core/src/Tizen/Forms.cs index af5beaf646e2..f68d0dbe75e8 100644 --- a/src/Compatibility/Core/src/Tizen/Forms.cs +++ b/src/Compatibility/Core/src/Tizen/Forms.cs @@ -282,7 +282,7 @@ public static bool IsInitialized public static bool UseFastLayout { get; private set; } - public static DisplayResolutionUnit DisplayResolutionUnit { get; private set; } + public static DisplayResolutionUnit DisplayResolutionUnit { get; private set; } = DisplayResolutionUnit.Pixel(); public static int ScreenDPI => s_dpi.Value; @@ -394,11 +394,13 @@ public static TOut GetHandlerForObject(object obj, params object[] args) w public static void Init(IActivationState activationState) => Init(activationState.Context); + public static void Init(IActivationState activationState, InitializationOptions options) => Init(activationState.Context, options); + public static void Init(CoreApplication application) => Init(new MauiContext(CoreUIAppContext.GetInstance(application))); - public static void Init(IMauiContext context) + public static void Init(IMauiContext context, InitializationOptions options = null) { - SetupInit(context); + SetupInit(context, options); } public static void Init(CoreApplication application, bool useDeviceIndependentPixel) @@ -465,6 +467,13 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null IsInitialized = true; } + // Once we get essentials/cg converted to using startup.cs + // we will delete all the renderer code inside this file + internal static void RenderersRegistered() + { + IsInitializedRenderers = true; + } + internal static void RegisterCompatRenderers(InitializationOptions options) { if (!IsInitializedRenderers) diff --git a/src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs b/src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs index b4be3520db6d..74185fe40c26 100644 --- a/src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs +++ b/src/Compatibility/Core/src/Tizen/HandlerToRendererShim.cs @@ -1,5 +1,6 @@ using System; using System.ComponentModel; +using Microsoft.Maui.Controls.Platform; using Microsoft.Maui.Controls.Internals; using Microsoft.Maui.Graphics; using EvasObject = ElmSharp.EvasObject; diff --git a/src/Compatibility/Core/src/Tizen/Renderers/IVisualElementRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/IVisualElementRenderer.cs index 56e494cd787c..df238d13ed80 100644 --- a/src/Compatibility/Core/src/Tizen/Renderers/IVisualElementRenderer.cs +++ b/src/Compatibility/Core/src/Tizen/Renderers/IVisualElementRenderer.cs @@ -1,5 +1,6 @@ using System; using ElmSharp; +using Microsoft.Maui.Controls.Platform; using ERect = ElmSharp.Rect; namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen diff --git a/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs b/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs index 7f5902fa8238..186c7cce98ac 100644 --- a/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs +++ b/src/Compatibility/Core/src/Tizen/Renderers/VisualElementRenderer.cs @@ -4,6 +4,7 @@ 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 Size = Microsoft.Maui.Graphics.Size; diff --git a/src/Compatibility/Core/src/Tizen/VisualElementChangedEventArgs.cs b/src/Compatibility/Core/src/Tizen/VisualElementChangedEventArgs.cs deleted file mode 100644 index 229309021c3e..000000000000 --- a/src/Compatibility/Core/src/Tizen/VisualElementChangedEventArgs.cs +++ /dev/null @@ -1,17 +0,0 @@ -namespace Microsoft.Maui.Controls.Compatibility.Platform.Tizen -{ - /// - /// Represents the arguments passed to every VisualElement change event. - /// - public class VisualElementChangedEventArgs : ElementChangedEventArgs - { - /// - /// Initializes a new instance of the class. - /// - /// Old element. - /// New element. - public VisualElementChangedEventArgs(VisualElement oldElement, VisualElement newElement) : base(oldElement, newElement) - { - } - } -} diff --git a/src/Controls/samples/Controls.Sample.Tizen/Controls.Sample.Tizen.csproj b/src/Controls/samples/Controls.Sample.Tizen/Controls.Sample.Tizen.csproj index bb9f7b218e01..4fd7ad8f8234 100644 --- a/src/Controls/samples/Controls.Sample.Tizen/Controls.Sample.Tizen.csproj +++ b/src/Controls/samples/Controls.Sample.Tizen/Controls.Sample.Tizen.csproj @@ -3,8 +3,6 @@ Exe tizen40 - - Maui.Controls.Sample.Tizen Maui.Controls.Sample.Tizen diff --git a/src/Controls/samples/Controls.Sample/Startup.cs b/src/Controls/samples/Controls.Sample/Startup.cs index 6715797622a0..ae8445d2852c 100644 --- a/src/Controls/samples/Controls.Sample/Startup.cs +++ b/src/Controls/samples/Controls.Sample/Startup.cs @@ -71,7 +71,10 @@ public static MauiApp CreateMauiApp() //#elif WINDOWS // handlers.AddCompatibilityRenderer(typeof(CustomButton), // typeof(Microsoft.Maui.Controls.Compatibility.Platform.UWP.ButtonRenderer)); -//#endif +// #elif TIZEN +// handlers.AddCompatibilityRenderer(typeof(CustomButton), +// typeof(Microsoft.Maui.Controls.Compatibility.Platform.Tizen.ButtonRenderer)); +// #endif //#pragma warning restore CS0618 // Type or member is obsolete // }); @@ -227,7 +230,7 @@ public static MauiApp CreateMauiApp() .OnClosed((a, b) => LogEvent(nameof(WindowsLifecycle.OnClosed))) .OnLaunched((a, b) => LogEvent(nameof(WindowsLifecycle.OnLaunched))) .OnVisibilityChanged((a, b) => LogEvent(nameof(WindowsLifecycle.OnVisibilityChanged)))); -#elif __TIZEN__ || TIZEN +#elif TIZEN events.AddTizen(tizen => tizen .OnAppControlReceived((a, b) => LogEvent(nameof(TizenLifecycle.OnAppControlReceived))) .OnCreate((a) => LogEvent(nameof(TizenLifecycle.OnCreate))) diff --git a/src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs b/src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs index cc820929d014..98c9b5a33517 100644 --- a/src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs +++ b/src/Core/src/Handlers/Editor/EditorHandler.Tizen.cs @@ -82,6 +82,11 @@ public static void MapFormatting(EditorHandler handler, IEditor editor) handler.NativeView?.UpdateMaxLength(editor); } + public static void MapKeyboard(EditorHandler handler, IEditor editor) + { + handler.NativeView?.UpdateKeyboard(editor); + } + [MissingMapper] public static void MapCharacterSpacing(EditorHandler handler, IEditor editor) { } diff --git a/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs b/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs index f8fc8b8f79c9..01df1b029a1d 100644 --- a/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs +++ b/src/Core/src/Handlers/Entry/EntryHandler.Tizen.cs @@ -1,11 +1,13 @@ using System; using Tizen.UIExtensions.ElmSharp; +using SmartEvent = ElmSharp.SmartEvent; using EEntry = ElmSharp.Entry; namespace Microsoft.Maui.Handlers { public partial class EntryHandler : ViewHandler { + protected override Entry CreateNativeView() { return new EditfieldEntry(NativeParent) @@ -17,14 +19,37 @@ protected override Entry CreateNativeView() protected override void ConnectHandler(Entry nativeView) { nativeView.Activated += OnCompleted; + nativeView.CursorChanged += OnCursorChanged; + + // In order to know when the selection is cleared, "selecton,cleared" event has been used. + // Because CursorChanged event is still invoked with the selected text when an user clears selection. It is an known issue in EFL. + SmartEvent selectionCleared = new SmartEvent(nativeView, nativeView.RealHandle, ThemeConstants.Entry.Signals.SelectionCleared); + selectionCleared.On += OnSelectionCleared; + nativeView.TextChanged += OnTextChanged; + nativeView.EntryLayoutFocused += OnFocused; + nativeView.EntryLayoutUnfocused += OnUnfocused; + nativeView.PrependMarkUpFilter(MaxLengthFilter); + + // TODO: Fix me later + // An initial CursorPosition is set after layouting to avoid timing issue when the EditField entry is initialized. + //if (VirtualView != null) + //{ + // MainThread.BeginInvokeOnMainThread(() => + // { + // nativeView.UpdateSelectionLength(VirtualView); + // }); + //} } protected override void DisconnectHandler(Entry nativeView) { nativeView.Activated -= OnCompleted; + nativeView.CursorChanged -= OnCursorChanged; nativeView.TextChanged -= OnTextChanged; + nativeView.EntryLayoutFocused -= OnFocused; + nativeView.EntryLayoutUnfocused -= OnUnfocused; } public static void MapText(EntryHandler handler, IEntry entry) @@ -101,6 +126,21 @@ public static void MapFormatting(EntryHandler handler, IEntry entry) handler.NativeView?.UpdateHorizontalTextAlignment(entry); } + public static void MapSelectionLength(EntryHandler handler, IEntry entry) + { + handler.NativeView?.UpdateSelectionLength(entry); + } + + public static void MapCursorPosition(EntryHandler handler, IEntry entry) + { + handler.NativeView?.UpdateSelectionLength(entry); + } + + public static void MapKeyboard(EditorHandler handler, IEditor editor) + { + handler.NativeView?.UpdateKeyboard(editor); + } + [MissingMapper] public static void MapCharacterSpacing(EntryHandler handler, IEntry entry) { } @@ -123,6 +163,37 @@ void OnTextChanged(object? sender, EventArgs e) VirtualView.Text = NativeView.Text; } + void OnCursorChanged(object? sender, EventArgs e) + { + if (VirtualView == null || NativeView == null) + return; + + var position = NativeView.CursorPosition; + + NativeView.GetSelectRegion(out int start, out int end); + + if (start > -1) + { + position = (start < end) ? start : end; + var selectionLength = Math.Abs(end - start); + VirtualView.SelectionLength = selectionLength; + } + + VirtualView.CursorPosition = position; + } + + void OnSelectionCleared(object sender, EventArgs e) + { + if (VirtualView == null || NativeView == null) + return; + + if (NativeView.IsFocused) + { + VirtualView.SelectionLength = 0; + VirtualView.CursorPosition = NativeView.CursorPosition; + } + } + void OnCompleted(object? sender, EventArgs e) { if (NativeView == null) diff --git a/src/Core/src/Handlers/GraphicsView/GraphicsViewHandler.Tizen.cs b/src/Core/src/Handlers/GraphicsView/GraphicsViewHandler.Tizen.cs new file mode 100644 index 000000000000..361bb245017e --- /dev/null +++ b/src/Core/src/Handlers/GraphicsView/GraphicsViewHandler.Tizen.cs @@ -0,0 +1,17 @@ +using Microsoft.Maui.Graphics.Skia.Views; + +namespace Microsoft.Maui.Handlers +{ + public partial class GraphicsViewHandler : ViewHandler + { + protected override SkiaGraphicsView CreateNativeView() + { + return new SkiaGraphicsView(NativeParent); + } + + public static void MapDrawable(GraphicsViewHandler handler, IGraphicsView graphicsView) + { + handler.NativeView?.UpdateDrawable(graphicsView); + } + } +} \ No newline at end of file diff --git a/src/Core/src/Handlers/Page/PageHandler.Tizen.cs b/src/Core/src/Handlers/Page/PageHandler.Tizen.cs index 1fc9097295df..a85caa596a33 100644 --- a/src/Core/src/Handlers/Page/PageHandler.Tizen.cs +++ b/src/Core/src/Handlers/Page/PageHandler.Tizen.cs @@ -1,30 +1,31 @@ using System; using Tizen.UIExtensions.Common; +using Tizen.UIExtensions.ElmSharp; using NativeView = ElmSharp.EvasObject; namespace Microsoft.Maui.Handlers { - public partial class PageHandler : ViewHandler, INativeViewHandler + public partial class PageHandler : ViewHandler, INativeViewHandler { INativeViewHandler? _contentHandler; - protected override PageView CreateNativeView() + protected override Page CreateNativeView() { _ = VirtualView ?? throw new InvalidOperationException($"{nameof(VirtualView)} must be set to create a Page"); _ = NativeParent ?? throw new InvalidOperationException($"{nameof(NativeParent)} cannot be null"); - var view = new PageView(NativeParent); + var view = new Page(NativeParent); view.Show(); return view; } - protected override void ConnectHandler(PageView nativeView) + protected override void ConnectHandler(Page nativeView) { base.ConnectHandler(nativeView); nativeView.LayoutUpdated += OnLayoutUpdated; } - protected override void DisconnectHandler(PageView nativeView) + protected override void DisconnectHandler(Page nativeView) { base.DisconnectHandler(nativeView); nativeView.LayoutUpdated -= OnLayoutUpdated; diff --git a/src/Core/src/Handlers/Picker/PickerHandler.Tizen.cs b/src/Core/src/Handlers/Picker/PickerHandler.Tizen.cs index 9ce5564a6037..a43e02593d2f 100644 --- a/src/Core/src/Handlers/Picker/PickerHandler.Tizen.cs +++ b/src/Core/src/Handlers/Picker/PickerHandler.Tizen.cs @@ -64,6 +64,11 @@ void Reload() public static void MapReload(PickerHandler handler, IPicker picker) => handler.Reload(); + public static void MapTitleColor(PickerHandler handler, IPicker picker) + { + handler.NativeView?.UpdateTitleColor(picker); + } + public static void MapFont(PickerHandler handler, IPicker picker) { var fontManager = handler.GetRequiredService(); diff --git a/src/Core/src/Handlers/SearchBar/SearchBarHandler.Tizen.cs b/src/Core/src/Handlers/SearchBar/SearchBarHandler.Tizen.cs index d7085f47d92d..870e875d3cc4 100644 --- a/src/Core/src/Handlers/SearchBar/SearchBarHandler.Tizen.cs +++ b/src/Core/src/Handlers/SearchBar/SearchBarHandler.Tizen.cs @@ -22,6 +22,8 @@ protected override void ConnectHandler(SearchBar nativeView) nativeView.Activated += OnActivated; nativeView.TextChanged += OnTextChanged; nativeView.PrependMarkUpFilter(MaxLengthFilter); + nativeView.EntryLayoutFocused += OnFocused; + nativeView.EntryLayoutUnfocused += OnUnfocused; } @@ -29,6 +31,8 @@ protected override void DisconnectHandler(SearchBar nativeView) { nativeView.Activated -= OnActivated; nativeView.TextChanged -= OnTextChanged; + nativeView.EntryLayoutFocused -= OnFocused; + nativeView.EntryLayoutUnfocused -= OnUnfocused; } public static void MapText(SearchBarHandler handler, ISearchBar searchBar) @@ -90,6 +94,11 @@ public static void MapFormatting(SearchBarHandler handler, ISearchBar searchBar) handler.NativeView?.UpdateHorizontalTextAlignment(searchBar); } + public static void MapCancelButtonColor(SearchBarHandler handler, ISearchBar searchBar) + { + handler.NativeView?.UpdateCancelButtonColor(searchBar); + } + [MissingMapper] public static void MapCharacterSpacing(SearchBarHandler handler, ISearchBar searchBar) { } diff --git a/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Tizen.cs b/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Tizen.cs new file mode 100644 index 000000000000..b0013175afec --- /dev/null +++ b/src/Core/src/Handlers/ShapeView/ShapeViewHandler.Tizen.cs @@ -0,0 +1,57 @@ +using Microsoft.Maui.Graphics; + +namespace Microsoft.Maui.Handlers +{ + public partial class ShapeViewHandler : ViewHandler + { + protected override MauiShapeView CreateNativeView() + { + return new MauiShapeView(NativeParent!); + } + + public static void MapShape(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.UpdateShape(shapeView); + } + + public static void MapAspect(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.InvalidateShape(shapeView); + } + + public static void MapFill(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.InvalidateShape(shapeView); + } + + public static void MapStroke(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.InvalidateShape(shapeView); + } + + public static void MapStrokeThickness(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.InvalidateShape(shapeView); + } + + public static void MapStrokeDashPattern(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.InvalidateShape(shapeView); + } + + public static void MapStrokeLineCap(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.InvalidateShape(shapeView); + } + + public static void MapStrokeLineJoin(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.InvalidateShape(shapeView); + } + + public static void MapStrokeMiterLimit(ShapeViewHandler handler, IShapeView shapeView) + { + handler.NativeView?.InvalidateShape(shapeView); + } + } +} \ No newline at end of file diff --git a/src/Core/src/Handlers/Slider/SliderHandler.Tizen.cs b/src/Core/src/Handlers/Slider/SliderHandler.Tizen.cs index 1a08127e9ebb..884755f80a50 100644 --- a/src/Core/src/Handlers/Slider/SliderHandler.Tizen.cs +++ b/src/Core/src/Handlers/Slider/SliderHandler.Tizen.cs @@ -66,6 +66,9 @@ public static void MapThumbColor(SliderHandler handler, ISlider slider) handler.NativeView?.UpdateThumbColor(slider, DefaultThumbColor); } + [MissingMapper] + public static void MapThumbImageSource(SliderHandler handler, ISlider slider) { } + void OnControlValueChanged(object? sender, EventArgs eventArgs) { if (NativeView == null || VirtualView == null) diff --git a/src/Core/src/Platform/Tizen/EntryExtensions.cs b/src/Core/src/Platform/Tizen/EntryExtensions.cs index aaec284fccd7..ce60baee45bd 100644 --- a/src/Core/src/Platform/Tizen/EntryExtensions.cs +++ b/src/Core/src/Platform/Tizen/EntryExtensions.cs @@ -1,4 +1,6 @@ -using Tizen.UIExtensions.Common; +using System; +using System.Runtime.InteropServices; +using Tizen.UIExtensions.Common; using Tizen.UIExtensions.ElmSharp; using InputPanelReturnKeyType = ElmSharp.InputPanelReturnKeyType; using TTextAlignment = Tizen.UIExtensions.Common.TextAlignment; @@ -85,6 +87,51 @@ public static void UpdateMaxLength(this Entry nativeEntry, ITextInput entry) nativeEntry.Text = nativeEntry.Text.Substring(0, entry.MaxLength); } + /* Updates both the IEntry.CursorPosition and IEntry.SelectionLength properties. */ + [PortHandler] + public static void UpdateSelectionLength(this Entry nativeEntry, IEntry entry) + { + var start = GetSelectionStart(nativeEntry, entry); + var end = GetSelectionEnd(nativeEntry, entry, start); + var selectionLength = end - start; + + if (selectionLength != entry.SelectionLength) + entry.SelectionLength = selectionLength; + + if (selectionLength > 0) + { + nativeEntry.SetSelectionRegion(start, end); + } + else + { + nativeEntry.CursorPosition = entry.CursorPosition; + } + } + + static int GetSelectionStart(Entry nativeEntry, IEntry entry) + { + var start = entry.Text?.Length ?? 0; + var cursorPosition = entry.CursorPosition; + + if (entry.CursorPosition > 0) + start = Math.Min(start, cursorPosition); + + if (start != cursorPosition) + entry.CursorPosition = start; + + return start; + } + + static int GetSelectionEnd(Entry nativeEntry, IEntry entry, int start) + { + var end = start; + + if (entry.SelectionLength > 0) + end = Math.Min((start + entry.SelectionLength), entry.Text?.Length ?? 0); + + return end; + } + public static InputPanelReturnKeyType ToInputPanelReturnKeyType(this ReturnType returnType) { switch (returnType) @@ -147,5 +194,13 @@ public static double ToNativeDouble(this TextAlignment alignment) return 0.5d; } } + + public static void GetSelectRegion(this Entry 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/Core/src/Platform/Tizen/GraphicsViewExtensions.cs b/src/Core/src/Platform/Tizen/GraphicsViewExtensions.cs new file mode 100644 index 000000000000..978262a5c46a --- /dev/null +++ b/src/Core/src/Platform/Tizen/GraphicsViewExtensions.cs @@ -0,0 +1,12 @@ +using Microsoft.Maui.Graphics.Skia.Views; + +namespace Microsoft.Maui +{ + public static class GraphicsViewExtensions + { + public static void UpdateDrawable(this SkiaGraphicsView nativeGraphicsView, IGraphicsView graphicsView) + { + nativeGraphicsView.Drawable = graphicsView.Drawable; + } + } +} \ No newline at end of file diff --git a/src/Core/src/Platform/Tizen/HandlerExtensions.cs b/src/Core/src/Platform/Tizen/HandlerExtensions.cs index eb58125d4f4c..e55243bcb187 100644 --- a/src/Core/src/Platform/Tizen/HandlerExtensions.cs +++ b/src/Core/src/Platform/Tizen/HandlerExtensions.cs @@ -16,6 +16,12 @@ public static EvasObject ToNative(this IView view, IMauiContext context) var handler = view.Handler; + if (handler?.MauiContext != null && + handler.MauiContext != context) + { + handler = null; + } + if (handler == null) { handler = context.Handlers.GetHandler(view.GetType()); @@ -24,10 +30,13 @@ public static EvasObject ToNative(this IView view, IMauiContext context) throw new Exception($"Handler not found for view {view}"); handler.SetMauiContext(context); - handler.SetVirtualView(view); view.Handler = handler; } + if (handler.VirtualView != view) + handler.SetVirtualView(view); + + if (((INativeViewHandler)handler).NativeView is not EvasObject result) { throw new InvalidOperationException($"Unable to convert {view} to {typeof(EvasObject)}"); diff --git a/src/Core/src/Platform/Tizen/MauiApplication.cs b/src/Core/src/Platform/Tizen/MauiApplication.cs index bf4a808a9ef1..62697a4592aa 100644 --- a/src/Core/src/Platform/Tizen/MauiApplication.cs +++ b/src/Core/src/Platform/Tizen/MauiApplication.cs @@ -10,9 +10,9 @@ namespace Microsoft.Maui public class MauiApplication : MauiApplication where TStartup : IStartup, new() { - protected override void OnCreate() + protected override void OnPreCreate() { - base.OnCreate(); + base.OnPreCreate(); var startup = new TStartup(); @@ -25,14 +25,35 @@ protected override void OnCreate() Services = host.Services; Application = Services.GetRequiredService(); + Current.Services?.InvokeLifecycleEvents(del => del(this)); + } + + protected override void OnCreate() + { + base.OnCreate(); + + var services = MauiApplication.Current.Services; + var mauiApp = MauiApplication.Current.Application; + + MauiContext mauiContext; + IWindow window; + var context = CoreUIAppContext.GetInstance(this); - var mauiContext = new MauiContext(Services, context); - var activationState = new ActivationState(mauiContext); - var window = Application.CreateWindow(activationState); + // TODO Fix once we have multiple windows + if (mauiApp.Windows.Count > 0) + { + window = mauiApp.Windows[0]; + mauiContext = new MauiContext(services, context); + } + else + { + mauiContext = new MauiContext(services, context); + ActivationState state = new ActivationState(mauiContext); + window = mauiApp.CreateWindow(state); + } var page = window.View; - context.SetContent(page.ToNative(mauiContext)); Current.Services?.InvokeLifecycleEvents(del => del(this)); @@ -74,12 +95,6 @@ protected override void OnPause() Current.Services?.InvokeLifecycleEvents(del => del(this)); } - protected override void OnPreCreate() - { - base.OnPreCreate(); - Current.Services?.InvokeLifecycleEvents(del => del(this)); - } - protected override void OnRegionFormatChanged(RegionFormatChangedEventArgs e) { base.OnRegionFormatChanged(e); diff --git a/src/Core/src/Platform/Tizen/MauiShapeView.cs b/src/Core/src/Platform/Tizen/MauiShapeView.cs new file mode 100644 index 000000000000..856540085da7 --- /dev/null +++ b/src/Core/src/Platform/Tizen/MauiShapeView.cs @@ -0,0 +1,13 @@ +using ElmSharp; +using Microsoft.Maui.Graphics.Skia.Views; + +namespace Microsoft.Maui +{ + public class MauiShapeView : SkiaGraphicsView + { + public MauiShapeView(EvasObject parent) : base(parent) + { + + } + } +} \ No newline at end of file diff --git a/src/Core/src/Platform/Tizen/PageView.cs b/src/Core/src/Platform/Tizen/PageView.cs deleted file mode 100644 index 013f11775913..000000000000 --- a/src/Core/src/Platform/Tizen/PageView.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using Microsoft.Maui.Graphics; -using Tizen.UIExtensions.ElmSharp; - -namespace Microsoft.Maui -{ - public class PageView : Page - { - public PageView(ElmSharp.EvasObject parent) : base(parent) - { - } - } -} diff --git a/src/Core/src/Platform/Tizen/PickerExtensions.cs b/src/Core/src/Platform/Tizen/PickerExtensions.cs index 974c2e97ba12..5ab618ce0979 100644 --- a/src/Core/src/Platform/Tizen/PickerExtensions.cs +++ b/src/Core/src/Platform/Tizen/PickerExtensions.cs @@ -7,6 +7,9 @@ public static class PickerExtensions public static void UpdateTitle(this Entry nativePicker, IPicker picker) => UpdatePicker(nativePicker, picker); + public static void UpdateTitleColor(this Entry nativePicker, IPicker picker) => + nativePicker.PlaceholderColor = picker.TitleColor.ToNative(); + public static void UpdateSelectedIndex(this Entry nativePicker, IPicker picker) => UpdatePicker(nativePicker, picker); diff --git a/src/Core/src/Platform/Tizen/SearchBarExtensions.cs b/src/Core/src/Platform/Tizen/SearchBarExtensions.cs new file mode 100644 index 000000000000..6c55af856c83 --- /dev/null +++ b/src/Core/src/Platform/Tizen/SearchBarExtensions.cs @@ -0,0 +1,12 @@ +using Tizen.UIExtensions.ElmSharp; + +namespace Microsoft.Maui +{ + public static class SearchBarExtensions + { + public static void UpdateCancelButtonColor(this SearchBar nativeView, ISearchBar searchBar) + { + nativeView.SetClearButtonColor(searchBar.CancelButtonColor.ToNativeEFL()); + } + } +} diff --git a/src/Core/src/Platform/Tizen/ShapeViewExtensions.cs b/src/Core/src/Platform/Tizen/ShapeViewExtensions.cs new file mode 100644 index 000000000000..d2ba90b21a76 --- /dev/null +++ b/src/Core/src/Platform/Tizen/ShapeViewExtensions.cs @@ -0,0 +1,17 @@ +using Microsoft.Maui.Graphics; + +namespace Microsoft.Maui +{ + public static class ShapeViewExtensions + { + public static void UpdateShape(this MauiShapeView nativeView, IShapeView shapeView) + { + nativeView.Drawable = new ShapeDrawable(shapeView); + } + + public static void InvalidateShape(this MauiShapeView nativeView, IShapeView shapeView) + { + nativeView.Invalidate(); + } + } +} \ No newline at end of file diff --git a/src/Core/src/Platform/Tizen/ViewExtensions.cs b/src/Core/src/Platform/Tizen/ViewExtensions.cs index 28e0f12bf9e6..c3452b102079 100644 --- a/src/Core/src/Platform/Tizen/ViewExtensions.cs +++ b/src/Core/src/Platform/Tizen/ViewExtensions.cs @@ -52,6 +52,14 @@ public static void UpdateBackground(this EvasObject nativeView, IView view) } } + public static void UpdateOpacity(this EvasObject nativeView, IView view) + { + if (nativeView is Widget widget) + { + widget.Opacity = (int)(view.Opacity * 255.0); + } + } + public static void UpdateAutomationId(this EvasObject nativeView, IView view) { {