favorite & view page & etc.
This commit is contained in:
@ -11,4 +11,5 @@
|
||||
<Detail>详细</Detail>
|
||||
<ProxyHost>代理主机</ProxyHost>
|
||||
<ProxyPort>代理端口</ProxyPort>
|
||||
<Favorite>收藏夹</Favorite>
|
||||
</root>
|
@ -32,6 +32,7 @@ namespace Gallery.Resources.Theme
|
||||
Add(TextColor, Color.White);
|
||||
Add(SubTextColor, Color.LightGray);
|
||||
Add(CardBackgroundColor, Color.FromRgb(0x33, 0x33, 0x33));
|
||||
Add(MaskColor, Color.FromRgba(0, 0, 0, 0x64));
|
||||
Add(NavigationColor, Color.FromRgb(0x11, 0x11, 0x11));
|
||||
Add(NavigationSelectedColor, Color.FromRgb(0x22, 0x22, 0x22));
|
||||
Add(OptionBackColor, Color.Black);
|
||||
|
@ -32,6 +32,7 @@ namespace Gallery.Resources.Theme
|
||||
Add(TextColor, Color.Black);
|
||||
Add(SubTextColor, Color.DimGray);
|
||||
Add(CardBackgroundColor, Color.FromRgb(0xf3, 0xf3, 0xf3));
|
||||
Add(MaskColor, Color.FromRgba(0, 0, 0, 0x64));
|
||||
Add(NavigationColor, Color.FromRgb(0xf0, 0xf0, 0xf0));
|
||||
Add(NavigationSelectedColor, Color.LightGray);
|
||||
Add(OptionBackColor, Color.FromRgb(0xf0, 0xf0, 0xf0));
|
||||
|
@ -11,6 +11,7 @@ namespace Gallery.Resources.Theme
|
||||
public const string TextColor = nameof(TextColor);
|
||||
public const string SubTextColor = nameof(SubTextColor);
|
||||
public const string CardBackgroundColor = nameof(CardBackgroundColor);
|
||||
public const string MaskColor = nameof(MaskColor);
|
||||
public const string NavigationColor = nameof(NavigationColor);
|
||||
public const string NavigationSelectedColor = nameof(NavigationSelectedColor);
|
||||
public const string OptionBackColor = nameof(OptionBackColor);
|
||||
@ -24,6 +25,9 @@ namespace Gallery.Resources.Theme
|
||||
public const string IconClose = nameof(IconClose);
|
||||
public const string FontIconOption = nameof(FontIconOption);
|
||||
public const string FontIconRefresh = nameof(FontIconRefresh);
|
||||
public const string FontIconLove = nameof(FontIconLove);
|
||||
public const string FontIconNotLove = nameof(FontIconNotLove);
|
||||
public const string FontIconShare = nameof(FontIconShare);
|
||||
|
||||
protected void InitResources()
|
||||
{
|
||||
@ -34,6 +38,9 @@ namespace Gallery.Resources.Theme
|
||||
|
||||
Add(FontIconOption, GetFontIcon(Definition.IconOption, Definition.IconSolidFamily));
|
||||
Add(FontIconRefresh, GetFontIcon(Definition.IconRefresh, Definition.IconSolidFamily));
|
||||
Add(FontIconLove, GetFontIcon(Definition.IconLove, Definition.IconSolidFamily, color: Definition.ColorRedBackground));
|
||||
Add(FontIconNotLove, GetFontIcon(Definition.IconLove, Definition.IconRegularFamily, color: Definition.ColorRedBackground));
|
||||
Add(FontIconShare, GetFontIcon(Definition.IconShare, Definition.IconSolidFamily));
|
||||
|
||||
Add(IconClose, Definition.IconClose);
|
||||
}
|
||||
|
@ -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