Esempio n. 1
0
        /// <summary>
        /// Handles a manage children call. This may translate into multiple
        /// manage children calls for multiple other views.
        /// </summary>
        /// <param name="nodeToManage">The node to manage.</param>
        /// <param name="indexesToRemove">The indices to remove.</param>
        /// <param name="tagsToRemove">The tags to remove.</param>
        /// <param name="viewsToAdd">The views to add.</param>
        /// <param name="tagsToDelete">The tags to delete.</param>
        /// <remarks>
        /// The assumption for calling this method is that all corresponding
        /// <see cref="ReactShadowNode"/>s have been updated, but
        /// <paramref name="tagsToDelete"/> have not been deleted yet. This is
        /// because we need to use the metadata from those nodes to figure out
        /// the correct commands to dispatch. This is unlike other calls on
        /// this class where we assume all operations on the shadow hierarchy
        /// have already completed by the time a corresponding method here is
        /// called.
        /// </remarks>
        public void HandleManageChildren(ReactShadowNode nodeToManage, int[] indexesToRemove, int[] tagsToRemove, ViewAtIndex[] viewsToAdd, int[] tagsToDelete)
        {
#if DISABLE_NATIVE_VIEW_HIERARCHY_OPTIMIZER
            _uiViewOperationQueue.EnqueueManageChildren(
                nodeToManage.ReactTag,
                indexesToRemove,
                viewsToAdd,
                tagsToDelete);
#else
            // We operate on tagsToRemove instead of indicesToDelete because by
            // the time this method is called, these views have already been
            // removed from the shadow hierarchy and the indices are no longer
            // useful to operate on.
            for (var i = 0; i < tagsToRemove.Length; ++i)
            {
                var tagToRemove  = tagsToRemove[i];
                var delete       = tagsToDelete.Contains(tagToRemove);
                var nodeToRemove = _shadowNodeRegistry.GetNode(tagToRemove);
                RemoveNodeFromParent(nodeToRemove, delete);
            }

            for (var i = 0; i < viewsToAdd.Length; ++i)
            {
                var toAdd     = viewsToAdd[i];
                var nodeToAdd = _shadowNodeRegistry.GetNode(toAdd.Tag);
                AddNodeToNode(nodeToManage, nodeToAdd, toAdd.Index);
            }
#endif
        }
        /// <summary>
        /// Invoked when the native view that corresponds to a root node has
        /// its size changed.
        /// </summary>
        /// <param name="rootViewTag">The root view tag.</param>
        /// <param name="newWidth">The new width.</param>
        /// <param name="newHeight">The new height.</param>
        public void UpdateRootNodeSize(
            int rootViewTag,
            double newWidth,
            double newHeight)
        {
            var rootCssNode = _shadowNodeRegistry.GetNode(rootViewTag);

            rootCssNode.StyleWidth  = (float)newWidth;
            rootCssNode.StyleHeight = (float)newHeight;

            // If we're in the middle of a batch, the change will be
            // automatically dispatched at the end of the batch. The event
            // queue should always be empty, but that is an implementation
            // detail.
            if (_operationsQueue.IsEmpty())
            {
                DispatchViewUpdates(-1 /* no associated batch id */);
            }
        }