Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
ajpinedam committed Oct 16, 2024
1 parent 475fef4 commit 6384f45
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -598,11 +598,11 @@ ItemsPresenter GetItemsPresenter(ListView listView)

if (ReadLocalValue(SelectedItemProperty) != DependencyProperty.UnsetValue)
{
#if __IOS__
UpdateSelectedIndexFromSelectedItem();
#else
//#if __IOS__
//UpdateSelectedIndexFromSelectedItem();

Check warning on line 602 in src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Uno.UI/Microsoft/UI/Xaml/Controls/TabView/TabView.cs#L602

Remove this commented out code.
//#else
UpdateSelectedItem();
#endif
//#endif
}
else
{
Expand Down
11 changes: 11 additions & 0 deletions src/Uno.UI/UI/Xaml/Controls/ListViewBase/NativeListViewBase.iOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,17 @@ public override void LayoutSubviews()
}
}
}

if (XamlParent?.PendingScrollIntoViewContainer is { } container)
{
var index = XamlParent.IndexFromContainer(container);
if (index != -1)
{
var vtree = Uno.UI.Extensions.ViewExtensions.TreeGraph(XamlParent);

Check notice on line 486 in src/Uno.UI/UI/Xaml/Controls/ListViewBase/NativeListViewBase.iOS.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Uno.UI/UI/Xaml/Controls/ListViewBase/NativeListViewBase.iOS.cs#L486

Remove the unused local variable 'vtree'.
Uno.UI.Helpers.ListViewHelper.InstantScrollToIndex(XamlParent, index);
}
XamlParent.PendingScrollIntoViewContainer = null;
}
}

private IEnumerable<(NSIndexPath Path, UICollectionViewCell Cell)> VisibleCellsAndPaths
Expand Down
25 changes: 21 additions & 4 deletions src/Uno.UI/UI/Xaml/Controls/Primitives/Selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,16 +200,32 @@ internal virtual void OnSelectedItemChanged(object oldSelectedItem, object selec
#if !IS_UNIT_TESTS
if (newIndex != -1 && IsInLiveTree)
{
if (this is ListViewBase lvb)
var container = ContainerFromIndex(newIndex) as FrameworkElement;

if (container is not null && container.IsLoaded == false)
{
container.Loaded += (o,s) => {

};

PendingScrollIntoViewContainer = container;
}
else
{
PendingScrollIntoViewContainer = null;

if (this is ListViewBase lvb)
{
#if __IOS__ || __ANDROID__
lvb.InstantScrollToIndex(newIndex);
lvb.InstantScrollToIndex(newIndex);
#elif __MACOS__
// not implemented
// not implemented
#else
lvb.ScrollIntoView(selectedItem);
lvb.ScrollIntoView(selectedItem);
#endif
}
}

}
#endif

Expand All @@ -225,6 +241,7 @@ internal virtual void OnSelectedItemChanged(object oldSelectedItem, object selec
}
}

internal DependencyObject PendingScrollIntoViewContainer { get; set; }
internal void TryUpdateSelectorItemIsSelected(object item, bool isSelected)
{
if (item is SelectorItem si)
Expand Down

0 comments on commit 6384f45

Please sign in to comment.