import type { ComponentType } from 'react'; import type { IconProps } from '@unif/react-native-icons'; import type { ReactElement, ReactNode } from 'react'; import type { StyleProp, ViewStyle } from 'react-native'; export type CellTextValue = string | number | bigint; export type CellLeading = | ComponentType | { kind: 'display'; node: ReactElement }; export type CellExtra = | { kind: 'text'; value: CellTextValue } | { kind: 'display'; node: ReactElement; accessibilityText?: string; } | { kind: 'control'; node: ReactElement }; type ActionableExtra = Exclude; type StaticExtra = | Extract | { kind: 'display'; node: ReactElement; accessibilityText?: never; }; type SharedCellProps = { /** 主标题由库内 Text 安全渲染。 */ title: CellTextValue; /** 主标题的 numberOfLines(默认 1)。 */ titleLines?: number; /** 副标题由库内 Text 安全渲染。 */ desc?: CellTextValue; /** 图标组件或显式的纯展示前导节点。 */ leading?: CellLeading; /** 危险态:图标与标题使用 error 色,图标盒子保持同组底色;action arrow 不显示。 */ danger?: boolean; /** * 选中态:标题使用 primary 色,表示「列表里当前这一项」(会话列表的当前会话、 * 设置列表的当前选项等)。与 `danger` 互斥——同时给时 `danger` 优先, * 危险语义比选中语义更需要被看见。 */ selected?: boolean; /** 额外样式覆盖。 */ style?: StyleProp; /** E2E / 测试定位。 */ testID?: string; }; type ActionableCellProps = { onPress: () => void; extra?: ActionableExtra; arrow?: boolean; disabled?: boolean; /** 覆盖由 title、desc 与 extra 自动组合的 accessible name。 */ accessibilityLabel?: string; /** SR 操作结果说明。 */ accessibilityHint?: string; }; type ControlCellProps = { extra: Extract; onPress?: never; arrow?: never; disabled?: never; accessibilityLabel?: never; accessibilityHint?: never; }; type StaticCellProps = { extra?: StaticExtra; onPress?: never; arrow?: never; disabled?: never; /** * 覆盖整行的 accessible name。**不可点不等于不需要名称** —— 状态型行 * (「定位权限,已授权·始终允许」)靠 title / desc / extra 自动拼,读屏会拆成三段读, * 措辞与顺序都不受控。给了这个就把整行合成一个 a11y 节点、按指定文案播报。 * * Control 分支刻意**不**开放它:那种行里有 Switch 等可聚焦控件,整行 accessible * 会吞掉控件自己的焦点与状态播报。 */ accessibilityLabel?: string; accessibilityHint?: never; }; export type CellProps = SharedCellProps & (ActionableCellProps | ControlCellProps | StaticCellProps); export type ListProps = { /** 一组 Cell */ children: ReactNode; /** * `flush=true` 时不重复绘制玻璃材质,行直接放在透明背景上。 * 用于:嵌套在 Card 内 / 第一屏 hero 区下方等已有底色的场景。 */ flush?: boolean; /** flush 模式下行间分隔线样式,默认 `'full'`(铺满全宽 hairline) / `'none'` 不画 */ divider?: 'full' | 'none'; /** 额外样式覆盖 */ style?: StyleProp; /** E2E / 测试定位 */ testID?: string; };