Skip to content

Commit

Permalink
Bump to latest
Browse files Browse the repository at this point in the history
- Modal Navigation Manager (dotnet#1563)
- Implement the basic WindowHandler (dotnet#1468)
- Don't extract native defaults, meaning users can no longer reset a color back to a platform theme (dotnet#1485)
- Implement Alerts (Alert, Prompt and ActionSheet) (dotnet#1328)
- And so on.
  • Loading branch information
rookiejava authored and myroot committed Aug 24, 2022
1 parent c2be8dc commit 494edc8
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 74 deletions.
12 changes: 12 additions & 0 deletions src/Controls/src/Core/HandlerImpl/Window.Tizen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#nullable enable
using System;
using EWindow = ElmSharp.Window;

namespace Microsoft.Maui.Controls
{
public partial class Window
{
internal EWindow NativeWindow =>
(Handler?.NativeView as EWindow) ?? throw new InvalidOperationException("Window should have a ElmSharp.Window set.");
}
}

This file was deleted.

1 change: 1 addition & 0 deletions src/Core/src/IMauiContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public interface IMauiContext
Android.Content.Context? Context { get; }
#elif TIZEN
CoreUIAppContext? Context { get; }
ElmSharp.Window? Window { get; }
#endif
}
}
2 changes: 2 additions & 0 deletions src/Core/src/Platform/MauiContext.Tizen.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using ElmSharp;

namespace Microsoft.Maui
{
Expand Down Expand Up @@ -33,5 +34,6 @@ public CoreUIAppContext? Context
}
}

public Window? Window => Context?.MainWindow;
}
}
1 change: 0 additions & 1 deletion src/Core/src/Platform/Tizen/CoreUIAppContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public static CoreUIAppContext GetInstance(CoreApplication application, Window?
if (IsInitialized)
return _instance!;


_instance = (window == null) ? new CoreUIAppContext(application) : new CoreUIAppContext(application, window);
return _instance;
}
Expand Down
44 changes: 29 additions & 15 deletions src/Core/src/Platform/Tizen/HandlerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Tizen.Applications;
using ElmSharp;

namespace Microsoft.Maui
Expand All @@ -15,34 +16,47 @@ public static EvasObject ToNative(this IView view, IMauiContext context)
view = ir.ReplacedView;

var handler = view.Handler;

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

if (handler == null)
{
handler = context.Handlers.GetHandler(view.GetType());
handler = context.Handlers.GetHandler(view.GetType()) as IViewHandler;

if (handler == null)
throw new Exception($"Handler not found for view {view} or was not {nameof(IViewHandler)}.");

if (handler == null)
throw new Exception($"Handler not found for view {view}");
handler.SetMauiContext(context);

handler.SetMauiContext(context);
view.Handler = handler;
}
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)}");
}

return result;
}

public static void SetWindow(this Window nativeWindow, IWindow window, IMauiContext mauiContext)
{
_ = nativeWindow ?? throw new ArgumentNullException(nameof(nativeWindow));
_ = window ?? throw new ArgumentNullException(nameof(window));
_ = mauiContext ?? throw new ArgumentNullException(nameof(mauiContext));

var handler = window.Handler as IWindowHandler;
if (handler == null)
handler = mauiContext.Handlers.GetHandler(window.GetType()) as IWindowHandler;

if (handler == null)
throw new Exception($"Handler not found for view {window} or was not {nameof(IWindowHandler)}'");

handler.SetMauiContext(mauiContext);

window.Handler = handler;

if (handler.VirtualView != window)
handler.SetVirtualView(window);
}
}
}
14 changes: 13 additions & 1 deletion src/Core/src/Platform/Tizen/MauiApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ protected override void OnCreate()

this.CreatePlatformWindow(Application);

Current.Services?.InvokeLifecycleEvents<TizenLifecycle.OnCreate>(del => del(this));
var tizenWindow = mauiContext.Window;

if (tizenWindow == null)
throw new InvalidOperationException($"The {nameof(tizenWindow)} instance was not found.");

var activationState = new ActivationState(mauiContext);
var window = Application.CreateWindow(activationState);

tizenWindow.SetWindow(window, mauiContext);

return tizenWindow;
}

protected override void OnAppControlReceived(AppControlReceivedEventArgs e)
Expand Down Expand Up @@ -113,6 +123,8 @@ protected override void OnTerminate()

public static new MauiApplication Current { get; private set; } = null!;

public Window MainWindow { get; protected set; } = null!;

public IServiceProvider Services { get; protected set; } = null!;

public IApplication Application { get; protected set; } = null!;
Expand Down

0 comments on commit 494edc8

Please sign in to comment.