feature: redirect to user page in collection

fix: title issue in some places
fix: back button text issue in user illust detail page
This commit is contained in:
2020-05-23 20:14:55 +08:00
parent 5e03b835a0
commit e6a5fa58d7
5 changed files with 35 additions and 25 deletions

View File

@ -71,6 +71,7 @@ namespace Pixiview.Illust
protected virtual double IndicatorMarginTop => 16; protected virtual double IndicatorMarginTop => 16;
protected readonly Command<IllustItem> commandIllustImageTapped; protected readonly Command<IllustItem> commandIllustImageTapped;
protected readonly Command<IIllustItem> commandUserTapped;
protected DateTime lastUpdated; protected DateTime lastUpdated;
protected double topOffset; protected double topOffset;
protected string lastError; protected string lastError;
@ -80,17 +81,35 @@ namespace Pixiview.Illust
public IllustCollectionPage() public IllustCollectionPage()
{ {
commandIllustImageTapped = new Command<IllustItem>(IllustImageTapped); commandIllustImageTapped = new Command<IllustItem>(OnIllustImageTapped);
commandUserTapped = new Command<IIllustItem>(OnIllustUserItemTapped);
BindingContext = this; BindingContext = this;
} }
private void IllustImageTapped(IllustItem illust) private void OnIllustImageTapped(IllustItem illust)
{ {
if (illust == null) if (illust == null)
{ {
return; 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 - #region - Overrides -
@ -176,11 +195,6 @@ namespace Pixiview.Illust
protected abstract T DoLoadIllustData(bool force); protected abstract T DoLoadIllustData(bool force);
protected abstract IEnumerable<IllustItem> DoGetIllustList(T data); protected abstract IEnumerable<IllustItem> 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) protected virtual IllustCollection GetIllustsLoadedCollection(IllustCollection collection, bool bottom)
{ {
IllustCollection = collection; 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(() => return new DataTemplate(() =>
{ {
@ -472,7 +486,7 @@ namespace Pixiview.Illust
pages, pages,
anime, anime,
title.Binding(Label.TextProperty, nameof(IllustItem.RankTitle)).GridRow(1), title.Binding(Label.TextProperty, titleBinding ?? nameof(IllustItem.Title)).GridRow(1),
// stacklayout: user // stacklayout: user
new Grid new Grid
@ -509,6 +523,14 @@ namespace Pixiview.Illust
// label: favorite // label: favorite
favorite.GridColumn(2) favorite.GridColumn(2)
},
GestureRecognizers =
{
new TapGestureRecognizer
{
Command = commandUserTapped
}
.Binding(TapGestureRecognizer.CommandParameterProperty, ".")
} }
} }
.GridRow(2) .GridRow(2)

View File

@ -108,7 +108,7 @@ namespace Pixiview.Illust
public RankingPage() public RankingPage()
{ {
Resources.Add("cardView", GetCardViewTemplate()); Resources.Add("cardView", GetCardViewTemplate(titleBinding: nameof(IllustItem.RankTitle)));
ToolbarCommand = new Command<string>(OnDateTrigger, OnCanDateTrigger); ToolbarCommand = new Command<string>(OnDateTrigger, OnCanDateTrigger);
InitializeComponent(); InitializeComponent();
gridFilter.TranslationY = -100; gridFilter.TranslationY = -100;

View File

@ -34,8 +34,6 @@ namespace Pixiview.Illust
set => SetValue(UserRecommendsVisibleProperty, value); set => SetValue(UserRecommendsVisibleProperty, value);
} }
private readonly Command<IllustUserItem> commandUserTapped;
private IllustData illustData; private IllustData illustData;
public RecommendsPage() public RecommendsPage()
@ -43,8 +41,6 @@ namespace Pixiview.Illust
Resources.Add("cardView", GetCardViewTemplate()); Resources.Add("cardView", GetCardViewTemplate());
Resources.Add("userCardView", GetUserCardViewTemplate()); Resources.Add("userCardView", GetUserCardViewTemplate());
InitializeComponent(); InitializeComponent();
commandUserTapped = new Command<IllustUserItem>(OnIllustUserItemTapped);
} }
protected override ActivityIndicator LoadingIndicator => activityLoading; protected override ActivityIndicator LoadingIndicator => activityLoading;
@ -55,15 +51,6 @@ namespace Pixiview.Illust
Users = null; 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) private Image GetUserCardViewImage(int column, CornerMask masks, string source, string parameter)
{ {
Image image; Image image;

View File

@ -14,7 +14,7 @@
<OnPlatform x:TypeArguments="Thickness" Android="0, 5, 0, 5"/> <OnPlatform x:TypeArguments="Thickness" Android="0, 5, 0, 5"/>
</u:CircleImage.Margin> </u:CircleImage.Margin>
</u:CircleImage> </u:CircleImage>
<Label Text="{Binding UserItem.UserName}" Margin="10, 0, 0, 0" <Label Text="{Binding Title}" Margin="10, 0, 0, 0"
VerticalOptions="Center" LineBreakMode="TailTruncation" VerticalOptions="Center" LineBreakMode="TailTruncation"
TextColor="{DynamicResource TextColor}"/> TextColor="{DynamicResource TextColor}"/>
</StackLayout> </StackLayout>

View File

@ -30,6 +30,7 @@ namespace Pixiview.Illust
{ {
UserItem = item; UserItem = item;
UserIcon = item.ProfileImage; UserIcon = item.ProfileImage;
Title = item.UserName;
Resources.Add("cardView", GetCardViewTemplate(true)); Resources.Add("cardView", GetCardViewTemplate(true));
InitializeComponent(); InitializeComponent();