Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuever committed Dec 29, 2024
1 parent 7a57ad2 commit e009e84
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 106 deletions.
4 changes: 2 additions & 2 deletions core/dimensions-model/src/types/ListDimensionsModel.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
IMasonryDimensions,
IMasonryDimensionsModel,
} from '@infinite-list/types';
import { RecyclerProps } from '@infinite-list/strategies';
import { IDefaultKeyExtra } from '@infinite-list/utils';

export type GetItemSeparatorLength<ItemT> = (
Expand Down Expand Up @@ -42,6 +43,7 @@ export type OnListDimensionsModelDataChanged<
export interface ListDimensionsModelProps<
ItemT extends GenericItemT = GenericItemT
> extends ListBaseDimensionsProps,
RecyclerProps,
BaseDimensionsProps {
/**
* @template ItemT the generic data item type
Expand Down Expand Up @@ -84,8 +86,6 @@ export interface ListDimensionsModelProps<
*/
manuallyApplyInitialData?: boolean;

recyclerTypes?: Array<string>;

onListDimensionsModelDataChanged?: OnListDimensionsModelDataChanged<ItemT>;
}

Expand Down
1 change: 0 additions & 1 deletion core/strategies/src/RecycleStateImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class RecycleStateImpl<
(indexInfo as ListGroupIndexInfo<ItemT>)?.indexInGroup ||
indexInfo?.index;
if (typeof index !== 'number') {
console.log('meta ', meta);
console.error(
'[RecycleStateImpl error]: index should has a valid number ' +
'or will cause recycler not work correctly'
Expand Down
7 changes: 7 additions & 0 deletions core/strategies/src/types/stateHub.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ export type BaseStateImplProps<ItemT extends GenericItemT = GenericItemT> = {
export type SpaceStateImplProps<ItemT extends GenericItemT = GenericItemT> =
{} & BaseStateImplProps<ItemT>;

export type RecyclerProps = {
recyclerTypes?: string[];
recyclerBufferSize?: number;
recyclerReservedBufferPerBatch?: number;
onRecyclerProcess?: (type?: string, index?: number) => boolean;
};

export type RecycleStateImplProps<ItemT extends GenericItemT = GenericItemT> = {
recyclerTypes?: string[];
recyclerBufferSize?: number;
Expand Down
17 changes: 8 additions & 9 deletions examples/react-playground/src/app/group.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ const meta: Meta<typeof ListGroup> = {
// overflowY: 'auto',
}}
>
<ListGroup id="basic">
<ListGroup
id="basic"
initialNumToRender={0}
recyclerBufferSize={100}
recyclerReservedBufferPerBatch={50}
>
<GroupList
id="first"
initialNumToRender={0}
data={buildData(500)}
recyclerBufferSize={100}
recyclerReservedBufferPerBatch={50}
renderItem={(props: RenderItemInfo<Item>) => {
const { item } = props;
return (
Expand All @@ -50,15 +52,12 @@ const meta: Meta<typeof ListGroup> = {
</div>
);
}}
keyExtractor={defaultKeyExtractor as KeyExtractor<Item>}
keyExtractor={defaultKeyExtractor}
/>

<GroupList
id="second"
initialNumToRender={0}
data={buildData(500, 500)}
recyclerBufferSize={100}
recyclerReservedBufferPerBatch={50}
renderItem={(props: RenderItemInfo<Item>) => {
const { item } = props;

Expand All @@ -76,7 +75,7 @@ const meta: Meta<typeof ListGroup> = {
</div>
);
}}
keyExtractor={defaultKeyExtractor as KeyExtractor<Item>}
keyExtractor={defaultKeyExtractor}
/>
</ListGroup>
</div>
Expand Down
1 change: 0 additions & 1 deletion ui/group/src/react-native/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export { default as ListGroup } from './ListGroup';
export { default as GroupList } from '../common/GroupList';
export { default as ListGroupContext } from '../common/context';
export { default as GroupListItem } from '../common/GroupDimensionItem';
export * from './types';
29 changes: 5 additions & 24 deletions ui/group/src/react-native/types/ListGroup.types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import {
OnEndReachedHelperProps,
ViewabilityConfig,
OnViewableItemsChanged,
ViewabilityConfigCallbackPairs,
} from '@infinite-list/viewable';
import { ComponentType, PropsWithChildren, MutableRefObject } from 'react';
import { MutableRefObject } from 'react';
import { View, ScrollView, LayoutChangeEvent } from 'react-native';
import { GenericItemT } from '@infinite-list/item-meta';
import { GenericItemT } from '@infinite-list/types';
import { RefObject } from 'react';
import { ListGroupProps as CommonListGroupProps } from '../../types';

export type ScrollComponentUseMeasureLayout = (
itemRef: MutableRefObject<View | null>,
Expand All @@ -24,19 +19,5 @@ export type ScrollComponentUseMeasureLayout = (

export type ContainerRef = RefObject<ScrollView | View | any>;

export type ListGroupProps<ItemT extends GenericItemT> = PropsWithChildren<{
id: string;
onViewableItemsChanged?: OnViewableItemsChanged;
viewabilityConfig?: ViewabilityConfig;
viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs;
initialNumToRender?: number;
windowSize?: number;
maxToRenderPerBatch?: number;
onRenderFinished?: () => void;
persistanceIndices?: number[];

scrollComponentContext: any;
containerRef: ContainerRef;
GroupListSeparatorComponent?: ComponentType<ItemT> | null | undefined;
}> &
OnEndReachedHelperProps;
export type ListGroupProps<ItemT extends GenericItemT> =
CommonListGroupProps<ItemT>;
1 change: 0 additions & 1 deletion ui/group/src/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ export { default as ListGroup } from './ListGroup';
export { default as GroupList } from '../common/GroupList';
export { default as ListGroupContext } from '../common/context';
export { default as GroupListItem } from '../common/GroupDimensionItem';
export * from './types';
27 changes: 5 additions & 22 deletions ui/group/src/react/types/ListGroup.types.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
OnEndReachedHelperProps,
ViewabilityConfig,
OnViewableItemsChanged,
ViewabilityConfigCallbackPairs,
} from '@infinite-list/viewable';
import { ComponentType, PropsWithChildren, MutableRefObject } from 'react';
import { MutableRefObject } from 'react';
import { View, LayoutChangeEvent } from 'react-native';
import { GenericItemT } from '@infinite-list/types';
import { ListGroupProps as CommonListGroupProps } from '../../types';

export type ScrollComponentUseMeasureLayout = (
itemRef: MutableRefObject<View | null>,
Expand All @@ -20,18 +16,5 @@ export type ScrollComponentUseMeasureLayout = (
layoutHandler: (e: LayoutChangeEvent) => void;
};

export type ListGroupProps = PropsWithChildren<{
GroupListSeparatorComponent?: ComponentType<any> | null | undefined;
id: string;
onViewableItemsChanged?: OnViewableItemsChanged;
viewabilityConfig?: ViewabilityConfig;
viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs;
initialNumToRender?: number;
windowSize?: number;
maxToRenderPerBatch?: number;
onRenderFinished?: () => void;
persistanceIndices?: number[];

scrollComponentContext: any;
}> &
OnEndReachedHelperProps;
export type ListGroupProps<ItemT extends GenericItemT> =
CommonListGroupProps<ItemT>;
64 changes: 18 additions & 46 deletions ui/group/src/types/ListGroup.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,51 +6,23 @@ import {
GenericItemT,
} from '@infinite-list/viewable';
import { ComponentType, PropsWithChildren } from 'react';
// import { View, LayoutChangeEvent } from 'react-native';
import { RecyclerProps } from '@infinite-list/strategies';

// export type ScrollComponentUseMeasureLayout = (
// itemRef: MutableRefObject<View | null>,
// options: {
// onLayout?: Function;
// getCurrentKey?: () => string;
// isIntervalTreeItem?: boolean;
// onMeasureLayout?: Function;
// }
// ) => {
// handler: Function;
// layoutHandler: (e: LayoutChangeEvent) => void;
// };
export type ListGroupProps<ItemT extends GenericItemT> = PropsWithChildren<
{
id: string;
horizontal?: boolean;
onViewableItemsChanged?: OnViewableItemsChanged;
viewabilityConfig?: ViewabilityConfig;
viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs;
initialNumToRender?: number;
windowSize?: number;
maxToRenderPerBatch?: number;
onRenderFinished?: () => void;
persistanceIndices?: number[];

// export type ListGroupProps = PropsWithChildren<{
// GroupListSeparatorComponent?: ComponentType<any> | null | undefined;
// id: string;
// onViewableItemsChanged?: OnViewableItemsChanged;
// viewabilityConfig?: ViewabilityConfig;
// viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs;
// initialNumToRender?: number;
// windowSize?: number;
// maxToRenderPerBatch?: number;
// onRenderFinished?: () => void;
// persistanceIndices?: number[];

// scrollComponentContext: any;
// scrollComponentUseMeasureLayout: ScrollComponentUseMeasureLayout;
// }> &
// OnEndReachedHelperProps;
export type ListGroupProps<ItemT extends GenericItemT> = PropsWithChildren<{
GroupListSeparatorComponent?: ComponentType<ItemT> | null | undefined;
id: string;
horizontal?: boolean;
onViewableItemsChanged?: OnViewableItemsChanged;
viewabilityConfig?: ViewabilityConfig;
viewabilityConfigCallbackPairs?: ViewabilityConfigCallbackPairs;
initialNumToRender?: number;
windowSize?: number;
maxToRenderPerBatch?: number;
onRenderFinished?: () => void;
persistanceIndices?: number[];

scrollComponentContext?: any;
// scrollComponentUseMeasureLayout?: ScrollComponentUseMeasureLayout;
}> &
OnEndReachedHelperProps;
scrollComponentContext?: any;
GroupListSeparatorComponent?: ComponentType<ItemT> | null | undefined;
} & OnEndReachedHelperProps &
RecyclerProps
>;

0 comments on commit e009e84

Please sign in to comment.