async void BindAllBlogs(string search, string category, string tag, int page) { try { overlay.IsVisible = true; Regex rx = new System.Text.RegularExpressions.Regex("<[^>]*>"); overlay.IsVisible = true; AllBlogs objAllBlogs = await App.TodoManager.GetAllBlogs(search, category, tag, page); listAllBlogs.ItemsSource = objAllBlogs.data.data; overlay.IsVisible = false; } catch (Exception ex) { overlay.IsVisible = false; DependencyService.Get <IMessage>().LongAlert(); } }
async void ShowBlogs() { try { overlay.IsVisible = true; AllBlogs objAllBlogs = await App.TodoManager.GetAllBlogs("", "", "", 1); List <BlogData> lstBlogData = new List <BlogData>(); lstBlogData = objAllBlogs.data.data; for (int i = 0; i < 3; i++) { var imagestack = new StackLayout(); imagestack.HorizontalOptions = LayoutOptions.Fill; imagestack.VerticalOptions = LayoutOptions.Fill; CachedImage image = new CachedImage(); image.Source = lstBlogData[i].blog_photo; imagestack.Margin = new Thickness(10, 5); imagestack.HeightRequest = 70; imagestack.WidthRequest = 70; image.Aspect = Aspect.AspectFill; imagestack.Children.Add(image); var textstack = new StackLayout(); textstack.Orientation = StackOrientation.Vertical; var labelblogtext = new Label(); labelblogtext.Text = lstBlogData[i].title; var labeldate = new Label(); labeldate.Text = lstBlogData[i].created_at.ToString("dd MMM,yyyy (hh:mm tt)"); textstack.Children.Add(labelblogtext); textstack.Children.Add(labeldate); var MainStack = new StackLayout(); MainStack.Orientation = StackOrientation.Horizontal; MainStack.Children.Add(imagestack); MainStack.Children.Add(textstack); var outerstack = new StackLayout(); outerstack.Orientation = StackOrientation.Horizontal; outerstack.HorizontalOptions = LayoutOptions.FillAndExpand; outerstack.IsClippedToBounds = true; outerstack.Children.Add(MainStack); Blogslack.Children.Add(outerstack); var gesture = new TapGestureRecognizer(); gesture.CommandParameter = lstBlogData[i].id; gesture.Tapped += (s, e) => { dynamic obj = e; int param = obj.Parameter; Navigation.PushAsync(new BlogDetail(param)); }; outerstack.GestureRecognizers.Add(gesture); } overlay.IsVisible = false; } catch (Exception ex) { } }
public Blog GetBlogById(int blogId) { return(AllBlogs.FirstOrDefault(b => b.BlogId == blogId)); }