Skip to content

Commit adfc006

Browse files
committed
chore: inverted support for all virtualized lists
1 parent 124d7c2 commit adfc006

4 files changed

Lines changed: 14 additions & 4 deletions

File tree

FabricExample/src/screens/Examples/KeyboardChatScrollView/VirtualizedListScrollView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ const VirtualizedListScrollView = forwardRef<
4949
ref={ref}
5050
automaticallyAdjustContentInsets={false}
5151
contentContainerStyle={
52-
inverted ? invertedContentContainerStyle : contentContainerStyle
52+
isInvertedSupported
53+
? invertedContentContainerStyle
54+
: contentContainerStyle
5355
}
5456
contentInsetAdjustmentBehavior="never"
5557
freeze={freeze}

FabricExample/src/screens/Examples/KeyboardChatScrollView/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ function KeyboardChatScrollViewPlayground() {
101101
{mode === "legend" && (
102102
<LegendList
103103
ref={legendRef}
104+
alignItemsAtEnd={inverted}
104105
data={messages}
106+
initialScrollAtEnd={inverted}
105107
keyExtractor={(item) => item.text}
106108
renderItem={({ item }) => <Message {...item} />}
107109
renderScrollComponent={memoList}
@@ -110,8 +112,11 @@ function KeyboardChatScrollViewPlayground() {
110112
{mode === "flash" && (
111113
<FlashList
112114
ref={flashRef}
113-
data={inverted ? reversedMessages : messages}
115+
data={messages}
114116
keyExtractor={(item) => item.text}
117+
maintainVisibleContentPosition={{
118+
startRenderingFromBottom: inverted,
119+
}}
115120
renderItem={({ item }) => <Message {...item} />}
116121
renderScrollComponent={VirtualizedListScrollView}
117122
/>

example/src/screens/Examples/KeyboardChatScrollView/VirtualizedListScrollView.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const VirtualizedListScrollView = forwardRef<
3333
() => ({ paddingTop: TEXT_INPUT_HEIGHT + MARGIN }),
3434
[],
3535
);
36-
// on new arch only FlatList supports `inverted` prop
37-
const isInvertedSupported = inverted && mode === "flat" ? inverted : false;
36+
// on old arch only FlatList and FlashList supports `inverted` prop
37+
const isInvertedSupported =
38+
inverted && (mode === "flat" || mode === "flash") ? inverted : false;
3839
const onLayout = useCallback(
3940
(e: LayoutChangeEvent) => {
4041
setLayoutPass((l) => l + 1);

example/src/screens/Examples/KeyboardChatScrollView/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ function KeyboardChatScrollViewPlayground() {
101101
{mode === "legend" && (
102102
<LegendList
103103
ref={legendRef}
104+
alignItemsAtEnd={inverted}
104105
data={messages}
105106
keyExtractor={(item) => item.text}
106107
renderItem={({ item }) => <Message {...item} />}
@@ -111,6 +112,7 @@ function KeyboardChatScrollViewPlayground() {
111112
<FlashList
112113
ref={flashRef}
113114
data={inverted ? reversedMessages : messages}
115+
inverted={inverted}
114116
keyExtractor={(item) => item.text}
115117
renderItem={({ item }) => <Message {...item} />}
116118
renderScrollComponent={VirtualizedListScrollView}

0 commit comments

Comments
 (0)