Private
_The current data source instance.
IHosannaView
Index to animate to for items.
Index to animate to for rows.
Optional
audioThis hint can be used in conjunction with the audio guide item
Optional
audioPrivate
cachedCached event object for event dispatching.
Indicates whether the element can receive focus.
These are the children that are rendered on screen in the tree structure of the view
Focus manager for the collection view.
Indicdates whether the view is a focus group which means it can have a focused child Otherwise it will be focused itself
The root container group for the collection view.
Private
currentCurrent index for rendering.
Optional
customOptional
dataThe data source for the collection view.
Private
directionDirection of navigation (1 for down/right, -1 for up/left).
Private
distanceThe distance that needs to be traveled to reach the next virtual item. This value is used to determine how far an element should move.
Dummy content for testing or placeholder.
Private
firstThe index of the first visible row.
Optional
focusedThe currently focused item index within the focused row.
The currently focused row index.
Optional
focusPrivate
indexCurrent row index.
Injected instance pool for row reuse.
Private
isWhether the view is active.
Private
isWhether content has been set.
Private
isEvent Loops
Indicates whether the element is currently focused.
If true, this view has been presented in an AggregateViewController
Private
isWhether the collection view has been rendered.
Private
lastStores the virtual position of the last focused item in the collection view. This value is used to keep track of the focus state within the virtualized list.
Last key pressed on a row.
Private
lastThe index of the last visible row.
Private
nextThe index of the next row to be processed or rendered. This is used to keep track of the current position in the collection view.
Private
nextThe position of the next virtual item in the collection view. This is used to keep track of the virtualized items' positions as they are rendered in the view.
Private
numberNumber of items (rows) in the collection view.
Optional
onHandler for item focus events.
Optional
onHandler for item selected events.
Optional
onHandler for row focus events.
Optional
parentThe parent focusable element, if any.
Private
renderAn event object that describes the changes to be rendered in the collection view.
Private
rowsArray of row instances.
Currently selected row and item indices.
Animation speed for row transitions.
Private
startStart index for animations.
These are the children that were created in getViews, in a flat strcuture - it contains EVERYTHING that we declared.
Private
targetTarget index for animations.
The IHosannaView subclass that created us in getViews
Private
viewportThe height of the viewport for visible rows.
Private
virtualThe current virtual Y position (scroll offset).
Indicates whether the navigatable entity is visible.
Private
visibleArray of currently visible rows.
Handles the tick event, processes the input, and updates the view accordingly.
The time delta since the last tick.
View Creation
Private
animateAnimates the view between the start index and the target index.
The time delta since the last animation step.
Applies state changes, including updating the data source if changed.
Optional
state: CollectionViewStateThe new state to apply.
Builds the view and attaches it to the view owner.
Optional
mountTarget: IHosannaView<ViewState>The target to mount the view.
The built view or undefined.
Private
calculateCalculates the range of visible rows within the viewport.
This method determines the first and last visible rows based on the current
vertical scroll position (virtualY
) and the height of the viewport (viewportHeight
).
It iterates through the rows starting from the first visible row and accumulates their
heights until it exceeds the viewport height or reaches the end of the rows.
An object containing:
firstVisible
: The index of the first visible row.lastVisible
: The index of the last visible row, clamped between 0 and the total number of items.Private
clearClears all existing rows from the collection view.
Determines if the given child is contained within this collection view.
The child view to check.
True if the child is a descendant, false otherwise.
Private
createCreates row instances from the data source.
Optional
options: IScreenDismissOptionsOptional
args: Record<string, unknown>Optional
cancellationToken: HsCancellationTokenAsync Support
Optional
args: Record<string, unknown>Optional
callback: AsyncCommandEventCallbackPrivate
dispatchDispatches an item focus event.
The type of row event.
The row index.
Optional
percent: numberThe percent completion.
Optional
direction: CollectionViewDirectionThe direction of focus.
Private
dispatchDispatches an item selected event.
The row index.
Optional
itemIndex: numberThe item index.
Private
dispatchDispatches a row focus event.
The type of row event.
The row index.
Optional
percent: numberThe percent completion.
Optional
direction: CollectionViewDirectionThe direction of focus.
Private
easeEasing function for smooth animation.
The current animation time.
The starting value.
The change in value.
The duration of the animation.
The eased value.
Private
findFinds the index of the first visible row based on the given virtual Y position. This method uses a binary search algorithm to efficiently locate the row.
The virtual Y position to find the first visible row for.
The index of the first visible row, clamped between 0 and the number of items minus one.
Finds the next focusable element based on the focus event.
The next focus resolution event.
The next focusable element or undefined.
Audio guide support
Measurement
Gets the cell for a given row and item index.
The row index.
The item index.
The cell, or undefined.
Gets the data source item for a given row and item index.
The row index.
The item index.
The item, or undefined.
Gets the data source row for a given index.
The row index.
The data source row, or undefined.
Gets the currently focused data source item.
The focused item, or undefined.
Gets the currently focused data source row.
The focused data source row, or undefined.
Gets the currently focused row instance.
The focused row, or undefined.
Retrieves the focus information for a specific row and item index.
The row index.
The item index (default: -1).
The focus info object, or undefined if not found.
Gets the focus manager for the collection view.
The collection view focus manager.
Private
getCalculates the focus percentage based on the current virtual position and the distance to travel.
The focus percentage, clamped between 0 and 1. Returns 0 if the distance to travel is 0, or if the next or last focused virtual positions are invalid.
Gets the Hosanna view for the currently focused row, if any.
The focused Hosanna view, or undefined.
Private
getGets the next row index for a key press.
The key pressed.
Whether the key press is a long press.
The next row index, or -1 if not handled.
Gets the row instance for a given data source row.
The data source row.
The row instance, or undefined.
Gets the row instance for a given index.
The row index.
The row instance, or undefined.
Gets all row instances.
The array of rows.
Instantly jumps to the specified row index without animation. Updates virtualY, focus, and row visibility immediately.
The target row index.
Handles a row key press event.
The key pressed.
Whether the key press is a long press.
True if handled, false otherwise.
Hibernates the view and its subviews by releasing native renderers and setting the view phase to Hibernating.
Private
initializeInitializes the collection view with the given data source.
The data source instance.
The view to be added as a subview.
index of the child in the parent view, -1 means add to end
Private
invalidateInvalidates the current layout starting from the specified row index. Recalculates renderedListPosition for each row and triggers rendering if needed.
The index of the first row to start invalidating from.
Focus
Determines if the current row handles the given key press.
The key pressed.
Whether the key press is a long press.
True if handled, false otherwise.
Private
onHandles the animation to a specific row index within the collection view.
The target row index.
Private
onAnimates the view to the specified item index within the currently focused row.
The item index.
Called when the navigatable entity is shown.
Called when the collection view loses focus.
Private
onHandles changes to the data source and updates rows/layout accordingly.
The list of data source changes.
Called after the navigatable entity has been added to an aggregate view.
The aggregate view to which the entity has been added.
Called after the navigatable entity has been removed from an aggregate view.
The aggregate view from which the entity has been removed.
Called when the navigatable entity is hidden.
Called when the collection view receives focus.
Processes the input event based on the key state and key type.
The key event to process.
Handles the Down key press.
True if handled, false otherwise.
Handles the FastForward key press (increases speed).
True if handled, false otherwise.
Handles the Left key press.
True if handled, false otherwise.
Handles the OK key press (selects the current item).
True if handled, false otherwise.
Handles the Rewind key press (decreases speed).
True if handled, false otherwise.
Handles the Right key press.
True if handled, false otherwise.
Handles the Up key press.
True if handled, false otherwise.
Handles the end of a long press on a key.
The key being released.
True if handled, false otherwise.
Handles the start of a long press on a key.
The key being long pressed.
True if handled, false otherwise.
Called when the view is unmounted.
Called before the navigatable entity is added to an aggregate view.
The aggregate view to which the entity will be added.
This method is called before applying state changes to the view. It is used to perform any necessary preparations before the state changes are applied.
Called before the navigatable entity is removed from an aggregate view.
The aggregate view from which the entity will be removed.
Presents a new screen in the navigation stack or as a dialog.
The screen to be presented, represented by a ViewStruct<ViewState>
.
Optional
options: IScreenPresentationOptionsOptional presentation options.
If true, the screen will be presented as a dialog.
If true, the screen transition will be animated.
Private
removePrivate
renderRenders the currently focused row in the collection view.
The time delta since the last render.
Private
renderPrivate
Renders the rows that are currently visible within the viewport.
This method calculates the first and last visible rows based on the current
vertical scroll position (virtualY
) and the height of the viewport (viewportHeight
).
It then iterates through the rows, rendering only those that are visible.
The method performs the following steps:
visibleRows
array.Sets the content of the collection view with the provided rows.
The rows to use as the data source.
Private
setSets the data source for the collection view.
The data source instance.
Navigatable View
Private
updateUpdates the focus tracker based on the percentage of movement to the next row.
This method renders the focus manager while moving between items and updates the focus tracking fields when the movement to the next row is complete.
A number representing the percentage of movement to the next row. When this value is 1 or greater, the focus tracking fields are updated and the focus manager is set to the next focus information.
Private
updatePrivate
Updates the focus tracking fields for the collection view.
This method calculates and updates several properties related to the focus tracking of rows in the collection view. It ensures that the focus is within the valid range of rows and calculates the distance to travel for the next focus position.
Private
updateUpdates the visibility of rows in the collection view.
This method calculates the currently visible rows and updates the currentIndex
to the first visible row. It then iterates through all rows and triggers the
onEnterScreen
method for rows that have become visible and the onExitScreen
method for rows that have gone off-screen.
Wakes up the view and its subviews by reserving native renderers and setting the view phase to Mounted.
CollectionViewView is the main Hosanna collection view implementation. Handles row and item rendering, focus management, data source changes, and input events. It is highly optimized for performance and supports virtualized rendering. It is designed to handle large data sets efficiently and can handle different sets of cards, rows and is very flexible in terms of layout and rendering.