Example #1
0
        /// <summary>
        /// Prepares drag system by setting initial drag object values
        /// </summary>
        /// <param name="item">The item</param>
        /// <param name="parent">The parent category</param>
        public void SetTargetInCategory(IClientPlanetListItem item,
                                        ChannelListCategoryComponent parent)
        {
            currentDragIndex = 0;

            if (parent != null)
            {
                currentDragIndex = parent.GetIndex(item);
            }

            currentDragParentPlanet   = null;
            currentDragParentCategory = parent;
            currentDragItem           = item;
        }
Example #2
0
        /// <summary>
        /// Run when an item is dropped on a planet
        /// </summary>
        /// <param name="target">The planet component that the item was dropped onto</param>
        public async Task OnItemDropOnPlanet(ChannelListPlanetComponent target)
        {
            // Insert item into the next slot in the category
            if (target == null)
            {
                return;
            }

            if (currentDragItem == null)
            {
                return;
            }

            // Only categories can be put under a planet
            if (currentDragItem.ItemType != Valour.Shared.Items.ItemType.Category)
            {
                return;
            }

            // Already parent
            if (target.Planet.Id == currentDragItem.Parent_Id)
            {
                return;
            }

            ushort position = (ushort)target.TopCategories.Count;


            StringContent content = new StringContent("none");

            // Add current item to target category
            var response = await ClientUserManager.Http.PutAsync($"api/category/{currentDragItem.Id}/parent_id?position={position}", content);

            Console.WriteLine($"Inserting category {currentDragItem.Id} into planet {target.Planet.Id} at position {position}");

            Console.WriteLine(await response.Content.ReadAsStringAsync());
        }