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 25, 2022
1 parent 3847cd3 commit f9deaa5
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 27 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;
}
}
32 changes: 27 additions & 5 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;
using Microsoft.Maui.Handlers;

Expand All @@ -18,11 +19,12 @@ public static EvasObject ToNative(this IView view, IMauiContext context, bool is
var handler = view.Handler;

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);

Expand All @@ -34,7 +36,6 @@ public static EvasObject ToNative(this IView view, IMauiContext context, bool is
if (!(handler.NativeView is EvasObject result))
{
throw new InvalidOperationException($"Unable to convert {view} to {typeof(EvasObject)}");
}

// Root content view should register to LayoutUpdated() callback.
if (isRoot && handler is LayoutHandler layoutHandler)
Expand All @@ -44,5 +45,26 @@ public static EvasObject ToNative(this IView view, IMauiContext context, bool is

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);
}
}
}
2 changes: 2 additions & 0 deletions src/Core/src/Platform/Tizen/MauiApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,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 f9deaa5

Please sign in to comment.