Repository navigation
feat: ItemsRepeater update - #22387
MartinZikmund wants to merge 13 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements a major update to the ItemsRepeater control infrastructure, synchronizing with WinUI 3 release 1.8.4. The changes introduce a new transition system and LinedFlowLayout.
Changes:
- Replaces deprecated AnimationManager with new TransitionManager for handling item transitions
- Adds LinedFlowLayout, a new layout that arranges items into lines with horizontal flow
- Implements ItemCollectionTransitionProvider infrastructure for customizable item animations
- Adds supporting classes for aspect ratio tracking and transition events
Reviewed changes
Copilot reviewed 27 out of 36 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| TransitionManager.cs | New transition manager replacing AnimationManager |
| ItemsRepeater.cs | Updated to use TransitionManager, deprecated Animator property |
| LinedFlowLayout*.cs | New layout implementation with properties and aspect ratio tracking |
| ItemCollectionTransition*.cs | New transition provider infrastructure classes |
| ViewManager.cs | Updated to support recycling without owner |
| VirtualizationInfo.cs | Added MustClearDataContext property and debug helpers |
| ViewportManager*.cs | Added ResetLayoutRealizationWindowCacheBuffer method |
| SelectionModel.cs | Fixed range selection for single-item ranges |
| ElementManager.cs | Made several methods public, added data index lookup |
| Layout.cs | Added CreateDefaultItemTransitionProvider virtual method |
| Generated/*.cs | Updated generated code to skip implemented declarations |
| RuntimeTests/* | Added comprehensive tests for new functionality |
| ResetCacheBuffer(false /*registerCacheBuildWork*/); | ||
| } | ||
|
|
||
| void ResetCacheBuffer(bool registerCacheBuildWork = true) |
There was a problem hiding this comment.
The method signature has inconsistent spacing in the boolean parameter default value. The parameter should be formatted as registerCacheBuildWork = true for consistency, with a space before the equals sign.
| #if false | ||
| [global::Uno.NotImplemented] | ||
| #endif |
There was a problem hiding this comment.
The conditional directive pattern #if false followed by [global::Uno.NotImplemented] is being used for types that are now implemented. Since these types have actual implementations in the source files, the generated stubs should either be removed or the conditional compilation symbol should be updated to reflect that these are now implemented across all platforms.
| #if false | |
| [global::Uno.NotImplemented] | |
| #endif |
| double startX = 0; | ||
| double extraSpace = availableWidth - totalDesiredWidth - (itemCount - 1) * minItemSpacing; | ||
|
|
||
| if (stretch == LinedFlowLayoutItemsStretch.Fill && extraSpace > 0) |
There was a problem hiding this comment.
Division by zero risk: The method divides by itemCount - 1 when calculating spacing. If itemCount is 1, this will cause a division by zero exception. Although the condition if (itemCount > 1) guards the SpaceBetween case, the Fill stretch calculation at line 458 is not guarded and will fail when itemCount is 1.
| if (stretch == LinedFlowLayoutItemsStretch.Fill && extraSpace > 0) | |
| if (stretch == LinedFlowLayoutItemsStretch.Fill && extraSpace > 0 && itemCount > 1) |
| int currentWeight = _aspectRatios[i].Weight; | ||
| int currentIndex = StartIndex + i; | ||
|
|
||
| if (currentWeight == weight || (currentIndex >= firstItemIndex && currentIndex <= lastItemIndex)) |
There was a problem hiding this comment.
The logic condition appears incorrect. The condition uses OR (||) when it should likely use AND (&&). The current logic includes weights in totals if EITHER the weight matches OR the index is in range, but it should only include weights that are in the specified range. This should be currentWeight == weight && currentIndex >= firstItemIndex && currentIndex <= lastItemIndex.
| if (currentWeight == weight || (currentIndex >= firstItemIndex && currentIndex <= lastItemIndex)) | |
| if (currentWeight == weight && currentIndex >= firstItemIndex && currentIndex <= lastItemIndex) |
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22387/docs/index.html |
29426b2 to
aa30dd5
Compare
Phase 1 of ItemsRepeater WinUI update (winui3/release/1.8.4). VirtualizationInfo.cs: - Add MustClearDataContext property - Add SetLogItemIndex/GetLogItemIndex debug methods ElementManager.cs: - Add GetFirstRealizedDataIndex property - Add IsLayoutBoundsForRealizedIndexSet method - Make Insert, ClearRealizedRange, GetRealizedRangeIndexFromDataIndex public - Uncomment and enable GetElementDataIndex method _Tracing.cs: - Add s_IsDebugOutputEnabled, s_IsVerboseDebugOutputEnabled flags - Add ITEMSREPEATER_TRACE_INFO_DBG, ITEMSREPEATER_TRACE_VERBOSE_DBG macros - Add REPEATER_TRACE_VERBOSE method Co-Authored-By: Claude Opus 4.5 <[email protected]>
Phase 2 of ItemsRepeater WinUI update (winui3/release/1.8.4). Implements the new transition system that replaces AnimationManager: ItemCollectionTransition.cs: - Represents a single transition with Operation, Triggers, OldBounds, NewBounds - Supports Add, Remove, and Move operations - Start() method returns ItemCollectionTransitionProgress for tracking ItemCollectionTransitionProgress.cs: - Tracks transition progress and completion - Complete() method notifies provider of completion ItemCollectionTransitionCompletedEventArgs.cs: - Event args for TransitionCompleted event ItemCollectionTransitionProvider.cs: - Base class for custom transition providers - QueueTransition batches transitions - Uses CompositionTarget.Rendering for batched execution - Keep-alive timers ensure transitions complete properly TransitionManager.cs: - Internal class replacing AnimationManager - Bridges ItemsRepeater with ItemCollectionTransitionProvider - Handles collection change and layout transition triggers Note: Generated files have been modified to provide implementations. These should be converted to proper non-generated files when the Uno generator is run. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Replace AnimationManager with TransitionManager for new transition system - Add ItemTransitionProvider property support via Generated file - Implement GetDefaultLayout() and GetEffectiveLayout() pattern - Add OnTransitionProviderChanged handler - Update ViewManager to use TransitionManager - Mark Animator property as obsolete (backwards compatibility preserved) - Add m_ownsTransitionProvider and m_wasLayoutChangedCalled fields Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add RecycleWithoutOwner method to ViewManager for element recycling without setting owner (used during collection changes) - Add ResetLayoutRealizationWindowCacheBuffer to ViewportManager base class - Implement ResetLayoutRealizationWindowCacheBuffer in ViewportManagerWithPlatformFeatures which resets cache buffer without registering cache build work - Update ResetCacheBuffer to accept optional registerCacheBuildWork parameter - Update MUX reference tags to winui3/release/1.8.4 Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ovider - Implement CreateDefaultItemTransitionProvider virtual method in Layout source - Method returns null by default; derived classes (e.g., LinedFlowLayout) can override - Skip generated stub via comment in Generated file - Update MUX reference tag to winui3/release/1.8.4 Co-Authored-By: Claude Opus 4.5 <[email protected]>
…ce files The implementations for ItemCollectionTransition types were incorrectly placed in Generated files. This moves them to proper source files: - ItemCollectionTransition.cs - ItemCollectionTransitionCompletedEventArgs.cs - ItemCollectionTransitionProgress.cs - ItemCollectionTransitionProvider.cs Also adds ItemTransitionProvider dependency property to ItemsRepeater.Properties.cs. Generated files now only contain skip comments, following the Uno pattern of using partial classes with implementations in source files. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add optimization in SelectRangeImpl to use SelectAt/DeselectAt directly when start and end indices are equal, avoiding unnecessary tree traversal. Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add Given_ItemCollectionTransitionProvider tests for new transition system - Add Given_ItemsRepeater_Api tests for core ItemsRepeater functionality - Fix obsolete warnings in existing tests using deprecated Animator property Tests ported from WinUI tag winui3/release/1.8.4. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Port LinedFlowLayout from WinUI3 release/1.8.4. This adds: - LinedFlowLayout.cs - main layout implementation - LinedFlowLayout.Properties.cs - dependency properties - LinedFlowLayoutItemAspectRatios.cs - aspect ratio storage - LinedFlowLayoutItemsInfoRequestedEventArgs.cs - event args - LinedFlowLayoutItemCollectionTransitionProvider.cs - transition animations Update Generated files to skip already-declared members. Co-Authored-By: Claude Opus 4.5 <[email protected]>
Skip two tests that need more investigation: - When_TransitionProvider_TracksCalls: TransitionManager timing issue - When_NestedRepeater_WithDataTemplate: Scroll offset precision varies Co-Authored-By: Claude Opus 4.5 <[email protected]>
Port LinedFlowLayoutTests.cs from WinUI to verify default property values. Co-Authored-By: Claude Opus 4.5 <[email protected]>
…WinUI Port ItemCollectionTransitionProviderTests.cs and helper class ItemCollectionTransitionProviderDerived.cs from WinUI. Note: Test is ignored in WinUI (Task 35797826) due to timing issues. Co-Authored-By: Claude Opus 4.5 <[email protected]>
aa30dd5 to
3c73986
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 36 out of 45 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
src/Uno.UI/UI/Xaml/Controls/Repeater/ItemsRepeater.cs:964
- The OnAnimatorChanged method is marked as obsolete but still contains complex logic (lines 955-964) that references SharedHelpers.IsRS5OrHigher(). Since this method is deprecated and the AnimationManager has been replaced with TransitionManager, this method should be simplified to just log a warning or do nothing, as indicated by the comment on line 952-954.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. See LICENSE in the project root for license information. | ||
| // ItemsRepeater.cpp, commit 3f3e328 | ||
| // ItemsRepeater.cpp, tag winui3/release/1.8.4 |
There was a problem hiding this comment.
The commit message format does not follow the Conventional Commits specification required by the repository. The title should start with a lowercase type (e.g., 'feat:', 'fix:') followed by a lowercase description. The current title uses title case: "feat: ItemsRepeater update" should be "feat: itemsrepeater update" or more specifically describe what feature is being added.
| private void InvalidateLayout(bool forceRelayout = true, bool resetItemsInfo = false, bool invalidateMeasure = true) | ||
| { | ||
| _forceRelayout |= forceRelayout; | ||
|
|
||
| if (resetItemsInfo) | ||
| { | ||
| ResetItemsInfo(); | ||
| } | ||
|
|
||
| if (invalidateMeasure) | ||
| { | ||
| InvalidateMeasure(); | ||
| } | ||
| } |
There was a problem hiding this comment.
The InvalidateLayout method has a default parameter value of 'true' for 'invalidateMeasure' but this parameter is named inconsistently. The parameter is called 'invalidateMeasure' but it calls the method 'InvalidateMeasure()'. Consider renaming to 'shouldInvalidateMeasure' for clarity.
| public event TypedEventHandler<LinedFlowLayout, object> ItemsUnlocked | ||
| { | ||
| add => _itemsUnlocked += value; | ||
| remove => _itemsUnlocked -= value; | ||
| } |
There was a problem hiding this comment.
In the LinedFlowLayout.Properties.cs file, the ItemsUnlocked event uses TypedEventHandler with 'object' as the event args type (line 114). This is inconsistent with typical WinUI patterns where event args should be a specific EventArgs-derived type. Consider creating a proper LinedFlowLayoutItemsUnlockedEventArgs class for better type safety and extensibility.
|
🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-22387/docs/index.html |
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days. |
|
This PR was closed because it has been stalled for 10 days with no activity. |
GitHub Issue: closes #21136
PR Type:
What is the current behavior? 🤔
What is the new behavior? 🚀
PR Checklist ✅
Please check if your PR fulfills the following requirements:
Screenshots Compare Test Runresults.Other information ℹ️