Ejemplo n.º 1
0
        void UpdateNextEpisode()
        {
            var  epis   = App.GetKeys <CloudStreamCore.CachedCoreEpisode>(nameof(CloudStreamCore.CachedCoreEpisode)).OrderBy(t => - t.createdAt.Ticks).ToArray();
            bool hasTxt = epis.Length > 0;

            UpdateHasNext(hasTxt);

            NextEpisode.Children.Clear();
            var pSource = App.GetImageSource("nexflixPlayBtt.png");

            for (int i = 0; i < Math.Min(epis.Length, 5); i++)
            {
                var  ep    = epis[i];
                Grid stack = new Grid()
                {
                };

                var ff = new FFImageLoading.Forms.CachedImage {
                    Source           = ep.poster,
                    HeightRequest    = FastPosterHeight,
                    WidthRequest     = FastPosterWith,
                    BackgroundColor  = Color.Transparent,
                    VerticalOptions  = LayoutOptions.Start,
                    InputTransparent = true,
                    Transformations  =
                    {
                        //  new FFImageLoading.Transformations.RoundedTransformation(10,1,1.5,10,"#303F9F")
                        new FFImageLoading.Transformations.RoundedTransformation(10, 1.78, 1, 0, "#303F9F")
                    },
                    //	InputTransparent = true,
                };

                const double textAddSpace = 20;
                Frame        boxView      = new Frame()
                {
                    BackgroundColor = Settings.ItemBackGroundColor,                    // Color.FromRgb(_color, _color, _color),
                    //	InputTransparent = true,
                    CornerRadius  = 5,
                    HeightRequest = FastPosterHeight + textAddSpace,
                    TranslationY  = 0,
                    WidthRequest  = FastPosterWith,
                    HasShadow     = true,
                };

                const double playSize = 30;
                var          playBtt  = new FFImageLoading.Forms.CachedImage {
                    Source            = pSource,
                    HeightRequest     = playSize,
                    WidthRequest      = playSize,
                    TranslationY      = -textAddSpace / 2,
                    BackgroundColor   = Color.Transparent,
                    HorizontalOptions = LayoutOptions.Center,
                    VerticalOptions   = LayoutOptions.Center,
                    InputTransparent  = true,
                };

                ProgressBar progress = new ProgressBar()
                {
                    HorizontalOptions = LayoutOptions.Fill,
                    ProgressColor     = Color.FromHex("#829eff"),
                    VerticalOptions   = LayoutOptions.End,
                    BackgroundColor   = Color.Transparent,
                    Progress          = ep.progress,
                    WidthRequest      = FastPosterWith,
                    TranslationY      = -(4 + textAddSpace / 2),
                };

                /*
                 * var brView = new BorderView() { VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill, CornerRadius = 5 };
                 *
                 * brView.SetValue(XamEffects.TouchEffect.ColorProperty, Color.White);
                 * Commands.SetTap(brView, new Command((o) => {
                 *      //PushPageFromUrlAndName(z.id, z.name);
                 * }));*/
                stack.Children.Add(boxView);
                stack.Children.Add(ff);
                stack.Children.Add(playBtt);
                stack.Children.Add(progress);
                bool isMovie = ep.season <= 0 || ep.episode <= 0;
                stack.Children.Add(new Label()
                {
                    Text = (isMovie ? "" : $"S{ep.season}:E{ep.episode} ") + $"{ep.episodeName}", VerticalOptions = LayoutOptions.Start, VerticalTextAlignment = TextAlignment.Center, HorizontalTextAlignment = TextAlignment.Center, HorizontalOptions = LayoutOptions.Center, Padding = 1, TextColor = Color.White, MaxLines = 1, ClassId = "OUTLINE", TranslationY = FastPosterHeight, WidthRequest = FastPosterWith
                });

                stack.Effects.Add(Effect.Resolve("CloudStreamForms.LongPressedEffect"));

                LongPressedEffect.SetCommand(stack, new Command(async() => {
                    var res = new MovieResult(ep.state);
                    await Navigation.PushModalAsync(res, false);
                    await res.LoadLinksForEpisode(new EpisodeResult()
                    {
                        Episode = ep.episode, Season = ep.season, Id = ep.episode - 1, Description = ep.description, IMDBEpisodeId = ep.imdbId, OgTitle = ep.episodeName
                    });
                }));

                NextEpisode.Children.Add(stack, i, 0);
            }
        }
Ejemplo n.º 2
0
        void UpdateNextEpisode()
        {
            var  epis   = App.GetKeys <CloudStreamCore.CachedCoreEpisode>(nameof(CloudStreamCore.CachedCoreEpisode)).OrderBy(t => - t.createdAt.Ticks).ToArray();
            bool hasTxt = epis.Length > 0;

            UpdateHasNext(hasTxt);

            //NextEpisode.Children.Clear();
            var pSource = App.GetImageSource("nexflixPlayBtt.png");

            epView.NextEpisodeCollection.Clear();
            var bgColor = Settings.ItemBackGroundColor.ToHex();

            for (int i = 0; i < Math.Min(epis.Length, 5); i++)
            {
                var ep = epis[i];

                string title = ep.episode > 0 && ep.season > 0 ? $"S{ep.season}:E{ep.episode} {ep.episodeName}" : $"{ep.episodeName}";

                /*const int MAX_TITLE_LENGHT = 20;
                 * if (title.Length > MAX_TITLE_LENGHT) {
                 *      title = title[0..MAX_TITLE_LENGHT] + "...";
                 * }*/

                epView.NextEpisodeCollection.Add(new HomeNextEpisode()
                {
                    ImdbId      = ep.imdbId,
                    PosterUrl   = ep.poster,
                    Title       = title,
                    Progress    = ep.progress,
                    ExtraColor  = bgColor,
                    InfoCommand = new Command(async() => {
                        var res = new MovieResult(ep.state);
                        await Navigation.PushModalAsync(res, false);
                    }),
                    OpenCommand = new Command(async() => {
                        var res = new MovieResult(ep.state);
                        await Navigation.PushModalAsync(res, false);
                        for (int i = 0; i < 100; i++)
                        {
                            if (res.epView.MyEpisodeResultCollection.Count > 0)                               // FIXES NEXT EPISODE PROBLEM
                            {
                                break;
                            }
                            await Task.Delay(50);
                        }
                        await res.LoadLinksForEpisode(new EpisodeResult()
                        {
                            Episode = ep.episode, Season = ep.season, Id = ep.episode - 1, Description = ep.description, IMDBEpisodeId = ep.imdbId, OgTitle = ep.episodeName
                        });
                    }),
                    RemoveCommand = new Command(() => {
                        App.RemoveKey(nameof(CachedCoreEpisode), ep.parentImdbId);
                        for (int i = 0; i < epView.NextEpisodeCollection.Count; i++)
                        {
                            if (epView.NextEpisodeCollection[i].ImdbId == ep.imdbId)
                            {
                                epView.NextEpisodeCollection.RemoveAt(i);
                                break;
                            }
                        }
                        if (epView.NextEpisodeCollection.Count == 0)
                        {
                            UpdateNextEpisode();
                        }
                    }),
                });
            }
        }