feature: open with URL
This commit is contained in:
@@ -15,6 +15,10 @@ namespace Pixiview.Illust
|
||||
|
||||
protected override bool IsFavoriteVisible => false;
|
||||
|
||||
public override void OnUnload()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
//base.OnAppearing();
|
||||
|
@@ -13,10 +13,7 @@ using Xamarin.Forms;
|
||||
|
||||
namespace Pixiview.Illust
|
||||
{
|
||||
public abstract class FavoriteIllustCollectionPage : IllustCollectionPage<IllustItem[]>
|
||||
{
|
||||
public override void OnUnload() { }
|
||||
}
|
||||
public abstract class FavoriteIllustCollectionPage : IllustCollectionPage<IllustItem[]> { }
|
||||
public abstract class IllustDataCollectionPage : IllustCollectionPage<IllustData> { }
|
||||
public abstract class IllustUserDataCollectionPage : IllustCollectionPage<IllustUserData> { }
|
||||
|
||||
@@ -138,7 +135,7 @@ namespace Pixiview.Illust
|
||||
protected abstract IEnumerable<IllustItem> DoGetIllustList(T data, ICommand command);
|
||||
protected virtual void OnIllustImageTapped(IllustItem illust)
|
||||
{
|
||||
var page = new ViewIllustPage(illust, this);
|
||||
var page = new ViewIllustPage(illust, IsFavoriteVisible);
|
||||
Navigation.PushAsync(page);
|
||||
}
|
||||
|
||||
@@ -452,6 +449,8 @@ namespace Pixiview.Illust
|
||||
[JsonObject(MemberSerialization.OptIn)]
|
||||
public class IllustItem : BindableObject
|
||||
{
|
||||
public static readonly BindableProperty TitleProperty = BindableProperty.Create(
|
||||
nameof(Title), typeof(string), typeof(IllustItem));
|
||||
public static readonly BindableProperty ImageProperty = BindableProperty.Create(
|
||||
nameof(Image), typeof(ImageSource), typeof(IllustItem));
|
||||
public static readonly BindableProperty ProfileImageProperty = BindableProperty.Create(
|
||||
@@ -461,6 +460,12 @@ namespace Pixiview.Illust
|
||||
public static readonly BindableProperty IsFavoriteProperty = BindableProperty.Create(
|
||||
nameof(IsFavorite), typeof(bool), typeof(IllustItem));
|
||||
|
||||
[JsonProperty]
|
||||
public string Title
|
||||
{
|
||||
get => (string)GetValue(TitleProperty);
|
||||
set => SetValue(TitleProperty, value);
|
||||
}
|
||||
public ImageSource Image
|
||||
{
|
||||
get => (ImageSource)GetValue(ImageProperty);
|
||||
@@ -488,8 +493,6 @@ namespace Pixiview.Illust
|
||||
[JsonProperty]
|
||||
public string ImageUrl { get; set; }
|
||||
[JsonProperty]
|
||||
public string Title { get; set; }
|
||||
[JsonProperty]
|
||||
public bool IsRestrict { get; set; }
|
||||
[JsonProperty]
|
||||
public string ProfileUrl { get; set; }
|
||||
|
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Windows.Input;
|
||||
using Pixiview.UI;
|
||||
using Pixiview.Utils;
|
||||
using Xamarin.Essentials;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Pixiview.Illust
|
||||
@@ -69,7 +70,7 @@ namespace Pixiview.Illust
|
||||
{
|
||||
date = date.Substring(0, 4) + "-" + date.Substring(4, 2) + "-" + date.Substring(6, 2);
|
||||
}
|
||||
Device.BeginInvokeOnMainThread(() => Title = date);
|
||||
MainThread.BeginInvokeOnMainThread(() => Title = date);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
@@ -55,15 +55,15 @@ namespace Pixiview.Illust
|
||||
|
||||
public int CurrentPage { get; private set; }
|
||||
|
||||
private readonly IIllustCollectionPage collectionPage;
|
||||
private readonly bool saveFavorites;
|
||||
private readonly ICommand longPressed;
|
||||
private readonly ImageSource fontIconLove;
|
||||
private readonly ImageSource fontIconNotLove;
|
||||
|
||||
public ViewIllustPage(IllustItem illust, IIllustCollectionPage page)
|
||||
public ViewIllustPage(IllustItem illust, bool save)
|
||||
{
|
||||
IllustItem = illust;
|
||||
collectionPage = page;
|
||||
saveFavorites = save;
|
||||
longPressed = new Command<IllustDetailItem>(Illust_LongPressed);
|
||||
BindingContext = this;
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Pixiview.Illust
|
||||
{
|
||||
base.OnDisappearing();
|
||||
|
||||
if (collectionPage is IllustDataCollectionPage)
|
||||
if (saveFavorites)
|
||||
{
|
||||
Stores.SaveFavoritesIllusts();
|
||||
}
|
||||
@@ -161,7 +161,7 @@ namespace Pixiview.Illust
|
||||
LongPressed = longPressed
|
||||
};
|
||||
}
|
||||
items = tmp;
|
||||
Illusts = items = tmp;
|
||||
}
|
||||
|
||||
for (var i = 0; i < items.Length; i++)
|
||||
@@ -170,6 +170,20 @@ namespace Pixiview.Illust
|
||||
var p = pages.body[i];
|
||||
item.PreviewUrl = p.urls.regular;
|
||||
item.OriginalUrl = p.urls.original;
|
||||
|
||||
if (i == 0 && illustItem.ImageUrl == null)
|
||||
{
|
||||
// maybe open from a link
|
||||
var preload = Stores.LoadIllustPreloadData(illustItem.Id);
|
||||
if (preload != null && preload.illust.TryGetValue(illustItem.Id, out var illust))
|
||||
{
|
||||
illust.CopyToItem(illustItem);
|
||||
if (preload.user.TryGetValue(illust.userId, out var user))
|
||||
{
|
||||
illustItem.ProfileUrl = user.image;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DoLoadImage(0, true);
|
||||
@@ -329,7 +343,7 @@ namespace Pixiview.Illust
|
||||
var image = Stores.LoadIllustImage(item.OriginalUrl);
|
||||
if (image != null)
|
||||
{
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
MainThread.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
var service = DependencyService.Get<IFileStore>();
|
||||
var result = await service.SaveImageToGalleryAsync(image);
|
||||
|
Reference in New Issue
Block a user