public FrameInfo(Frame frame, int index, int priority, ModalViewController modalViewController = null) { Frame = frame; Index = index; Priority = priority; ModalViewController = modalViewController; State = FrameState.Hidden; }
/// <summary> /// Gets or creates a Frame with the specified name and priority. /// </summary> /// <param name="name">The name of the Frame to retrieve or create.</param> /// <param name="priority">The priority determines the Z order of the view. It's only used when creating a new Frame.</param> /// <param name="transitionInfoType">The transition info type to determine how to create the Frame.</param> public Frame GetOrCreateFrame(string name, int priority, FrameSectionsTransitionInfoTypes transitionInfoType) // Must run on UI thread { if (_frames.TryGetValue(name, out var existingFrame)) { return(existingFrame.Frame); } else { var frame = new Frame() { Name = name, Opacity = 0, IsHitTestVisible = false, RenderTransform = new TranslateTransform() }; var framesAbove = _frames.Values.Where(fi => fi.Priority > priority).ToList(); var index = _frames.Count - framesAbove.Count; FrameInfo frameState; switch (transitionInfoType) { case FrameSectionsTransitionInfoTypes.FrameBased: foreach (var frameAbove in framesAbove) { ++frameAbove.Index; } frameState = new FrameInfo(frame, index, priority); Children.Insert(index, frame); break; case FrameSectionsTransitionInfoTypes.UIViewControllerBased: if (framesAbove.Any()) { throw new InvalidOperationException("A UIViewController-based modal must be above all others."); } var modalViewController = new ModalViewController(name, frame); modalViewController.ClosedNatively += OnModalViewControllerClosed; frameState = new FrameInfo(frame, index, priority, modalViewController); break; default: throw new InvalidOperationException($"Unsupported transition info type '{transitionInfoType}'."); } _frames.Add(name, frameState); return(frame); } }