optimize: remove unnecessary bindable objects
This commit is contained in:
parent
f6dbec2fda
commit
08ad76d8de
@ -29,8 +29,8 @@
|
|||||||
<string>com.apple.share-services</string>
|
<string>com.apple.share-services</string>
|
||||||
</dict>
|
</dict>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.513</string>
|
<string>1.0.514</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>3</string>
|
<string>4</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@ -79,8 +79,8 @@
|
|||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.513</string>
|
<string>1.0.514</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>3</string>
|
<string>4</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
@ -20,6 +20,7 @@ namespace Pixiview.iOS.Renderers
|
|||||||
if (renderer is ShellSectionRenderer sr && Element is AppShell shell)
|
if (renderer is ShellSectionRenderer sr && Element is AppShell shell)
|
||||||
{
|
{
|
||||||
shell.SetNavigationBarHeight(sr.NavigationBar.Frame.Height);
|
shell.SetNavigationBarHeight(sr.NavigationBar.Frame.Height);
|
||||||
|
shell.SetStatusBarHeight(UIApplication.SharedApplication.StatusBarFrame.Height);
|
||||||
}
|
}
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,7 @@ namespace Pixiview.iOS.Renderers
|
|||||||
|
|
||||||
if (e.NewElement != null)
|
if (e.NewElement != null)
|
||||||
{
|
{
|
||||||
|
e.NewElement.BackgroundColor = Color.Default;
|
||||||
if (Control == null)
|
if (Control == null)
|
||||||
{
|
{
|
||||||
var blur = UIBlurEffect.FromStyle(UIBlurEffectStyle.SystemMaterial);
|
var blur = UIBlurEffect.FromStyle(UIBlurEffectStyle.SystemMaterial);
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using Pixiview.Resources;
|
using Pixiview.Resources;
|
||||||
using Pixiview.Utils;
|
using Pixiview.Utils;
|
||||||
using Xamarin.Essentials;
|
using Xamarin.Essentials;
|
||||||
@ -33,13 +31,9 @@ namespace Pixiview.Illust
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IEnumerable<IllustItem> DoGetIllustList(IllustItem[] data, ICommand command)
|
protected override IEnumerable<IllustItem> DoGetIllustList(IllustItem[] data)
|
||||||
{
|
{
|
||||||
return data.Select(i =>
|
return data;
|
||||||
{
|
|
||||||
i.IllustTapped = command;
|
|
||||||
return i;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IllustItem[] DoLoadIllustData(bool force)
|
protected override IllustItem[] DoLoadIllustData(bool force)
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Pixiview.Resources;
|
using Pixiview.Resources;
|
||||||
using Pixiview.UI;
|
using Pixiview.UI;
|
||||||
@ -56,12 +55,12 @@ namespace Pixiview.Illust
|
|||||||
public IllustCollection IllustCollection { get; set; }
|
public IllustCollection IllustCollection { get; set; }
|
||||||
|
|
||||||
protected virtual bool IsFavoriteVisible => true;
|
protected virtual bool IsFavoriteVisible => true;
|
||||||
protected virtual bool IsLazyload => false;
|
protected readonly Command<IllustItem> commandIllustImageTapped;
|
||||||
protected DateTime lastUpdated;
|
protected DateTime lastUpdated;
|
||||||
|
protected double topOffset;
|
||||||
|
|
||||||
private T illustData;
|
private T illustData;
|
||||||
private readonly ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Configs.MaxThreads };
|
private readonly ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Configs.MaxThreads };
|
||||||
private readonly Command<IllustItem> commandIllustImageTapped;
|
|
||||||
|
|
||||||
public IllustCollectionPage()
|
public IllustCollectionPage()
|
||||||
{
|
{
|
||||||
@ -71,6 +70,10 @@ namespace Pixiview.Illust
|
|||||||
|
|
||||||
private void IllustImageTapped(IllustItem illust)
|
private void IllustImageTapped(IllustItem illust)
|
||||||
{
|
{
|
||||||
|
if (illust == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
Start(() => OnIllustImageTapped(illust));
|
Start(() => OnIllustImageTapped(illust));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,18 +92,11 @@ namespace Pixiview.Illust
|
|||||||
|
|
||||||
if (lastUpdated != LastUpdated)
|
if (lastUpdated != LastUpdated)
|
||||||
{
|
{
|
||||||
if (IsLazyload)
|
Device.StartTimer(TimeSpan.FromMilliseconds(200), () =>
|
||||||
{
|
|
||||||
Device.StartTimer(TimeSpan.FromMilliseconds(200), () =>
|
|
||||||
{
|
|
||||||
StartLoad();
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
StartLoad();
|
StartLoad();
|
||||||
}
|
return false;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else if (IsFavoriteVisible && IllustCollection != null)
|
else if (IsFavoriteVisible && IllustCollection != null)
|
||||||
{
|
{
|
||||||
@ -133,6 +129,7 @@ namespace Pixiview.Illust
|
|||||||
{
|
{
|
||||||
base.OnSizeAllocated(width, height);
|
base.OnSizeAllocated(width, height);
|
||||||
int columns;
|
int columns;
|
||||||
|
#if __IOS__
|
||||||
var oldMargin = PanelTopMargin;
|
var oldMargin = PanelTopMargin;
|
||||||
Thickness newMargin;
|
Thickness newMargin;
|
||||||
if (StyleDefinition.IsFullscreenDevice)
|
if (StyleDefinition.IsFullscreenDevice)
|
||||||
@ -140,22 +137,26 @@ namespace Pixiview.Illust
|
|||||||
newMargin = width > height ?
|
newMargin = width > height ?
|
||||||
AppShell.HalfNavigationBarOffset :
|
AppShell.HalfNavigationBarOffset :
|
||||||
AppShell.NavigationBarOffset;
|
AppShell.NavigationBarOffset;
|
||||||
|
topOffset = width > height ?
|
||||||
|
AppShell.NavigationBarOffset.Top :
|
||||||
|
AppShell.TotalBarOffset.Top;
|
||||||
}
|
}
|
||||||
else if (isPhone)
|
else if (isPhone)
|
||||||
{
|
{
|
||||||
#if __IOS__
|
|
||||||
newMargin = width > height ?
|
newMargin = width > height ?
|
||||||
StyleDefinition.TopOffset16 :
|
StyleDefinition.TopOffset16 :
|
||||||
StyleDefinition.TopOffset32;
|
StyleDefinition.TopOffset32;
|
||||||
#elif __ANDROID__
|
topOffset = width > height ?
|
||||||
newMargin = default;
|
StyleDefinition.TopOffset32.Top :
|
||||||
#endif
|
AppShell.TotalBarOffset.Top;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// TODO ipad
|
// ipad
|
||||||
newMargin = StyleDefinition.TopOffset32;
|
newMargin = StyleDefinition.TopOffset37;
|
||||||
|
topOffset = AppShell.TotalBarOffset.Top;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (width > height)
|
if (width > height)
|
||||||
{
|
{
|
||||||
columns = isPhone ? 4 : 6;
|
columns = isPhone ? 4 : 6;
|
||||||
@ -164,11 +165,13 @@ namespace Pixiview.Illust
|
|||||||
{
|
{
|
||||||
columns = isPhone ? 2 : 4;
|
columns = isPhone ? 2 : 4;
|
||||||
}
|
}
|
||||||
|
#if __IOS__
|
||||||
if (oldMargin != newMargin)
|
if (oldMargin != newMargin)
|
||||||
{
|
{
|
||||||
PanelTopMargin = newMargin;
|
PanelTopMargin = newMargin;
|
||||||
OnPanelTopMarginChanged(oldMargin, newMargin);
|
OnPanelTopMarginChanged(oldMargin, newMargin);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (Columns != columns)
|
if (Columns != columns)
|
||||||
{
|
{
|
||||||
Columns = columns;
|
Columns = columns;
|
||||||
@ -179,7 +182,7 @@ namespace Pixiview.Illust
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
protected abstract T DoLoadIllustData(bool force);
|
protected abstract T DoLoadIllustData(bool force);
|
||||||
protected abstract IEnumerable<IllustItem> DoGetIllustList(T data, ICommand command);
|
protected abstract IEnumerable<IllustItem> DoGetIllustList(T data);
|
||||||
protected virtual void OnIllustImageTapped(IllustItem illust)
|
protected virtual void OnIllustImageTapped(IllustItem illust)
|
||||||
{
|
{
|
||||||
var page = new ViewIllustPage(illust, IsFavoriteVisible);
|
var page = new ViewIllustPage(illust, IsFavoriteVisible);
|
||||||
@ -217,9 +220,11 @@ namespace Pixiview.Illust
|
|||||||
Aspect = Aspect.AspectFill,
|
Aspect = Aspect.AspectFill,
|
||||||
GestureRecognizers =
|
GestureRecognizers =
|
||||||
{
|
{
|
||||||
new TapGestureRecognizer()
|
new TapGestureRecognizer
|
||||||
.Binding(TapGestureRecognizer.CommandProperty, nameof(IllustItem.IllustTapped))
|
{
|
||||||
.Binding(TapGestureRecognizer.CommandParameterProperty, ".")
|
Command = commandIllustImageTapped
|
||||||
|
}
|
||||||
|
.Binding(TapGestureRecognizer.CommandParameterProperty, ".")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.Binding(Image.SourceProperty, nameof(IllustItem.Image));
|
.Binding(Image.SourceProperty, nameof(IllustItem.Image));
|
||||||
@ -436,7 +441,7 @@ namespace Pixiview.Illust
|
|||||||
lastUpdated = now;
|
lastUpdated = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
var data = DoGetIllustList(illustData, commandIllustImageTapped).Where(i => i != null);
|
var data = DoGetIllustList(illustData).Where(i => i != null);
|
||||||
|
|
||||||
var collection = new IllustCollection(data);
|
var collection = new IllustCollection(data);
|
||||||
if (IsFavoriteVisible)
|
if (IsFavoriteVisible)
|
||||||
@ -493,6 +498,13 @@ namespace Pixiview.Illust
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ScrollDirection
|
||||||
|
{
|
||||||
|
Stop,
|
||||||
|
Up,
|
||||||
|
Down
|
||||||
|
}
|
||||||
|
|
||||||
public class IllustCollection : List<IllustItem>
|
public class IllustCollection : List<IllustItem>
|
||||||
{
|
{
|
||||||
private static IllustCollection empty;
|
private static IllustCollection empty;
|
||||||
@ -546,13 +558,29 @@ namespace Pixiview.Illust
|
|||||||
Anime = 2
|
Anime = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonObject(MemberSerialization.OptIn)]
|
public interface IIllustUser
|
||||||
public class IllustItem : BindableObject
|
|
||||||
{
|
{
|
||||||
//public static readonly BindableProperty TitleProperty = BindableProperty.Create(
|
string UserId { get; }
|
||||||
// nameof(Title), typeof(string), typeof(IllustItem));
|
string UserName { get; }
|
||||||
//public static readonly BindableProperty RankTitleProperty = BindableProperty.Create(
|
ImageSource ProfileImage { get; }
|
||||||
// nameof(RankTitle), typeof(string), typeof(IllustItem));
|
}
|
||||||
|
|
||||||
|
[JsonObject(MemberSerialization.OptIn)]
|
||||||
|
public class IllustItem : BindableObject, IIllustUser
|
||||||
|
{
|
||||||
|
private static IllustItem empty;
|
||||||
|
public static IllustItem Empty
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (empty == null)
|
||||||
|
{
|
||||||
|
empty = new IllustItem();
|
||||||
|
}
|
||||||
|
return empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static readonly BindableProperty ImageProperty = BindableProperty.Create(
|
public static readonly BindableProperty ImageProperty = BindableProperty.Create(
|
||||||
nameof(Image), typeof(ImageSource), typeof(IllustItem));
|
nameof(Image), typeof(ImageSource), typeof(IllustItem));
|
||||||
public static readonly BindableProperty ProfileImageProperty = BindableProperty.Create(
|
public static readonly BindableProperty ProfileImageProperty = BindableProperty.Create(
|
||||||
@ -561,20 +589,10 @@ namespace Pixiview.Illust
|
|||||||
nameof(ImageHeight), typeof(GridLength), typeof(IllustItem), GridLength.Auto);
|
nameof(ImageHeight), typeof(GridLength), typeof(IllustItem), GridLength.Auto);
|
||||||
public static readonly BindableProperty IsFavoriteProperty = BindableProperty.Create(
|
public static readonly BindableProperty IsFavoriteProperty = BindableProperty.Create(
|
||||||
nameof(IsFavorite), typeof(bool), typeof(IllustItem));
|
nameof(IsFavorite), typeof(bool), typeof(IllustItem));
|
||||||
//public static readonly BindableProperty IsPlayingProperty = BindableProperty.Create(
|
|
||||||
// nameof(IsPlaying), typeof(bool), typeof(IllustItem));
|
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
//{
|
|
||||||
// get => (string)GetValue(TitleProperty);
|
|
||||||
// set => SetValue(TitleProperty, value);
|
|
||||||
//}
|
|
||||||
public string RankTitle { get; set; }
|
public string RankTitle { get; set; }
|
||||||
//{
|
|
||||||
// get => (string)GetValue(RankTitleProperty);
|
|
||||||
// set => SetValue(RankTitleProperty, value);
|
|
||||||
//}
|
|
||||||
public ImageSource Image
|
public ImageSource Image
|
||||||
{
|
{
|
||||||
get => (ImageSource)GetValue(ImageProperty);
|
get => (ImageSource)GetValue(ImageProperty);
|
||||||
@ -596,11 +614,6 @@ namespace Pixiview.Illust
|
|||||||
set => SetValue(IsFavoriteProperty, value);
|
set => SetValue(IsFavoriteProperty, value);
|
||||||
}
|
}
|
||||||
public bool IsPlaying { get; set; }
|
public bool IsPlaying { get; set; }
|
||||||
//{
|
|
||||||
// get => (bool)GetValue(IsPlayingProperty);
|
|
||||||
// set => SetValue(IsPlayingProperty, value);
|
|
||||||
//}
|
|
||||||
public ICommand IllustTapped { get; set; }
|
|
||||||
|
|
||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
x:Class="Pixiview.OptionPage"
|
x:Class="Pixiview.OptionPage"
|
||||||
Title="{r:Text Option}">
|
Title="{r:Text Option}">
|
||||||
<TableView Intent="Settings" VerticalOptions="Start"
|
<TableView Intent="Settings" VerticalOptions="Start"
|
||||||
BackgroundColor="{DynamicResource NavColor}">
|
BackgroundColor="{DynamicResource OptionBackColor}">
|
||||||
<TableRoot>
|
<TableRoot>
|
||||||
<TableSection Title="{r:Text Proxy}">
|
<TableSection Title="{r:Text Proxy}">
|
||||||
<u:OptionSwitchCell Title="{r:Text Enabled}"
|
<u:OptionSwitchCell Title="{r:Text Enabled}"
|
||||||
|
@ -50,16 +50,13 @@ namespace Pixiview.UI
|
|||||||
|
|
||||||
public virtual void OnOrientationChanged(Orientation orientation)
|
public virtual void OnOrientationChanged(Orientation orientation)
|
||||||
{
|
{
|
||||||
|
#if __IOS__
|
||||||
var oldMargin = PageTopMargin;
|
var oldMargin = PageTopMargin;
|
||||||
Thickness newMargin;
|
Thickness newMargin;
|
||||||
switch (orientation)
|
switch (orientation)
|
||||||
{
|
{
|
||||||
case Orientation.Portrait:
|
case Orientation.Portrait:
|
||||||
#if __IOS__
|
|
||||||
newMargin = AppShell.TotalBarOffset;
|
newMargin = AppShell.TotalBarOffset;
|
||||||
#elif __ANDROID__
|
|
||||||
newMargin = default;
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
case Orientation.PortraitUpsideDown:
|
case Orientation.PortraitUpsideDown:
|
||||||
case Orientation.Unknown:
|
case Orientation.Unknown:
|
||||||
@ -72,11 +69,7 @@ namespace Pixiview.UI
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if __IOS__
|
|
||||||
newMargin = isPhone ? StyleDefinition.TopOffset32 : AppShell.TotalBarOffset;
|
newMargin = isPhone ? StyleDefinition.TopOffset32 : AppShell.TotalBarOffset;
|
||||||
#elif __ANDROID__
|
|
||||||
newMargin = default;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -85,9 +78,37 @@ namespace Pixiview.UI
|
|||||||
PageTopMargin = newMargin;
|
PageTopMargin = newMargin;
|
||||||
OnPageTopMarginChanged(oldMargin, newMargin);
|
OnPageTopMarginChanged(oldMargin, newMargin);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
OrientationChanged?.Invoke(this, new OrientationEventArgs { CurrentOrientation = orientation });
|
OrientationChanged?.Invoke(this, new OrientationEventArgs { CurrentOrientation = orientation });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __IOS__
|
||||||
|
protected override void OnSizeAllocated(double width, double height)
|
||||||
|
{
|
||||||
|
base.OnSizeAllocated(width, height);
|
||||||
|
|
||||||
|
if (PageTopMargin == default)
|
||||||
|
{
|
||||||
|
if (StyleDefinition.IsFullscreenDevice)
|
||||||
|
{
|
||||||
|
PageTopMargin = width > height ?
|
||||||
|
AppShell.NavigationBarOffset :
|
||||||
|
AppShell.TotalBarOffset;
|
||||||
|
}
|
||||||
|
else if (isPhone)
|
||||||
|
{
|
||||||
|
PageTopMargin = width > height ?
|
||||||
|
StyleDefinition.TopOffset32 :
|
||||||
|
AppShell.TotalBarOffset;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PageTopMargin = AppShell.TotalBarOffset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public virtual void OnPageTopMarginChanged(Thickness old, Thickness @new)
|
public virtual void OnPageTopMarginChanged(Thickness old, Thickness @new)
|
||||||
{
|
{
|
||||||
PageTopMarginChanged?.Invoke(this, new ThicknessEventArgs
|
PageTopMarginChanged?.Invoke(this, new ThicknessEventArgs
|
||||||
|
@ -10,6 +10,7 @@ namespace Pixiview.UI
|
|||||||
public static readonly Thickness ScreenBottomPadding;
|
public static readonly Thickness ScreenBottomPadding;
|
||||||
public static readonly Thickness TopOffset16 = new Thickness(0, 16, 0, 0);
|
public static readonly Thickness TopOffset16 = new Thickness(0, 16, 0, 0);
|
||||||
public static readonly Thickness TopOffset32 = new Thickness(0, 32, 0, 0);
|
public static readonly Thickness TopOffset32 = new Thickness(0, 32, 0, 0);
|
||||||
|
public static readonly Thickness TopOffset37 = new Thickness(0, 37, 0, 0);
|
||||||
public static readonly Color ColorLightShadow = Color.FromRgba(0, 0, 0, 0x20);
|
public static readonly Color ColorLightShadow = Color.FromRgba(0, 0, 0, 0x20);
|
||||||
public static readonly Color ColorDeepShadow = Color.FromRgba(0, 0, 0, 0x50);
|
public static readonly Color ColorDeepShadow = Color.FromRgba(0, 0, 0, 0x50);
|
||||||
public static readonly Color ColorRedBackground = Color.FromRgb(0xfd, 0x43, 0x63);
|
public static readonly Color ColorRedBackground = Color.FromRgb(0xfd, 0x43, 0x63);
|
||||||
@ -42,13 +43,15 @@ namespace Pixiview.UI
|
|||||||
public const string IconFavorite = "\uf02e";
|
public const string IconFavorite = "\uf02e";
|
||||||
public const string IconShare = "\uf35d";
|
public const string IconShare = "\uf35d";
|
||||||
public const string IconCaretDown = "\uf0d7";
|
public const string IconCaretDown = "\uf0d7";
|
||||||
public const string IconCaretUp = "\uf0d8";
|
//public const string IconCaretUp = "\uf0d8";
|
||||||
public const string IconCircleCheck = "\uf058";
|
public const string IconCircleCheck = "\uf058";
|
||||||
public const string IconPlay = "\uf04b";
|
public const string IconPlay = "\uf04b";
|
||||||
|
public const string IconMore = "\uf142";
|
||||||
|
|
||||||
static StyleDefinition()
|
static StyleDefinition()
|
||||||
{
|
{
|
||||||
if (IsFullscreenDevice)
|
_ = IsFullscreenDevice;
|
||||||
|
if (_isBottomPadding)
|
||||||
{
|
{
|
||||||
if (DeviceInfo.Idiom == DeviceIdiom.Phone)
|
if (DeviceInfo.Idiom == DeviceIdiom.Phone)
|
||||||
{
|
{
|
||||||
@ -61,6 +64,7 @@ namespace Pixiview.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool _isBottomPadding;
|
||||||
private static bool? _isFullscreenDevice;
|
private static bool? _isFullscreenDevice;
|
||||||
public static bool IsFullscreenDevice
|
public static bool IsFullscreenDevice
|
||||||
{
|
{
|
||||||
@ -78,6 +82,7 @@ namespace Pixiview.UI
|
|||||||
{
|
{
|
||||||
// iPhone X
|
// iPhone X
|
||||||
_isFullscreenDevice = true;
|
_isFullscreenDevice = true;
|
||||||
|
_isBottomPadding = true;
|
||||||
}
|
}
|
||||||
else if (model.StartsWith("iPhone"))
|
else if (model.StartsWith("iPhone"))
|
||||||
{
|
{
|
||||||
@ -85,7 +90,9 @@ namespace Pixiview.UI
|
|||||||
if (vs.Length == 2 && int.TryParse(vs[0], out int main) && int.TryParse(vs[1], out int sub))
|
if (vs.Length == 2 && int.TryParse(vs[0], out int main) && int.TryParse(vs[1], out int sub))
|
||||||
{
|
{
|
||||||
// iPhone X/XS/XR or iPhone 11
|
// iPhone X/XS/XR or iPhone 11
|
||||||
_isFullscreenDevice = (main == 10 && sub >= 6) || (main > 10);
|
var flag = (main == 10 && sub >= 6) || (main > 10);
|
||||||
|
_isFullscreenDevice = flag;
|
||||||
|
_isBottomPadding = flag;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -95,18 +102,21 @@ namespace Pixiview.UI
|
|||||||
else if (model.StartsWith("iPad8,"))
|
else if (model.StartsWith("iPad8,"))
|
||||||
{
|
{
|
||||||
// iPad 11-inch or 12.9-inch (3rd+)
|
// iPad 11-inch or 12.9-inch (3rd+)
|
||||||
_isFullscreenDevice = true;
|
//_isFullscreenDevice = true;
|
||||||
|
_isBottomPadding = true;
|
||||||
}
|
}
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// iPad or Simulator
|
// iPad or Simulator
|
||||||
var name = DeviceInfo.Name;
|
var name = DeviceInfo.Name;
|
||||||
_isFullscreenDevice = name.StartsWith("iPhone X")
|
var flag = name.StartsWith("iPhone X")
|
||||||
|| name.StartsWith("iPhone 11")
|
|| name.StartsWith("iPhone 11")
|
||||||
|| name.StartsWith("iPad Pro (11-inch)")
|
|| name.StartsWith("iPad Pro (11-inch)")
|
||||||
|| name.StartsWith("iPad Pro (12.9-inch) (3rd generation)")
|
|| name.StartsWith("iPad Pro (12.9-inch) (3rd generation)")
|
||||||
|| name.StartsWith("iPad Pro (12.9-inch) (4th generation)");
|
|| name.StartsWith("iPad Pro (12.9-inch) (4th generation)");
|
||||||
|
_isFullscreenDevice = flag;
|
||||||
|
_isBottomPadding = flag;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -117,6 +127,7 @@ namespace Pixiview.UI
|
|||||||
#else
|
#else
|
||||||
// TODO:
|
// TODO:
|
||||||
_isFullscreenDevice = false;
|
_isFullscreenDevice = false;
|
||||||
|
_isBottomPadding = false;
|
||||||
#endif
|
#endif
|
||||||
if (_isFullscreenDevice == null)
|
if (_isFullscreenDevice == null)
|
||||||
{
|
{
|
||||||
|
@ -34,8 +34,9 @@ namespace Pixiview.UI.Theme
|
|||||||
Add(SubTextColor, Color.LightGray);
|
Add(SubTextColor, Color.LightGray);
|
||||||
Add(CardBackgroundColor, Color.FromRgb(0x33, 0x33, 0x33));
|
Add(CardBackgroundColor, Color.FromRgb(0x33, 0x33, 0x33));
|
||||||
Add(MaskColor, Color.FromRgba(0xff, 0xff, 0xff, 0x50));
|
Add(MaskColor, Color.FromRgba(0xff, 0xff, 0xff, 0x50));
|
||||||
Add(NavColor, Color.Black);
|
Add(NavColor, Color.FromRgb(0x11, 0x11, 0x11));
|
||||||
Add(NavSelectedColor, Color.FromRgb(0x22, 0x22, 0x22));
|
Add(NavSelectedColor, Color.FromRgb(0x22, 0x22, 0x22));
|
||||||
|
Add(OptionBackColor, Color.Black);
|
||||||
Add(OptionTintColor, Color.FromRgb(0x11, 0x11, 0x11));
|
Add(OptionTintColor, Color.FromRgb(0x11, 0x11, 0x11));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ namespace Pixiview.UI.Theme
|
|||||||
Add(MaskColor, Color.FromRgba(0, 0, 0, 0x50));
|
Add(MaskColor, Color.FromRgba(0, 0, 0, 0x50));
|
||||||
Add(NavColor, Color.FromRgb(0xf0, 0xf0, 0xf0));
|
Add(NavColor, Color.FromRgb(0xf0, 0xf0, 0xf0));
|
||||||
Add(NavSelectedColor, Color.LightGray);
|
Add(NavSelectedColor, Color.LightGray);
|
||||||
|
Add(OptionBackColor, Color.FromRgb(0xf0, 0xf0, 0xf0));
|
||||||
Add(OptionTintColor, Color.White);
|
Add(OptionTintColor, Color.White);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,9 @@ namespace Pixiview.UI.Theme
|
|||||||
public const string FontIconOption = nameof(FontIconOption);
|
public const string FontIconOption = nameof(FontIconOption);
|
||||||
public const string FontIconFavorite = nameof(FontIconFavorite);
|
public const string FontIconFavorite = nameof(FontIconFavorite);
|
||||||
public const string FontIconShare = nameof(FontIconShare);
|
public const string FontIconShare = nameof(FontIconShare);
|
||||||
|
public const string FontIconMore = nameof(FontIconMore);
|
||||||
public const string IconCircleCheck = nameof(IconCircleCheck);
|
public const string IconCircleCheck = nameof(IconCircleCheck);
|
||||||
|
public const string IconCaretDown = nameof(IconCaretDown);
|
||||||
|
|
||||||
public const string StatusBarStyle = nameof(StatusBarStyle);
|
public const string StatusBarStyle = nameof(StatusBarStyle);
|
||||||
public const string WindowColor = nameof(WindowColor);
|
public const string WindowColor = nameof(WindowColor);
|
||||||
@ -24,6 +26,7 @@ namespace Pixiview.UI.Theme
|
|||||||
public const string MaskColor = nameof(MaskColor);
|
public const string MaskColor = nameof(MaskColor);
|
||||||
public const string NavColor = nameof(NavColor);
|
public const string NavColor = nameof(NavColor);
|
||||||
public const string NavSelectedColor = nameof(NavSelectedColor);
|
public const string NavSelectedColor = nameof(NavSelectedColor);
|
||||||
|
public const string OptionBackColor = nameof(OptionBackColor);
|
||||||
public const string OptionTintColor = nameof(OptionTintColor);
|
public const string OptionTintColor = nameof(OptionTintColor);
|
||||||
|
|
||||||
public const string IconLightFontFamily = nameof(IconLightFontFamily);
|
public const string IconLightFontFamily = nameof(IconLightFontFamily);
|
||||||
@ -53,8 +56,10 @@ namespace Pixiview.UI.Theme
|
|||||||
Add(FontIconOption, GetSolidIcon(StyleDefinition.IconOption, solidFontFamily));
|
Add(FontIconOption, GetSolidIcon(StyleDefinition.IconOption, solidFontFamily));
|
||||||
Add(FontIconFavorite, GetSolidIcon(StyleDefinition.IconFavorite, solidFontFamily));
|
Add(FontIconFavorite, GetSolidIcon(StyleDefinition.IconFavorite, solidFontFamily));
|
||||||
Add(FontIconShare, GetSolidIcon(StyleDefinition.IconShare, solidFontFamily));
|
Add(FontIconShare, GetSolidIcon(StyleDefinition.IconShare, solidFontFamily));
|
||||||
|
Add(FontIconMore, GetSolidIcon(StyleDefinition.IconMore, regularFontFamily));
|
||||||
|
|
||||||
Add(IconCircleCheck, StyleDefinition.IconCircleCheck);
|
Add(IconCircleCheck, StyleDefinition.IconCircleCheck);
|
||||||
|
Add(IconCaretDown, StyleDefinition.IconCaretDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
private FontImageSource GetSolidIcon(string icon, string family, Color color = default)
|
private FontImageSource GetSolidIcon(string icon, string family, Color color = default)
|
||||||
|
@ -50,6 +50,10 @@ namespace Pixiview.Utils
|
|||||||
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
|
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
|
||||||
{
|
{
|
||||||
Droid.MainActivity.Main.SetStatusBarColor(color.ToAndroid());
|
Droid.MainActivity.Main.SetStatusBarColor(color.ToAndroid());
|
||||||
|
Droid.MainActivity.Main.Window.DecorView.SystemUiVisibility =
|
||||||
|
App.CurrentTheme == Xamarin.Essentials.AppTheme.Dark ?
|
||||||
|
Android.Views.StatusBarVisibility.Visible :
|
||||||
|
(Android.Views.StatusBarVisibility)Android.Views.SystemUiFlags.LightStatusBar;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,12 @@ namespace Pixiview.Utils
|
|||||||
Grid.SetColumn(view, column);
|
Grid.SetColumn(view, column);
|
||||||
return view;
|
return view;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static T GridColumnSpan<T>(this T view, int columnSpan) where T : BindableObject
|
||||||
|
{
|
||||||
|
Grid.SetColumnSpan(view, columnSpan);
|
||||||
|
return view;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Screen
|
public static class Screen
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Pixiview.Illust;
|
using Pixiview.Illust;
|
||||||
|
using Xamarin.Forms;
|
||||||
|
|
||||||
namespace Pixiview.Utils
|
namespace Pixiview.Utils
|
||||||
{
|
{
|
||||||
@ -44,7 +45,7 @@ namespace Pixiview.Utils
|
|||||||
public string x540;
|
public string x540;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IllustItem ConvertToItem()
|
public IllustItem ConvertToItem(ImageSource image = null)
|
||||||
{
|
{
|
||||||
return new IllustItem
|
return new IllustItem
|
||||||
{
|
{
|
||||||
@ -52,6 +53,7 @@ namespace Pixiview.Utils
|
|||||||
Title = illustTitle,
|
Title = illustTitle,
|
||||||
RankTitle = illustTitle,
|
RankTitle = illustTitle,
|
||||||
IllustType = (IllustType)illustType,
|
IllustType = (IllustType)illustType,
|
||||||
|
Image = image,
|
||||||
ImageUrl = urls?.x360 ?? url,
|
ImageUrl = urls?.x360 ?? url,
|
||||||
IsRestrict = xRestrict == 1,
|
IsRestrict = xRestrict == 1,
|
||||||
ProfileUrl = profileImageUrl,
|
ProfileUrl = profileImageUrl,
|
||||||
|
@ -16,7 +16,7 @@ namespace Pixiview.Utils
|
|||||||
public static readonly string PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
public static readonly string PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||||
#if __IOS__
|
#if __IOS__
|
||||||
public static readonly string CacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
|
public static readonly string CacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
|
||||||
#elif __ANDROID__
|
#else
|
||||||
public static readonly string CacheFolder = FileSystem.CacheDirectory;
|
public static readonly string CacheFolder = FileSystem.CacheDirectory;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ namespace Pixiview.Utils
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
App.DebugError("read", $"file not found: {file}");
|
//App.DebugError("read", $"file not found: {file}");
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@ -434,16 +434,18 @@ namespace Pixiview.Utils
|
|||||||
//public const string AcceptEncoding = "gzip, deflate";
|
//public const string AcceptEncoding = "gzip, deflate";
|
||||||
public const string AcceptLanguage = "zh-cn";
|
public const string AcceptLanguage = "zh-cn";
|
||||||
|
|
||||||
//public const string UserId = "53887721";
|
#if !TEST
|
||||||
//public const string Cookie =
|
public const string UserId = "53887721";
|
||||||
// "PHPSESSID=5sn8n049j5c18l0tlj91qrjhesgddhjv; " +
|
public const string Cookie =
|
||||||
// "a_type=0; b_type=1; c_type=29; d_type=2; " +
|
"PHPSESSID=5sn8n049j5c18l0tlj91qrjhesgddhjv; " +
|
||||||
// "p_ab_d_id=1021624041; p_ab_id=2; p_ab_id_2=0; " +
|
"a_type=0; b_type=1; c_type=29; d_type=2; " +
|
||||||
// "privacy_policy_agreement=2; " +
|
"p_ab_d_id=1021624041; p_ab_id=2; p_ab_id_2=0; " +
|
||||||
// "login_ever=yes; " +
|
"privacy_policy_agreement=2; " +
|
||||||
// "__cfduid=d84153bf70ae67315a8bc297299d39eb61588856027; " +
|
"login_ever=yes; " +
|
||||||
// "first_visit_datetime_pc=2020-05-07+21%3A53%3A47; " +
|
"__cfduid=d84153bf70ae67315a8bc297299d39eb61588856027; " +
|
||||||
// "yuid_b=MYkIJXc";
|
"first_visit_datetime_pc=2020-05-07+21%3A53%3A47; " +
|
||||||
|
"yuid_b=MYkIJXc";
|
||||||
|
#else
|
||||||
public const string UserId = "2603358";
|
public const string UserId = "2603358";
|
||||||
public const string Cookie =
|
public const string Cookie =
|
||||||
"PHPSESSID=2603358_VHyGPeRaz7LpeoFkRsHvjXIpApCMb56a; " +
|
"PHPSESSID=2603358_VHyGPeRaz7LpeoFkRsHvjXIpApCMb56a; " +
|
||||||
@ -454,6 +456,7 @@ namespace Pixiview.Utils
|
|||||||
"__cfduid=d9fa2d4d1ddd30db85ebb519f9855d2561587806747; " +
|
"__cfduid=d9fa2d4d1ddd30db85ebb519f9855d2561587806747; " +
|
||||||
"first_visit_datetime_pc=2019-10-29+22%3A05%3A30; " +
|
"first_visit_datetime_pc=2019-10-29+22%3A05%3A30; " +
|
||||||
"yuid_b=NgcXQWQ";
|
"yuid_b=NgcXQWQ";
|
||||||
|
#endif
|
||||||
|
|
||||||
public static string GetThumbnailUrl(string url)
|
public static string GetThumbnailUrl(string url)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user