From 6d9594f9e11dabab70b4bf8dfb579b0d49d12538 Mon Sep 17 00:00:00 2001 From: Kangho Hur Date: Tue, 29 Jun 2021 10:22:31 +0900 Subject: [PATCH] Bump to latest - Apply to patch related to Animation (#1436) - Apply to register Microsoft.Maui.Graphics Platforms (#1441) - and so on. --- .../Core/src/Tizen/TizenPlatformServices.cs | 30 +------------ .../ModalNavigationService.Tizen.cs | 22 ++++++++++ src/Core/src/Animations/NativeTicker.Tizen.cs | 42 +++++++++++++++++++ .../Tizen/TizenLifecycleExtensions.cs | 5 ++- .../src/Platform/Tizen/MauiApplication.cs | 22 ++++++---- .../SkiaGraphicsService.cs | 5 +++ src/Core/src/Platform/Tizen/ViewExtensions.cs | 5 +++ 7 files changed, 92 insertions(+), 39 deletions(-) create mode 100644 src/Controls/src/Core/Platform/ModalNavigationService/ModalNavigationService.Tizen.cs create mode 100644 src/Core/src/Animations/NativeTicker.Tizen.cs diff --git a/src/Compatibility/Core/src/Tizen/TizenPlatformServices.cs b/src/Compatibility/Core/src/Tizen/TizenPlatformServices.cs index 3085ec1bb53a..55121ad3fbe3 100644 --- a/src/Compatibility/Core/src/Tizen/TizenPlatformServices.cs +++ b/src/Compatibility/Core/src/Tizen/TizenPlatformServices.cs @@ -7,6 +7,7 @@ using System.Threading; using System.Threading.Tasks; using ElmSharp; +using Microsoft.Maui.Animations; using Microsoft.Maui.Controls.Internals; using TAppControl = Tizen.Applications.AppControl; using Color = Microsoft.Maui.Graphics.Color; @@ -22,30 +23,6 @@ public TizenPlatformServices() s_context = SynchronizationContext.Current; } - public class TizenTicker : Ticker - { - readonly Timer _timer; - - public TizenTicker() - { - _timer = new Timer((object o) => HandleElapsed(o), this, Timeout.Infinite, Timeout.Infinite); - } - - protected override void EnableTimer() - { - _timer.Change(16, 16); - } - - protected override void DisableTimer() - { - _timer.Change(-1, -1); - } - - void HandleElapsed(object state) - { - s_context.Post((o) => SendSignals(-1), null); - } - } #region IPlatformServices implementation public void BeginInvokeOnMainThread(Action action) @@ -53,11 +30,6 @@ public void BeginInvokeOnMainThread(Action action) s_context.Post((o) => action(), null); } - public Ticker CreateTicker() - { - return new TizenTicker(); - } - public void StartTimer(TimeSpan interval, Func callback) { Timer timer = null; diff --git a/src/Controls/src/Core/Platform/ModalNavigationService/ModalNavigationService.Tizen.cs b/src/Controls/src/Core/Platform/ModalNavigationService/ModalNavigationService.Tizen.cs new file mode 100644 index 000000000000..f9800c51b6d9 --- /dev/null +++ b/src/Controls/src/Core/Platform/ModalNavigationService/ModalNavigationService.Tizen.cs @@ -0,0 +1,22 @@ +#nullable enable + +using System; +using System.Threading.Tasks; + +namespace Microsoft.Maui.Controls.Platform +{ + internal partial class ModalNavigationService + { + public Task PopModalAsync(bool animated) + { + // TODO: Need to implementation + throw new NotImplementedException(); + } + + public Task PushModalAsync(Page modal, bool animated) + { + // TODO: Need to implementation + throw new NotImplementedException(); + } + } +} diff --git a/src/Core/src/Animations/NativeTicker.Tizen.cs b/src/Core/src/Animations/NativeTicker.Tizen.cs new file mode 100644 index 000000000000..6d7fc0495fae --- /dev/null +++ b/src/Core/src/Animations/NativeTicker.Tizen.cs @@ -0,0 +1,42 @@ +using System.Threading; +using Tizen.Applications; + +namespace Microsoft.Maui.Animations +{ + public class NativeTicker : Ticker + { + readonly Timer _timer; + readonly SynchronizationContext? _context; + bool _isRunning; + + public override bool IsRunning => _isRunning; + + public NativeTicker() + { + if (SynchronizationContext.Current == null) + { + TizenSynchronizationContext.Initialize(); + } + + _context = SynchronizationContext.Current; + _timer = new Timer((object o) => HandleElapsed(o), this, Timeout.Infinite, Timeout.Infinite); + } + + public override void Start() + { + _timer.Change(16, 16); + _isRunning = true; + } + + public override void Stop() + { + _timer.Change(-1, -1); + _isRunning = false; + } + + void HandleElapsed(object state) + { + _context?.Post((o) => Fire?.Invoke(), null); + } + } +} \ No newline at end of file diff --git a/src/Core/src/LifecycleEvents/Tizen/TizenLifecycleExtensions.cs b/src/Core/src/LifecycleEvents/Tizen/TizenLifecycleExtensions.cs index 4b88192b27ec..b1328b278291 100644 --- a/src/Core/src/LifecycleEvents/Tizen/TizenLifecycleExtensions.cs +++ b/src/Core/src/LifecycleEvents/Tizen/TizenLifecycleExtensions.cs @@ -22,8 +22,11 @@ public LifecycleBuilder(ILifecycleBuilder builder) _builder = builder; } - public void AddEvent(string eventName, Delegate action) => + public void AddEvent(string eventName, TDelegate action) + where TDelegate : Delegate + { _builder.AddEvent(eventName, action); + } } } } \ No newline at end of file diff --git a/src/Core/src/Platform/Tizen/MauiApplication.cs b/src/Core/src/Platform/Tizen/MauiApplication.cs index 62697a4592aa..874435ecd8f0 100644 --- a/src/Core/src/Platform/Tizen/MauiApplication.cs +++ b/src/Core/src/Platform/Tizen/MauiApplication.cs @@ -23,17 +23,21 @@ protected override void OnPreCreate() .Build(); Services = host.Services; - Application = Services.GetRequiredService(); - Current.Services?.InvokeLifecycleEvents(del => del(this)); + if (Services == null) + throw new InvalidOperationException($"The {nameof(IServiceProvider)} instance was not found."); + + Current.Services.InvokeLifecycleEvents(del => del(this)); } protected override void OnCreate() { base.OnCreate(); - var services = MauiApplication.Current.Services; - var mauiApp = MauiApplication.Current.Application; + Application = Services.GetRequiredService(); + + if (Application == null) + throw new InvalidOperationException($"The {nameof(IApplication)} instance was not found."); MauiContext mauiContext; IWindow window; @@ -41,16 +45,16 @@ protected override void OnCreate() var context = CoreUIAppContext.GetInstance(this); // TODO Fix once we have multiple windows - if (mauiApp.Windows.Count > 0) + if (Application.Windows.Count > 0) { - window = mauiApp.Windows[0]; - mauiContext = new MauiContext(services, context); + window = Application.Windows[0]; + mauiContext = new MauiContext(Services, context); } else { - mauiContext = new MauiContext(services, context); + mauiContext = new MauiContext(Services, context); ActivationState state = new ActivationState(mauiContext); - window = mauiApp.CreateWindow(state); + window = Application.CreateWindow(state); } var page = window.View; diff --git a/src/Core/src/Platform/Tizen/Microsoft.Maui.Graphics.Skia/SkiaGraphicsService.cs b/src/Core/src/Platform/Tizen/Microsoft.Maui.Graphics.Skia/SkiaGraphicsService.cs index 9ae7a864ac45..a1f7b6644cb8 100644 --- a/src/Core/src/Platform/Tizen/Microsoft.Maui.Graphics.Skia/SkiaGraphicsService.cs +++ b/src/Core/src/Platform/Tizen/Microsoft.Maui.Graphics.Skia/SkiaGraphicsService.cs @@ -90,5 +90,10 @@ public BitmapExportContext CreateBitmapExportContext(int width, int height, floa { return new SkiaBitmapExportContext(width, height, displayScale, 72, false); } + + public RectangleF GetPathBounds(PathF path) + { + return path.GetBoundsByFlattening(); + } } } diff --git a/src/Core/src/Platform/Tizen/ViewExtensions.cs b/src/Core/src/Platform/Tizen/ViewExtensions.cs index c3452b102079..50e50d9b34c9 100644 --- a/src/Core/src/Platform/Tizen/ViewExtensions.cs +++ b/src/Core/src/Platform/Tizen/ViewExtensions.cs @@ -60,6 +60,11 @@ public static void UpdateOpacity(this EvasObject nativeView, IView view) } } + public static void UpdateClip(this WrapperView nativeView, IView view) + { + nativeView.Clip = view.Clip; + } + public static void UpdateAutomationId(this EvasObject nativeView, IView view) { {