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

    Class BaseView<T, R>

    The BaseView class is a generic class that represents a base view in the Hosanna UI framework. It provides a foundation for creating custom views by managing state, layout, and rendering.

    It implements several interfaces including IFocusable, ILayoutable, IHosannaView

    This class manages the state and layout of a view, handles focus and key events, and supports rendering and updating the view. It maintains parent-child relationships for both the view tree and on-screen rendering. The class also provides methods for setting and applying state changes, laying out children, inflating view structures, and reconciling children based on the next view structures.

    The BaseView class uses decorators for dependency injection and state management, and it interacts with the ViewManager and ViewBuilder for managing and building views. It also supports debug information retrieval and navigation support.

    Type Parameters

    Hierarchy (View Summary)

    Implements

    • IHosannaView<T>
    • IIdentifiable
    Index

    Constructors

    Properties

    Accessors

    Methods

    addChild addChildren addRendererToParentViewRenderer addSubView animateViews applyFocusedChildResolution applyIdsToViewStructs applyInitialState applyLayoutStateToNativeRenderer applyStateChanges bringChildInFrontOfChild bringChildToFront buildLayoutStateForWakingNativeRenderer buildView calculateBoundsCenterDistance canChangeOrientation canMeasureBounds clearErrorByErrorField clearErrors configureAudioGuideItem containsChild createDataEvent dismiss dispatch dispatchAction dispatchAsync dispatchSelection enableSkeletonMode findNearestDirectChild findNextFocusable findNextFocusableView findNextFocusableViewByDirection getAnimationPropsForStateProperty getAudioGuideItem getBounds getBoundsInApp getBoundsInParent getChangedField getChildView getCustomData getField getFlattenedStructs getFlattenedStructsById getFocusEntryStrategy getNavController getObservableField getPointInLocalCoordinates getSubView getSubViewRenderer getViewById hibernateView inflateViewStructs insertChild insertChildAfterOtherChild insertChildBeforeOtherChild insertSubView invalidateLayout invalidateParentLayout isBoundsInDirection isDescendantOf isErrorExists isInFocusChain layoutAt layoutChildren markStateDirtyForViewManager mountInsertedChild notifyOnFocusedChildChange onAppear onAppearAgain onBlur onDidAddToAggregateView onDidAppearInAggregateView onDidChangeOrientation onDidReappearInAggregateView onDidRemoveFromAggregateView onDisappear onDisappearFromAggregateView onFirstAppear onFocus onInputEvent onMount onUnmount onWillAddToAggregateView onWillApplyStateChanges onWillChangeOrientation onWillRemoveFromAggregateView onWillReuse performViewManagerLayoutChildren present printViewStructDebugInfo reconcileChildren recycle registerControlWithErrorMessage registerControlWithKnownError release releaseStructOnce removeChild removeSubView render requestFocusedChild resolveFirstFocusableDirectChildId resolveFocusEntryTarget resolveInsertIndexAfterReplacingAt resolveLastFocusableDirectChildId sendChildBehindOtherChild sendChildToBack setChildIndex setError setField setLayoutField setObservableField setShowOnScreen setState showDialog unobserveObservableObjects wakeView

    Constructors

    Properties

    __isMemoizedStateValid: boolean = false
    _cacheKey: string = ''
    _hid: string
    _isInFocusChain: boolean = false
    _renderer: undefined | R
    _viewPhase: ViewPhase = ViewPhase.Initial
    activeAnimation?: HosannaViewAnimator

    If present, an animation currently targeting this view (or its subviews).

    activeStyleViewStatus: ViewStatus = ViewStatus.Normal
    aggregateView: undefined | IAggregateView.IAggregateView

    IHosannaView


    appConfig: IAppConfig
    audioGuideHint?: string = ''

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

    audioGuideItem?: string | IAudioGuideItem
    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[] = ...
    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

    customData?: unknown
    defaultValues: Partial<T> = {}
    eventHandlers: Record<string, Function> = {}
    focusedChildId?: string
    focusId: string = ''
    height: number = 0
    id: string = ''
    includeInLayout: boolean = true
    initialFocusId: string = ''
    instancePool: IInstancePool
    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

    isReconcilingChildren: boolean = false

    True while reconcileChildren is swapping this view's children. Focus recovery for a removed focused child is deferred until the swap completes — restoring mid-reconcile cannot resolve getInitialFocusId because the replacement views are not mounted yet.

    isSkeleton: boolean = false
    isSkeletonMode: boolean = false
    isWaking: boolean = false
    keyboardAvoidance: "none" | "auto" = 'auto'

    Automatic keyboard avoidance opt-out. When a software keyboard appears, the framework translates the visible screen to keep the editing input in view; set 'none' on the screen or the input to disable. Plain field (not reactive) — checked at keyboard-show time.

    nativeGlass: undefined | SGNativeGlassEffect = undefined
    nextViewId: number = 0
    nodePool: INodePool
    opacity: number = 1.0
    parent?: IHosannaView<ViewState> = undefined
    partialRendererHibernatedState: Partial<T> = {}
    pendingFocusRecoveryAfterReconcile: boolean = false

    Set when a focused child was removed mid-reconcile; consumed at reconcile end.

    releasedStructsThisBatch: undefined | Record<string, boolean> = undefined

    Tracks structs released this inflate batch to prevent double-release when same struct appears twice (e.g. pool corruption). Uses Record for efficiency (avoids Set allocation, faster lookups on Roku).

    rotation: number = 0
    scale: number[] = ...
    scaleRotateCenter: number[] = ...
    scrollablePositionX: undefined | number = undefined
    scrollablePositionY: undefined | number = undefined
    staticType: ViewStaticType = ViewStaticType.None
    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
    translation: number[] = ...
    viewOwner: IHosannaView<ViewState>

    The IHosannaView subclass that created us in getViews

    viewStatus: ViewStatus = ViewStatus.Normal
    visible: boolean = true

    Indicates whether the navigatable entity is visible.

    width: number = 0

    Accessors

    • get _rendereredTranslation(): [number, number]

      Returns [number, number]

    • set _rendereredTranslation(value: [number, number]): void

      Parameters

      • value: [number, number]

      Returns void

    • get renderer(): undefined | R

      Returns undefined | R

    • set renderer(value: undefined | R): void

      Parameters

      • value: undefined | R

      Returns void

    • get viewPhase(): ViewPhase

      Returns ViewPhase

    • set viewPhase(phase: ViewPhase): void

      Parameters

      Returns void

    Methods


    • Children


      Parameters

      • child: IHosannaView<ViewState>
      • OptionalmountTarget: IHosannaView<ViewState>

      Returns void

    • Parameters

      • children: IHosannaView<ViewState>[]

      Returns void

    • Parameters

      • parent: undefined | IHosannaView<ViewState>
      • childIndex: number = -1

      Returns void


    • View Creation


      Parameters

      • view: IHosannaView<ViewState>

      Returns void

    • Convenience: animate logical properties across this view's subtree.

      Parameters

      • anims: AnimationSpec

        Animation specification mapping view IDs to their target property values

      • duration: number

        Animation duration in milliseconds

      • OptionalonCompleted: () => void

        Optional callback invoked when animation completes

      • Optionaloptions: Partial<AnimationOptions>

        Extra animation options; duration and useCurrentState here are ignored (see HosannaViewAnimator.animateViews).

      Returns HosannaViewAnimator

    • Applies a resolved child id: setFocus when in the focus chain, else stores focusedChildId.

      Parameters

      • resolvedId: string

      Returns void

    • Parameters

      • nextViewStructs: undefined | ViewStruct<ViewState>[]
      • parentId: string = ""
      • level: number = 0

      Returns void

    • Parameters

      • state: Partial<T>

      Returns void

    • Parameters

      • state: Partial<T>

      Returns void

    • Parameters

      • OptionalnextState: T

      Returns void

    • Parameters

      • child: IHosannaView<ViewState>
      • otherChild: IHosannaView<ViewState>

      Returns void

    • Parameters

      • child: IHosannaView<ViewState>

      Returns void

    • Returns Partial<T>

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

    • Parameters

      • bounds1: I2DRectangle
      • bounds2: I2DRectangle

      Returns number

    • Parameters

      • _event: HosannaOrientationChangeEvent

      Returns boolean

    • Parameters

      • errorField: IDebugErrorFieldMap

      Returns void

    • Returns void

    • Parameters

      • child: IHosannaView<ViewState>

      Returns boolean

    • Parameters

      • Optionaloptions: IScreenDismissOptions

      Returns void

    • Type Parameters

      • T

      Parameters

      • command: string
      • Optionalargs: Record<string, unknown>
      • OptionalcancellationToken: HsCancellationToken
      • OptionaltaskId: string

      Returns HsPromise<T>

    • Parameters

      • enabled: boolean

      Returns void

    • Parameters

      • originBounds: I2DRectangle
      • direction: api.Direction
      • requireDirection: boolean
      • originView: IHosannaView<ViewState>

      Returns undefined | BaseView.BaseView<ViewState, ISGNGroup>

    • Resolves the next focusable element in the given direction.

      Parameters

      Returns undefined | IFocusable | NextViewFocus

      The next focusable element, or undefined if none exists.

    • Default animation provider mapping for simple properties. By default, maps 'opacity' to the base renderer's 'opacity' field. Views can override to provide richer mappings.

      Parameters

      • prop: string

      Returns undefined | AnimationFieldBinding[]


    • Audio guide support

      Returns undefined | IAudioGuideItem


    • Measurement


      Returns I2DRectangle

    • Returns I2DRectangle

    • Parameters

      • otherView: IHosannaView<ViewState>

      Returns I2DRectangle

    • Parameters

      Returns undefined | string

    • Type Parameters

      • T extends IHosannaView<ViewState>

      Parameters

      • id: string

      Returns undefined | T

    • Type Parameters

      • T

      Returns T

    • Type Parameters

      • K extends string | number | symbol

      Parameters

      • field: K

      Returns any

    • Parameters

      • nextStructs: ViewStruct<ViewState>[]

      Returns ViewStruct<ViewState>[]

    • 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>>;
      }

    • Returns undefined | GroupFocusEntryStrategy

    • Returns undefined | INavController


    • Obserbable support

      Parameters

      • key: string
      • resolvedIdentifier: string

      Returns HsObservable

    • Parameters

      • point: { x: number; y: number }

      Returns { x: number; y: number }


    • Rendererers


      Type Parameters

      • T extends IHosannaView<ViewState>

      Parameters

      • id: string
      • isDeepSearch: boolean = false

      Returns undefined | T

    • Type Parameters

      Parameters

      • id: string

      Returns undefined | T

    • Type Parameters

      • T extends IHosannaView<ViewState>

      Parameters

      • id: string

      Returns undefined | T

    • Hibernates the view and its subviews by releasing native renderers and setting the view phase to Hibernating.

      Returns void

    • Parameters

      • nextViewStructs: ViewStruct<ViewState>[]

      Returns void

    • Parameters

      • child: IHosannaView<ViewState>
      • OptionalmountTarget: IHosannaView<ViewState>
      • index: number = -1

      Returns void

    • Parameters

      • child: IHosannaView<ViewState>
      • otherChild: IHosannaView<ViewState>

      Returns void

    • Parameters

      • child: IHosannaView<ViewState>
      • otherChild: IHosannaView<ViewState>

      Returns void

    • Parameters

      • view: IHosannaView<ViewState>

        The view to be added as a subview.

      • index: number = -1

        index of the child in the parent view, -1 means add to end

      Returns void

    • Returns void

    • Returns void

    • Parameters

      • fromBounds: I2DRectangle
      • toBounds: I2DRectangle
      • direction: api.Direction

      Returns boolean

    • Parameters

      • view: IHosannaView<ViewState>

      Returns boolean

    • Parameters

      • __namedParameters: IDebugErrorObject

      Returns boolean


    • Focus


      Returns boolean

    • Parameters

      • x: number
      • y: number
      • parentWidth: number
      • parentHeight: number

      Returns void

    • Returns void

    • Returns void

    • Parameters

      • child: IHosannaView<ViewState>
      • mountTarget: undefined | IHosannaView<ViewState>
      • mountIndex: number
      • logMountDebug: boolean

      Returns void

    • Parameters

      • event: FocusChildChangeEvent

      Returns void

    • Called when this view becomes the visible top again after having been covered by another screen on the same NavController (same transition finish as onAppear, immediately after it).

      Returns void

      Prefer overriding onDidReappearInAggregateView; default implementation chains from it.

    • DO NOT CALL THIS METHOD DIRECTLY DO NOT OVERRIDE IT

      Returns void

    • Called after the navigatable entity has been added to an aggregate view.

      Parameters

      Returns void

    • Parameters

      • _event: HosannaOrientationChangeEvent

      Returns void

    • Called when this view becomes the visible top again after having been covered by another screen on the same NavController. Default implementation delegates to onAppear and onAppearAgain.

      Parameters

      Returns void

    • Called after the navigatable entity has been removed from an aggregate view.

      Parameters

      Returns void

    • Returns void

      Prefer BaseView.onDisappearFromAggregateView when leaving an aggregate context during a transition. The framework still invokes this for other paths until migrated.

      IHosannaView.onDisappear

    • Called when this view is hidden during an aggregate transition or via BaseAggregateView.hideView. Default implementation delegates to onDisappear.

      Parameters

      Returns void

    • Called when this view becomes the visible top of a NavController stack for the first time for that controller (same transition finish as onAppear, immediately after it).

      Returns void

      Prefer overriding onDidAppearInAggregateView; default implementation chains from it.

    • DO NOT CALL THIS METHOD DIRECTLY DO NOT OVERRIDE IT

      Returns void

    • Handles an input event.

      Parameters

      Returns void


    • Lifecycle


      Parameters

      • parent: IHosannaView<ViewState> | BaseApp.BaseApp
      • childIndex: number = -1

      Returns void

    • Returns void

    • Called before the navigatable entity is added to an aggregate view.

      Parameters

      Returns void

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

      Returns void

    • Parameters

      • _event: HosannaOrientationChangeEvent

      Returns void

    • Called before the navigatable entity is removed from an aggregate view.

      Parameters

      Returns void

    • Called by InstancePool.get() before a pooled instance is handed out. Restores the view to a construction-equivalent state so that stale lifecycle data (focus, viewStatus, old text, dirty flags, etc.) from the previous owner does not bleed into the new one.

      Class-default

      Returns void

      values (captured on first construction into the InstancePool per-class-name registry) are placed into pendingState with state left empty — matching a freshly-constructed view. This guarantees that every subsequent setField call (in applyInitialState) detects a difference against the empty state and pushes the value into pendingState, so applyLayoutStateToNativeRenderer applies ALL layout props (opacity, visible, translation, …) to the newly-acquired renderer even when the logical value equals the class default.

    • Returns void

    • 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

    • Prints out view type and id of each struct in the nextViewStructs array.

      Parameters

      • nextViewStructs: undefined | ViewStruct<ViewState>[]

      Returns void

    • Parameters

      • nextStructs: ViewStruct<ViewState>[]

      Returns void


    • IReusable implementation


      Parameters

      • initialState: T

      Returns void

    • Parameters

      • message: string
      • errorField: IDebugErrorFieldMap

      Returns void

    • Parameters

      • message: string
      • errorField: IDebugErrorFieldMap

      Returns void

    • Returns void

    • Releases a struct to the pool once per inflate batch. Prevents double-release when same struct appears twice (id collision).

      Parameters

      • struct: ViewStruct<ViewState>

      Returns void

    • Parameters

      • child: IHosannaView<ViewState>

      Returns void

    • Parameters

      • view: IHosannaView<ViewState>

      Returns void

    • Parameters

      • changes: Partial<T>

      Returns void

    • Sets which direct child this composite prefers on the next focus cascade, or moves focus to that child if this view is already in the focus chain.

      • First / Last: first or last direct child in children order with canReceiveFocus && visible.
      • Default: clears focusedChildId only (next cascade uses getInitialFocusId()); does not call setFocus.
      • Specific: same behavior as setFocusedSubview for a known child id.

      Parameters

      • target: ChildFocusTarget
      • OptionalchildId: string

      Returns void

    • First direct child id in layout order that can receive focus and is visible.

      Returns undefined | string

    • After removing the child that was at oldIndex, returns the splice index for the replacement so ordering matches insertChild(..., requestedIndex) on the pre-removal children array (buildView / insert-before-after). requestedIndex === -1 keeps the replaced slot (same z-order position as the removed child).

      Parameters

      • oldIndex: number
      • requestedIndex: number
      • lengthAfterRemoval: number

      Returns number

    • Last direct child id in layout order that can receive focus and is visible.

      Returns undefined | string

    • Parameters

      • child: IHosannaView<ViewState>
      • otherChild: IHosannaView<ViewState>

      Returns void

    • Parameters

      • child: IHosannaView<ViewState>

      Returns void

    • Changes the visual z-order of a child by moving it to a new index. Higher indices render on top. Updates both the children array and the renderer. Requires removeChild before insertChild because the SG node's insertChild always adds (splices in) and does not move; calling it on an already-present child would duplicate.

      Parameters

      • child: IHosannaView<ViewState>
      • newIndex: number

      Returns void

    • Parameters

      • errorObj: IDebugErrorObject

      Returns void

    • Type Parameters

      • K extends string | number | symbol

      Parameters

      • field: K
      • value: T[K]

      Returns void

    • Type Parameters

      • K extends string | number | symbol

      Parameters

      • field: K
      • value: T[K]

      Returns void

    • Parameters

      • key: string
      • newVal: unknown

      Returns void


    • Navigatable View


      Parameters

      • shown: boolean

      Returns void

    • Parameters

      • state: Partial<T>

      Returns void

    • Parameters

      • dialog: ViewStruct<ViewState>

      Returns void

    • Returns void

    • Wakes up the view and its subviews by reserving native renderers and setting the view phase to Mounted.

      Returns void