Skip to content

Commit 67c19ed

Browse files
committed
Merge branch '47' into youssef/progress-indicator-snack-fixes47
2 parents 8cbaa5c + 008cd0c commit 67c19ed

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

packages/core/src/components/DeckSwiper/DeckSwiper.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { StyleProp, ViewStyle, StyleSheet, View } from "react-native";
33
import DeckSwiperComponent from "react-native-deck-swiper";
44

55
export interface DeckSwiperProps<T> {
6+
onStartSwipe?: () => void;
7+
onEndSwipe?: () => void;
68
onSwipe?: (index: number) => void;
79
onSwipedLeft?: (index: number) => void;
810
onSwipedRight?: (index: number) => void;
@@ -22,6 +24,8 @@ export interface DeckSwiperProps<T> {
2224
}
2325

2426
const DeckSwiper = <T extends object>({
27+
onStartSwipe,
28+
onEndSwipe,
2529
onSwipe,
2630
onSwipedLeft,
2731
onSwipedRight,
@@ -150,6 +154,10 @@ const DeckSwiper = <T extends object>({
150154
onSwipedDown?.(index);
151155
onSwipe?.(index);
152156
}}
157+
//@ts-ignore Not typed, but is implemented and works
158+
dragStart={onStartSwipe}
159+
//@ts-ignore
160+
dragEnd={onEndSwipe}
153161
/>
154162
</View>
155163
);

packages/core/src/components/SectionList/SectionList.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ type ListComponentType = "FlatList" | "FlashList";
77

88
interface AdditionalSectionListProps<T> {
99
sectionKey: string;
10+
stickyHeader?: boolean;
1011
renderItem: (itemInfo: {
1112
item?: T;
1213
index: number;
@@ -37,6 +38,7 @@ export const DEFAULT_SECTION = "Uncategorized";
3738

3839
const SectionList = <T extends { [key: string]: any }>({
3940
sectionKey,
41+
stickyHeader = false,
4042
listComponent = "FlatList",
4143
data: dataProp,
4244
renderItem: renderItemProp,
@@ -68,6 +70,16 @@ const SectionList = <T extends { [key: string]: any }>({
6870
return result;
6971
}, [data, sectionKey]);
7072

73+
const sectionHeaderIndicies = React.useMemo(
74+
() =>
75+
stickyHeader
76+
? dataWithSections
77+
.filter((item) => item.type === "SECTION_ITEM")
78+
.map((item) => dataWithSections.indexOf(item))
79+
: undefined,
80+
[dataWithSections, stickyHeader]
81+
);
82+
7183
const extractSectionHeader = (
7284
element: JSX.Element | null
7385
): JSX.Element | null => {
@@ -152,6 +164,7 @@ const SectionList = <T extends { [key: string]: any }>({
152164
case "FlatList":
153165
return (
154166
<FlatList
167+
stickyHeaderIndices={sectionHeaderIndicies}
155168
{...(rest as FlatListProps<SectionListItem<T>>)}
156169
data={dataWithSections}
157170
renderItem={renderItem}
@@ -160,6 +173,7 @@ const SectionList = <T extends { [key: string]: any }>({
160173
case "FlashList":
161174
return (
162175
<FlashList
176+
stickyHeaderIndices={sectionHeaderIndicies}
163177
{...(rest as FlashListProps<SectionListItem<T>>)}
164178
data={dataWithSections}
165179
renderItem={renderItem}

0 commit comments

Comments
 (0)