favorite & view page & etc.
This commit is contained in:
@ -36,6 +36,7 @@ namespace Gallery.Resources.UI
|
||||
public const string IconLove = "\uf004";
|
||||
public const string IconCircleLove = "\uf4c7";
|
||||
public const string IconClose = "\uf057";
|
||||
public const string IconShare = "\uf1e0";
|
||||
|
||||
static Definition()
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.Resources.UI
|
||||
{
|
||||
public abstract class GalleryCollectionPage : GalleryScrollableCollectionPage<GalleryItem[]>
|
||||
public abstract class GalleryCollectionPage : GalleryScrollableCollectionPage<IEnumerable<GalleryItem>>
|
||||
{
|
||||
public GalleryCollectionPage(IGallerySource source) : base(source) { }
|
||||
}
|
||||
@ -93,11 +93,11 @@ namespace Gallery.Resources.UI
|
||||
}
|
||||
}
|
||||
|
||||
protected readonly Command<GalleryItem> commandGalleryItemTapped;
|
||||
protected double topOffset;
|
||||
protected string lastError;
|
||||
|
||||
private readonly object sync = new();
|
||||
private readonly Command<GalleryItem> commandGalleryItemTapped;
|
||||
private readonly Stack<ParallelTask> tasks = new();
|
||||
private T galleryData;
|
||||
|
||||
@ -107,17 +107,8 @@ namespace Gallery.Resources.UI
|
||||
commandGalleryItemTapped = new Command<GalleryItem>(OnGalleryItemTapped);
|
||||
}
|
||||
|
||||
private void OnGalleryItemTapped(GalleryItem item)
|
||||
protected virtual void OnGalleryItemTapped(GalleryItem item)
|
||||
{
|
||||
if (item == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//Start(async () =>
|
||||
//{
|
||||
// var page = new GalleryItemPage(item);
|
||||
// await Navigation.PushAsync(page);
|
||||
//});
|
||||
}
|
||||
|
||||
public override void OnUnload()
|
||||
@ -145,6 +136,14 @@ namespace Gallery.Resources.UI
|
||||
{
|
||||
StartLoading();
|
||||
}
|
||||
else if (GalleryCollection != null)
|
||||
{
|
||||
var favorites = Store.FavoriteList;
|
||||
foreach (var item in GalleryCollection)
|
||||
{
|
||||
item.IsFavorite = favorites.Any(i => i.SourceEquals(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if __IOS__
|
||||
@ -217,6 +216,17 @@ namespace Gallery.Resources.UI
|
||||
{
|
||||
if (force || Expired)
|
||||
{
|
||||
if (!isBottom)
|
||||
{
|
||||
lock (sync)
|
||||
{
|
||||
// destory all the tasks
|
||||
while (tasks.TryPop(out var t))
|
||||
{
|
||||
t?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
var indicator = LoadingIndicator;
|
||||
if (indicator == null || isBottom)
|
||||
{
|
||||
@ -257,6 +267,7 @@ namespace Gallery.Resources.UI
|
||||
_ = DoloadGallerySource(force, isBottom);
|
||||
});
|
||||
}
|
||||
BeforeLoading();
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,6 +287,7 @@ namespace Gallery.Resources.UI
|
||||
#endif
|
||||
{
|
||||
Gallery = collection;
|
||||
AfterLoaded();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
@ -301,12 +313,16 @@ namespace Gallery.Resources.UI
|
||||
#endif
|
||||
{
|
||||
Gallery = collection;
|
||||
AfterLoaded();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void BeforeLoading() { }
|
||||
protected virtual void AfterLoaded() { }
|
||||
|
||||
protected async Task ScrollToTopAsync(ScrollView scrollView)
|
||||
{
|
||||
if (scrollView.ScrollY > -topOffset)
|
||||
@ -425,16 +441,18 @@ namespace Gallery.Resources.UI
|
||||
|
||||
var data = DoGetGalleryList(galleryData, out int tag).Where(i => i != null);
|
||||
var collection = new GalleryCollection(data);
|
||||
var favorites = Store.FavoriteList;
|
||||
foreach (var item in collection)
|
||||
{
|
||||
if (item.PreviewImage == null)
|
||||
{
|
||||
var image = await Store.LoadPreviewImage(item.PreviewUrl, false);
|
||||
var image = await Store.LoadPreviewImage(item, false);
|
||||
if (image != null)
|
||||
{
|
||||
item.PreviewImage = image;
|
||||
}
|
||||
}
|
||||
item.IsFavorite = favorites.Any(i => i.SourceEquals(item));
|
||||
}
|
||||
|
||||
DoGalleryLoaded(collection, bottom);
|
||||
@ -473,7 +491,7 @@ namespace Gallery.Resources.UI
|
||||
if (model.StartsWith("iPhone") || model.StartsWith("iPad"))
|
||||
{
|
||||
#endif
|
||||
var image = Store.LoadPreviewImage(item.PreviewUrl, true, force: true).Result;
|
||||
var image = Store.LoadPreviewImage(item, true, force: true).Result;
|
||||
if (image != null)
|
||||
{
|
||||
item.PreviewImage = image;
|
||||
@ -539,7 +557,7 @@ namespace Gallery.Resources.UI
|
||||
{
|
||||
lastRefreshY = double.MinValue;
|
||||
}
|
||||
base.StartLoading(force, isBottom);
|
||||
base.StartLoading(force: force, isBottom: isBottom);
|
||||
}
|
||||
|
||||
protected override GalleryCollection FilterGalleryCollection(GalleryCollection collection, bool bottom)
|
||||
@ -578,7 +596,7 @@ namespace Gallery.Resources.UI
|
||||
#if DEBUG
|
||||
Log.Print("start to load next page");
|
||||
#endif
|
||||
StartLoading(true, true);
|
||||
StartLoading(force: true, isBottom: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user