-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ported pending fixes from Xamarin.Forms #5510
Changes from all commits
050fd7b
ac6a07c
87adbfb
477cbe3
1ba1974
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -334,17 +334,10 @@ void SetCell(object newContext) | |
// If there is a ListView, load the Cell content from the ItemTemplate. | ||
// Otherwise, the given Cell is already a templated Cell from a TableView. | ||
ListView lv = _listView.Value; | ||
|
||
if (lv != null) | ||
{ | ||
// 🚀 If there is an old cell, check if it was a group header | ||
// we need this later to know whether we can recycle this cell | ||
bool? wasGroupHeader = null; | ||
var oldCell = Cell; | ||
if (oldCell != null) | ||
{ | ||
wasGroupHeader = oldCell.GetIsGroupHeader<ItemsView<Cell>, Cell>(); | ||
} | ||
|
||
Cell oldCell = Cell; | ||
bool isGroupHeader = IsGroupHeader; | ||
DataTemplate template = isGroupHeader ? lv.GroupHeaderTemplate : lv.ItemTemplate; | ||
object bindingContext = newContext; | ||
|
@@ -362,15 +355,8 @@ void SetCell(object newContext) | |
sameTemplate = oldTemplate == template; | ||
} | ||
} | ||
// 🚀 if there is no datatemplateselector, we now verify if the old cell | ||
// was a groupheader and whether the new one is as well. | ||
// Again, this is only to verify we can reuse this cell | ||
else if (wasGroupHeader.HasValue) | ||
{ | ||
sameTemplate = wasGroupHeader == isGroupHeader; | ||
} | ||
|
||
// reuse cell | ||
// Reuse cell | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix ListView grouping not working on Windows |
||
var canReuseCell = Cell != null && sameTemplate; | ||
|
||
// 🚀 If we can reuse the cell, just reuse it... | ||
|
@@ -407,7 +393,8 @@ void SetCell(object newContext) | |
|
||
if (Cell != cell) | ||
Cell = cell; | ||
// 🚀 even if the cell did not change, we **must** call SendDisappearing() and SendAppearing() | ||
|
||
// 🚀 Even if the cell did not change, we **must** call SendDisappearing() and SendAppearing() | ||
// because frameworks such as Reactive UI rely on this! (this.WhenActivated()) | ||
else if (Cell != null) | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ public sealed class FontImageSourceHandler : IImageSourceHandler, IIconElementHa | |
{ | ||
FontFamily = GetFontSource(fontsource), | ||
FontSize = (float)fontsource.Size, | ||
HorizontalAlignment = CanvasHorizontalAlignment.Center, | ||
HorizontalAlignment = CanvasHorizontalAlignment.Left, | ||
VerticalAlignment = CanvasVerticalAlignment.Center, | ||
Options = CanvasDrawTextOptions.Default | ||
}; | ||
|
@@ -51,9 +51,7 @@ public sealed class FontImageSourceHandler : IImageSourceHandler, IIconElementHa | |
var iconcolor = (fontsource.Color != null ? fontsource.Color : Colors.White).ToWindowsColor(); | ||
|
||
// offset by 1 as we added a 1 inset | ||
var x = (float)layout.DrawBounds.X * -1; | ||
|
||
ds.DrawTextLayout(layout, x, 1f, iconcolor); | ||
ds.DrawTextLayout(layout, 1f, 1f, iconcolor); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix FontIcons alignment |
||
} | ||
|
||
return Task.FromResult((UI.Xaml.Media.ImageSource)imageSource); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ public abstract class ItemsViewController<TItemsView> : UICollectionViewControll | |
public TItemsView ItemsView { get; } | ||
protected ItemsViewLayout ItemsViewLayout { get; set; } | ||
bool _initialized; | ||
bool _isEmpty; | ||
bool _isEmpty = true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prevent CollectionView.EmptyView from showing up while it shouldn't on iOS |
||
bool _emptyViewDisplayed; | ||
bool _disposed; | ||
|
||
|
@@ -212,6 +212,7 @@ public virtual void UpdateItemsSource() | |
{ | ||
_measurementCells.Clear(); | ||
ItemsViewLayout?.ClearCellSizeCache(); | ||
ItemsSource?.Dispose(); | ||
ItemsSource = CreateItemsViewSource(); | ||
CollectionView.ReloadData(); | ||
CollectionView.CollectionViewLayout.InvalidateLayout(); | ||
|
@@ -470,7 +471,14 @@ void AlignEmptyView() | |
return; | ||
} | ||
|
||
if (CollectionView.EffectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirection.RightToLeft) | ||
bool isRtl; | ||
|
||
if (PlatformVersion.IsAtLeast(10)) | ||
isRtl = CollectionView.EffectiveUserInterfaceLayoutDirection == UIUserInterfaceLayoutDirection.RightToLeft; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix CollectionView crash in iOS < 10 |
||
else | ||
isRtl = CollectionView.SemanticContentAttribute == UISemanticContentAttribute.ForceRightToLeft; | ||
|
||
if (isRtl) | ||
{ | ||
if (_emptyUIView.Transform.A == -1) | ||
{ | ||
|
@@ -621,6 +629,7 @@ internal protected virtual void UpdateVisibility() | |
{ | ||
if (CollectionView.Hidden) | ||
{ | ||
CollectionView.ReloadData(); | ||
CollectionView.Hidden = false; | ||
Layout.InvalidateLayout(); | ||
CollectionView.LayoutIfNeeded(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
|
@@ -52,9 +53,9 @@ public void AddFrameData(int index, CGImageSource imageSource) | |
using (var delayTimeValue = gifImageProperties?.ValueForKey(ImageIO.CGImageProperties.GIFDelayTime)) | ||
{ | ||
if (unclampedDelayTimeValue != null) | ||
double.TryParse(unclampedDelayTimeValue.ToString(), out delayTime); | ||
double.TryParse(unclampedDelayTimeValue.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out delayTime); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix issue with gifs and differents DefaultThreadCurrentCulture on iOS |
||
else if (delayTimeValue != null) | ||
double.TryParse(delayTimeValue.ToString(), out delayTime); | ||
double.TryParse(delayTimeValue.ToString(), NumberStyles.Any, CultureInfo.InvariantCulture, out delayTime); | ||
|
||
// Frame delay compability adjustment. | ||
if (delayTime <= 0.02f) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,6 +274,9 @@ protected override void OnElementChanged(ElementChangedEventArgs<ListView> e) | |
} | ||
_tableViewController = new FormsUITableViewController(e.NewElement, _usingLargeTitles); | ||
SetNativeControl(_tableViewController.TableView); | ||
|
||
if (Forms.IsiOS15OrNewer) | ||
_tableViewController.TableView.SectionHeaderTopPadding = new nfloat(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix issue with ListView wrong top padding in iOS 15 |
||
|
||
_backgroundUIView = _tableViewController.TableView.BackgroundView; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -440,14 +440,27 @@ void UpdateIsRefreshing(bool isInitialValue = false) | |
}); | ||
} | ||
else | ||
_refresh.Refreshing = isRefreshing; | ||
_refresh.Refreshing = isRefreshing; | ||
|
||
// Allow to disable SwipeToRefresh layout AFTER refresh is done | ||
UpdateIsSwipeToRefreshEnabled(); | ||
} | ||
} | ||
|
||
void UpdateIsSwipeToRefreshEnabled() | ||
{ | ||
if (_refresh != null) | ||
_refresh.Enabled = Element.IsPullToRefreshEnabled && (Element as IListViewController).RefreshAllowed; | ||
{ | ||
var isEnabled = Element.IsPullToRefreshEnabled && (Element as IListViewController).RefreshAllowed; | ||
_refresh.Post(() => | ||
{ | ||
// NOTE: only disable while NOT refreshing, otherwise Command bindings CanExecute behavior will effectively | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid that disabling ListView RefreshAllowed cancels refresh indicator on Android |
||
// cancel refresh animation. If not possible right now we will be called by UpdateIsRefreshing(). | ||
// For details see https://github.com/xamarin/Xamarin.Forms/issues/8384 | ||
if (isEnabled || !_refresh.Refreshing) | ||
_refresh.Enabled = isEnabled; | ||
}); | ||
} | ||
} | ||
|
||
void UpdateFastScrollEnabled() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -330,17 +330,10 @@ void SetCell(object newContext) | |
// If there is a ListView, load the Cell content from the ItemTemplate. | ||
// Otherwise, the given Cell is already a templated Cell from a TableView. | ||
ListView lv = _listView.Value; | ||
|
||
if (lv != null) | ||
{ | ||
// 🚀 If there is an old cell, check if it was a group header | ||
// we need this later to know whether we can recycle this cell | ||
bool? wasGroupHeader = null; | ||
var oldCell = Cell; | ||
if (oldCell != null) | ||
{ | ||
wasGroupHeader = oldCell.GetIsGroupHeader<ItemsView<Cell>, Cell>(); | ||
} | ||
|
||
Cell oldCell = Cell; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
bool isGroupHeader = IsGroupHeader; | ||
DataTemplate template = isGroupHeader ? lv.GroupHeaderTemplate : lv.ItemTemplate; | ||
object bindingContext = newContext; | ||
|
@@ -358,15 +351,8 @@ void SetCell(object newContext) | |
sameTemplate = oldTemplate == template; | ||
} | ||
} | ||
// 🚀 if there is no datatemplateselector, we now verify if the old cell | ||
// was a groupheader and whether the new one is as well. | ||
// Again, this is only to verify we can reuse this cell | ||
else if (wasGroupHeader.HasValue) | ||
{ | ||
sameTemplate = wasGroupHeader == isGroupHeader; | ||
} | ||
|
||
// reuse cell | ||
// Reuse cell | ||
var canReuseCell = Cell != null && sameTemplate; | ||
|
||
// 🚀 If we can reuse the cell, just reuse it... | ||
|
@@ -403,7 +389,8 @@ void SetCell(object newContext) | |
|
||
if (Cell != cell) | ||
Cell = cell; | ||
// 🚀 even if the cell did not change, we **must** call SendDisappearing() and SendAppearing() | ||
|
||
// 🚀 Even if the cell did not change, we **must** call SendDisappearing() and SendAppearing() | ||
// because frameworks such as Reactive UI rely on this! (this.WhenActivated()) | ||
else if (Cell != null) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid reset ListView adapter in TabbedPage if is already disposed
xamarin/Xamarin.Forms#14635