From 29fd8e96678dc49e03e609284ef26787f753dc68 Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Thu, 14 May 2020 20:22:24 +0800 Subject: [PATCH] * Pixiview/UI/StyleDefinition.cs: issue in simulator iPad Pro 11-inch * Pixiview/UI/FlowLayout.cs: * Pixiview/Illust/RankingPage.xaml: * Pixiview/Illust/RankingPage.xaml.cs: fix: scrolling issue * Pixiview/Illust/ViewIllustPage.xaml: * Pixiview/Illust/ViewIllustPage.xaml.cs: fix: swipe page indicator issue --- Pixiview/Illust/RankingPage.xaml | 2 +- Pixiview/Illust/RankingPage.xaml.cs | 19 ++++++++++++++----- Pixiview/Illust/ViewIllustPage.xaml | 3 +-- Pixiview/Illust/ViewIllustPage.xaml.cs | 9 ++------- Pixiview/UI/FlowLayout.cs | 14 ++++++++++++-- Pixiview/UI/StyleDefinition.cs | 6 +++--- 6 files changed, 33 insertions(+), 20 deletions(-) diff --git a/Pixiview/Illust/RankingPage.xaml b/Pixiview/Illust/RankingPage.xaml index 3018bcf..d181b7a 100644 --- a/Pixiview/Illust/RankingPage.xaml +++ b/Pixiview/Illust/RankingPage.xaml @@ -48,7 +48,7 @@ - diff --git a/Pixiview/Illust/RankingPage.xaml.cs b/Pixiview/Illust/RankingPage.xaml.cs index 7b44108..8f7e7bb 100644 --- a/Pixiview/Illust/RankingPage.xaml.cs +++ b/Pixiview/Illust/RankingPage.xaml.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Pixiview.Resources; +using Pixiview.UI; using Pixiview.Utils; using Xamarin.Essentials; using Xamarin.Forms; @@ -77,9 +78,10 @@ namespace Pixiview.Illust public Command ToolbarCommand { get; private set; } private double lastScrollY = double.MinValue; - public bool previousEnabled; - public bool dateEnabled; - public bool nextEnabled; + private bool previousEnabled; + private bool dateEnabled; + private bool nextEnabled; + private double offset; private bool isFilterVisible; private string lastQueryKey; @@ -126,6 +128,14 @@ namespace Pixiview.Illust } } + private void FlowLayout_MaxHeightChanged(object sender, HeightEventArgs e) + { + if (e.ContentHeight > 0) + { + offset = e.ContentHeight - scrollView.Bounds.Height - 33; + } + } + protected override void DoIllustsLoaded(IllustCollection collection) { var now = IllustCollection; @@ -333,8 +343,7 @@ namespace Pixiview.Illust } lastScrollY = y; - var bottomOffset = scrollView.ContentSize.Height - (scrollView.LayoutAreaOverride.Height * 2); - if (y > 0 && y + topOffset > bottomOffset) + if (y > 0 && offset > 0 && y - topOffset > offset) { bool refresh = false; lock (sync) diff --git a/Pixiview/Illust/ViewIllustPage.xaml b/Pixiview/Illust/ViewIllustPage.xaml index ba327c9..39fadf1 100644 --- a/Pixiview/Illust/ViewIllustPage.xaml +++ b/Pixiview/Illust/ViewIllustPage.xaml @@ -22,8 +22,7 @@ + IsScrollAnimated="{Binding IsScrollAnimated}"> diff --git a/Pixiview/Illust/ViewIllustPage.xaml.cs b/Pixiview/Illust/ViewIllustPage.xaml.cs index 6d551f2..bda3188 100644 --- a/Pixiview/Illust/ViewIllustPage.xaml.cs +++ b/Pixiview/Illust/ViewIllustPage.xaml.cs @@ -86,7 +86,7 @@ namespace Pixiview.Illust public int CurrentPage { get => (int)GetValue(CurrentPageProperty); - private set => SetValue(CurrentPageProperty, value); + set => SetValue(CurrentPageProperty, value); } public bool IsScrollAnimated { @@ -413,11 +413,6 @@ namespace Pixiview.Illust item.Loading = false; } - private void CarouselView_PositionChanged(object sender, PositionChangedEventArgs e) - { - CurrentPage = e.CurrentPosition; - } - private void TapPrevious_Tapped(object sender, EventArgs e) { var index = CurrentPage; @@ -520,7 +515,7 @@ namespace Pixiview.Illust var illustItem = IllustItem; var result = await DisplayActionSheet( - illustItem.Title, + $"{illustItem.Title} (id: {illustItem.Id})", ResourceHelper.Cancel, saveOriginal, extras.ToArray()); diff --git a/Pixiview/UI/FlowLayout.cs b/Pixiview/UI/FlowLayout.cs index 39a48a1..23b55e8 100644 --- a/Pixiview/UI/FlowLayout.cs +++ b/Pixiview/UI/FlowLayout.cs @@ -1,4 +1,5 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Specialized; using System.Linq; using Xamarin.Forms; @@ -19,7 +20,7 @@ namespace Pixiview.UI var flowLayout = (FlowLayout)obj; if (oldValue is int column && column != flowLayout.Column) { - //flowLayout.UpdateChildrenLayout(); + flowLayout.UpdateChildrenLayout(); flowLayout.InvalidateLayout(); } } @@ -40,6 +41,8 @@ namespace Pixiview.UI set => SetValue(ColumnSpacingProperty, value); } + public event EventHandler MaxHeightChanged; + public double ColumnWidth { get; private set; } private double maximumHeight; @@ -109,6 +112,8 @@ namespace Pixiview.UI } maximumHeight = columnHeights.Max(); + MaxHeightChanged?.Invoke(this, new HeightEventArgs { ContentHeight = maximumHeight }); + return new SizeRequest(new Size(widthConstraint, maximumHeight)); } @@ -191,4 +196,9 @@ namespace Pixiview.UI InvalidateLayout(); } } + + public class HeightEventArgs : EventArgs + { + public double ContentHeight { get; set; } + } } diff --git a/Pixiview/UI/StyleDefinition.cs b/Pixiview/UI/StyleDefinition.cs index b1bba58..1c50a4d 100644 --- a/Pixiview/UI/StyleDefinition.cs +++ b/Pixiview/UI/StyleDefinition.cs @@ -114,12 +114,12 @@ namespace Pixiview.UI // iPad or Simulator var name = DeviceInfo.Name; var flag = name.StartsWith("iPhone X") - || name.StartsWith("iPhone 11") + || name.StartsWith("iPhone 11"); + _isFullscreenDevice = flag; + _isBottomPadding = flag || name.StartsWith("iPad Pro (11-inch)") || name.StartsWith("iPad Pro (12.9-inch) (3rd generation)") || name.StartsWith("iPad Pro (12.9-inch) (4th generation)"); - _isFullscreenDevice = flag; - _isBottomPadding = flag; } #endif }