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:
Tsanie Lily 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 readonly Command<IllustItem> commandIllustImageTapped;
protected readonly Command<IIllustItem> commandUserTapped;
protected DateTime lastUpdated;
protected double topOffset;
protected string lastError;
@ -80,17 +81,35 @@ namespace Pixiview.Illust
public IllustCollectionPage()
{
commandIllustImageTapped = new Command<IllustItem>(IllustImageTapped);
commandIllustImageTapped = new Command<IllustItem>(OnIllustImageTapped);
commandUserTapped = new Command<IIllustItem>(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<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)
{
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)

View File

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

View File

@ -34,8 +34,6 @@ namespace Pixiview.Illust
set => SetValue(UserRecommendsVisibleProperty, value);
}
private readonly Command<IllustUserItem> 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<IllustUserItem>(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;

View File

@ -14,7 +14,7 @@
<OnPlatform x:TypeArguments="Thickness" Android="0, 5, 0, 5"/>
</u:CircleImage.Margin>
</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"
TextColor="{DynamicResource TextColor}"/>
</StackLayout>

View File

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