95 lines
2.5 KiB
C#
95 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Pixiview.Resources;
|
|
using Pixiview.Utils;
|
|
using Xamarin.Essentials;
|
|
using Xamarin.Forms;
|
|
|
|
namespace Pixiview.Illust
|
|
{
|
|
public partial class FavoritesPage : FavoriteIllustCollectionPage
|
|
{
|
|
private bool flag = false;
|
|
|
|
public FavoritesPage()
|
|
{
|
|
Resources.Add("cardView", GetCardViewTemplate());
|
|
InitializeComponent();
|
|
}
|
|
|
|
protected override bool IsFavoriteVisible => false;
|
|
protected override ActivityIndicator LoadingIndicator => activityLoading;
|
|
protected override bool IsDelayLoading => true;
|
|
|
|
protected override void OnAppearing()
|
|
{
|
|
if (lastUpdated != LastUpdated)
|
|
{
|
|
StartLoad();
|
|
}
|
|
else
|
|
{
|
|
var favorites = Stores.Favorites;
|
|
if (favorites.Changed)
|
|
{
|
|
favorites.Reload();
|
|
lastUpdated = default;
|
|
StartLoad();
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override IEnumerable<IllustItem> DoGetIllustList(IllustItem[] data)
|
|
{
|
|
return data;
|
|
}
|
|
|
|
protected override IllustItem[] DoLoadIllustData(bool force)
|
|
{
|
|
var favorites = Stores.GetFavoriteObject(flag);
|
|
flag = false;
|
|
if (favorites == null)
|
|
{
|
|
return null;
|
|
}
|
|
var illusts = favorites.Illusts;
|
|
for (var i = 0; i < illusts.Count; i++)
|
|
{
|
|
var item = illusts[i];
|
|
if (item.RankTitle == null)
|
|
{
|
|
item.RankTitle = item.Title;
|
|
}
|
|
}
|
|
return illusts.ToArray();
|
|
}
|
|
|
|
public void Reload(bool force = false)
|
|
{
|
|
lastUpdated = default;
|
|
if (force)
|
|
{
|
|
flag = true;
|
|
}
|
|
StartLoad(force);
|
|
}
|
|
|
|
private void Refresh_Clicked(object sender, EventArgs e)
|
|
{
|
|
flag = false;
|
|
lastUpdated = default;
|
|
StartLoad(true);
|
|
}
|
|
|
|
private async void ShareFavorites_Clicked(object sender, EventArgs e)
|
|
{
|
|
var file = Stores.FavoritesPath;
|
|
await Share.RequestAsync(new ShareFileRequest
|
|
{
|
|
Title = ResourceHelper.Favorites,
|
|
File = new ShareFile(file)
|
|
});
|
|
}
|
|
}
|
|
}
|