コード例 #1
0
        protected override View createViewForSingleItem(NewsfeedItemWebModel item)
        {
            try
            {
                NewsfeedItemBaseControl ctrl = null;
                if (item.ItemType == NewsfeedItemTypeEnum.Post)
                {
                    ctrl = new NewsfeedItemPostControl(item, true);
                }
                else if (item.ItemType == NewsfeedItemTypeEnum.Result)
                {
                    ctrl = new NewsfeedItemResultControl(item, true);
                }
                else if (item.ItemType == NewsfeedItemTypeEnum.Score)
                {
                    ctrl = new NewsfeedItemScoreControl(item, true);
                }
                else if (item.ItemType == NewsfeedItemTypeEnum.GameHost)
                {
                    ctrl = new NewsfeedItemGameHostControl(item, true);
                }
                else if (item.ItemType == NewsfeedItemTypeEnum.NewUser)
                {
                    ctrl = new NewsfeedItemNewUserControl(item, true);
                }
                else
                {
                    throw new Exception("Unknown type of NewsfeedItem");
                }

                ctrl.NeedsARefresh += (s1, e1) => { this.onNeedsARefresh(); };
                return(ctrl);
            }
            catch (Exception exc)
            {
                return(new BybLabel()
                {
                    Text = TraceHelper.ExceptionToString(exc)
                });
            }
        }
コード例 #2
0
        public NewsfeedItemPage(NewsfeedItemWebModel item, bool isModal)
        {
            this.isModal = isModal;
            this.item    = item;

            NewsfeedItemBaseControl newsfeedItemControl;

            if (item.ItemType == NewsfeedItemTypeEnum.Post)
            {
                newsfeedItemControl = new NewsfeedItemPostControl(item, false);
            }
            else if (item.ItemType == NewsfeedItemTypeEnum.Result)
            {
                newsfeedItemControl = new NewsfeedItemResultControl(item, false);
            }
            else if (item.ItemType == NewsfeedItemTypeEnum.Score)
            {
                newsfeedItemControl = new NewsfeedItemScoreControl(item, false);
            }
            else if (item.ItemType == NewsfeedItemTypeEnum.GameHost)
            {
                newsfeedItemControl = new NewsfeedItemGameHostControl(item, false);
            }
            else if (item.ItemType == NewsfeedItemTypeEnum.NewUser)
            {
                newsfeedItemControl = new NewsfeedItemNewUserControl(item, true);
            }
            else
            {
                throw new NotImplementedException();
            }
            newsfeedItemControl.ShowCommentsCount  = false;
            newsfeedItemControl.TreatAsASingleItem = false;
            newsfeedItemControl.NeedsARefresh     += (s1, e1) => { this.AnythingChanged = true; };
            //newsfeedItemControl.Padding = new Thickness(0);

            this.labelLoading = new BybLabel()
            {
                HeightRequest         = 40,
                VerticalTextAlignment = TextAlignment.Center,
                HorizontalOptions     = LayoutOptions.Center,
                TextColor             = Config.ColorBlackTextOnWhite,
                IsVisible             = true,
                Text = "Loading...",
            };

            this.listOfCommentsControl = new ListOfCommentsControl()
            {
                Padding = new Thickness(10, 10, 0, 0),
            };

            this.editor = new BybEditor()
            {
                HeightRequest = 40,
            };
            this.editor.Unfocused += editor_Unfocused;
            this.editor.Focused   += editor_Focused;
            this.editor.Completed += editor_Completed;

            this.buttonCancel = new BybButton {
                Text = "Close", Style = (Style)App.Current.Resources["BlackButtonStyle"]
            };
            buttonCancel.Clicked += buttonCancel_Clicked;

            Button buttonPostComment = new BybButton {
                Text = "Done", Style = (Style)App.Current.Resources["SimpleButtonStyle"], HorizontalOptions = LayoutOptions.End
            };

            buttonPostComment.Clicked += buttonPostComment_Clicked;
            this.panelWithButtons      = new StackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                //BackgroundColor = Config.ColorBackground,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = Config.OkCancelButtonsHeight,
                Padding           = new Thickness(10, 0, 10, 0),
                Spacing           = 0,
                IsVisible         = false,
                Children          =
                {
                    buttonPostComment,
                    //buttonCancel2,
                }
            };

            var stackLayout = new StackLayout
            {
                Spacing = 0,
                Padding = new Thickness(0, 0, 0, 0),

                Children =
                {
                    new StackLayout
                    {
                        Padding           = new Thickness(10, 10, 10, 0),
                        Orientation       = StackOrientation.Vertical,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Children          =
                        {
                            newsfeedItemControl,
                        }
                    },

                    this.labelLoading,
                    new ScrollView
                    {
                        Padding         = new Thickness(10, 0, 10, 10),
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        Content         = new StackLayout
                        {
                            Orientation = StackOrientation.Vertical,
                            Children    =
                            {
                                this.listOfCommentsControl,
                                new StackLayout
                                {
                                    Orientation     = StackOrientation.Horizontal,
                                    BackgroundColor = Config.ColorGrayBackground,
                                    Padding         = new Thickness(10, 10, 0, 0),
                                    Children        =
                                    {
                                        new BybLabel
                                        {
                                            Text            = "Enter your comments here:",
                                            VerticalOptions = LayoutOptions.Center,
                                            TextColor       = Config.ColorGrayTextOnWhite
                                        },
                                        panelWithButtons,
                                    },
                                },
//                                new Frame
//                                {
//                                    BackgroundColor = Config.ColorGrayBackground,
//                                    Padding = new Thickness(10,10,0,0),
//                                    Content = new BybLabel
//                                    {
//                                        Text = "Enter your comments here:"
//                                    }
//                                },
                                //panelWithButtons,
                                new Frame
                                {
                                    BackgroundColor = Config.ColorGrayBackground,
                                    Padding         = new Thickness(15,  5, 5, 5),
                                    Content         = editor,
                                },
                            }
                        }
                    },

                    new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        //BackgroundColor = Config.ColorBackground,
                        HorizontalOptions = LayoutOptions.Fill,
                        HeightRequest     = Config.OkCancelButtonsHeight,
                        Padding           = new Thickness(Config.OkCancelButtonsPadding),
                        Children          =
                        {
                            buttonCancel,
                        }
                    }
                }
            };

            if (this.isModal)
            {
                stackLayout.Children.Insert(0, new BybTitle("Comments"));
            }

            this.Content         = stackLayout;
            this.Padding         = new Thickness(0, 0, 0, 0);
            this.BackgroundColor = Config.ColorGrayBackground;
            this.Title           = "Comments";
        }