Hosanna UI API v1.30.2-next
    Preparing search index...

    CustomViewRowLayout is a specialized implementation of BaseCollectionViewLayout designed to handle the layout for rows with custom views. It manages the rendering and lifecycle of custom views within a collection view row.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    background: ISGNRectangle

    The background rectangle for the layout.

    cellsByIndex: Record<string, BaseCell.BaseCell> = {}

    Map of cell indices to cell instances.

    currentHeaderStyle: string = ''

    Current header style key for component-based headers.

    debugLabel: ISGNLabel

    The debug label for the layout.

    enabled: boolean = true

    Indicates whether this layout is enabled.

    Injected font manager for font lookups.

    hasHeader: boolean = true

    Whether this layout has a header.

    headerFragment: undefined | IViewFragment = undefined

    Header fragment for component-based headers.

    headerLabel: undefined | ISGNLabel

    Header label node, if present.

    instancePool: IInstancePool

    Injected instance pool for cell reuse.

    lastUpdatedVisibleCellsVirtualPosition: number = 0

    The last updated visible cells virtual position.

    nodePool: INodePool

    Injected node pool for managing reusable nodes.

    onReleaseFinish:
        | undefined
        | ((layout: BaseCollectionViewLayout.BaseCollectionViewLayout) => void) = undefined

    The callback to invoke when the row is released.

    onRowRenderFinish: undefined | ((event: RenderEvent) => void) = undefined

    The callback to invoke at the end of row layout rendering.

    onRowRenderStart: undefined | ((event: RenderEvent) => void) = undefined

    The callback to invoke at the start of row layout rendering.

    renderedCells: BaseCell.BaseCell[]

    Array of currently rendered cells.

    row: ResolvedHorizontalReadingDirectionRow

    The row this layout manages.

    screenPosition: number = 0

    The current screen position (y offset).

    Injected view fragment provider for component-based headers.

    virtualPosition: number

    The current virtual scroll position.

    Accessors

    • get numberOfItems(): number

      Returns the number of items in the row.

      Returns number

    Methods

    • Calculates and updates the visible cells based on the given virtual position WHEN SCROLLING UP AND DOWN

      Parameters

      • virtualPosition: number

        The virtual position to calculate the visible cells from.

        This method determines the range of cells that should be visible within the viewport, configures and renders them, and removes any cells that are no longer visible.

        The method performs the following steps:

        1. Calculates the first and last visible cell indices based on the virtual position and viewport width.
        2. Configures and renders the cells within the visible range.
        3. Removes cells that are no longer visible and releases them back to the cell pool.
      • yPosition: number
      • useBufferCells: boolean = true

      Returns void

    • Retrieves a cell at the specified index. If the cell does not exist, it reserves a new cell from the instancePool, sets it to visible, assigns the index, and stores it in the cellsByIndex array.

      The pool key is normally the row's cellSettingsKey (or loadingCellStyleKey for loading placeholders). When the row has useMixedCellStyleKeys, each item may supply its own cellSettingsKey so different cells in the same row can use different styles.

      Parameters

      • index: number

        The index of the cell to retrieve.

      Returns ICollectionViewCell

      The cell at the specified index, or a newly reserved cell if it did not exist.

      A warning if no cells are available in the instancePool.

    • Gets the cell index at a given virtual position.

      Parameters

      • virtualPosition: number

        The virtual position.

      Returns number

      The cell index.

    • Gets the width for a specific cell index.

      Parameters

      • index: number

        The cell index.

      Returns number

      The cell width.

    • Gets the item index whose center is closest to the stored focused cell X position. Used for FocusOnClosestItem strategy.

      Parameters

      • direction: number

      Returns number

      The item index closest to the stored X position.

    • Gets the next item index when moving vertically within row. Override this function if your row has more than one item per sub-row, and you want to move to the next item when moving vertically. That is, for rows containing one line of items (for instance, HorizontalRow), the method returns -1 (because the next or previous line of items does not exist)

      Parameters

      • direction: number

        1 for up, 1 for down

      Returns number

    • Gets the next page item index when moving horizontally within row. Override this function if your row has more than one item per sub-row, and you want to move to the next page item when moving horizontally.

      Parameters

      • direction: number

        1 for left, 1 for right

      Returns number

      The index of the next page item.

    • Calculates the on-screen position for a cell index, accounting for the current horizontal scroll (virtualPosition). Used by pointer/touch focus so the focus indicator follows the item to its scrolled location rather than its release point. The returned X is clamped to the visible viewport so the indicator never renders past the row edges. Assumes a horizontal layout; subclasses may override.

      Parameters

      • index: number

        The cell index.

      • offset: [number, number]

        The base offset to apply ([x, y]); offset[0] is the minimum X, offset[1] is the Y.

      Returns undefined | [number, number]

      The clamped [x, y] screen position, or undefined if the index is out of bounds.

    • Gets the target item index in the horizontal direction.

      Parameters

      • direction: number

        1 for left, 1 for right

      • isLongPress: boolean

        Whether the key press is a long press.

      Returns number

      The index of the target item.

    • Returns the [x, y] virtual position within this row necessary to bring the target item index into view according to the requested position strategy. Base implementation returns a default x using xOffset and a y based on the row's rendered list position and screen position. Specialized layouts should override this to provide accurate item positions.

      Parameters

      • index: number

      Returns number

    • Returns the vertical position of the item index.

      Parameters

      • index: number

        The item index.

      Returns number

      The vertical position of the item index. The same as getVerticalCorrectedPositionForItemIndex, but without the screen position offset.

    • Gets the virtual vertical position for a specific row index related to the row header.

      Parameters

      • rowIndex: number

        The item index.

      Returns number

      The virtual vertical position for the row.

    • Gets the number of sub-rows to move when moving vertically to the target index.

      Parameters

      • targetIndex: number

        The target index.

      Returns number

      The number of sub-rows to move.

    • Determines if a cell index is in the modified floating focus area at the given virtual position. The modified floating focus area is the floating focus area without the xOffset. This is used for horizontal scrolling with floating focus.

      Parameters

      • index: number

        The cell index.

      • virtualPosition: number

        The virtual position.

      Returns boolean

      True if the cell is in the modified floating focus area, false otherwise.

    • Called when the row enters the screen. Handles any necessary initialization or inflation of the custom view.

      Returns void

    • Called when the row exits the screen. Handles any necessary cleanup or state updates for the custom view.

      Returns void

    • Called before the layout is released back to the pool. Releases all cells, resets virtual position, and clears rendered cells.

      Returns void

    • Called before the layout is reused from the pool. Resets virtual position, clears rendered cells, and hides the header.

      Returns void

    • Renders the custom view row at the specified position. Updates the translation of the custom view's renderer based on the render event.

      Parameters

      • event: RenderEvent

        The render event containing position and other details.

      Returns void

    • Determines if the visible cells should be recalculated.

      Parameters

      • yPosition: number

        The virtual screen y position.

      Returns boolean

      True if the visible cells should be recalculated, false otherwise.