* Pixiview.iOS/Renderers/AdaptedPageRenderer.cs: fixed: status bar
hidden issue when startup with landscape * Pixiview/MainPage.xaml: * Pixiview/MainPage.xaml.cs: feature: add illust command * Pixiview/UI/CardView.cs: feature: resize height when measure card view. * Pixiview/Utils/Stores.cs: fixed: update working dirs
This commit is contained in:
parent
1bbfdb6477
commit
d40dfccc07
@ -54,12 +54,12 @@ namespace Pixiview.iOS.Renderers
|
|||||||
{
|
{
|
||||||
if (style == UIStatusBarStyle.BlackOpaque)
|
if (style == UIStatusBarStyle.BlackOpaque)
|
||||||
{
|
{
|
||||||
UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Fade);
|
UIApplication.SharedApplication.SetStatusBarHidden(true, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UIApplication.SharedApplication.SetStatusBarStyle(style, true);
|
UIApplication.SharedApplication.SetStatusBarStyle(style, true);
|
||||||
UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Fade);
|
UIApplication.SharedApplication.SetStatusBarHidden(false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetNeedsStatusBarAppearanceUpdate();
|
SetNeedsStatusBarAppearanceUpdate();
|
||||||
@ -93,6 +93,14 @@ namespace Pixiview.iOS.Renderers
|
|||||||
if (lastOrientation != current)
|
if (lastOrientation != current)
|
||||||
{
|
{
|
||||||
lastOrientation = current;
|
lastOrientation = current;
|
||||||
|
if (current == UIDeviceOrientation.Portrait && UIApplication.SharedApplication.StatusBarHidden)
|
||||||
|
{
|
||||||
|
var style = ConvertStyle(StatusBar.GetStatusBarStyle(Element));
|
||||||
|
if (style != UIStatusBarStyle.BlackOpaque)
|
||||||
|
{
|
||||||
|
UIApplication.SharedApplication.SetStatusBarHidden(false, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (Element is AdaptedPage page)
|
if (Element is AdaptedPage page)
|
||||||
{
|
{
|
||||||
page.OnOrientationChanged((Orientation)lastOrientation);
|
page.OnOrientationChanged((Orientation)lastOrientation);
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
|
||||||
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
xmlns:d="http://xamarin.com/schemas/2014/forms/design"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:p="clr-namespace:Pixiview"
|
||||||
xmlns:u="clr-namespace:Pixiview.UI"
|
xmlns:u="clr-namespace:Pixiview.UI"
|
||||||
xmlns:util="clr-namespace:Pixiview.Utils"
|
xmlns:util="clr-namespace:Pixiview.Utils"
|
||||||
xmlns:r="clr-namespace:Pixiview.Resources"
|
xmlns:r="clr-namespace:Pixiview.Resources"
|
||||||
@ -13,8 +14,7 @@
|
|||||||
util:StatusBar.StatusBarStyle="{DynamicResource StatusBarStyle}">
|
util:StatusBar.StatusBarStyle="{DynamicResource StatusBarStyle}">
|
||||||
<NavigationPage.TitleView>
|
<NavigationPage.TitleView>
|
||||||
<u:NavigationTitle Title="{r:Text Follow}"
|
<u:NavigationTitle Title="{r:Text Follow}"
|
||||||
IsLeftButtonVisible="True"
|
IsRightButtonVisible="True"
|
||||||
LeftButtonClicked="NavigationTitle_LeftButtonClicked"
|
|
||||||
RightButtonClicked="NavigationTitle_RightButtonClicked"/>
|
RightButtonClicked="NavigationTitle_RightButtonClicked"/>
|
||||||
</NavigationPage.TitleView>
|
</NavigationPage.TitleView>
|
||||||
<Grid>
|
<Grid>
|
||||||
@ -23,14 +23,14 @@
|
|||||||
HorizontalOptions="Fill" Column="{Binding Columns}"
|
HorizontalOptions="Fill" Column="{Binding Columns}"
|
||||||
Margin="16" RowSpacing="16" ColumnSpacing="16">
|
Margin="16" RowSpacing="16" ColumnSpacing="16">
|
||||||
<u:FlowLayout.ItemTemplate>
|
<u:FlowLayout.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate x:DataType="p:IllustItem">
|
||||||
<u:CardView Padding="0" Margin="0" CornerRadius="10"
|
<u:CardView Padding="0" Margin="0" CornerRadius="10"
|
||||||
ShadowColor="#20000000"
|
ShadowColor="#20000000"
|
||||||
ShadowOffset="2, 2"
|
ShadowOffset="2, 2"
|
||||||
BackgroundColor="{DynamicResource SubColor}">
|
BackgroundColor="{DynamicResource SubColor}">
|
||||||
<Grid HorizontalOptions="Fill">
|
<Grid HorizontalOptions="Fill">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="{Binding ImageHeight}"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
<RowDefinition Height="Auto"/>
|
<RowDefinition Height="Auto"/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
@ -39,7 +39,11 @@
|
|||||||
CornerMasks="Top"
|
CornerMasks="Top"
|
||||||
Source="{Binding Image}"
|
Source="{Binding Image}"
|
||||||
HorizontalOptions="Fill"
|
HorizontalOptions="Fill"
|
||||||
Aspect="AspectFit"/>
|
Aspect="AspectFit">
|
||||||
|
<u:RoundImage.GestureRecognizers>
|
||||||
|
<TapGestureRecognizer Command="{Binding IllustTapped}" CommandParameter="{Binding .}"/>
|
||||||
|
</u:RoundImage.GestureRecognizers>
|
||||||
|
</u:RoundImage>
|
||||||
<u:RoundLabel Text="R-18" BackgroundColor="#fd4363" Margin="6, 6, 0, 0"
|
<u:RoundLabel Text="R-18" BackgroundColor="#fd4363" Margin="6, 6, 0, 0"
|
||||||
Padding="6, 2" CornerRadius="4"
|
Padding="6, 2" CornerRadius="4"
|
||||||
HorizontalOptions="Start" VerticalOptions="Start"
|
HorizontalOptions="Start" VerticalOptions="Start"
|
||||||
|
@ -4,6 +4,7 @@ using System.Collections.ObjectModel;
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Input;
|
||||||
using Pixiview.UI;
|
using Pixiview.UI;
|
||||||
using Pixiview.Utils;
|
using Pixiview.Utils;
|
||||||
using Xamarin.Essentials;
|
using Xamarin.Essentials;
|
||||||
@ -16,6 +17,8 @@ namespace Pixiview
|
|||||||
[DesignTimeVisible(false)]
|
[DesignTimeVisible(false)]
|
||||||
public partial class MainPage : AdaptedPage
|
public partial class MainPage : AdaptedPage
|
||||||
{
|
{
|
||||||
|
#region - Properties -
|
||||||
|
|
||||||
public static readonly BindableProperty IllustsProperty = BindableProperty.Create(
|
public static readonly BindableProperty IllustsProperty = BindableProperty.Create(
|
||||||
nameof(Illusts), typeof(IllustCollection), typeof(MainPage));
|
nameof(Illusts), typeof(IllustCollection), typeof(MainPage));
|
||||||
public static readonly BindableProperty ColumnsProperty = BindableProperty.Create(
|
public static readonly BindableProperty ColumnsProperty = BindableProperty.Create(
|
||||||
@ -51,7 +54,10 @@ namespace Pixiview
|
|||||||
set => SetValue(LoadingProperty, value);
|
set => SetValue(LoadingProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
private readonly ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Configs.MaxThreads };
|
private readonly ParallelOptions parallelOptions = new ParallelOptions { MaxDegreeOfParallelism = Configs.MaxThreads };
|
||||||
|
private readonly Command<IllustItem> commandIllustImageTapped;
|
||||||
|
|
||||||
private IllustData illustData;
|
private IllustData illustData;
|
||||||
private bool loaded;
|
private bool loaded;
|
||||||
@ -61,8 +67,11 @@ namespace Pixiview
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
BindingContext = this;
|
BindingContext = this;
|
||||||
|
commandIllustImageTapped = new Command<IllustItem>(OnIllustImageTapped);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region - Overrides -
|
||||||
|
|
||||||
public override void OnLoad()
|
public override void OnLoad()
|
||||||
{
|
{
|
||||||
App.DebugPrint($"folder: {Stores.PersonalFolder}");
|
App.DebugPrint($"folder: {Stores.PersonalFolder}");
|
||||||
@ -83,6 +92,8 @@ namespace Pixiview
|
|||||||
Connectivity.ConnectivityChanged -= Connectivity_ConnectivityChanged;
|
Connectivity.ConnectivityChanged -= Connectivity_ConnectivityChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
private void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
|
private void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.NetworkAccess == NetworkAccess.Internet || e.NetworkAccess == NetworkAccess.ConstrainedInternet)
|
if (e.NetworkAccess == NetworkAccess.Internet || e.NetworkAccess == NetworkAccess.ConstrainedInternet)
|
||||||
@ -91,6 +102,8 @@ namespace Pixiview
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region - Illust Tasks -
|
||||||
|
|
||||||
async void DoLoadIllusts()
|
async void DoLoadIllusts()
|
||||||
{
|
{
|
||||||
illustData = await Stores.LoadIllustData();
|
illustData = await Stores.LoadIllustData();
|
||||||
@ -109,14 +122,18 @@ namespace Pixiview
|
|||||||
}
|
}
|
||||||
return new IllustItem
|
return new IllustItem
|
||||||
{
|
{
|
||||||
|
Id = illust.illustId,
|
||||||
ImageUrl = illust.urls.x360 ?? illust.url,
|
ImageUrl = illust.urls.x360 ?? illust.url,
|
||||||
Title = illust.illustTitle,
|
Title = illust.illustTitle,
|
||||||
IsRestrict = illust.xRestrict == 1,
|
IsRestrict = illust.xRestrict == 1,
|
||||||
ProfileUrl = illust.profileImageUrl,
|
ProfileUrl = illust.profileImageUrl,
|
||||||
|
UserId = illust.userId,
|
||||||
UserName = illust.userName,
|
UserName = illust.userName,
|
||||||
Width = illust.width,
|
Width = illust.width,
|
||||||
Height = illust.height,
|
Height = illust.height,
|
||||||
PageCount = illust.pageCount
|
PageCount = illust.pageCount,
|
||||||
|
|
||||||
|
IllustTapped = commandIllustImageTapped
|
||||||
};
|
};
|
||||||
}).Where(i => i != null);
|
}).Where(i => i != null);
|
||||||
|
|
||||||
@ -156,7 +173,14 @@ namespace Pixiview
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Page_OrientationChanged(object sender, OrientationEventArgs e)
|
#endregion
|
||||||
|
|
||||||
|
private void OnIllustImageTapped(IllustItem illust)
|
||||||
|
{
|
||||||
|
DisplayAlert("title", $"open illust: {illust.Id}", "Ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Page_OrientationChanged(object sender, OrientationEventArgs e)
|
||||||
{
|
{
|
||||||
switch (e.CurrentOrientation)
|
switch (e.CurrentOrientation)
|
||||||
{
|
{
|
||||||
@ -173,11 +197,7 @@ namespace Pixiview
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NavigationTitle_RightButtonClicked(object sender, EventArgs e)
|
private void NavigationTitle_RightButtonClicked(object sender, EventArgs e)
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void NavigationTitle_LeftButtonClicked(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
DisplayAlert("title", "message", "Ok");
|
DisplayAlert("title", "message", "Ok");
|
||||||
}
|
}
|
||||||
@ -212,6 +232,8 @@ namespace Pixiview
|
|||||||
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(
|
||||||
nameof(ProfileImage), typeof(ImageSource), typeof(IllustItem));
|
nameof(ProfileImage), typeof(ImageSource), typeof(IllustItem));
|
||||||
|
public static readonly BindableProperty ImageHeightProperty = BindableProperty.Create(
|
||||||
|
nameof(ImageHeight), typeof(GridLength), typeof(IllustItem), GridLength.Auto);
|
||||||
|
|
||||||
public ImageSource Image
|
public ImageSource Image
|
||||||
{
|
{
|
||||||
@ -223,11 +245,19 @@ namespace Pixiview
|
|||||||
get => (ImageSource)GetValue(ProfileImageProperty);
|
get => (ImageSource)GetValue(ProfileImageProperty);
|
||||||
set => SetValue(ProfileImageProperty, value);
|
set => SetValue(ProfileImageProperty, value);
|
||||||
}
|
}
|
||||||
|
public GridLength ImageHeight
|
||||||
|
{
|
||||||
|
get => (GridLength)GetValue(ImageHeightProperty);
|
||||||
|
set => SetValue(ImageHeightProperty, value);
|
||||||
|
}
|
||||||
|
public ICommand IllustTapped { get; set; }
|
||||||
|
|
||||||
|
public string Id { get; set; }
|
||||||
public string ImageUrl { get; set; }
|
public string ImageUrl { get; set; }
|
||||||
public string Title { get; set; }
|
public string Title { get; set; }
|
||||||
public bool IsRestrict { get; set; }
|
public bool IsRestrict { get; set; }
|
||||||
public string ProfileUrl { get; set; }
|
public string ProfileUrl { get; set; }
|
||||||
|
public string UserId { get; set; }
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
public int Width { get; set; }
|
public int Width { get; set; }
|
||||||
public int Height { get; set; }
|
public int Height { get; set; }
|
||||||
|
@ -33,6 +33,15 @@ namespace Pixiview.UI
|
|||||||
get => (Size)GetValue(ShadowOffsetProperty);
|
get => (Size)GetValue(ShadowOffsetProperty);
|
||||||
set => SetValue(ShadowOffsetProperty, value);
|
set => SetValue(ShadowOffsetProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
|
||||||
|
{
|
||||||
|
if (BindingContext is IllustItem illust)
|
||||||
|
{
|
||||||
|
illust.ImageHeight = widthConstraint * illust.Height / illust.Width;
|
||||||
|
}
|
||||||
|
return base.OnMeasure(widthConstraint, heightConstraint);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,8 +14,9 @@ namespace Pixiview.Utils
|
|||||||
public class Stores
|
public class Stores
|
||||||
{
|
{
|
||||||
public static readonly string PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
public static readonly string PersonalFolder = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
|
||||||
//public static readonly string CacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
|
public static readonly string CacheFolder = Environment.GetFolderPath(Environment.SpecialFolder.InternetCache);
|
||||||
private const string imageFolder = "img-master";
|
private const string imageFolder = "img-master";
|
||||||
|
private const string previewFolder = "img-preview";
|
||||||
private const string thumbFolder = "img-thumb";
|
private const string thumbFolder = "img-thumb";
|
||||||
private const string userFolder = "user-profile";
|
private const string userFolder = "user-profile";
|
||||||
private const string illustFile = "illust.json";
|
private const string illustFile = "illust.json";
|
||||||
@ -88,25 +89,30 @@ namespace Pixiview.Utils
|
|||||||
|
|
||||||
public static ImageSource LoadIllustImage(string url)
|
public static ImageSource LoadIllustImage(string url)
|
||||||
{
|
{
|
||||||
return LoadImage(url, imageFolder);
|
return LoadImage(url, PersonalFolder, imageFolder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ImageSource LoadPreviewImage(string url)
|
||||||
|
{
|
||||||
|
return LoadImage(url, PersonalFolder, previewFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageSource LoadThumbnailImage(string url)
|
public static ImageSource LoadThumbnailImage(string url)
|
||||||
{
|
{
|
||||||
return LoadImage(url, thumbFolder);
|
return LoadImage(url, CacheFolder, thumbFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageSource LoadUserProfileImage(string url)
|
public static ImageSource LoadUserProfileImage(string url)
|
||||||
{
|
{
|
||||||
return LoadImage(url, userFolder);
|
return LoadImage(url, CacheFolder, userFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ImageSource LoadImage(string url, string folder)
|
private static ImageSource LoadImage(string url, string working, string folder)
|
||||||
{
|
{
|
||||||
var file = Path.Combine(PersonalFolder, folder, Path.GetFileName(url));
|
var file = Path.Combine(working, folder, Path.GetFileName(url));
|
||||||
if (!File.Exists(file))
|
if (!File.Exists(file))
|
||||||
{
|
{
|
||||||
file = DownloadImage(url, folder);
|
file = DownloadImage(url, working, folder);
|
||||||
}
|
}
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
@ -115,11 +121,11 @@ namespace Pixiview.Utils
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string DownloadImage(string url, string folder)
|
private static string DownloadImage(string url, string working, string folder)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var directory = Path.Combine(PersonalFolder, folder);
|
var directory = Path.Combine(working, folder);
|
||||||
if (!Directory.Exists(directory))
|
if (!Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(directory);
|
Directory.CreateDirectory(directory);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user