Skip to content

Instantly share code, notes, and snippets.

@tugcearar
Last active September 29, 2019 15:29
Show Gist options
  • Save tugcearar/d537388aa75b2200aee62c3f2327967f to your computer and use it in GitHub Desktop.
Save tugcearar/d537388aa75b2200aee62c3f2327967f to your computer and use it in GitHub Desktop.
[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