Example #1
0
        private void onSearchFinished(BeatmapListingFilterControl.SearchResult searchResult)
        {
            if (searchResult.Type == BeatmapListingFilterControl.SearchResultType.SupporterOnlyFilters)
            {
                supporterRequiredContent.UpdateText(searchResult.SupporterOnlyFiltersUsed);
                addContentToPlaceholder(supporterRequiredContent);
                return;
            }

            var newPanels = searchResult.Results.Select(b => new BeatmapCard(b)
            {
                Anchor = Anchor.TopCentre,
                Origin = Anchor.TopCentre,
            });

            if (filterControl.CurrentPage == 0)
            {
                //No matches case
                if (!newPanels.Any())
                {
                    addContentToPlaceholder(notFoundContent);
                    return;
                }

                // spawn new children with the contained so we only clear old content at the last moment.
                // reverse ID flow is required for correct Z-ordering of the cards' expandable content (last card should be front-most).
                var content = new ReverseChildIDFillFlowContainer <BeatmapCard>
                {
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Spacing          = new Vector2(10),
                    Alpha            = 0,
                    Margin           = new MarginPadding {
                        Vertical = 15
                    },
                    ChildrenEnumerable = newPanels
                };

                panelLoadDelegate = LoadComponentAsync(foundContent = content, addContentToPlaceholder, (cancellationToken = new CancellationTokenSource()).Token);
            }
            else
            {
                panelLoadDelegate = LoadComponentsAsync(newPanels, loaded =>
                {
                    lastFetchDisplayedTime = Time.Current;
                    foundContent.AddRange(loaded);
                    loaded.ForEach(p => p.FadeIn(200, Easing.OutQuint));
                });
            }
        }
Example #2
0
        private void onSearchFinished(BeatmapListingFilterControl.SearchResult searchResult)
        {
            cancellationToken?.Cancel();

            if (searchResult.Type == BeatmapListingFilterControl.SearchResultType.SupporterOnlyFilters)
            {
                supporterRequiredContent.UpdateText(searchResult.SupporterOnlyFiltersUsed);
                addContentToResultsArea(supporterRequiredContent);
                return;
            }

            var newCards = createCardsFor(searchResult.Results);

            if (filterControl.CurrentPage == 0)
            {
                //No matches case
                if (!newCards.Any())
                {
                    addContentToResultsArea(notFoundContent);
                    return;
                }

                var content = createCardContainerFor(newCards);

                panelLoadTask = LoadComponentAsync(foundContent = content, addContentToResultsArea, (cancellationToken = new CancellationTokenSource()).Token);
            }
            else
            {
                panelLoadTask = LoadComponentsAsync(newCards, loaded =>
                {
                    lastFetchDisplayedTime = Time.Current;
                    foundContent.AddRange(loaded);
                    loaded.ForEach(p => p.FadeIn(200, Easing.OutQuint));
                }, (cancellationToken = new CancellationTokenSource()).Token);
            }
        }