feature: r-18 filter
This commit is contained in:
parent
90816bc57e
commit
f83f533f5f
@ -26,6 +26,7 @@ namespace Pixiview
|
||||
|
||||
private void InitPreferences()
|
||||
{
|
||||
Configs.IsOnR18 = Preferences.Get(Configs.IsOnR18Key, false);
|
||||
var isProxied = Preferences.Get(Configs.IsProxiedKey, false);
|
||||
if (isProxied)
|
||||
{
|
||||
|
@ -17,10 +17,6 @@ namespace Pixiview.Illust
|
||||
|
||||
protected override bool IsFavoriteVisible => false;
|
||||
|
||||
public override void OnUnload()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void OnAppearing()
|
||||
{
|
||||
//base.OnAppearing();
|
||||
|
@ -443,7 +443,8 @@ namespace Pixiview.Illust
|
||||
lastUpdated = now;
|
||||
}
|
||||
|
||||
var data = DoGetIllustList(illustData).Where(i => i != null);
|
||||
var r18 = Configs.IsOnR18;
|
||||
var data = DoGetIllustList(illustData).Where(i => i != null && (r18 || !i.IsRestrict));
|
||||
|
||||
var collection = new IllustCollection(data);
|
||||
if (IsFavoriteVisible)
|
||||
|
@ -14,7 +14,7 @@
|
||||
<Grid>
|
||||
<ScrollView HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never">
|
||||
<StackLayout>
|
||||
<u:FlowLayout ItemsSource="{Binding Users}"
|
||||
<u:FlowLayout ItemsSource="{Binding Users}" IsVisible="{Binding UserRecommendsVisible}"
|
||||
HorizontalOptions="Fill" Column="{Binding UserColumns}"
|
||||
Margin="16" RowSpacing="16"
|
||||
ItemTemplate="{StaticResource userCardView}"/>
|
||||
|
@ -15,6 +15,8 @@ namespace Pixiview.Illust
|
||||
nameof(Users), typeof(List<IllustUserItem>), typeof(RecommendsPage));
|
||||
public static readonly BindableProperty UserColumnsProperty = BindableProperty.Create(
|
||||
nameof(UserColumns), typeof(int), typeof(RecommendsPage), 1);
|
||||
public static readonly BindableProperty UserRecommendsVisibleProperty = BindableProperty.Create(
|
||||
nameof(UserRecommendsVisible), typeof(bool), typeof(RecommendsPage));
|
||||
|
||||
public List<IllustUserItem> Users
|
||||
{
|
||||
@ -26,6 +28,11 @@ namespace Pixiview.Illust
|
||||
get => (int)GetValue(UserColumnsProperty);
|
||||
set => SetValue(UserColumnsProperty, value);
|
||||
}
|
||||
public bool UserRecommendsVisible
|
||||
{
|
||||
get => (bool)GetValue(UserRecommendsVisibleProperty);
|
||||
set => SetValue(UserRecommendsVisibleProperty, value);
|
||||
}
|
||||
|
||||
private readonly Command<IllustUserItem> commandUserTapped;
|
||||
|
||||
@ -200,6 +207,7 @@ namespace Pixiview.Illust
|
||||
|
||||
private void DoLoadUserRecommendsData(IllustData data)
|
||||
{
|
||||
var r18 = Configs.IsOnR18;
|
||||
var defaultImage = StyleDefinition.DownloadBackground;
|
||||
var users = data.body.page.recommendUser.Select(u =>
|
||||
{
|
||||
@ -229,6 +237,15 @@ namespace Pixiview.Illust
|
||||
item3 = data.body.thumbnails.illust.FirstOrDefault(l => l.illustId == id)?.ConvertToItem(defaultImage);
|
||||
}
|
||||
}
|
||||
if (!r18)
|
||||
{
|
||||
if (item1?.IsRestrict == true ||
|
||||
item2?.IsRestrict == true ||
|
||||
item3?.IsRestrict == true)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return new IllustUserItem
|
||||
{
|
||||
UserId = usrId,
|
||||
@ -238,9 +255,10 @@ namespace Pixiview.Illust
|
||||
Image2Item = item2,
|
||||
Image3Item = item3
|
||||
};
|
||||
});
|
||||
}).Where(u => u != null);
|
||||
|
||||
var list = new List<IllustUserItem>(users);
|
||||
UserRecommendsVisible = list.Count > 0;
|
||||
Users = list;
|
||||
Illusts = IllustCollection;
|
||||
|
||||
|
@ -8,6 +8,10 @@
|
||||
<TableView Intent="Settings" VerticalOptions="Start"
|
||||
BackgroundColor="{DynamicResource OptionBackColor}">
|
||||
<TableRoot>
|
||||
<TableSection Title="{r:Text Illusts}">
|
||||
<u:OptionSwitchCell Title="{r:Text R18}"
|
||||
IsToggled="{Binding IsOnR18, Mode=TwoWay}"/>
|
||||
</TableSection>
|
||||
<TableSection Title="{r:Text Proxy}">
|
||||
<u:OptionSwitchCell Title="{r:Text Enabled}"
|
||||
IsToggled="{Binding IsProxied, Mode=TwoWay}"/>
|
||||
|
@ -7,6 +7,8 @@ namespace Pixiview
|
||||
{
|
||||
public partial class OptionPage : AdaptedPage
|
||||
{
|
||||
public static readonly BindableProperty IsOnR18Property = BindableProperty.Create(
|
||||
nameof(IsOnR18), typeof(bool), typeof(OptionPage));
|
||||
public static readonly BindableProperty IsProxiedProperty = BindableProperty.Create(
|
||||
nameof(IsProxied), typeof(bool), typeof(OptionPage));
|
||||
public static readonly BindableProperty HostProperty = BindableProperty.Create(
|
||||
@ -14,6 +16,11 @@ namespace Pixiview
|
||||
public static readonly BindableProperty PortProperty = BindableProperty.Create(
|
||||
nameof(Port), typeof(string), typeof(OptionPage));
|
||||
|
||||
public bool IsOnR18
|
||||
{
|
||||
get => (bool)GetValue(IsOnR18Property);
|
||||
set => SetValue(IsOnR18Property, value);
|
||||
}
|
||||
public bool IsProxied
|
||||
{
|
||||
get => (bool)GetValue(IsProxiedProperty);
|
||||
@ -40,6 +47,7 @@ namespace Pixiview
|
||||
{
|
||||
base.OnAppearing();
|
||||
|
||||
IsOnR18 = Preferences.Get(Configs.IsOnR18Key, false);
|
||||
IsProxied = Preferences.Get(Configs.IsProxiedKey, false);
|
||||
Host = Preferences.Get(Configs.HostKey, string.Empty);
|
||||
int pt = Preferences.Get(Configs.PortKey, 0);
|
||||
@ -53,9 +61,14 @@ namespace Pixiview
|
||||
{
|
||||
base.OnDisappearing();
|
||||
|
||||
var r18 = IsOnR18;
|
||||
var proxied = IsProxied;
|
||||
var h = Host?.Trim();
|
||||
|
||||
Preferences.Set(Configs.IsOnR18Key, r18);
|
||||
Configs.IsOnR18 = r18;
|
||||
App.DebugPrint($"r-18 filter: {r18}");
|
||||
|
||||
Preferences.Set(Configs.IsProxiedKey, proxied);
|
||||
Preferences.Set(Configs.HostKey, h);
|
||||
var p = Port;
|
||||
|
@ -5,6 +5,7 @@
|
||||
<Cancel>取消</Cancel>
|
||||
<Yes>是</Yes>
|
||||
<No>否</No>
|
||||
<Illusts>插画</Illusts>
|
||||
<Proxy>代理</Proxy>
|
||||
<Detail>详细</Detail>
|
||||
<Enabled>启用</Enabled>
|
||||
|
@ -442,7 +442,8 @@ namespace Pixiview.Utils
|
||||
|
||||
public static class Configs
|
||||
{
|
||||
public const string IsProxiedKey = "isProxied";
|
||||
public const string IsOnR18Key = "is_on_r18";
|
||||
public const string IsProxiedKey = "is_proxied";
|
||||
public const string HostKey = "host";
|
||||
public const string PortKey = "port";
|
||||
public const string QueryModeKey = "query_mode";
|
||||
@ -455,6 +456,7 @@ namespace Pixiview.Utils
|
||||
public const string RefererIllustRanking = "https://www.pixiv.net/ranking.php?{0}";
|
||||
public const string RefererIllustUser = "https://www.pixiv.net/users/{0}/illustrations";
|
||||
|
||||
public static bool IsOnR18;
|
||||
public static WebProxy Proxy;
|
||||
private static string Prefix => Proxy == null ?
|
||||
"https://hk.tsanie.us/reverse/" :
|
||||
|
Loading…
x
Reference in New Issue
Block a user