public void Fill(NewsfeedItemWebModel item) { this.item = item; this.imageAthlete.Source = App.ImagesService.GetImageSource(item.AthletePicture, BackgroundEnum.White); this.labelDate.Text = DateTimeHelper.DateToString(item.Time); this.labelAthleteName.Text = item.AthleteName; if (this.labelAthlete2Name != null) { this.labelAthlete2Name.Text = item.Athlete2Name; } this.imageLike.Source = new FileImageSource() { File = item.Liked ? "like2.png" : "like1.png" }; this.imageComments.Source = new FileImageSource() { File = item.CommentsCount > 0 ? "right2.png" : "right1.png" }; this.labelLikesCount.Text = item.LikesCount.ToString(); this.labelLikesCount.TextColor = item.LikesCount > 0 ? Config.ColorBlackTextOnWhite : Config.ColorGrayTextOnWhite; this.labelCommentsCount.Text = item.CommentsCount.ToString(); this.labelCommentsCount.TextColor = item.CommentsCount > 0 ? Config.ColorBlackTextOnWhite : Config.ColorGrayTextOnWhite; }
public NewsfeedItemPostControl(NewsfeedItemWebModel item, bool treatAsASingleItem) : base(item, treatAsASingleItem) { FormattedString formattedString = new FormattedString(); formattedString.Spans.Add(new Span() { Text = "Posted \"", ForegroundColor = Config.ColorTextOnBackgroundGrayed }); formattedString.Spans.Add(new Span() { Text = item.Text, ForegroundColor = Config.ColorBlackTextOnWhite }); formattedString.Spans.Add(new Span() { Text = "\"", ForegroundColor = Config.ColorTextOnBackgroundGrayed }); Label labelContent = new BybLabel { FormattedText = formattedString, TextColor = Config.ColorBlackTextOnWhite, //HorizontalOptions = LayoutOptions.FillAndExpand, WidthRequest = 200, }; labelContent.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { await this.onOpenItem(); }), NumberOfTapsRequired = 1 }); this.Children.Add(this.frameAthleteImage); var panel = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.FillAndExpand, Spacing = 3, Padding = new Thickness(5, 0, 0, 0), Children = { labelDate, this.labelAthleteName, labelContent, } }; this.Children.Add(panel); this.Children.Add(panelCommentsCount); }
public NewsfeedItemResultControl(NewsfeedItemWebModel item, bool treatAsASingleItem) : base(item, treatAsASingleItem) { FormattedString formattedString = new FormattedString(); formattedString.Spans.Add(new Span() { Text = "Recorded a break of ", ForegroundColor = Config.ColorTextOnBackgroundGrayed }); formattedString.Spans.Add(new Span() { Text = item.Text, ForegroundColor = Config.ColorBlackTextOnWhite, FontAttributes = FontAttributes.Bold, FontSize = Config.DefaultFontSize }); Label labelContent = new BybLabel { FormattedText = formattedString }; labelContent.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { await this.onOpenItem(); }), NumberOfTapsRequired = 1 }); this.Children.Add(this.frameAthleteImage); var panel = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(5, 0, 0, 0), Spacing = 3, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { labelDate, this.labelAthleteName, labelContent, } }; if (this.labelVenue != null) { panel.Children.Add(labelVenue); } this.Children.Add(panel); this.Children.Add(panelCommentsCount); }
public async Task <NewsfeedItemWebModel> GetNewsfeedItemFromCommentID(int commentID) { string url = WebApiUrl + "Newsfeed/SingleFromCommentID?commentID=" + commentID; try { string json = await this.sendGetRequestAndReceiveResponse(url, true); NewsfeedItemWebModel item = JsonConvert.DeserializeObject <NewsfeedItemWebModel>(json); item.Time = System.TimeZone.CurrentTimeZone.ToLocalTime(item.Time); return(item); } catch (Exception exc) { LastExceptionUrl = url; LastException = exc; return(null); } }
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"; }
public NewsfeedItemGameHostControl(NewsfeedItemWebModel item, bool treatAsASingleItem) : base(item, treatAsASingleItem) { DateTime when = item.TimeOfEvent.Value.ToLocalTime(); Label labelText = new BybLabel { Text = "Invites to play snooker", TextColor = Config.ColorGrayTextOnWhite, HorizontalOptions = LayoutOptions.FillAndExpand, }; labelText.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { await this.onOpenItem(); }), NumberOfTapsRequired = 1 }); FormattedString formattedString = new FormattedString(); formattedString.Spans.Add(new Span() { Text = "On ", ForegroundColor = Config.ColorTextOnBackgroundGrayed }); formattedString.Spans.Add(new Span() { Text = DateTimeHelper.DateAndTimeToString(when), ForegroundColor = Config.ColorBlackTextOnWhite, FontSize = Config.DefaultFontSize }); Label labelWhen = new BybLabel { FormattedText = formattedString }; labelWhen.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { await this.onOpenItem(); }), NumberOfTapsRequired = 1 }); this.Children.Add(this.frameAthleteImage); var panel = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(5, 0, 0, 0), Spacing = 3, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { labelDate, new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center, Spacing = 3, Children = { this.labelAthleteName, } }, labelText, labelWhen, } }; if (this.labelVenue != null) { panel.Children.Add(labelVenue); } this.Children.Add(panel); this.Children.Add(panelCommentsCount); }
public NewsfeedItemScoreControl(NewsfeedItemWebModel item, bool treatAsASingleItem) : base(item, treatAsASingleItem) { FormattedString formattedString = new FormattedString(); formattedString.Spans.Add(new Span() { Text = "Recorded a score ", ForegroundColor = Config.ColorTextOnBackgroundGrayed }); formattedString.Spans.Add(new Span() { Text = item.Text, ForegroundColor = Config.ColorBlackTextOnWhite, FontSize = Config.DefaultFontSize }); Label labelContent = new BybLabel { FormattedText = formattedString }; labelContent.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { await this.onOpenItem(); }), NumberOfTapsRequired = 1 }); this.Children.Add(new BoxView() { WidthRequest = imageSize + imageExtraPadding * 2 }); var panel = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(0, 0, 0, 0), Spacing = 3, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { labelDate, new StackLayout { Orientation = StackOrientation.Horizontal, VerticalOptions = LayoutOptions.Center, Spacing = 3, Children = { this.labelAthleteName, new BybLabel { Text = "vs.", TextColor= Config.ColorGrayTextOnWhite, HorizontalOptions = LayoutOptions.Start, VerticalTextAlignment = TextAlignment.Center }, this.labelAthlete2Name, } }, labelContent, } }; if (this.labelVenue != null) { panel.Children.Add(labelVenue); } this.Children.Add(panel); this.Children.Add(panelCommentsCount); }
public NewsfeedItemBaseControl(NewsfeedItemWebModel item, bool treatAsASingleItem) { this.TreatAsASingleItem = treatAsASingleItem; this.Orientation = StackOrientation.Horizontal; this.Spacing = 0; this.Padding = new Thickness(5, 5, 5, 5); this.BackgroundColor = Color.White; this.HorizontalOptions = LayoutOptions.FillAndExpand; // athlete image this.imageAthlete = new Image() { WidthRequest = imageSize, HeightRequest = imageSize, }; this.frameAthleteImage = new Grid { BackgroundColor = Color.White, Padding = new Thickness(this.imageExtraPadding, 0, this.imageExtraPadding, 0), Children = { this.imageAthlete, } //Content = this.imageAthlete, }; // date this.labelDate = new BybLabel { TextColor = Config.ColorGrayTextOnWhite, FontSize = Config.SmallFontSize, HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.Start, }; // likes panel this.imageLike = new Image() { Source = new FileImageSource() { File = "like1.png" }, HeightRequest = Config.LikeImageSize, WidthRequest = Config.LikeImageSize, }; this.imageComments = new Image() { Source = new FileImageSource() { File = "right.png" }, HeightRequest = Config.CommentImageSize, WidthRequest = Config.CommentImageSize, }; this.labelLikesCount = new BybLabel { }; this.panelLikes = new StackLayout { Orientation = StackOrientation.Horizontal, //HorizontalOptions = LayoutOptions.Center, Padding = new Thickness(0, 0, Config.IsTablet ? 5 : 0, 5), Spacing = 3, Children = { this.labelLikesCount, this.imageLike } }; // this.panelLikes = new Frame() // { // Padding = new Thickness(0, 0, Config.IsTablet ? 5 : 0, 5), // Content = new StackLayout // { // Orientation = StackOrientation.Horizontal, // HorizontalOptions = LayoutOptions.Center, // Spacing = 3, // Children = // { // this.labelLikesCount, // this.imageLike // } // } // }; this.labelCommentsCount = new BybLabel { }; this.panelComments = new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.Center, Padding = new Thickness(0, 5, Config.IsTablet ? 5 : 0, 0), Spacing = 5, Children = { this.labelCommentsCount, this.imageComments, } }; // this.frameComments = new Frame() // { // Padding = new Thickness(0,5,Config.IsTablet ? 5 : 0,0), // Content = new StackLayout // { // Orientation = StackOrientation.Horizontal, // HorizontalOptions = LayoutOptions.Center, // Spacing = 5, // Children = // { // this.labelCommentsCount, // this.imageComments, // } // } // }; this.panelCommentsCount = new StackLayout { Orientation = StackOrientation.Vertical, Spacing = 0, HorizontalOptions = LayoutOptions.End, VerticalOptions = LayoutOptions.Center, Children = { panelLikes, panelComments, } }; // athlete name this.labelAthleteName = new BybLabel() { HorizontalOptions = LayoutOptions.Start, FontAttributes = this.TreatAsASingleItem ? FontAttributes.None : FontAttributes.Bold, TextColor = Config.ColorBlackTextOnWhite, }; // athlete 2 name if (item.Athlete2ID > 0) { this.labelAthlete2Name = new BybLabel() { HorizontalOptions = LayoutOptions.Start, FontAttributes = this.TreatAsASingleItem ? FontAttributes.Bold : FontAttributes.None, TextColor = Config.ColorBlackTextOnWhite, }; } // venue if (string.IsNullOrEmpty(item.VenueName) == false) { FormattedString formattedString = new FormattedString(); formattedString.Spans.Add(new Span() { Text = "@ ", ForegroundColor = Config.ColorTextOnBackgroundGrayed }); formattedString.Spans.Add(new Span() { Text = item.VenueName, ForegroundColor = Config.ColorBlackTextOnWhite }); this.labelVenue = new BybLabel() { FormattedText = formattedString }; } /// events /// this.imageAthlete.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { if (this.TreatAsASingleItem) { await this.onOpenItem(); } else { await App.Navigator.GoToPersonProfile(item.AthleteID); } }), NumberOfTapsRequired = 1 }); this.labelAthleteName.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { if (this.TreatAsASingleItem) { await this.onOpenItem(); } else { await App.Navigator.GoToPersonProfile(item.AthleteID); } }), NumberOfTapsRequired = 1 }); if (this.labelAthlete2Name != null) { this.labelAthlete2Name.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { if (this.TreatAsASingleItem) { await this.onOpenItem(); } else { await App.Navigator.GoToPersonProfile(item.Athlete2ID); } }), NumberOfTapsRequired = 1 }); } if (this.labelVenue != null) { this.labelVenue.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { if (this.TreatAsASingleItem) { await this.onOpenItem(); } else { await App.Navigator.GoToVenueProfile(item.VenueID); } }), NumberOfTapsRequired = 1 }); } panelLikes.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { if (item.Liked) { item.LikesCount -= 1; } else { item.LikesCount += 1; } item.Liked = !item.Liked; this.Fill(this.item); bool ok = await App.WebService.SetLike(item.ItemType, item.ID, item.Liked); if (ok == false) { App.Navigator.DisplayAlertError("Couldn't set the like. Internet issues?"); } }), NumberOfTapsRequired = 1 }); panelComments.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { await this.onOpenItem(); }), NumberOfTapsRequired = 1 }); this.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command(async() => { await this.onOpenItem(); }), NumberOfTapsRequired = 1 }); this.Fill(item); }