This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
WkWebViewRenderer.cs
764 lines (622 loc) · 20.6 KB
/
WkWebViewRenderer.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Foundation;
using ObjCRuntime;
using UIKit;
using WebKit;
using Xamarin.Forms.Internals;
using PreserveAttribute = Foundation.PreserveAttribute;
using Uri = System.Uri;
namespace Xamarin.Forms.Platform.iOS
{
public class WkWebViewRenderer : WKWebView, IVisualElementRenderer, IWebViewDelegate, IEffectControlProvider, ITabStop
{
EventTracker _events;
bool _ignoreSourceChanges;
WebNavigationEvent _lastBackForwardEvent;
VisualElementPackager _packager;
#pragma warning disable 0414
VisualElementTracker _tracker;
#pragma warning restore 0414
[Preserve(Conditional = true)]
public WkWebViewRenderer() : base(RectangleF.Empty, new WKWebViewConfiguration())
{
}
[Preserve(Conditional = true)]
public WkWebViewRenderer(WKWebViewConfiguration config) : base(RectangleF.Empty, config)
{
}
WebView WebView => Element as WebView;
public VisualElement Element { get; private set; }
public event EventHandler<VisualElementChangedEventArgs> ElementChanged;
public SizeRequest GetDesiredSize(double widthConstraint, double heightConstraint)
{
return NativeView.GetSizeRequest(widthConstraint, heightConstraint, 44, 44);
}
public void SetElement(VisualElement element)
{
var oldElement = Element;
Element = element;
Element.PropertyChanged += HandlePropertyChanged;
WebView.EvalRequested += OnEvalRequested;
WebView.EvaluateJavaScriptRequested += OnEvaluateJavaScriptRequested;
WebView.GoBackRequested += OnGoBackRequested;
WebView.GoForwardRequested += OnGoForwardRequested;
WebView.ReloadRequested += OnReloadRequested;
NavigationDelegate = new CustomWebViewNavigationDelegate(this);
UIDelegate = new CustomWebViewUIDelegate();
BackgroundColor = UIColor.Clear;
AutosizesSubviews = true;
_tracker = new VisualElementTracker(this);
_packager = new VisualElementPackager(this);
_packager.Load();
_events = new EventTracker(this);
_events.LoadEvents(this);
Load();
OnElementChanged(new VisualElementChangedEventArgs(oldElement, element));
EffectUtilities.RegisterEffectControlProvider(this, oldElement, element);
if (Element != null && !string.IsNullOrEmpty(Element.AutomationId))
AccessibilityIdentifier = Element.AutomationId;
if (element != null)
element.SendViewInitialized(this);
}
public void SetElementSize(Size size)
{
Layout.LayoutChildIntoBoundingRegion(Element, new Rectangle(Element.X, Element.Y, size.Width, size.Height));
}
public void LoadHtml(string html, string baseUrl)
{
if (html != null)
LoadHtmlString(html, baseUrl == null ? new NSUrl(NSBundle.MainBundle.BundlePath, true) : new NSUrl(baseUrl, true));
}
public async void LoadUrl(string url)
{
try
{
var uri = new Uri(url);
var safeHostUri = new Uri($"{uri.Scheme}://{uri.Authority}", UriKind.Absolute);
var safeRelativeUri = new Uri($"{uri.PathAndQuery}{uri.Fragment}", UriKind.Relative);
NSUrlRequest request = new NSUrlRequest(new Uri(safeHostUri, safeRelativeUri));
await SyncNativeCookies(url);
LoadRequest(request);
}
catch (Exception exc)
{
Log.Warning(nameof(WkWebViewRenderer), $"Unable to Load Url {exc}");
}
}
public override void LayoutSubviews()
{
base.LayoutSubviews();
// ensure that inner scrollview properly resizes when frame of webview updated
ScrollView.Frame = Bounds;
}
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (IsLoading)
StopLoading();
Element.PropertyChanged -= HandlePropertyChanged;
WebView.EvalRequested -= OnEvalRequested;
WebView.EvaluateJavaScriptRequested -= OnEvaluateJavaScriptRequested;
WebView.GoBackRequested -= OnGoBackRequested;
WebView.GoForwardRequested -= OnGoForwardRequested;
WebView.ReloadRequested -= OnReloadRequested;
_tracker?.Dispose();
_packager?.Dispose();
}
base.Dispose(disposing);
}
protected virtual void OnElementChanged(VisualElementChangedEventArgs e)
{
var changed = ElementChanged;
if (changed != null)
changed(this, e);
}
HashSet<string> _loadedCookies = new HashSet<string>();
Uri CreateUriForCookies(string url)
{
if (url == null)
return null;
Uri uri;
if (url.Length > 2000)
url = url.Substring(0, 2000);
if (Uri.TryCreate(url, UriKind.Absolute, out uri))
{
if (String.IsNullOrWhiteSpace(uri.Host))
return null;
return uri;
}
return null;
}
async Task<List<NSHttpCookie>> GetCookiesFromNativeStore(string url)
{
NSHttpCookie[] _initialCookiesLoaded = null;
if (Forms.IsiOS11OrNewer)
{
_initialCookiesLoaded = await Configuration.WebsiteDataStore.HttpCookieStore.GetAllCookiesAsync();
}
else
{
// I haven't found a different way to get the cookies pre ios 11
var cookieString = await WebView.EvaluateJavaScriptAsync("document.cookie");
if (cookieString != null)
{
CookieContainer extractCookies = new CookieContainer();
var uri = CreateUriForCookies(url);
foreach (var cookie in cookieString.Split(';'))
extractCookies.SetCookies(uri, cookie);
var extracted = extractCookies.GetCookies(uri);
_initialCookiesLoaded = new NSHttpCookie[extracted.Count];
for(int i = 0; i < extracted.Count; i++)
{
_initialCookiesLoaded[i] = new NSHttpCookie(extracted[i]);
}
}
}
_initialCookiesLoaded = _initialCookiesLoaded ?? new NSHttpCookie[0];
List<NSHttpCookie> existingCookies = new List<NSHttpCookie>();
string domain = CreateUriForCookies(url).Host;
foreach (var cookie in _initialCookiesLoaded)
{
// we don't care that much about this being accurate
// the cookie container will split the cookies up more correctly
if (!cookie.Domain.Contains(domain) && !domain.Contains(cookie.Domain))
continue;
existingCookies.Add(cookie);
}
return existingCookies;
}
async Task InitialCookiePreloadIfNecessary(string url)
{
var myCookieJar = WebView.Cookies;
if (myCookieJar == null)
return;
var uri = CreateUriForCookies(url);
if (uri == null)
return;
if (!_loadedCookies.Add(uri.Host))
return;
// pre ios 11 we sync cookies after navigated
if (!Forms.IsiOS11OrNewer)
return;
var cookies = myCookieJar.GetCookies(uri);
var existingCookies = await GetCookiesFromNativeStore(url);
foreach (var nscookie in existingCookies)
{
if (cookies[nscookie.Name] == null)
{
string cookieH = $"{nscookie.Name}={nscookie.Value}; domain={nscookie.Domain}; path={nscookie.Path}";
myCookieJar.SetCookies(uri, cookieH);
}
}
}
internal async Task SyncNativeCookiesToElement(string url)
{
if (String.IsNullOrWhiteSpace(url))
return;
var myCookieJar = WebView.Cookies;
if (myCookieJar == null)
return;
var uri = CreateUriForCookies(url);
if (uri == null)
return;
var cookies = myCookieJar.GetCookies(uri);
var retrieveCurrentWebCookies = await GetCookiesFromNativeStore(url);
foreach (var nscookie in retrieveCurrentWebCookies)
{
if (cookies[nscookie.Name] == null)
{
string cookieH = $"{nscookie.Name}={nscookie.Value}; domain={nscookie.Domain}; path={nscookie.Path}";
myCookieJar.SetCookies(uri, cookieH);
}
}
foreach (Cookie cookie in cookies)
{
NSHttpCookie nSHttpCookie = null;
foreach(var findCookie in retrieveCurrentWebCookies)
{
if(findCookie.Name == cookie.Name)
{
nSHttpCookie = findCookie;
break;
}
}
if (nSHttpCookie == null)
cookie.Expired = true;
else
cookie.Value = nSHttpCookie.Value;
}
await SyncNativeCookies(url);
}
async Task SyncNativeCookies(string url)
{
var uri = CreateUriForCookies(url);
if (uri == null)
return;
var myCookieJar = WebView.Cookies;
if (myCookieJar == null)
return;
await InitialCookiePreloadIfNecessary(url);
var cookies = myCookieJar.GetCookies(uri);
if (cookies == null)
return;
var retrieveCurrentWebCookies = await GetCookiesFromNativeStore(url);
List<NSHttpCookie> deleteCookies = new List<NSHttpCookie>();
foreach (var cookie in retrieveCurrentWebCookies)
{
if (cookies[cookie.Name] != null)
continue;
deleteCookies.Add(cookie);
}
List<Cookie> cookiesToSet = new List<Cookie>();
foreach (Cookie cookie in cookies)
{
bool changeCookie = true;
// This code is used to only push updates to cookies that have changed.
// This doesn't quite work on on iOS 10 if we have to delete any cookies.
// I haven't found a way on iOS 10 to remove individual cookies.
// The trick we use on Android with writing a cookie that expires doesn't work
// So on iOS10 if the user wants to remove any cookies we just delete
// the cookie for the entire domain inside of DeleteCookies and then rewrite
// all the cookies
if (Forms.IsiOS11OrNewer || deleteCookies.Count == 0)
{
foreach (var nsCookie in retrieveCurrentWebCookies)
{
// if the cookie value hasn't changed don't set it again
if (nsCookie.Domain == cookie.Domain &&
nsCookie.Name == cookie.Name &&
nsCookie.Value == cookie.Value)
{
changeCookie = false;
break;
}
}
}
if (changeCookie)
cookiesToSet.Add(cookie);
}
await SetCookie(cookiesToSet);
await DeleteCookies(deleteCookies);
}
async Task SetCookie(List<Cookie> cookies)
{
if (Forms.IsiOS11OrNewer)
{
foreach(var cookie in cookies)
await Configuration.WebsiteDataStore.HttpCookieStore.SetCookieAsync(new NSHttpCookie(cookie));
}
else
{
Configuration.UserContentController.RemoveAllUserScripts();
if (cookies.Count > 0)
{
WKUserScript wKUserScript = new WKUserScript(new NSString(GetCookieString(cookies)), WKUserScriptInjectionTime.AtDocumentStart, false);
Configuration.UserContentController.AddUserScript(wKUserScript);
}
}
}
async Task DeleteCookies(List<NSHttpCookie> cookies)
{
if (Forms.IsiOS11OrNewer)
{
foreach (var cookie in cookies)
await Configuration.WebsiteDataStore.HttpCookieStore.DeleteCookieAsync(cookie);
}
else
{
var wKWebsiteDataStore = WKWebsiteDataStore.DefaultDataStore;
// This is the only way I've found to delete cookies on pre ios 11
// I tried to set an expired cookie but it doesn't delete the cookie
// So, just deleting the whole domain is the best option I've found
WKWebsiteDataStore.DefaultDataStore.FetchDataRecordsOfTypes(WKWebsiteDataStore.AllWebsiteDataTypes, (NSArray records) =>
{
for (nuint i = 0; i < records.Count; i++)
{
var record = records.GetItem<WKWebsiteDataRecord>(i);
foreach(var deleteme in cookies)
{
if (record.DisplayName.Contains(deleteme.Domain) || deleteme.Domain.Contains(record.DisplayName))
{
WKWebsiteDataStore.DefaultDataStore.RemoveDataOfTypes(record.DataTypes,
new[] { record }, () => { });
break;
}
}
}
});
}
}
void HandlePropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == WebView.SourceProperty.PropertyName)
Load();
}
void Load()
{
if (_ignoreSourceChanges)
return;
if (((WebView)Element).Source != null)
((WebView)Element).Source.Load(this);
UpdateCanGoBackForward();
}
void OnEvalRequested(object sender, EvalRequested eventArg)
{
EvaluateJavaScriptAsync(eventArg.Script);
}
async Task<string> OnEvaluateJavaScriptRequested(string script)
{
var result = await EvaluateJavaScriptAsync(script);
return result?.ToString();
}
void OnGoBackRequested(object sender, EventArgs eventArgs)
{
if (CanGoBack)
{
_lastBackForwardEvent = WebNavigationEvent.Back;
GoBack();
}
UpdateCanGoBackForward();
}
void OnGoForwardRequested(object sender, EventArgs eventArgs)
{
if (CanGoForward)
{
_lastBackForwardEvent = WebNavigationEvent.Forward;
GoForward();
}
UpdateCanGoBackForward();
}
async void OnReloadRequested(object sender, EventArgs eventArgs)
{
try
{
await SyncNativeCookies(Url?.AbsoluteUrl?.ToString());
}
catch (Exception exc)
{
Log.Warning(nameof(WkWebViewRenderer), $"Syncing Existing Cookies Failed: {exc}");
}
Reload();
}
void UpdateCanGoBackForward()
{
((IWebViewController)WebView).CanGoBack = CanGoBack;
((IWebViewController)WebView).CanGoForward = CanGoForward;
}
string GetCookieString(List<Cookie> existingCookies)
{
StringBuilder cookieBuilder = new StringBuilder();
foreach (System.Net.Cookie jCookie in existingCookies)
{
cookieBuilder.Append("document.cookie = '");
cookieBuilder.Append(jCookie.Name);
cookieBuilder.Append("=");
if (jCookie.Expired)
{
cookieBuilder.Append($"; Max-Age=0");
cookieBuilder.Append($"; expires=Sun, 31 Dec 2000 00:00:00 UTC");
}
else
{
cookieBuilder.Append(jCookie.Value);
cookieBuilder.Append($"; Max-Age={jCookie.Expires.Subtract(DateTime.UtcNow).TotalSeconds}");
}
if (!String.IsNullOrWhiteSpace(jCookie.Domain))
{
cookieBuilder.Append($"; Domain={jCookie.Domain}");
}
if (!String.IsNullOrWhiteSpace(jCookie.Domain))
{
cookieBuilder.Append($"; Path={jCookie.Path}");
}
if (jCookie.Secure)
{
cookieBuilder.Append($"; Secure");
}
if (jCookie.HttpOnly)
{
cookieBuilder.Append($"; HttpOnly");
}
cookieBuilder.Append("';");
}
return cookieBuilder.ToString();
}
class CustomWebViewNavigationDelegate : WKNavigationDelegate
{
readonly WkWebViewRenderer _renderer;
WebNavigationEvent _lastEvent;
public CustomWebViewNavigationDelegate(WkWebViewRenderer renderer)
{
if (renderer == null)
throw new ArgumentNullException("renderer");
_renderer = renderer;
}
WebView WebView => _renderer.WebView;
public override void DidFailNavigation(WKWebView webView, WKNavigation navigation, NSError error)
{
var url = GetCurrentUrl();
WebView.SendNavigated(
new WebNavigatedEventArgs(_lastEvent, new UrlWebViewSource { Url = url }, url, WebNavigationResult.Failure)
);
_renderer.UpdateCanGoBackForward();
}
public override void DidFinishNavigation(WKWebView webView, WKNavigation navigation)
{
if (webView.IsLoading)
return;
var url = GetCurrentUrl();
if (url == $"file://{NSBundle.MainBundle.BundlePath}/")
return;
_renderer._ignoreSourceChanges = true;
WebView.SetValueFromRenderer(WebView.SourceProperty, new UrlWebViewSource { Url = url });
_renderer._ignoreSourceChanges = false;
ProcessNavigated(url);
}
async void ProcessNavigated(string url)
{
try
{
if(_renderer?.WebView?.Cookies != null)
await _renderer.SyncNativeCookiesToElement(url);
}
catch(Exception exc)
{
Log.Warning(nameof(WkWebViewRenderer), $"Failed to Sync Cookies {exc}");
}
var args = new WebNavigatedEventArgs(_lastEvent, WebView.Source, url, WebNavigationResult.Success);
WebView.SendNavigated(args);
_renderer.UpdateCanGoBackForward();
}
public override void DidStartProvisionalNavigation(WKWebView webView, WKNavigation navigation)
{
}
// https://stackoverflow.com/questions/37509990/migrating-from-uiwebview-to-wkwebview
public override void DecidePolicy(WKWebView webView, WKNavigationAction navigationAction, Action<WKNavigationActionPolicy> decisionHandler)
{
var navEvent = WebNavigationEvent.NewPage;
var navigationType = navigationAction.NavigationType;
switch (navigationType)
{
case WKNavigationType.LinkActivated:
navEvent = WebNavigationEvent.NewPage;
if (navigationAction.TargetFrame == null)
webView?.LoadRequest(navigationAction.Request);
break;
case WKNavigationType.FormSubmitted:
navEvent = WebNavigationEvent.NewPage;
break;
case WKNavigationType.BackForward:
navEvent = _renderer._lastBackForwardEvent;
break;
case WKNavigationType.Reload:
navEvent = WebNavigationEvent.Refresh;
break;
case WKNavigationType.FormResubmitted:
navEvent = WebNavigationEvent.NewPage;
break;
case WKNavigationType.Other:
navEvent = WebNavigationEvent.NewPage;
break;
}
_lastEvent = navEvent;
var request = navigationAction.Request;
var lastUrl = request.Url.ToString();
var args = new WebNavigatingEventArgs(navEvent, new UrlWebViewSource { Url = lastUrl }, lastUrl);
WebView.SendNavigating(args);
_renderer.UpdateCanGoBackForward();
decisionHandler(args.Cancel ? WKNavigationActionPolicy.Cancel : WKNavigationActionPolicy.Allow);
}
string GetCurrentUrl()
{
return _renderer?.Url?.AbsoluteUrl?.ToString();
}
}
class CustomWebViewUIDelegate : WKUIDelegate
{
static string LocalOK = NSBundle.FromIdentifier("com.apple.UIKit").GetLocalizedString("OK");
static string LocalCancel = NSBundle.FromIdentifier("com.apple.UIKit").GetLocalizedString("Cancel");
public override void RunJavaScriptAlertPanel(WKWebView webView, string message, WKFrameInfo frame, Action completionHandler)
{
PresentAlertController(
webView,
message,
okAction: _ => completionHandler()
);
}
public override void RunJavaScriptConfirmPanel(WKWebView webView, string message, WKFrameInfo frame, Action<bool> completionHandler)
{
PresentAlertController(
webView,
message,
okAction: _ => completionHandler(true),
cancelAction: _ => completionHandler(false)
);
}
public override void RunJavaScriptTextInputPanel(
WKWebView webView, string prompt, string defaultText, WKFrameInfo frame, Action<string> completionHandler)
{
PresentAlertController(
webView,
prompt,
defaultText: defaultText,
okAction: x => completionHandler(x.TextFields[0].Text),
cancelAction: _ => completionHandler(null)
);
}
static string GetJsAlertTitle(WKWebView webView)
{
// Emulate the behavior of UIWebView dialogs.
// The scheme and host are used unless local html content is what the webview is displaying,
// in which case the bundle file name is used.
if (webView.Url != null && webView.Url.AbsoluteString != $"file://{NSBundle.MainBundle.BundlePath}/")
return $"{webView.Url.Scheme}://{webView.Url.Host}";
return new NSString(NSBundle.MainBundle.BundlePath).LastPathComponent;
}
static UIAlertAction AddOkAction(UIAlertController controller, Action handler)
{
var action = UIAlertAction.Create(LocalOK, UIAlertActionStyle.Default, (_) => handler());
controller.AddAction(action);
controller.PreferredAction = action;
return action;
}
static UIAlertAction AddCancelAction(UIAlertController controller, Action handler)
{
var action = UIAlertAction.Create(LocalCancel, UIAlertActionStyle.Cancel, (_) => handler());
controller.AddAction(action);
return action;
}
static void PresentAlertController(
WKWebView webView,
string message,
string defaultText = null,
Action<UIAlertController> okAction = null,
Action<UIAlertController> cancelAction = null)
{
var controller = UIAlertController.Create(GetJsAlertTitle(webView), message, UIAlertControllerStyle.Alert);
if (defaultText != null)
controller.AddTextField((textField) => textField.Text = defaultText);
if (okAction != null)
AddOkAction(controller, () => okAction(controller));
if (cancelAction != null)
AddCancelAction(controller, () => cancelAction(controller));
GetTopViewController(UIApplication.SharedApplication.GetKeyWindow().RootViewController)
.PresentViewController(controller, true, null);
}
static UIViewController GetTopViewController(UIViewController viewController)
{
if (viewController is UINavigationController navigationController)
return GetTopViewController(navigationController.VisibleViewController);
if (viewController is UITabBarController tabBarController)
return GetTopViewController(tabBarController.SelectedViewController);
if (viewController.PresentedViewController != null)
return GetTopViewController(viewController.PresentedViewController);
return viewController;
}
}
#region IPlatformRenderer implementation
public UIView NativeView
{
get { return this; }
}
public UIViewController ViewController
{
get { return null; }
}
UIView ITabStop.TabStop => this;
#endregion
void IEffectControlProvider.RegisterEffect(Effect effect)
{
VisualElementRenderer<VisualElement>.RegisterEffect(effect, this, NativeView);
}
}
}