* 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
This commit is contained in:
Tsanie Lily 2020-05-14 20:22:24 +08:00
parent a2b91a2406
commit 29fd8e9667
6 changed files with 33 additions and 20 deletions

View File

@ -48,7 +48,7 @@
<Grid>
<ScrollView x:Name="scrollView" Scrolled="ScrollView_Scrolled"
HorizontalOptions="Fill" HorizontalScrollBarVisibility="Never">
<u:FlowLayout ItemsSource="{Binding Illusts}"
<u:FlowLayout ItemsSource="{Binding Illusts}" MaxHeightChanged="FlowLayout_MaxHeightChanged"
HorizontalOptions="Fill" Column="{Binding Columns}"
Margin="16, 16, 16, 16" RowSpacing="16" ColumnSpacing="16"
ItemTemplate="{StaticResource cardView}"/>

View File

@ -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<string> 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)

View File

@ -22,8 +22,7 @@
<CarouselView ItemsSource="{Binding Illusts}" HorizontalScrollBarVisibility="Never"
Position="{Binding CurrentPage}"
ItemTemplate="{StaticResource carouselView}"
IsScrollAnimated="{Binding IsScrollAnimated}"
PositionChanged="CarouselView_PositionChanged">
IsScrollAnimated="{Binding IsScrollAnimated}">
<CarouselView.ItemsLayout>
<LinearItemsLayout Orientation="Vertical" ItemSpacing="20"/>
</CarouselView.ItemsLayout>

View File

@ -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());

View File

@ -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<HeightEventArgs> 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; }
}
}

View File

@ -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
}