import { // DefaultSectionT, // SectionList as RNSectionList, SectionListData, SectionListRenderItemInfo, StyleSheet, View, } from 'react-native'; import { useColors } from '../../hook'; import { Alert } from '../../ui/Alert'; import { SectionListFactory } from '../../ui/SectionList'; import { BottomSheetNameMenu } from '../BottomSheetMenu'; import type { IndexModel } from '../ListIndex'; import { EmptyPlaceholder, ErrorPlaceholder } from '../Placeholder'; import { SearchStyle } from '../SearchStyle'; import { useBlockList } from './BlockList.hooks'; import { BlockListNavigationBar } from './BlockList.navi'; import type { BlockListItemProps, BlockListProps } from './types'; const SectionList = SectionListFactory(); /** * The block list component mainly consists of four parts, including navigation component, search style component, individual list item component, and list component. Supports displaying bottom menu components and warning components. The navigation bar component can be set to display or not, customize the style, or even replace it as a whole. The search style component supports whether to display, and the individual list item component supports whether to display, add or replace any multiple components. List components support more property settings. */ export function BlockList(props: BlockListProps) { const { containerStyle, onBack, navigationBarVisible, customNavigationBar, searchStyleVisible, customSearch, onClickedSearch, isVisibleIndex = true, isVisibleItemHeader = true, } = props; const { ref, sections, indexTitles, onRefresh, refreshing, onMore, viewabilityConfig, onViewableItemsChanged, listState, AlphabeticIndex, onIndexSelected, onRequestCloseMenu, menuRef, alertRef, onClicked, onLongPressed, tr, ListItemRender, ListItemHeaderRender, sectionListProps, blockCount, onError, } = useBlockList(props); const { style, contentContainerStyle, refreshing: propsRefreshing, onRefresh: propsOnRefresh, onEndReached: propsOnEndReached, viewabilityConfig: propsViewabilityConfig, onViewableItemsChanged: propsOnViewableItemsChanged, showsVerticalScrollIndicator, ...others } = sectionListProps ?? {}; const { getColor } = useColors(); return ( {navigationBarVisible !== false ? ( ) : null} {searchStyleVisible !== false ? ( customSearch ? ( <>{customSearch} ) : ( { onClickedSearch?.(); }} /> ) ) : null} > ) => { const { item } = info; return ( ); }} keyExtractor={(item: BlockListItemProps) => { return item.id; }} renderSectionHeader={ isVisibleItemHeader === true ? (info: { section: SectionListData; }) => { const { section } = info; return ; } : undefined } onEndReached={propsOnEndReached ?? onMore} viewabilityConfig={propsViewabilityConfig ?? viewabilityConfig} onViewableItemsChanged={ propsOnViewableItemsChanged ?? onViewableItemsChanged } ListEmptyComponent={EmptyPlaceholder} ListErrorComponent={ listState === 'error' ? ( { onError?.(); }} /> ) : null } {...others} /> {isVisibleIndex === true && AlphabeticIndex ? ( ) : null} ); }