Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tizen] Renaming APIs Native to Platform #6643

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/BlazorWebView/src/Maui/Tizen/BlazorWebViewHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public partial class BlazorWebViewHandler : ViewHandler<IBlazorWebView, WebViewC
private TizenWebViewManager? _webviewManager;
private WebViewExtensions.InterceptRequestCallback? _interceptRequestCallback;

private TWebView NativeWebView => PlatformView.WebView;
private TWebView PlatformWebView => PlatformView.WebView;

private bool RequiredStartupPropertiesSet =>
//_webview != null &&
Expand All @@ -58,23 +58,23 @@ protected override WebViewContainer CreatePlatformView()
TChromium.Initialize();
MauiApplication.Current.Terminated += (s, e) => TChromium.Shutdown();

return new WebViewContainer(NativeParent);
return new WebViewContainer(PlatformParent);
}

/// <inheritdoc />
protected override void ConnectHandler(WebViewContainer platformView)
{
_interceptRequestCallback = OnRequestInterceptCallback;
NativeWebView.LoadFinished += OnLoadFinished;
NativeWebView.AddJavaScriptMessageHandler("BlazorHandler", PostMessageFromJS);
NativeWebView.SetInterceptRequestCallback(_interceptRequestCallback);
NativeWebView.GetSettings().JavaScriptEnabled = true;
PlatformWebView.LoadFinished += OnLoadFinished;
PlatformWebView.AddJavaScriptMessageHandler("BlazorHandler", PostMessageFromJS);
PlatformWebView.SetInterceptRequestCallback(_interceptRequestCallback);
PlatformWebView.GetSettings().JavaScriptEnabled = true;
}

/// <inheritdoc />
protected override void DisconnectHandler(WebViewContainer platformView)
{
NativeWebView.LoadFinished -= OnLoadFinished;
PlatformWebView.LoadFinished -= OnLoadFinished;
base.DisconnectHandler(platformView);
}

Expand All @@ -87,7 +87,7 @@ private void PostMessageFromJS(JavaScriptMessage message)

if (message.Name.Equals("BlazorHandler", StringComparison.Ordinal))
{
_webviewManager!.MessageReceivedInternal(new Uri(NativeWebView.Url), message.GetBodyAsString());
_webviewManager!.MessageReceivedInternal(new Uri(PlatformWebView.Url), message.GetBodyAsString());
}
}

Expand All @@ -112,7 +112,7 @@ private void StartWebViewCoreIfPossible()

_webviewManager = new TizenWebViewManager(
this,
NativeWebView,
PlatformWebView,
Services!,
new MauiDispatcher(Services!.GetRequiredService<IDispatcher>()),
fileProvider,
Expand All @@ -125,7 +125,7 @@ private void StartWebViewCoreIfPossible()
VirtualView.BlazorWebViewInitializing(new BlazorWebViewInitializingEventArgs());
VirtualView.BlazorWebViewInitialized(new BlazorWebViewInitializedEventArgs
{
WebView = NativeWebView,
WebView = PlatformWebView,
});

if (RootComponents != null)
Expand All @@ -146,7 +146,7 @@ private void OnRequestInterceptCallback(IntPtr context, IntPtr request, IntPtr u
return;
}

var url = NativeWebView.GetInterceptRequestUrl(request);
var url = PlatformWebView.GetInterceptRequestUrl(request);

if (url.StartsWith(AppOrigin))
{
Expand All @@ -165,22 +165,22 @@ private void OnRequestInterceptCallback(IntPtr context, IntPtr request, IntPtr u
{
content.CopyTo(memstream);
var body = memstream.ToArray();
NativeWebView.SetInterceptRequestResponse(request, header, body, (uint)body.Length);
PlatformWebView.SetInterceptRequestResponse(request, header, body, (uint)body.Length);
}
return;
}
}

NativeWebView.IgnoreInterceptRequest(request);
PlatformWebView.IgnoreInterceptRequest(request);
}

private void OnLoadFinished(object? sender, EventArgs e)
{
NativeWebView.SetFocus(true);
var url = NativeWebView.Url;
PlatformWebView.SetFocus(true);
var url = PlatformWebView.Url;

if (url == AppOrigin)
NativeWebView.Eval(BlazorInitScript);
PlatformWebView.Eval(BlazorInitScript);
}

internal IFileProvider CreateFileProvider(string contentRootDir)
Expand Down
2 changes: 1 addition & 1 deletion src/Compatibility/Core/src/Tizen/Forms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static void SetupInit(IMauiContext context, InitializationOptions options = null
{
MauiContext = context;
Context = options?.Context ?? MauiApplication.Current;
NativeParent = context.GetNativeParent();
NativeParent = context.GetPlatformParent();
Registrar.RegisterRendererToHandlerShim(RendererToHandlerShim.CreateShim);

if (!IsInitialized)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected ItemsViewHandler(PropertyMapper mapper, CommandMapper commandMapper =

protected override TCollectionView CreatePlatformView()
{
return new TCollectionView(NativeParent);
return new TCollectionView(PlatformParent);
}

public static void MapItemsSource(ItemsViewHandler<TItemsView> handler, ItemsView itemsView)
Expand Down
4 changes: 2 additions & 2 deletions src/Controls/src/Core/Handlers/Shell/ShellHandler.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ protected override ShellView CreatePlatformView()
{
if (DeviceInfo.GetDeviceType() == DeviceType.TV)
{
return new TVShellView(NativeParent);
return new TVShellView(PlatformParent);
}
else
{
return new ShellView(NativeParent);
return new ShellView(PlatformParent);
}
}
}
Expand Down
20 changes: 10 additions & 10 deletions src/Controls/src/Core/Platform/AlertManager/AlertManager.Tizen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@ internal partial class AlertManager
internal void Subscribe(Window window)
{
IMauiContext mauiContext = window?.MauiContext;
EWindow nativeWindow = mauiContext.GetNativeWindow();
EWindow platformWindow = mauiContext.GetPlatformWindow();

if (mauiContext == null || nativeWindow == null)
if (mauiContext == null || platformWindow == null)
return;

if (Subscriptions.Any(s => s.Window == nativeWindow))
if (Subscriptions.Any(s => s.Window == platformWindow))
{
return;
}

Subscriptions.Add(new AlertRequestHelper(nativeWindow, mauiContext));
Subscriptions.Add(new AlertRequestHelper(platformWindow, mauiContext));
}

internal void Unsubscribe(Window window)
{
IMauiContext mauiContext = window?.MauiContext;
EWindow nativeWindow = mauiContext.GetNativeWindow();
EWindow nativeWindow = mauiContext.GetPlatformWindow();

var toRemove = Subscriptions.Where(s => s.Window == nativeWindow).ToList();

Expand Down Expand Up @@ -89,7 +89,7 @@ void OnBusySetRequest(Page sender, bool enabled)

if (null == _pageBusyDialog)
{
_pageBusyDialog = new Dialog(MauiContext.GetNativeParent())
_pageBusyDialog = new Dialog(MauiContext.GetPlatformParent())
{
Orientation = PopupOrientation.Center,
BackgroundColor = EColor.Transparent
Expand Down Expand Up @@ -123,7 +123,7 @@ void OnAlertRequest(Page sender, AlertArguments arguments)
if (!PageIsInThisContext(sender))
return;

var alert = Dialog.CreateDialog(MauiContext.GetNativeParent(), (arguments.Accept != null));
var alert = Dialog.CreateDialog(MauiContext.GetPlatformParent(), (arguments.Accept != null));

alert.Title = arguments.Title;
var message = arguments.Message?.Replace("&", "&amp;", StringComparison.Ordinal).Replace("<", "&lt;", StringComparison.Ordinal).Replace(">", "&gt;", StringComparison.Ordinal).Replace(Environment.NewLine, "<br>", StringComparison.Ordinal);
Expand Down Expand Up @@ -165,7 +165,7 @@ void OnActionSheetRequest(Page sender, ActionSheetArguments arguments)
if (!PageIsInThisContext(sender))
return;

var alert = Dialog.CreateDialog(MauiContext.GetNativeParent());
var alert = Dialog.CreateDialog(MauiContext.GetPlatformParent());

alert.Title = arguments.Title;
var box = new EBox(alert);
Expand Down Expand Up @@ -236,7 +236,7 @@ void OnPromptRequested(Page sender, PromptArguments args)
if (!PageIsInThisContext(sender))
return;

var prompt = Dialog.CreateDialog(MauiContext.GetNativeParent(), (args.Accept != null));
var prompt = Dialog.CreateDialog(MauiContext.GetPlatformParent(), (args.Accept != null));
prompt.Title = args.Title;

var entry = new Entry
Expand Down Expand Up @@ -325,7 +325,7 @@ void OnPromptRequested(Page sender, PromptArguments args)
bool PageIsInThisContext(IView sender)
{
var context = sender.Handler?.MauiContext ?? null;
return context?.GetNativeWindow() == Window;
return context?.GetPlatformWindow() == Window;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal partial class ModalNavigationManager

partial void OnPageAttachedHandler()
{
MauiContext.GetNativeWindow().SetBackButtonPressedHandler(OnBackButtonPressed);
MauiContext.GetPlatformWindow().SetBackButtonPressedHandler(OnBackButtonPressed);
}

public Task<Page> PopModalAsync(bool animated)
Expand Down
30 changes: 15 additions & 15 deletions src/Controls/src/Core/Platform/Tizen/Shell/ShellItemView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ public ShellItemView(ShellItem item, IMauiContext context)
MauiContext = context;

//Initialize();
_mainLayout = new EBox(NativeParent);
_mainLayout = new EBox(PlatformParent);
_mainLayout.SetLayoutCallback(OnLayout);
_mainLayout.Show();
_contentHolder = new EBox(NativeParent);
_contentHolder = new EBox(PlatformParent);
_contentHolder.Show();
_mainLayout.PackEnd(_contentHolder);

Expand All @@ -69,9 +69,9 @@ public ShellItemView(ShellItem item, IMauiContext context)

protected IMauiContext MauiContext { get; private set; }

protected EvasObject NativeParent => MauiContext.GetNativeParent();
protected EvasObject PlatformParent => MauiContext.GetPlatformParent();

public EvasObject NativeView
public EvasObject PlatformView
{
get
{
Expand Down Expand Up @@ -142,7 +142,7 @@ protected virtual void Dispose(bool disposing)
_shellSectionStackCache.Clear();
_tabsItems.Clear();
}
NativeView.Unrealize();
PlatformView.Unrealize();
}
_disposed = true;
}
Expand Down Expand Up @@ -215,7 +215,7 @@ void InitializeTabs()
if (_tabs != null)
return;

_tabs = new Tabs(NativeParent);
_tabs = new Tabs(PlatformParent);
_tabs.Show();
_tabs.BackgroundColor = _tabBarBackgroudColor;
_tabs.Scrollable = TabsType.Fixed;
Expand All @@ -239,11 +239,11 @@ void CreateMoreItems()
if (_moreItemsDrawer != null)
return;

_moreItemsList = new ShellMoreTabs(NativeParent);
_moreItemsList = new ShellMoreTabs(PlatformParent);
_moreItemsList.Show();
_moreItemsList.ItemSelected += OnMoreItemSelected;

_moreItemsDrawer = new Panel(NativeParent);
_moreItemsDrawer = new Panel(PlatformParent);
_moreItemsDrawer.Show();

_moreItemsDrawer.SetScrollable(true);
Expand Down Expand Up @@ -380,17 +380,17 @@ void UpdateCurrentShellSection(ShellSection section)
return;
}

ShellSectionStack native;
ShellSectionStack platformView;
if (_shellSectionStackCache.ContainsKey(section))
{
native = _shellSectionStackCache[section];
platformView = _shellSectionStackCache[section];
}
else
{
native = CreateShellSectionStack(section);
_shellSectionStackCache[section] = native;
platformView = CreateShellSectionStack(section);
_shellSectionStackCache[section] = platformView;
}
_currentStack = native;
_currentStack = platformView;
_currentStack.Show();
_contentHolder.PackEnd(_currentStack);
}
Expand All @@ -415,7 +415,7 @@ void OnTabsSelected(object? sender, EToolbarItemEventArgs e)

void OnLayout()
{
if (NativeView.Geometry.Height == 0 || NativeView.Geometry.Width == 0)
if (PlatformView.Geometry.Height == 0 || PlatformView.Geometry.Width == 0)
return;

int tabsHeight = 0;
Expand Down Expand Up @@ -448,7 +448,7 @@ void OnLayout()
{
if (iconSource != null)
{
TImage image = new TImage(NativeParent);
TImage image = new TImage(PlatformParent);
var provider = MauiContext.Services.GetRequiredService<IImageSourceServiceProvider>();
var service = provider.GetRequiredImageSourceService(iconSource);

Expand Down
12 changes: 6 additions & 6 deletions src/Controls/src/Core/Platform/Tizen/Shell/ShellNavBar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ public class ShellNavBar : EBox, IFlyoutBehaviorObserver, IDisposable
private bool disposedValue;
bool _isTV = DeviceInfo.Idiom == DeviceIdiom.TV;

public ShellNavBar(IMauiContext context) : base(context?.GetNativeParent())
public ShellNavBar(IMauiContext context) : base(context?.GetPlatformParent())
{
MauiContext = context;

SetLayoutCallback(OnLayout);

_menuButton = new TButton(NativeParent);
_menuButton = new TButton(PlatformParent);
_menuButton.Clicked += OnMenuClicked;

_menuIcon = new TImage(NativeParent);
_menuIcon = new TImage(PlatformParent);
UpdateMenuIcon();

_title = new TLabel(NativeParent)
_title = new TLabel(PlatformParent)
{
FontSize = this.GetDefaultTitleFontSize(),
VerticalTextAlignment = (global::Tizen.UIExtensions.Common.TextAlignment)TextAlignment.Center,
Expand All @@ -76,7 +76,7 @@ public ShellNavBar(IMauiContext context) : base(context?.GetNativeParent())

protected IMauiContext? MauiContext { get; private set; }

protected EvasObject NativeParent => MauiContext?.GetNativeParent() ?? throw new InvalidOperationException($"NativeParent cannot be null here");
protected EvasObject PlatformParent => MauiContext?.GetPlatformParent() ?? throw new InvalidOperationException($"PlatformParent cannot be null here");

public IShellController ShellController => Shell.Current;

Expand Down Expand Up @@ -239,7 +239,7 @@ async void UpdateMenuIcon()
if (_isTV)
{
_menuButton.Style = TThemeConstants.Button.Styles.Circle;
_menuIcon = new TImage(NativeParent);
_menuIcon = new TImage(PlatformParent);
}
source = Shell.Current.FlyoutIcon;
}
Expand Down
Loading