hosanna-ui-docs - v0.9.0
    Preparing search index...

    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.

    Hierarchy (View Summary)

    Implements

    Index

    Constructors

    Properties

    Accessors

    Methods

    _tick addChild addChildren addRendererToParentViewRenderer addSubView animateBetweenIndexes applyIdsToViewStructs applyInitialState applyLayoutStateToNativeRenderer applyStateChanges buildView calculateVisibleRows canMeasureBounds clearErrorByErrorField clearErrors clearExistingRows configureAudioGuideItem containsChild createDataEvent createRows dismiss dispatch dispatchAction dispatchAsync dispatchItemFocusEvent dispatchItemSelectedEvent dispatchRowFocusEvent dispatchSelection easeOutCubic findFirstVisibleRow findNextFocusable findNextFocusableView findNextFocusableViewByDirection getAudioGuideItem getBounds getBoundsInApp getBoundsInParent getCellForIndex getChangedField getChildView getCustomData getDataSourceItemForIndex getDataSourceRowForIndex getField getFlattenedStructs getFlattenedStructsById getFocusedDataSourceItem getFocusedDataSourceRow getFocusedRow getFocusInfo getFocusManager getFocusPercent getHosannaViewForFocusedRow getNavController getNextFocusableRowIndex getNextRowIndexForKeyPress getObservableField getRowForDataSourceRow getRowForIndex getRows getSubView getSubViewRenderer goToRowWithoutAnimation handleRowKeyPress hibernateView inflateViewStructs initializeWithDataSource insertChild insertSubView invalidateLayout invalidateParentLayout invalidateRowLayout isDescendantOf isInFocusChain isRowHandlingKeyPress layoutAt layoutChildren notifyOnFocusedChildChange onAnimateToRowIndex onAnimatToItemIndex onAppear onBlur onDataSourceChanged onDidAddToAggregateView onDidRemoveFromAggregateView onDisappear onFocus onKeyEvent onKeyPressBack onKeyPressDown onKeyPressFastForward onKeyPressLeft onKeyPressOK onKeyPressRewind onKeyPressRight onKeyPressUp onLongPressFinish onLongPressStart onMount onUnmount onWillAddToAggregateView onWillApplyStateChanges onWillRemoveFromAggregateView performViewManagerLayoutChildren present reconcileChildren recycle registerControlWithErrorMessage registerControlWithKnownError release removeChild removeRowByIndex removeSubView render renderCurrentRow renderVisibleRows setContent setDataSource setError setField setLayoutField setObservableField setShowOnScreen setState showDialog unobserveObservableObjects updateFocusTracker updateFocusTrackingFields updateRowVisibility wakeView

    Constructors

    Properties

    __isMemoizedStateValid: boolean = false
    _cacheKey: string = ''

    The current data source instance.

    _hid: string
    _isInFocusChain: boolean = false
    _rendereredTranslation: [number, number] = ...
    activeStyleViewStatus: ViewStatus = ViewStatus.Normal
    aggregateView: undefined | IAggregateView.IAggregateView

    IHosannaView


    animateToItemIndex: number = -1

    Index to animate to for items.

    animateToRowIndex: number = -1

    Index to animate to for rows.

    audioGuideHint?: string = ''

    This hint can be used in conjunction with the audio guide item

    audioGuideItem?: string | IAudioGuideItem
    cachedEvent: CollectionViewEvent = ...

    Cached event object for event dispatching.

    calculatedHeight: number = 0
    calculatedWidth: number = 0
    calculatedX: number = 0
    calculatedY: number = 0
    canReceiveFocus: boolean = true

    Indicates whether the element can receive focus.

    children: BaseView.BaseView<ViewState, ISGNGroup>[] = []

    These are the children that are rendered on screen in the tree structure of the view

    childrenChanged: boolean = false
    clippingRect: number[] = ...
    collectionViewFocusManager: CollectionViewFocusManager.CollectionViewFocusManager = ...

    Focus manager for the collection view.

    compositeView: boolean = true

    Indicdates whether the view is a focus group which means it can have a focused child Otherwise it will be focused itself

    container: ISGNGroup = ...

    The root container group for the collection view.

    currentIndex: number = -1

    Current index for rendering.

    customData?: unknown

    The data source for the collection view.

    defaultValues: Partial<CollectionViewState> = {}
    direction: number = 1

    Direction of navigation (1 for down/right, -1 for up/left).

    distanceToTravel: number = 0

    The distance that needs to be traveled to reach the next virtual item. This value is used to determine how far an element should move.

    dummyContent: any

    Dummy content for testing or placeholder.

    eventHandlers: Record<string, Function> = {}
    fastScrollSpeed: number = 4
    firstVisibleRow: number = 0

    The index of the first visible row.

    focusedChildId?: string
    focusedItemIndex: number = 0

    The currently focused item index within the focused row.

    focusedRowIndex: number = 0

    The currently focused row index.

    focusId: string = ''
    focusIndicatorTranslation?: [number, number] = ...
    height: number = 0
    id: string = ''
    includeInLayout: boolean = true
    index: number = -1

    Current row index.

    initialFocusId: string = ''

    Injected instance pool for row reuse.

    isActive: boolean = true

    Whether the view is active.

    isContentSet: boolean = false

    Whether content has been set.

    isFast: boolean = false

    Event Loops


    isFastScroll: boolean = false
    isFocused: boolean = false

    Indicates whether the element is currently focused.

    isLayoutDirty: boolean = false
    isPresented: boolean = false

    If true, this view has been presented in an AggregateViewController

    isRendered: boolean = false

    Whether the collection view has been rendered.

    isSkeleton: boolean = false
    isWaking: boolean = false
    lastFocusedVirtualPosition: number = 0

    Stores 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.

    lastRowKeyPress: Key = Key.None

    Last key pressed on a row.

    lastVisibleRow: number = 0

    The index of the last visible row.

    nextRowIndex: number = 0

    The index of the next row to be processed or rendered. This is used to keep track of the current position in the collection view.

    nextViewId: number = 0
    nextVirtualPosition: number = 0

    The 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.

    nodePool: INodePool
    numberOfItems: number = 0

    Number of items (rows) in the collection view.

    onItemFocus?: ViewEventHandler<CollectionViewEvent>

    Handler for item focus events.

    onItemSelected?: ViewEventHandler<CollectionViewEvent>

    Handler for item selected events.

    onRowFocus?: ViewEventHandler<CollectionViewEvent>

    Handler for row focus events.

    opacity: number = 1.0
    parent?: IHosannaView<ViewState> = undefined

    The parent focusable element, if any.

    partialRendererHibernatedState: Partial<CollectionViewState> = {}
    renderChangeEvent: ApplyChangesRenderEvent = ...

    An event object that describes the changes to be rendered in the collection view.

    rotation: number = 0

    Array of row instances.

    scale: number[] = ...
    scaleRotateCenter: number[] = ...
    scrollablePositionX: undefined | number = undefined
    scrollablePositionY: undefined | number = undefined
    selectedIndices: number[] = ...

    Currently selected row and item indices.

    speed: number = 3

    Animation speed for row transitions.

    startIndex: number = -1

    Start index for animations.

    staticType: ViewStaticType = ViewStaticType.None
    styleRegistry: IStyleRegistry
    subViews: BaseView.BaseView<ViewState, ISGNGroup>[] = []

    These are the children that were created in getViews, in a flat strcuture - it contains EVERYTHING that we declared.

    subViewsChanged: boolean = false
    targetIndex: number = -1

    Target index for animations.

    translation: number[] = ...
    viewOwner: IHosannaView<ViewState>

    The IHosannaView subclass that created us in getViews

    viewportHeight: number = 1080

    The height of the viewport for visible rows.

    viewStatus: ViewStatus = ViewStatus.Normal
    virtualY: number = 0

    The current virtual Y position (scroll offset).

    visible: boolean = true

    Indicates whether the navigatable entity is visible.

    visibleRows: any[] = []

    Array of currently visible rows.

    width: number = 0

    Accessors

    Methods

    • Animates the view between the start index and the target index.

      Parameters

      • delta: number

        The time delta since the last animation step.

      Returns void

    • Builds the view and attaches it to the view owner.

      Parameters

      • struct: ViewStruct<ViewState>
      • OptionalmountTarget: IHosannaView<ViewState>

        The target to mount the view.

      • childIndex: number = -1

      Returns undefined | IHosannaView<ViewState>

      The built view or undefined.

    • Calculates 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.

      Returns { firstVisible: number; lastVisible: number }

      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.
    • Dispatches an item selected event.

      Parameters

      • rowIndex: number

        The row index.

      • OptionalitemIndex: number

        The item index.

      Returns void

    • Easing function for smooth animation.

      Parameters

      • currentTime: number

        The current animation time.

      • startValue: number

        The starting value.

      • changeInValue: number

        The change in value.

      • duration: number

        The duration of the animation.

      Returns number

      The eased value.

    • Finds 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.

      Parameters

      • virtualY: number

        The virtual Y position to find the first visible row for.

      Returns number

      The index of the first visible row, clamped between 0 and the number of items minus one.

    • Parameters

      • nextStructs: ViewStruct<ViewState>[]
      • map: Record<string, ViewStruct<ViewState>> = {}
      • idList: { childIndex: number; id: string }[] = []

      Returns {
          idList: { childIndex: number; id: string }[];
          mappedNextStructs: Record<string, ViewStruct<ViewState>>;
      }

    • Calculates the focus percentage based on the current virtual position and the distance to travel.

      Returns number

      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.

      Returns undefined | IHosannaView<ViewState>

      The focused Hosanna view, or undefined.

    • Gets the next row index for a key press.

      Parameters

      • key: Key

        The key pressed.

      • isLongPress: boolean

        Whether the key press is a long press.

      Returns any

      The next row index, or -1 if not handled.

    • Instantly jumps to the specified row index without animation. Updates virtualY, focus, and row visibility immediately.

      Parameters

      • index: number

        The target row index.

      • force: boolean = false

      Returns void

    • Handles a row key press event.

      Parameters

      • key: Key

        The key pressed.

      • isLongPress: boolean

        Whether the key press is a long press.

      • isLongPressRelease: boolean

      Returns boolean

      True if handled, false otherwise.

    • Invalidates the current layout starting from the specified row index. Recalculates renderedListPosition for each row and triggers rendering if needed.

      Parameters

      • firstRowIndex: number = 0

        The index of the first row to start invalidating from.

      Returns void

    • Determines if the current row handles the given key press.

      Parameters

      • key: Key

        The key pressed.

      • isLongPress: boolean

        Whether the key press is a long press.

      Returns any

      True if handled, false otherwise.

    • Handles the animation to a specific row index within the collection view.

      Parameters

      • index: number

        The target row index.

      • fast: boolean = false

      Returns void

    • Animates the view to the specified item index within the currently focused row.

      Parameters

      • index: number

        The item index.

      • fast: boolean = false

      Returns void

    • Handles the Down key press.

      Parameters

      • isLongPress: boolean
      • isLongPressRelease: boolean

      Returns boolean

      True if handled, false otherwise.

    • Handles the Left key press.

      Parameters

      • isLongPress: boolean
      • isLongPressRelease: boolean

      Returns boolean

      True if handled, false otherwise.

    • Handles the Right key press.

      Parameters

      • isLongPress: boolean
      • isLongPressRelease: boolean

      Returns boolean

      True if handled, false otherwise.

    • Handles the Up key press.

      Parameters

      • isLongPress: boolean
      • isLongPressRelease: boolean

      Returns boolean

      True if handled, false otherwise.

    • Presents a new screen in the navigation stack or as a dialog.

      Parameters

      • screen: ViewStruct<ViewState>

        The screen to be presented, represented by a ViewStruct<ViewState>.

      • Optionaloptions: IScreenPresentationOptions

        Optional presentation options.

        • isDialog

          If true, the screen will be presented as a dialog.

        • animated

          If true, the screen transition will be animated.

      Returns void

    • Private

      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:

      1. Determines the first visible row by finding the row at the current scroll position.
      2. Iterates through the rows to determine the last visible row based on the viewport height.
      3. Clears the visibleRows array.
      4. Renders each row that is within the visible range.

      Returns void

    • Updates 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.

      Parameters

      • percentToNextRow: number

        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.

      Returns void

    • Private

      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.

      Returns void

      • If there are no rows, a warning is logged and the method returns early.
      • If the next row index is out of bounds, a warning is logged and the method returns early.
    • Updates 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.

      Returns void