Utilização

Scroll a list in a test.

Este tipo é usado por List

tsx
// Scroll a list in a test.
import { List, Text } from 'kuito';
import { assert, render, screen, scroll, test } from 'kuito/tests';

const rows = Array.from({ length: 200 }, (_, index) => `Row ${index}`);

const Long = () => <List data={rows} renderItem={({ item }) => <Text height={44}>{item}</Text>} />;

test('rows far down bind once the list scrolls to them', async () => {
  await render(<Long />);

  assert.equal(screen.queryByText('Row 150'), null);

  await scroll(screen.getByText('Row 0'), { y: 150 * 44 });

  assert.ok(screen.getByText('Row 150'));
});

Declaração do tipo

ts
export interface ListProps<T> extends Omit<
  ScrollProps,
  'children' | 'ref' | 'paging' | 'snapOffsets' | 'onScrollEnd'
> {
  /** The items, or a signal of them. */
  data: Prop<readonly T[]>;
  renderItem: (info: ListItem<T>) => KuitoNode;
  /** A unique key per item; defaults to `item.key`, then `item.id`, then the index. */
  itemKey?: (item: T, index: number) => string;
  /** The item's section: each run of items with the same section gets a header row. */
  sectionKey?: (item: T, index: number) => string;
  /** Renders a section's header row, given its section and its first item. */
  renderSection?: (info: { section: string; item: T }) => KuitoNode;
  /** Section headers stay at the top while their section scrolls under them; vertical lists only. */
  stickySections?: boolean;
  separator?: Slot;
  header?: Slot;
  footer?: Slot;
  /** Rendered instead of the rows when `data` is empty. */
  empty?: Slot;
  /** Lays items out in rows of this many; `gap` spaces both directions. */
  columns?: number;
  /** Starts at the end, with the first item at the bottom (or the right). */
  inverted?: boolean;
  /** Scrolls to this item when the list first shows it; no `getItemLayout` needed. */
  initialIndex?: number;
  /** The length of a row not measured yet; the average measured row by default. */
  estimatedItemSize?: number;
  onViewableChange?: (info: {
    viewableItems: ViewableItem<T>[];
    changed: ViewableItem<T>[];
  }) => void;
  viewability?: Viewability;
  ref?: ElementRef<ListHandle>;
}

Membros 120

NomeTipoObrigatórioDescrição
dataProp<readonly T[]>SimThe items, or a signal of them.
renderItem(info: ListItem<T>) => KuitoNodeSim—
itemKey(item: T, index: number) => stringNãoA unique key per item; defaults to item.key, then item.id, then the index.
sectionKey(item: T, index: number) => stringNãoThe item's section: each run of items with the same section gets a header row.
renderSection(info: { section: string; item: T;}) => KuitoNodeNãoRenders a section's header row, given its section and its first item.
stickySectionsbooleanNãoSection headers stay at the top while their section scrolls under them; vertical lists only.
separatorSlotNão—
headerSlotNão—
emptySlotNãoRendered instead of the rows when data is empty.
columnsnumberNãoLays items out in rows of this many; gap spaces both directions.
invertedbooleanNãoStarts at the end, with the first item at the bottom (or the right).
initialIndexnumberNãoScrolls to this item when the list first shows it; no getItemLayout needed.
estimatedItemSizenumberNãoThe length of a row not measured yet; the average measured row by default.
onViewableChange(info: { viewableItems: ViewableItem<T>[]; changed: ViewableItem<T>[];}) => voidNão—
viewabilityViewabilityNão—
refElementRef<ListHandle>Não—
scrollbarProp<boolean>NãoShows the scrollbar while scrolling; true by default.
opacityAnimatable<number>Não—
backgroundColorAnimatable<string>Não—
borderRadiusAnimatable<number>Não—
borderColorAnimatable<string>Não—
widthAnimatable<SizeValue>Não—
heightAnimatable<SizeValue>Não—
translateXAnimatable<number>Não—
translateYAnimatable<number>Não—
scaleAnimatable<number>Não—
scaleXAnimatable<number>Não—
scaleYAnimatable<number>Não—
rotateAnimatable<number>NãoDegrees.
shadowColorAnimatable<string>Não—
shadowRadiusAnimatable<number>Não—
shadowOffsetXAnimatable<number>Não—
shadowOffsetYAnimatable<number>Não—
hiddenProp<boolean>NãoTakes the view out of layout and off screen, as CSS display: none.
paddingProp<LengthPercentage>Não—
positionProp<"relative" | "absolute">Não—
idstringNão—
classProp<ClassNames>NãoClass names from a .css import or styles(): a string, or a list with falsy entries skipped, following the signals it reads.
styleStyleDeclarationsNãoStyles of this view alone, compiled at build time: CSS properties in camelCase. A value that changes must set a native prop (opacity).
onPress(event: PressEvent) => voidNão—
onPressCapture(event: PressEvent) => voidNão—
keystring | numberNão—
paddingTopProp<LengthPercentage>Não—
paddingRightProp<LengthPercentage>Não—
paddingBottomProp<LengthPercentage>Não—
paddingLeftProp<LengthPercentage>Não—
minWidthProp<SizeValue>Não—
maxWidthProp<SizeValue>Não—
minHeightProp<SizeValue>Não—
maxHeightProp<SizeValue>Não—
aspectRatioProp<number>NãoWidth divided by height; sizes the missing side from the other.
topProp<LengthPercentageAuto>Não—
rightProp<LengthPercentageAuto>Não—
bottomProp<LengthPercentageAuto>Não—
leftProp<LengthPercentageAuto>Não—
marginProp<LengthPercentageAuto>Não—
marginTopProp<LengthPercentageAuto>Não—
marginRightProp<LengthPercentageAuto>Não—
marginBottomProp<LengthPercentageAuto>Não—
marginLeftProp<LengthPercentageAuto>Não—
flexGrowProp<number>Não—
flexShrinkProp<number>Não—
flexBasisProp<SizeValue | "content">Não—
flexProp<number>NãoA grow factor from a zero basis, as CSS flex: n; 0 is inflexible.
alignSelfProp<"auto" | SelfAlignment>Não—
directionProp<"ltr" | "rtl">NãoThe way lines run; unset, the parent's, and the app's first language's at the root.
boxSizingProp<"border-box" | "content-box">Não—
paddingInlineStartProp<LengthPercentage>NãoPadding on the side lines start from: the left in ltr, the right in rtl.
paddingInlineEndProp<LengthPercentage>NãoPadding on the side lines end at: the right in ltr, the left in rtl.
marginInlineStartProp<LengthPercentageAuto>NãoMargin on the side lines start from: the left in ltr, the right in rtl.
marginInlineEndProp<LengthPercentageAuto>NãoMargin on the side lines end at: the right in ltr, the left in rtl.
insetInlineStartProp<LengthPercentageAuto>Nãoleft in ltr, right in rtl.
insetInlineEndProp<LengthPercentageAuto>Nãoright in ltr, left in rtl.
roleProp<Role>Não—
onAction(event: AccessibilityActionEvent) => voidNãoThe screen reader action taken, by name.
accessibleProp<boolean>NãoMakes the view one screen reader element, read as its label or its children's text.
labelProp<string>NãoWhat a screen reader says for the view.
hintProp<string>NãoWhat happens when the view is activated, read after the label.
aria-hiddenProp<boolean>NãoScreen readers skip the view and its subtree.
actionsProp<readonly AccessibilityAction[]>NãoActions a screen reader offers; onAction receives the one taken.
liveProp<"off" | "polite" | "assertive">NãoARIA's aria-live: announces changes to the view's content, on iOS too.
aria-disabledProp<boolean>Não—
aria-selectedProp<boolean>Não—
aria-checkedProp<boolean | "mixed">Não—
aria-busyProp<boolean>Não—
aria-expandedProp<boolean>Não—
aria-valueminProp<number>Não—
aria-valuemaxProp<number>Não—
aria-valuenowProp<number>Não—
aria-valuetextProp<string>Não—
gesturesreadonly Composable[]NãoThe view's gestures; several race unless composed with together or orElse.
transitionPartial<Record<"opacity" | "backgroundColor" | "transform" | "borderRadius" | "borderColor" | "shadow" | "width" | "height" | "all", Animation<unknown> | AnimationSpec>>NãoHow the animatable props move when they change, enter or leave, by group; a CSS transition compiles to it.
animatePartial<Record<AnimatableProps, string | number>>NãoAnimatable props whose every change moves as transition says; the first value applies at once.
enterEffectNãoWhere the view enters from: fade.and(slide.up(12)).
exitProp<Effect>NãoWhere the view leaves to; it stays on screen until it is there. The renderer gets true, and keeps the view until exited.
layoutAnimation<number>NãoHow the view moves to a new frame the layout gives it: layout={spring()}.
overflowProp<"visible" | "hidden" | "clip" | "scroll">Nãohidden and scroll clip; as in CSS, either lets a flex item shrink below its content.
borderWidthProp<number>Não—
backgroundGradient{ angle: number; colors: string[];}Não—
colorProp<string>Não—
sharedIdProp<string>NãoA view the navigation stack flies to the view with the same sharedId on the screen it pushes or pops to (docs/navigation.md#shared-elements).
alignItemsProp<SelfAlignment>Não—
justifyContentProp<ContentAlignment>Não—
gapProp<LengthPercentage>Não—
rowGapProp<LengthPercentage>Não—
columnGapProp<LengthPercentage>Não—
flexDirectionProp<"row" | "column" | "row-reverse" | "column-reverse">Não—
flexWrapProp<"nowrap" | "wrap" | "wrap-reverse" | "balance">Não—
flexLineCountProp<number>NãoThe minimum number of lines a wrapping container breaks into (CSS Flexbox 2).
alignContentProp<ContentAlignment>Não—
keyboardProp<{ dismiss?: "none" | "on-drag" | "interactive"; persistTaps?: "never" | "always" | "handled"; inset?: boolean; avoid?: "none" | "padding" | "position";}>Não—
horizontalProp<boolean>NãoScrolls sideways; changing it remounts the view, as the native axis is fixed.
motionScrollMotionNãoMoves with the view every frame on the UI thread: scrollMotion(), given to one view.
onScroll(event: ScrollEvent) => voidNão—
onReachEnd(event: KuitoEvent<"reachend">) => voidNãoCalled once each time the content end comes within the threshold.
onRefresh(event: KuitoEvent<"refresh">) => voidNãoEnables pull-to-refresh.
scrollIntervalProp<number>NãoAt most one scroll event per this many milliseconds; 50 by default.
reachEndThresholdProp<number>NãoDistance from the end, in visible lengths, that counts as the end; 0.5 by default.
refreshingBound<boolean>NãoShows the pull-to-refresh spinner while true.
renderItem — assinaturas de método

Assinaturas

ts
(info: ListItem<T>): KuitoNode

Parâmetros

NomeTipoObrigatórioDescrição
infoListItem<T>Sim—

Devolve

KuitoNode

itemKey — assinaturas de método

Assinaturas

ts
(item: T, index: number): string

Parâmetros

NomeTipoObrigatórioDescrição
itemTSim—
indexnumberSim—

Devolve

string

sectionKey — assinaturas de método

Assinaturas

ts
(item: T, index: number): string

Parâmetros

NomeTipoObrigatórioDescrição
itemTSim—
indexnumberSim—

Devolve

string

renderSection — assinaturas de método

Assinaturas

ts
(info: { section: string; item: T; }): KuitoNode

Parâmetros

NomeTipoObrigatórioDescrição
info{ section: string; item: T;}Sim—

Devolve

KuitoNode

onViewableChange — assinaturas de método

Assinaturas

ts
(info: { viewableItems: ViewableItem<T>[]; changed: ViewableItem<T>[]; }): void

Parâmetros

NomeTipoObrigatórioDescrição
info{ viewableItems: ViewableItem<T>[]; changed: ViewableItem<T>[];}Sim—

Devolve

void

onPress — assinaturas de método

Assinaturas

ts
(event: PressEvent): void

Parâmetros

NomeTipoObrigatórioDescrição
eventPressEventSim—

Devolve

void

onPressCapture — assinaturas de método

Assinaturas

ts
(event: PressEvent): void

Parâmetros

NomeTipoObrigatórioDescrição
eventPressEventSim—

Devolve

void

onAction — assinaturas de método

Assinaturas

ts
(event: AccessibilityActionEvent): void

Parâmetros

NomeTipoObrigatórioDescrição
eventAccessibilityActionEventSim—

Devolve

void

backgroundGradient — campos aninhados

backgroundGradient campos

NomeTipoObrigatórioDescrição
anglenumberSim—
colorsstring[]Sim—
onScroll — assinaturas de método

Assinaturas

ts
(event: ScrollEvent): void

Parâmetros

NomeTipoObrigatórioDescrição
eventScrollEventSim—

Devolve

void

onReachEnd — assinaturas de método

Assinaturas

ts
(event: KuitoEvent<"reachend">): void

Parâmetros

NomeTipoObrigatórioDescrição
eventKuitoEvent<"reachend">Sim—

Devolve

void

onRefresh — assinaturas de método

Assinaturas

ts
(event: KuitoEvent<"refresh">): void

Parâmetros

NomeTipoObrigatórioDescrição
eventKuitoEvent<"refresh">Sim—

Devolve

void

Gerado a partir das declarações TypeScript públicas: assinaturas, props e predefinições vêm da fonte verificada, as descrições da sua JSDoc. Nenhuma predefinição é inventada.