Last active
September 29, 2019 15:29
-
-
Save tugcearar/d537388aa75b2200aee62c3f2327967f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[assembly: ExportRenderer(typeof(LPView), typeof(LPViewRenderer))] | |
namespace XFLPApp.iOS.CustomRenderers | |
{ | |
public class LPViewRenderer : ViewRenderer<LPView, LPLinkView> | |
{ | |
protected override void OnElementChanged(ElementChangedEventArgs<LPView> e) | |
{ | |
base.OnElementChanged(e); | |
if (e.OldElement != null || Element == null) return; | |
if (e.NewElement != null) | |
{ | |
if (Control == null) | |
{ | |
var linkView = new LPLinkView(new NSUrl(e.NewElement.Url.ToString())); | |
var provider = new LPMetadataProvider(); | |
provider.StartFetchingMetadata(new NSUrl(e.NewElement.Url), (metadata, error) => | |
{ | |
DispatchQueue.MainQueue.DispatchAsync(() => | |
{ | |
linkView.Metadata = metadata; | |
}); | |
}); | |
linkView.Frame = new CoreGraphics.CGRect(20, 20, 1000, 1000); | |
SetNativeControl(linkView); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment