public StackLayout CreateScrollableFeedView(List <PostItemStackLayout> PostsContent, string placeholder, string scopeName, string groupid = null) { StackLayout stack = new StackLayout(); if (PostsContent != null && PostsContent.Count > 0) { Debug.WriteLine("Posts found"); feedPosts = Util.CreateFeed(PostsContent); ScrollFeed = new ScrollView { Content = feedPosts }; refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Content = ScrollFeed, RefreshColor = Color.FromHex("#3498db"), IsPullToRefreshEnabled = true }; refreshView.SetBinding(PullToRefreshLayout.IsRefreshingProperty, new Xamarin.Forms.Binding() { Path = "IsBusy", Mode = BindingMode.OneWay }); refreshView.SetBinding(PullToRefreshLayout.RefreshCommandProperty, new Xamarin.Forms.Binding() { Path = "RefreshCommand" }); stack = new StackLayout { Orientation = StackOrientation.Vertical, Children = { refreshView } }; } else { Label NoPostsLabel = new Label { Text = "Be the first to start this secret file!", TextColor = Color.Silver, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), VerticalOptions = LayoutOptions.Fill, HorizontalOptions = LayoutOptions.Fill }; refreshView = new PullToRefreshLayout { VerticalOptions = LayoutOptions.Center, HorizontalOptions = LayoutOptions.Center, Content = NoPostsLabel, RefreshColor = Color.FromHex("#3498db"), IsPullToRefreshEnabled = true }; stack = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { refreshView } }; } return(UIBuilder.AddFloatingActionButtonToStackLayout(stack, "ic_add_white_24dp.png", new Command(async() => { Navigation.PushAsync(new CreatePostPage(refreshHandler, "Add a Secret to " + this.Title, groupname, groupid)); }), Color.FromHex(Values.PURPLE), Color.FromHex(Values.GOOGLEBLUE))); }
async void CreateView() { this.BackgroundColor = Color.White; Title = "Groups"; SubscribeToRefreshListener(); CreateGroup = new ToolbarItem("Add", "ic_group_add_white_24dp.png", async() => { await Navigation.PushAsync(new CreateNewGroupPage()); }); //this.ToolbarItems.Add (CreateGroup); //setup list of groups that allows for pull-to-refresh functionality listView = new ListView(); if (App.GroupsContent != null) { listView.ItemsSource = App.GroupsContent; } listView.IsPullToRefreshEnabled = true; listView.RefreshCommand = RefreshCommand; listView.SetBinding(ListView.IsRefreshingProperty, new Xamarin.Forms.Binding() { Path = "IsBusy", Mode = BindingMode.OneWay }); //IsBusy = false; groupCell = new DataTemplate(() => { return(new ContextImageCell(this)); }); groupCell.SetBinding(ContextImageCell.TextProperty, new Xamarin.Forms.Binding() { Path = "groupName" }); groupCell.SetBinding(ContextImageCell.DetailProperty, new Xamarin.Forms.Binding() { Path = "groupDesc" }); groupCell.SetBinding(ContextImageCell.ImageSourceProperty, new Xamarin.Forms.Binding() { Path = "groupImage" }); listView.ItemTemplate = groupCell; listView.ItemSelected += async(sender, e) => { if (e.SelectedItem == null) { return; } GroupSelected = (GroupItem)e.SelectedItem; await Navigation.PushAsync(new GroupFeed(GroupSelected.groupName, GroupSelected.ID)); ((ListView)sender).SelectedItem = null; }; searchBar = Util.CreateSearchBar(this); var stack = new StackLayout { Orientation = StackOrientation.Vertical, Padding = new Thickness(0, 0, 0, 15), Children = { Util.CreateSeparator(Color.Gray, 1), searchBar, listView } }; Content = UIBuilder.AddFloatingActionButtonToStackLayout(stack, "ic_add_white_24dp.png", new Command(async() => { await Navigation.PushAsync(new CreateNewGroupPage()); }), Color.FromHex(Values.GOOGLEBLUE), Color.FromHex(Values.PURPLE)); ExecuteRefreshCommand(); }