adjust UI
This commit is contained in:
@ -1,24 +1,63 @@
|
||||
using System;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using Gallery.Util;
|
||||
using Gallery.Util.Interface;
|
||||
using Gallery.Util.Model;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.Danbooru
|
||||
{
|
||||
public class GallerySource : IGallerySource
|
||||
{
|
||||
public string Name => "Danbooru";
|
||||
|
||||
public string Route => "danbooru";
|
||||
public string FlyoutIconKey => "Danbooru";
|
||||
public string HomePage => "https://danbooru.donmai.us";
|
||||
|
||||
public Task<GalleryItem[]> GetRecentItemsAsync(int page)
|
||||
public async Task<GalleryItem[]> GetRecentItemsAsync(int page)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
var url = $"https://danbooru.donmai.us/posts?page={page}";
|
||||
var (result, error) = await NetHelper.RequestObject<GalleryItem[]>(url, contentHandler: ContentHandler);
|
||||
|
||||
if (result == null || !string.IsNullOrEmpty(error))
|
||||
{
|
||||
Log.Error("danbooru.content.load", $"failed to load content array, error: {error}");
|
||||
return null;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string ContentHandler(string content)
|
||||
{
|
||||
var regex = new Regex(@"<article id=""post_\d+"".+?data-id=""(\d+)"".+?data-tags=""([^""]+?)"".+?data-width=""(\d+?)"" data-height=""(\d+?)"".+?data-source=""([^""]+?)"" data-uploader-id=""(\d+?)"" data-normalized-source=""([^""]+?)"".+?data-file-url=""([^""]+?)"".+?data-preview-file-url=""([^""]+?)""", RegexOptions.Multiline);
|
||||
var matches = regex.Matches(content);
|
||||
var array = new string[matches.Count];
|
||||
for (var i = 0; i < array.Length; i++)
|
||||
{
|
||||
var g = matches[i].Groups;
|
||||
var tags = g[2].Value.Replace(" ", "\",\"");
|
||||
array[i] = $"{{\"Id\":{g[0].Value},\"Tags\":[\"{tags}\"]}}";
|
||||
}
|
||||
return $"[{string.Join(',', array)}]";
|
||||
}
|
||||
|
||||
public void SetCookie()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InitDynamicResources(string family, ResourceDictionary light, ResourceDictionary dark)
|
||||
{
|
||||
var icon = new FontImageSource
|
||||
{
|
||||
FontFamily = family,
|
||||
Glyph = "\uf5d2",
|
||||
Size = 18.0
|
||||
};
|
||||
light.Add(FlyoutIconKey, icon);
|
||||
dark.Add(FlyoutIconKey, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,15 @@
|
||||
using System.Threading.Tasks;
|
||||
using Gallery.Util.Interface;
|
||||
using Gallery.Util.Model;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.Gelbooru
|
||||
{
|
||||
public class GallerySource : IGallerySource
|
||||
{
|
||||
public string Name => "Gelbooru";
|
||||
|
||||
public string Route => "gelbooru";
|
||||
public string FlyoutIconKey => "Gelbooru";
|
||||
public string HomePage => "https://gelbooru.com";
|
||||
|
||||
public Task<GalleryItem[]> GetRecentItemsAsync(int page)
|
||||
@ -20,5 +22,17 @@ namespace Gallery.Gelbooru
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InitDynamicResources(string family, ResourceDictionary light, ResourceDictionary dark)
|
||||
{
|
||||
var icon = new FontImageSource
|
||||
{
|
||||
FontFamily = family,
|
||||
Glyph = "\uf5d2",
|
||||
Size = 18.0
|
||||
};
|
||||
light.Add(FlyoutIconKey, icon);
|
||||
dark.Add(FlyoutIconKey, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,15 @@ using System.Threading.Tasks;
|
||||
using Gallery.Util;
|
||||
using Gallery.Util.Interface;
|
||||
using Gallery.Util.Model;
|
||||
using Xamarin.Forms;
|
||||
|
||||
namespace Gallery.Yandere
|
||||
{
|
||||
public class GallerySource : IGallerySource
|
||||
{
|
||||
public string Name => "Yande.re";
|
||||
public string Route => "yandere";
|
||||
public string FlyoutIconKey => "Yandere";
|
||||
public string HomePage => "https://yande.re";
|
||||
|
||||
public async Task<GalleryItem[]> GetRecentItemsAsync(int page)
|
||||
@ -61,5 +64,17 @@ namespace Gallery.Yandere
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InitDynamicResources(string family, ResourceDictionary light, ResourceDictionary dark)
|
||||
{
|
||||
var icon = new FontImageSource
|
||||
{
|
||||
FontFamily = family,
|
||||
Glyph = "\uf302",
|
||||
Size = 18.0
|
||||
};
|
||||
light.Add(FlyoutIconKey, icon);
|
||||
dark.Add(FlyoutIconKey, icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user