diff --git a/Pixiview/Illust/IllustCollectionPage.cs b/Pixiview/Illust/IllustCollectionPage.cs index 727f058..eebf3a1 100644 --- a/Pixiview/Illust/IllustCollectionPage.cs +++ b/Pixiview/Illust/IllustCollectionPage.cs @@ -71,6 +71,7 @@ namespace Pixiview.Illust protected virtual double IndicatorMarginTop => 16; protected readonly Command commandIllustImageTapped; + protected readonly Command commandUserTapped; protected DateTime lastUpdated; protected double topOffset; protected string lastError; @@ -80,17 +81,35 @@ namespace Pixiview.Illust public IllustCollectionPage() { - commandIllustImageTapped = new Command(IllustImageTapped); + commandIllustImageTapped = new Command(OnIllustImageTapped); + commandUserTapped = new Command(OnIllustUserItemTapped); BindingContext = this; } - private void IllustImageTapped(IllustItem illust) + private void OnIllustImageTapped(IllustItem illust) { if (illust == null) { return; } - Start(() => OnIllustImageTapped(illust)); + Start(async () => + { + var page = new ViewIllustPage(illust); + await Navigation.PushAsync(page); + }); + } + + private void OnIllustUserItemTapped(IIllustItem item) + { + if (item == null) + { + return; + } + Start(async () => + { + var page = new UserIllustPage(item); + await Navigation.PushAsync(page); + }); } #region - Overrides - @@ -176,11 +195,6 @@ namespace Pixiview.Illust protected abstract T DoLoadIllustData(bool force); protected abstract IEnumerable DoGetIllustList(T data); - protected virtual void OnIllustImageTapped(IllustItem illust) - { - var page = new ViewIllustPage(illust); - Navigation.PushAsync(page); - } protected virtual IllustCollection GetIllustsLoadedCollection(IllustCollection collection, bool bottom) { IllustCollection = collection; @@ -299,7 +313,7 @@ namespace Pixiview.Illust } } - protected DataTemplate GetCardViewTemplate(bool hideUser = false) + protected DataTemplate GetCardViewTemplate(bool hideUser = false, string titleBinding = null) { return new DataTemplate(() => { @@ -472,7 +486,7 @@ namespace Pixiview.Illust pages, anime, - title.Binding(Label.TextProperty, nameof(IllustItem.RankTitle)).GridRow(1), + title.Binding(Label.TextProperty, titleBinding ?? nameof(IllustItem.Title)).GridRow(1), // stacklayout: user new Grid @@ -509,6 +523,14 @@ namespace Pixiview.Illust // label: favorite favorite.GridColumn(2) + }, + GestureRecognizers = + { + new TapGestureRecognizer + { + Command = commandUserTapped + } + .Binding(TapGestureRecognizer.CommandParameterProperty, ".") } } .GridRow(2) diff --git a/Pixiview/Illust/RankingPage.xaml.cs b/Pixiview/Illust/RankingPage.xaml.cs index 7d5a2af..fd499b1 100644 --- a/Pixiview/Illust/RankingPage.xaml.cs +++ b/Pixiview/Illust/RankingPage.xaml.cs @@ -108,7 +108,7 @@ namespace Pixiview.Illust public RankingPage() { - Resources.Add("cardView", GetCardViewTemplate()); + Resources.Add("cardView", GetCardViewTemplate(titleBinding: nameof(IllustItem.RankTitle))); ToolbarCommand = new Command(OnDateTrigger, OnCanDateTrigger); InitializeComponent(); gridFilter.TranslationY = -100; diff --git a/Pixiview/Illust/RecommendsPage.xaml.cs b/Pixiview/Illust/RecommendsPage.xaml.cs index 0a9e703..c4a41d7 100644 --- a/Pixiview/Illust/RecommendsPage.xaml.cs +++ b/Pixiview/Illust/RecommendsPage.xaml.cs @@ -34,8 +34,6 @@ namespace Pixiview.Illust set => SetValue(UserRecommendsVisibleProperty, value); } - private readonly Command commandUserTapped; - private IllustData illustData; public RecommendsPage() @@ -43,8 +41,6 @@ namespace Pixiview.Illust Resources.Add("cardView", GetCardViewTemplate()); Resources.Add("userCardView", GetUserCardViewTemplate()); InitializeComponent(); - - commandUserTapped = new Command(OnIllustUserItemTapped); } protected override ActivityIndicator LoadingIndicator => activityLoading; @@ -55,15 +51,6 @@ namespace Pixiview.Illust Users = null; } - private void OnIllustUserItemTapped(IllustUserItem item) - { - Start(async () => - { - var page = new UserIllustPage(item); - await Navigation.PushAsync(page); - }); - } - private Image GetUserCardViewImage(int column, CornerMask masks, string source, string parameter) { Image image; diff --git a/Pixiview/Illust/UserIllustPage.xaml b/Pixiview/Illust/UserIllustPage.xaml index a53c2e5..4e5d086 100644 --- a/Pixiview/Illust/UserIllustPage.xaml +++ b/Pixiview/Illust/UserIllustPage.xaml @@ -14,7 +14,7 @@ -