Ejemplo n.º 1
0
        protected override void InitBindings()
        {
            AnimeDetailsPagePivot.Adapter = new AnimeDetailsPagerAdapter(ChildFragmentManager);
            AnimeDetailsPageTabStrip.SetViewPager(AnimeDetailsPagePivot);
            AnimeDetailsPageTabStrip.CenterTabs();
            AnimeDetailsPagePivot.SetCurrentItem(_navArgs.SourceTabIndex, false);
            AnimeDetailsPagePivot.OffscreenPageLimit = 7;

            AnimeDetailsPagePivot.AddOnPageChangeListener(
                new OnPageChangedListener(i => ViewModel.DetailsPivotSelectedIndex = i));

            Bindings.Add(
                this.SetBinding(() => ViewModel.MyScoreBind,
                                () => AnimeDetailsPageScoreButton.Text));
            Bindings.Add(
                this.SetBinding(() => ViewModel.MyStatusBind,
                                () => AnimeDetailsPageStatusButton.Text));
            Bindings.Add(
                this.SetBinding(() => ViewModel.MyEpisodesBind,
                                () => AnimeDetailsPageWatchedButton.Text));
            Bindings.Add(
                this.SetBinding(() => ViewModel.MyVolumesBind,
                                () => AnimeDetailsPageReadVolumesButton.Text));
            Bindings.Add(
                this.SetBinding(() => ViewModel.LoadingGlobal,
                                () => AnimeDetailsPageLoadingOverlay.Visibility)
                .ConvertSourceToTarget(Converters.BoolToVisibility));

            Bindings.Add(this.SetBinding(() => ViewModel.IsIncrementButtonEnabled).WhenSourceChanges(() =>
            {
                AnimeDetailsPageIncrementButton.Alpha = ViewModel.IsIncrementButtonEnabled ? 1 : .35f;
            }));
            Bindings.Add(this.SetBinding(() => ViewModel.IsDecrementButtonEnabled).WhenSourceChanges(() =>
            {
                AnimeDetailsPageDecrementButton.Alpha = ViewModel.IsDecrementButtonEnabled ? 1 : .35f;
            }));

            Bindings.Add(this.SetBinding(() => ViewModel.AddAnimeVisibility)
                         .WhenSourceChanges(() =>
            {
                if (ViewModel.AddAnimeVisibility)
                {
                    AnimeDetailsPageIncDecSection.Visibility   = ViewStates.Gone;
                    AnimeDetailsPageUpdateSection.Visibility   = ViewStates.Gone;
                    AnimeDetailsPageAddSection.Visibility      = ViewStates.Visible;
                    AnimeDetailsPageFavouriteButton.Visibility = ViewStates.Gone;
                }
                else
                {
                    AnimeDetailsPageIncDecSection.Visibility   = ViewStates.Visible;
                    AnimeDetailsPageUpdateSection.Visibility   = ViewStates.Visible;
                    AnimeDetailsPageAddSection.Visibility      = ViewStates.Gone;
                    AnimeDetailsPageFavouriteButton.Visibility = ViewStates.Visible;
                }
            }));

            Bindings.Add(
                this.SetBinding(() => ViewModel.DetailsPivotSelectedIndex)
                .WhenSourceChanges(
                    () => AnimeDetailsPagePivot.SetCurrentItem(ViewModel.DetailsPivotSelectedIndex, true)));


            Bindings.Add(
                this.SetBinding(() => ViewModel.IsFavourite)
                .WhenSourceChanges(() =>
            {
                if (ViewModel.IsFavourite)
                {
                    AnimeDetailsPageFavouriteButton.ImageTintList = ColorStateList.ValueOf(Color.White);
                    AnimeDetailsPageFavouriteButton.SetImageResource(Resource.Drawable.icon_favourite);
                    AnimeDetailsPageFavouriteButton.SetBackgroundResource(ResourceExtension.AccentColourRes);
                }
                else
                {
                    AnimeDetailsPageFavouriteButton.ImageTintList = ColorStateList.ValueOf(new Color(ResourceExtension.BrushText));
                    AnimeDetailsPageFavouriteButton.SetImageResource(Resource.Drawable.icon_unfavourite);
                    AnimeDetailsPageFavouriteButton.SetBackgroundColor(Color.Transparent);
                }
            }));


            Bindings.Add(this.SetBinding(() => ViewModel.AnimeMode)
                         .WhenSourceChanges(() =>
            {
                if (ViewModel.AnimeMode)
                {
                    AnimeDetailsPageReadVolumesButton.Visibility    =
                        AnimeDetailsPageReadVolumesLabel.Visibility = ViewStates.Gone;
                }
                else
                {
                    AnimeDetailsPageReadVolumesButton.Visibility    =
                        AnimeDetailsPageReadVolumesLabel.Visibility = ViewStates.Visible;
                }
            }));

            Bindings.Add(this.SetBinding(() => ViewModel.DetailImage)
                         .WhenSourceChanges(() =>
            {
                AnimeDetailsPageShowCoverImage.Visibility = ViewStates.Invisible;
                AnimeDetailsPageShowCoverImage.Into(ViewModel.DetailImage);
            }));

            Bindings.Add(
                this.SetBinding(() => ViewModel.LoadingUpdate,
                                () => AnimeDetailsPageLoadingUpdateSpinner.Visibility)
                .ConvertSourceToTarget(Converters.BoolToVisibility));

            Bindings.Add(
                this.SetBinding(() => ViewModel.IsAddAnimeButtonEnabled,
                                () => AnimeDetailsPageAddButton.Enabled));

            AnimeDetailsPageFavouriteButton.SetOnClickListener(
                new OnClickListener(view => ViewModel.ToggleFavouriteCommand.Execute(null)));
            AnimeDetailsPageIncrementButton.SetOnClickListener(
                new OnClickListener(view => ViewModel.IncrementEpsCommand.Execute(null)));
            AnimeDetailsPageDecrementButton.SetOnClickListener(
                new OnClickListener(view => ViewModel.DecrementEpsCommand.Execute(null)));
            AnimeDetailsPageAddButton.SetOnClickListener(
                new OnClickListener(view => ViewModel.AddAnimeCommand.Execute(null)));
            AnimeDetailsPageMoreButton.SetOnClickListener(new OnClickListener(view =>
            {
                _menu = AnimeDetailsPageMoreFlyoutBuilder.BuildForAnimeDetailsPage(Activity, ViewModel,
                                                                                   AnimeDetailsPageMoreButton,
                                                                                   OnMoreFlyoutClick);
                _menu.Show();
            }));
            ImageContainer.SetOnClickListener(new OnClickListener(view =>
                                                                  KeyImageDialog.Instance.ShowDialog(Activity, ViewModel.DetailImage)));



            //OneTime

            AnimeDetailsPageWatchedLabel.Text = ViewModel.WatchedEpsLabel;



            //

            //Events
            AnimeDetailsPageStatusButton.SetOnClickListener(
                new OnClickListener(view => AnimeDetailsPageStatusButtonOnClick()));
            AnimeDetailsPageScoreButton.SetOnClickListener(
                new OnClickListener(view => AnimeDetailsPageScoreButtonOnClick()));
            AnimeDetailsPageWatchedButton.SetOnClickListener(
                new OnClickListener(view => AnimeDetailsPageWatchedButtonOnClick()));
            AnimeDetailsPageReadVolumesButton.SetOnClickListener(
                new OnClickListener(view => AnimeDetailsPageVolumesButtonOnClick()));
        }
Ejemplo n.º 2
0
        protected override void InitBindings()
        {
            AnimeDetailsPagePivot.Adapter = new AnimeDetailsPagerAdapter(FragmentManager);
            AnimeDetailsPageTabStrip.SetViewPager(AnimeDetailsPagePivot);

            Bindings = new List <Binding>();


            Bindings.Add(
                this.SetBinding(() => ViewModel.MyScoreBind,
                                () => AnimeDetailsPageScoreButton.Text));


            Bindings.Add(
                this.SetBinding(() => ViewModel.MyStatusBind,
                                () => AnimeDetailsPageStatusButton.Text));


            Bindings.Add(
                this.SetBinding(() => ViewModel.MyEpisodesBind,
                                () => AnimeDetailsPageWatchedButton.Text));


            Bindings.Add(
                this.SetBinding(() => ViewModel.MyVolumesBind,
                                () => AnimeDetailsPageReadVolumesButton.Text));


            Bindings.Add(
                this.SetBinding(() => ViewModel.LoadingGlobal,
                                () => AnimeDetailsPageLoadingOverlay.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));


            Bindings.Add(
                this.SetBinding(() => ViewModel.AddAnimeVisibility,
                                () => AnimeDetailsPageAddSection.Visibility).ConvertSourceToTarget(Converters.BoolToVisibility));


            Bindings.Add(
                this.SetBinding(() => ViewModel.IsIncrementButtonEnabled,
                                () => AnimeDetailsPageIncrementButton.Enabled));


            Bindings.Add(
                this.SetBinding(() => ViewModel.IsDecrementButtonEnabled,
                                () => AnimeDetailsPageDecrementButton.Enabled));


            Bindings.Add(
                this.SetBinding(() => ViewModel.AddAnimeVisibility,
                                () => AnimeDetailsPageUpdateSection.Visibility).ConvertSourceToTarget(Converters.BoolToVisibilityInverted));


            Bindings.Add(
                this.SetBinding(() => ViewModel.AddAnimeVisibility,
                                () => AnimeDetailsPageIncDecSection.Visibility).ConvertSourceToTarget(Converters.BoolToVisibilityInverted));


            Bindings.Add(
                this.SetBinding(() => ViewModel.DetailsPivotSelectedIndex).WhenSourceChanges(() => AnimeDetailsPagePivot.SetCurrentItem(ViewModel.DetailsPivotSelectedIndex, true)));


            Bindings.Add(
                this.SetBinding(() => ViewModel.IsFavourite).WhenSourceChanges(() =>
            {
                AnimeDetailsPageFavouriteButton.SetImageResource(ViewModel.IsFavourite
                        ? Resource.Drawable.icon_favourite
                        : Resource.Drawable.icon_fav_outline);
            }));

            AnimeDetailsPageFavouriteButton.SetCommand("Click", ViewModel.ToggleFavouriteCommand);
            AnimeDetailsPageIncrementButton.SetCommand("Click", ViewModel.IncrementEpsCommand);
            AnimeDetailsPageDecrementButton.SetCommand("Click", ViewModel.DecrementEpsCommand);
            AnimeDetailsPageMoreButton.Click +=
                (sender, args) =>
            {
                _menu = AnimeDetailsPageMoreFlyoutBuilder.BuildForAnimeDetailsPage(Activity, AnimeDetailsPageMoreButton,
                                                                                   ViewModel);
                _menu.Show();
            };
            AnimeDetailsPageAddButton.SetCommand("Click", ViewModel.AddAnimeCommand);


            //OneTime

            AnimeDetailsPageWatchedLabel.Text = ViewModel.WatchedEpsLabel;



            //

            //Events
            AnimeDetailsPageStatusButton.Click      += AnimeDetailsPageStatusButtonOnClick;
            AnimeDetailsPageScoreButton.Click       += AnimeDetailsPageScoreButtonOnClick;
            AnimeDetailsPageWatchedButton.Click     += AnimeDetailsPageWatchedButtonOnClick;
            AnimeDetailsPageReadVolumesButton.Click += AnimeDetailsPageVolumesButtonOnClick;
        }