private void NavigateToSub(SubredditItem sub) { string navigationParamName = "Subreddit"; BootStrapper.Current.SessionState[navigationParamName] = sub; BootStrapper.Current.NavigationService.Navigate(typeof(SubGalleryPage), navigationParamName); }
private void SubredditWrapper_Tapped(object sender, TappedRoutedEventArgs e) { SubredditItem subreddit = (sender as Grid).DataContext as SubredditItem; mainVM.LoadSubreddit(subreddit); MainSplitView.IsPaneOpen = false; }
protected void NavigateToSub(SubredditItem sub) { string navigationParamName = "Subreddit"; StateHelper.SessionState[navigationParamName] = sub; navigationService.NavigateTo(PageKeyHolder.SubGalleryPageKey, navigationParamName); }
private void BindRedditView(CachingViewHolder holder, SubredditItem item, int position) { holder.FindCachedViewById <TextView>(Resource.Id.TitleTextView).Text = item.Title.Replace("&", "&"); holder.FindCachedViewById <TextView>(Resource.Id.SubtitleTextView).Text = $"/r/{item.Url} • {item.Subscribers} Subscribers"; var addButton = holder.FindCachedViewById <View>(Resource.Id.AddButton); var addButtonVisibilityBinding = new Binding <bool, ViewStates>(item, () => item.IsFavorited, addButton, () => addButton.Visibility).ConvertSourceToTarget((flag) => flag ? ViewStates.Gone : ViewStates.Visible); holder.DeleteBinding(nameof(addButtonVisibilityBinding)); holder.SaveBinding(nameof(addButtonVisibilityBinding), addButtonVisibilityBinding); //addButton.SetCommand("Click", Vm.ToggleFavorite, item); var checkButton = holder.FindCachedViewById <View>(Resource.Id.CheckButton); var checkButtonVisibilityBinding = new Binding <bool, ViewStates>(item, () => item.IsFavorited, checkButton, () => checkButton.Visibility).ConvertSourceToTarget((flag) => !flag ? ViewStates.Gone : ViewStates.Visible); holder.DeleteBinding(nameof(checkButtonVisibilityBinding)); holder.SaveBinding(nameof(checkButtonVisibilityBinding), checkButtonVisibilityBinding); //checkButton.SetCommand("Click", Vm.ToggleFavorite, item); var toggleContainer = holder.FindCachedViewById <View>(Resource.Id.ToggleContainer); toggleContainer.SetCommand("Click", Vm.ToggleFavorite, item); }
private View GetSubredditView(int position, SubredditItem item, View convertView) { View ret = convertView ?? Activity.LayoutInflater.Inflate(Resource.Layout.Tmpl_SubredditItem, null); ret.FindViewById <TextView>(Resource.Id.TitleTextView).Text = item.Title; ret.FindViewById <TextView>(Resource.Id.SubtitleTextView).Text = $"/r/{item.Url}"; return(ret); }
public void RemoveSubreddit(SubredditItem subreddit) { Subreddits.Remove(subreddit); SaveSubreddits(); if (subreddit.Title == GalleryTitle) { LoadGallery(); } }
public async void LoadSubreddit(SubredditItem subreddit) { //ImageItems = new ObservableCollection<GalleryItem>(); //GalleryTitle = subreddit.FriendlyName; //var subredditGallery = await Gallery.GetSubreddditGallery(subreddit.ActualName); //foreach (var image in subredditGallery) //{ // ImageItems.Add(new GalleryItem(image)); //} }
private async void TogglePin(SubredditItem subreddit, Rect rect) { string tileId = subreddit.Url; if (SecondaryTile.Exists(tileId)) { SecondaryTile secondaryTile = new SecondaryTile(tileId); Windows.UI.Popups.Placement placement = Windows.UI.Popups.Placement.Above; bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(rect, placement); ToggleAppBarButton(isUnpinned); } else { string displayName = $"/r/{subreddit.Url}"; string tileActivationArguments = $"subreddit://{tileId}"; Uri logo = new Uri("ms-appx:///Assets/Square150x150Logo.png"); TileSize newTileDesiredSize = TileSize.Square150x150; SecondaryTile secondaryTile = new SecondaryTile(tileId, displayName, tileActivationArguments, logo, newTileDesiredSize); secondaryTile.VisualElements.Square71x71Logo = new Uri("ms-appx:///Assets/Square71x71Logo.png"); secondaryTile.VisualElements.Wide310x150Logo = new Uri("ms-appx:///Assets/Wide310x150Logo.png"); secondaryTile.VisualElements.Square310x310Logo = new Uri("ms-appx:///Assets/Square310x310Logo.png"); secondaryTile.VisualElements.Square44x44Logo = new Uri("ms-appx:///Assets/Square44x44Logo.png"); secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true; secondaryTile.VisualElements.ShowNameOnSquare310x310Logo = true; secondaryTile.VisualElements.ShowNameOnWide310x150Logo = true; Windows.UI.Popups.Placement placement = Windows.UI.Popups.Placement.Above; var tileManager = SimpleIoc.Default.GetInstance <TileManager>(); if (!(Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons")))) { bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(rect, placement); ToggleAppBarButton(!isPinned); } //Phone if ((Windows.Foundation.Metadata.ApiInformation.IsTypePresent(("Windows.Phone.UI.Input.HardwareButtons")))) { //tileManager.ScheduleRedditTileUpdate(tileId, Vm.Images); bool isPinned = await secondaryTile.RequestCreateAsync(); ToggleAppBarButton(!isPinned); } tileManager.UpdateRedditTile(tileId, Vm.Images); } }
private async Task RestoreState(IDictionary <string, object> state) { if (state["subredditUrl"] == null) { Sub = JsonConvert.DeserializeObject <SubredditItem>((string)state["sub"]); Images = IncrementalSubredditGallery.FromJson((string)state["images"]); state.Clear(); } else { string subUrl = (string)state["subredditUrl"]; var sub = await Initializer.Reddits.GetSubreddit(subUrl); Sub = new SubredditItem(sub); Images = new IncrementalSubredditGallery(subUrl, Enums.Sort.Time); } }
public async Task SearchSubreddits(string query) { if (string.IsNullOrWhiteSpace(QueryText)) { return; } Subreddits = new ObservableCollection <SubredditItem>(); var subs = await Reddits.SearchSubreddits(query); IEnumerable <string> subscribedSubs = subredditsVM.Subreddits.Select(s => s.Url); foreach (var sub in subs) { SubredditItem si = new SubredditItem(sub); si.IsFavorited = subscribedSubs.Contains(si.Url); Subreddits.Add(si); } }
public async Task SearchSubreddits(string query) { if (string.IsNullOrWhiteSpace(QueryText)) { return; } Subreddits = new ObservableCollection <SubredditItem>(); var subs = await Helpers.Initializer.Reddits.SearchSubreddits(query); IEnumerable <string> subscribedSubs = subredditsVM.Subreddits.Select(s => s.Url); bool filterMature = !GetIsMatureEnabled(); foreach (var sub in subs) { if (filterMature && (sub.Over18 ?? false)) { continue; } SubredditItem si = new SubredditItem(sub); si.IsFavorited = subscribedSubs.Contains(si.Url); Subreddits.Add(si); } }
public async Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state) { IsBusy = true; if (State != null && State.Any()) { await RestoreState(State); State = null; } else if (state.Any()) { await RestoreState(state); } else { if (mode == NavigationMode.Back) { if (galleryMetaInfo == null) { galleryMetaInfo = BootStrapper.Current.SessionState["GalleryInfo"] as GalleryMetaInfo; Images = galleryMetaInfo?.Gallery as IncrementalSubredditGallery; var sub = await Initializer.Reddits.GetSubreddit(Images.Subreddit); Sub = new SubredditItem(sub); } ImageSelectedIndex = galleryMetaInfo?.SelectedIndex ?? 0; } else { Activate(parameter); } } await Task.CompletedTask; IsBusy = false; }
public void AddSubreddit(SubredditItem subreddit) { Subreddits.Insert(0, subreddit); SaveSubreddits(); }
public async Task AddSubreddit(SubredditItem subreddit) { subreddit.IsFavorited = true; Subreddits.Insert(0, subreddit); await SaveSubreddits(); }
public async Task RemoveSubreddit(SubredditItem subreddit) { subreddit.IsFavorited = false; Subreddits.Remove(Subreddits.Where(s => s.Url == subreddit.Url).First()); await SaveSubreddits(); }
public void SubredditTapped(SubredditItem item) { subredditsVM.GoToSub.Execute(item); }