protected override void InitBindings()
        {
            Bindings.Add(
                this.SetBinding(() => ViewModel.CurrentData).WhenSourceChanges(() =>
            {
                ImageService.Instance.LoadUrl(ViewModel.CurrentData.User.ImgUrl)
                .Success(ProfilePageGeneralTabAnimeUserImg.AnimateFadeIn)
                .Into(ProfilePageGeneralTabAnimeUserImg);

                ProfilePageGeneralTabDetailsList.SetAdapter(
                    ViewModel.CurrentData.Details.GetAdapter(GetDetailTemplateDelegate));

                ProfilePageGeneralTabFriendsGrid.ItemHeight    =
                    ProfilePageGeneralTabFriendsGrid.ItemWidth = DimensionsHelper.DpToPx(65);
                ProfilePageGeneralTabFriendsGrid.SetColumnWidth((int)ProfilePageGeneralTabFriendsGrid.ItemWidth);
                ProfilePageGeneralTabFriendsGrid.Adapter =
                    ViewModel.CurrentData.Friends.GetAdapter(GetFriendTemplateDelegate);

                ProfilePageGeneralTabCommentsList.SetAdapter(
                    ViewModel.CurrentData.Comments.GetAdapter(GetCommentTemplateDelegate));
            }));

            ProfilePageGeneralTabAnimeListButton.SetCommand(ViewModel.NavigateAnimeListCommand);
            ProfilePageGeneralTabMangaListButton.SetCommand(ViewModel.NavigateMangaListCommand);
            ProfilePageGeneralTabHistoryButton.SetCommand(ViewModel.NavigateHistoryCommand);
        }
Пример #2
0
        protected override void InitBindings()
        {
            Bindings.Add(this.SetBinding(() => ViewModel.CurrentData)
                         .WhenSourceChanges(async() =>
            {
                ProfilePageGeneralTabScrollingContainer.ScrollY = 0;

                if (string.IsNullOrEmpty(ViewModel.CurrentData.User.ImgUrl))
                {
                    ProfilePageGeneralTabAnimeUserImg.Visibility     = ViewStates.Invisible;
                    ProfilePageGeneralTabImagePlaceholder.Visibility = ViewStates.Visible;
                }
                else
                {
                    ProfilePageGeneralTabAnimeUserImg.Into(ViewModel.CurrentData.User.ImgUrl);
                    ProfilePageGeneralTabImagePlaceholder.Visibility = ViewStates.Gone;
                }


                ProfilePageGeneralTabDetailsList.SetAdapter(
                    ViewModel.CurrentData.Details.GetAdapter(GetDetailTemplateDelegate));

                ProfilePageGeneralTabFriendsGrid.ItemHeight    =
                    ProfilePageGeneralTabFriendsGrid.ItemWidth = DimensionsHelper.DpToPx(65);
                ProfilePageGeneralTabFriendsGrid.SetColumnWidth((int)ProfilePageGeneralTabFriendsGrid.ItemWidth);
                if (ViewModel.CurrentData.Friends.Any())
                {
                    ProfilePageGeneralTabFriendsGrid.Adapter =
                        ViewModel.CurrentData.Friends.GetAdapter(GetFriendTemplateDelegate);
                    ProfilePageGeneralTabFriendsEmptyNotice.Visibility = ViewStates.Gone;
                    ProfilePageGeneralTabMoreFriendsButton.Visibility  = ViewStates.Visible;
                }
                else
                {
                    ProfilePageGeneralTabFriendsGrid.Adapter           = null;
                    ProfilePageGeneralTabFriendsEmptyNotice.Visibility = ViewStates.Visible;
                    ProfilePageGeneralTabMoreFriendsButton.Visibility  = ViewStates.Gone;
                }

                await Task.Delay(500);
                PopulateComments();
            }));

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

            Bindings.Add(this.SetBinding(() => ViewModel.LoadingOhersLibrariesProgressVisiblity).WhenSourceChanges(() =>
            {
                if (ViewModel.LoadingOhersLibrariesProgressVisiblity)
                {
                    ProfilePageGeneralTabCompareList.Enabled = false;
                }
                else
                {
                    ProfilePageGeneralTabCompareList.Enabled = true;
                }
            }));

            Bindings.Add(this.SetBinding(() => ViewModel.CommentInputBoxVisibility).WhenSourceChanges(() =>
            {
                if (ViewModel.CommentInputBoxVisibility)
                {
                    ProfilePageGeneralTabCommentInput.Visibility      = ViewStates.Visible;
                    ProfilePageGeneralTabSendCommentButton.Visibility = ViewStates.Visible;
                }
                else
                {
                    ProfilePageGeneralTabCommentInput.Visibility      = ViewStates.Gone;
                    ProfilePageGeneralTabSendCommentButton.Visibility = ViewStates.Gone;
                }
            }));

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



            Bindings.Add(
                this.SetBinding(() => ViewModel.CommentText,
                                () => ProfilePageGeneralTabCommentInput.Text, BindingMode.TwoWay));

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

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


            Bindings.Add(this.SetBinding(() => ViewModel.IsPinned).WhenSourceChanges(() =>
            {
                if (!ViewModel.PinProfileVisibility)
                {
                    return;
                }

                if (ViewModel.IsPinned)
                {
                    PinButton.SetBackgroundColor(new Color(ResourceExtension.AccentColour));
                    PinButtonIcon.Rotation = 0;
                    PinButtonIcon.SetImageResource(Resource.Drawable.icon_unpin);
                }
                else
                {
                    PinButton.SetBackgroundColor(new Color(ResourceExtension.OpaqueAccentColour));
                    PinButtonIcon.Rotation = 45;
                    PinButtonIcon.SetImageResource(Resource.Drawable.icon_pin);
                }
            }));


            PinButton.SetOnClickListener(new OnClickListener(view =>
            {
                ViewModel.IsPinned     = !ViewModel.IsPinned;
                PinButtonIcon.Rotation = ViewModel.IsPinned ? 0 : 45;
            }));
            ProfilePageGeneralTabAnimeListButton.SetOnClickListener(new OnClickListener(v => ViewModel.NavigateAnimeListCommand.Execute(null)));
            ProfilePageGeneralTabMangaListButton.SetOnClickListener(new OnClickListener(v => ViewModel.NavigateMangaListCommand.Execute(null)));
            ProfilePageGeneralTabHistoryButton.SetOnClickListener(new OnClickListener(v => ViewModel.NavigateHistoryCommand.Execute(null)));
            ProfilePageGeneralTabSendCommentButton.SetOnClickListener(new OnClickListener(v => ViewModel.SendCommentCommand.Execute(null)));
            ProfilePageGeneralTabActionButton.SetOnClickListener(new OnClickListener(v => ProfilePageGeneralTabActionButtonOnClick()));
            ProfilePageGeneralTabCompareList.SetOnClickListener(new OnClickListener(v => ViewModel.NavigateComparisonCommand.Execute(null)));
            ProfilePageGeneralTabMoreFriendsButton.SetOnClickListener(new OnClickListener(v => ViewModel.NavigateFriendsCommand.Execute(null)));
            ProfilePageGeneralTabMoreFriendsButton.SetOnClickListener(new OnClickListener(v => ViewModel.NavigateFriendsCommand.Execute(null)));
            ReloadButton.SetOnClickListener(new OnClickListener(view => ViewModel.RefreshCommentsCommand.Execute(null)));


            PopulateComments();
            ProfilePageGeneralTabScrollingContainer.ViewTreeObserver.ScrollChanged -= ViewTreeObserverOnScrollChanged;
            ProfilePageGeneralTabScrollingContainer.ViewTreeObserver.ScrollChanged += ViewTreeObserverOnScrollChanged;
            ProfilePageGeneralTabScrollingContainer.Touch -= RootViewOnTouch;
            ProfilePageGeneralTabScrollingContainer.Touch += RootViewOnTouch;
            ProfilePageGeneralTabCommentsList.Touch       -= RootViewOnTouch;
            ProfilePageGeneralTabCommentsList.Touch       += RootViewOnTouch;
        }