void LayoutChildren(bool animated) { var frame = Element.Bounds.ToRectangleF(); var flyoutFrame = frame; nfloat opacity = 1; flyoutFrame.Width = (int)(Math.Min(flyoutFrame.Width, flyoutFrame.Height) * 0.8); var detailRenderer = Platform.GetRenderer(FlyoutPage.Detail); if (detailRenderer == null) { return; } var detailView = detailRenderer.ViewController.View; var isRTL = (Element as IVisualElementController)?.EffectiveFlowDirection.IsRightToLeft() == true; if (isRTL) { flyoutFrame.X = (int)(flyoutFrame.Width * .25); } _flyoutController.View.Frame = flyoutFrame; var target = frame; if (Presented) { target.X += flyoutFrame.Width; if (_applyShadow) { opacity = 0.5f; } } if (isRTL) { target.X = target.X * -1; } if (animated) { UIView.BeginAnimations("Flyout"); var view = _detailController.View; view.Frame = target; detailView.Layer.Opacity = (float)opacity; UIView.SetAnimationCurve(UIViewAnimationCurve.EaseOut); UIView.SetAnimationDuration(250); UIView.CommitAnimations(); } else { _detailController.View.Frame = target; detailView.Layer.Opacity = (float)opacity; } FlyoutPageController.FlyoutBounds = new Rectangle(flyoutFrame.X, 0, flyoutFrame.Width, flyoutFrame.Height); FlyoutPageController.DetailBounds = new Rectangle(0, 0, frame.Width, frame.Height); if (Presented) { _clickOffView.Frame = _detailController.View.Frame; } }
public override UIViewController ChildViewControllerForStatusBarHidden() { return((UIViewController)Platform.GetRenderer(Platform.Page)); }
public void SetCustomContent(View content) { if (content == Content) { return; } removeScolledEvent?.Invoke(); removeScolledEvent = null; if (Content != null) { var oldRenderer = Platform.GetRenderer(Content); var oldContentView = ContentView; var oldContent = Content; Content = null; ContentView = null; oldContent.ClearValue(Platform.RendererProperty); oldContentView?.RemoveFromSuperview(); oldRenderer?.Dispose(); } // If the user hasn't defined custom content then only the ContentView is set else if (ContentView != null) { var oldContentView = ContentView; ContentView = null; oldContentView.RemoveFromSuperview(); } Content = content; if (Content != null) { var renderer = Platform.CreateRenderer(Content); ContentView = renderer.NativeView; Platform.SetRenderer(Content, renderer); ContentView.ClipsToBounds = true; // not sure if there's a more efficient way to do this // I can test the native control to see if it inherits from UIScrollView // But the CollectionViewRenderer doesn't inherit from UIScrollView if (Content is ScrollView sv) { sv.Scrolled += ScrollViewScrolled; removeScolledEvent = () => sv.Scrolled -= ScrollViewScrolled; void ScrollViewScrolled(object sender, ScrolledEventArgs e) => OnScrolled((nfloat)sv.ScrollY); } else if (Content is CollectionView cv) { cv.Scrolled += CollectionViewScrolled; removeScolledEvent = () => cv.Scrolled -= CollectionViewScrolled; void CollectionViewScrolled(object sender, ItemsViewScrolledEventArgs e) => OnScrolled((nfloat)e.VerticalOffset); } else if (Content is ListView lv) { lv.Scrolled += ListViewScrolled; removeScolledEvent = () => lv.Scrolled -= ListViewScrolled; void ListViewScrolled(object sender, ScrolledEventArgs e) => OnScrolled((nfloat)e.ScrollY); } } }