Skip to content

Commit

Permalink
Remove IPage on Tizen (#72)
Browse files Browse the repository at this point in the history
- Merge IFrameworkElement and IView and Remove IPage (dotnet#1875)
  • Loading branch information
rookiejava committed Apr 13, 2022
1 parent 58c9564 commit 4b64913
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ void OnPromptRequested(Page sender, PromptArguments args)
prompt.Dismissed += (s, e) => _alerts.Remove(prompt);
}

bool PageIsInThisContext(IPage page)
bool PageIsInThisContext(IView sender)
{
var context = page.Handler?.MauiContext ?? null;
var context = sender.Handler?.MauiContext ?? null;
return context == MauiContext;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,13 @@ void UpdateTitle(IView page, NaviItem? item = null)

string SpanTitle(IView view)
{
if (view is not IPage page)
if (view is not ITitledElement page)
return string.Empty;
else
{
var span = new TSpan
{
Text = page.Title,
Text = page.Title??string.Empty,
HorizontalTextAlignment = TTextAlignment.Center,
//ForegroundColor = VirtualView.BarTextColor.ToNative()
};
Expand Down
18 changes: 11 additions & 7 deletions src/Core/src/Handlers/Page/PageHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Microsoft.Maui.Handlers
{
public partial class PageHandler : ViewHandler<IPage, Page>, INativeViewHandler
public partial class PageHandler : ViewHandler<IView, Page>, INativeViewHandler
{
INativeViewHandler? _contentHandler;

Expand Down Expand Up @@ -35,11 +35,11 @@ protected override void DisconnectHandler(Page nativeView)
nativeView.LayoutUpdated -= OnLayoutUpdated;
}

public static void MapTitle(PageHandler handler, IPage page)
public static void MapTitle(PageHandler handler, IView page)
{
}

public static void MapContent(PageHandler handler, IPage page)
public static void MapContent(PageHandler handler, IView page)
{
handler.UpdateContent();
}
Expand Down Expand Up @@ -76,11 +76,15 @@ void UpdateContent()
_contentHandler?.Dispose();
_contentHandler = null;

NativeView.Children.Add(VirtualView.Content.ToNative(MauiContext));
if (VirtualView.Content.Handler is INativeViewHandler thandler)
if (VirtualView is IContentView cv && cv.Content is IView view)
{
thandler?.SetParent(this);
_contentHandler = thandler;
NativeView.Children.Add(view.ToNative(MauiContext));

if (view.Handler is INativeViewHandler thandler)
{
thandler?.SetParent(this);
_contentHandler = thandler;
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Core/src/Platform/Tizen/SemanticExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Microsoft.Maui
{
public static partial class SemanticExtensions
{
public static void SetSemanticFocus(this IFrameworkElement element)
public static void SetSemanticFocus(this IView element)
{
if (element?.Handler?.NativeView == null)
throw new NullReferenceException("Can't access view from a null handler");
Expand Down

0 comments on commit 4b64913

Please sign in to comment.