Skip to content

Commit

Permalink
[DF] feat(#547): fix typescript pr requests
Browse files Browse the repository at this point in the history
  • Loading branch information
friyiajr committed Aug 16, 2023
1 parent c044882 commit 788eb40
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

- Add support for `experimentalMaintainTopContentPosition`

- Update types to match `react-native@0.72` view types.
- https://github.com/Shopify/flash-list/pull/890
- Add support for `experimentalMaintainTopContentPosition`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class AutoLayoutView(context: Context) : ReactViewGroup(context) {
alShadow.clearGapsAndOverlaps(
positionSortedViews,
getParentScrollView() as ScrollView,
experimentalScrollPositionManagement
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/BiDirectionalScrollView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
View,
} from "react-native";

import { BidirectionalFlatlist } from "./BidirectionalFlatlist";
import { BidirectionalList } from "./BidirectionalList";
import type { ShiftFunction } from "./types";

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
10 changes: 5 additions & 5 deletions src/BidirectionalFlatlist.ts → src/BidirectionalList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ const LINKING_ERROR =
)}- You rebuilt the app after installing the package\n` +
`- You are not using Expo managed workflow\n`;

interface BidirectionalFlatlistProps {
interface BidirectionalListProps {
style: ViewStyle;
children: ReactNode;
}

const ComponentName = "DoubleSidedScrollView";

const BidirectionalFlatlist =
requireNativeComponent<BidirectionalFlatlistProps>(ComponentName);
const BidirectionalList =
requireNativeComponent<BidirectionalListProps>(ComponentName);

if (BidirectionalFlatlist === null) {
if (BidirectionalList === null) {
throw new Error(LINKING_ERROR);
}

export { BidirectionalFlatlist };
export { BidirectionalList };
13 changes: 5 additions & 8 deletions src/FlashList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
NativeSyntheticEvent,
StyleSheet,
NativeScrollEvent,
Platform,
} from "react-native";
import {
BaseItemAnimator,
Expand All @@ -32,6 +31,7 @@ import {
RenderTargetOptions,
} from "./FlashListProps";
import {
getBidirectionalScrollView,
getCellContainerPlatformStyles,
getFooterContainer,
getItemAnimator,
Expand All @@ -43,7 +43,6 @@ import {
hasUnsupportedKeysInContentContainerStyle,
updateContentStyle,
} from "./utils/ContentContainerUtils";
import { BidirectionalScrollView } from "./BiDirectionalScrollView";

interface StickyProps extends StickyContainerProps {
children: any;
Expand Down Expand Up @@ -399,12 +398,10 @@ class FlashList<T> extends React.PureComponent<
windowCorrectionConfig={this.getUpdatedWindowCorrectionConfig()}
itemAnimator={this.itemAnimator}
suppressBoundedSizeException
externalScrollView={
this.props.experimentalScrollPositionManagement &&
Platform.OS === "android"
? (BidirectionalScrollView as unknown as RecyclerListViewProps["externalScrollView"])
: (renderScrollComponent as RecyclerListViewProps["externalScrollView"])
}
externalScrollView={getBidirectionalScrollView(
Boolean(this.props.maintainVisibleContentPosition),
renderScrollComponent
)}
/>
</StickyHeaderContainer>
);
Expand Down
19 changes: 18 additions & 1 deletion src/native/config/PlatformHelper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { BaseItemAnimator } from "recyclerlistview";
import { Platform, ScrollViewProps } from "react-native";
import { BaseItemAnimator, RecyclerListViewProps } from "recyclerlistview";
import { DefaultJSItemAnimator } from "recyclerlistview/dist/reactnative/platform/reactnative/itemanimators/defaultjsanimator/DefaultJSItemAnimator";
import React from "react";

import { BidirectionalScrollView } from "../../BiDirectionalScrollView";

const PlatformConfig = {
defaultDrawDistance: 250,
Expand All @@ -21,9 +25,22 @@ const getFooterContainer = (): React.ComponentClass | undefined => {
return undefined;
};

const getBidirectionalScrollView = (
experimentalScrollPositionManagement: boolean,
renderScrollComponent:
| React.FC<ScrollViewProps>
| React.ComponentType<ScrollViewProps>
| undefined
) => {
return experimentalScrollPositionManagement && Platform.OS === "android"
? (BidirectionalScrollView as unknown as RecyclerListViewProps["externalScrollView"])
: (renderScrollComponent as unknown as RecyclerListViewProps["externalScrollView"]);
};

export {
PlatformConfig,
getCellContainerPlatformStyles,
getItemAnimator,
getFooterContainer,
getBidirectionalScrollView,
};

0 comments on commit 788eb40

Please sign in to comment.