From 871ec56ea56dd26b5fa71c85485e823b8a7d90fc Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Tue, 1 Jun 2021 19:04:18 +0200 Subject: [PATCH 1/3] chore: minor refactor --- .eslintrc.js | 12 +----------- .../BottomSheetHandleContainer.tsx | 6 +----- .../createBottomSheetScrollableComponent.tsx | 2 +- src/hooks/useScrollableInternal.ts | 1 - src/utilities/normalizeSnapPoint.ts | 2 +- 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cdc024184..60ab22df3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,16 +3,6 @@ module.exports = { extends: ['@react-native-community', 'prettier'], rules: { 'no-console': ['error', { allow: ['warn', 'error'] }], - 'prettier/prettier': [ - 'error', - { - printWidth: 80, - arrowParens: 'avoid', - singleQuote: true, - tabWidth: 2, - trailingComma: 'es5', - useTabs: false, - }, - ], + 'prettier/prettier': 'error', }, }; diff --git a/src/components/bottomSheetHandleContainer/BottomSheetHandleContainer.tsx b/src/components/bottomSheetHandleContainer/BottomSheetHandleContainer.tsx index afc3a0990..b417323b1 100644 --- a/src/components/bottomSheetHandleContainer/BottomSheetHandleContainer.tsx +++ b/src/components/bottomSheetHandleContainer/BottomSheetHandleContainer.tsx @@ -44,11 +44,6 @@ function BottomSheetHandleContainerComponent({ return refs; }, [_providedSimultaneousHandlers, _internalSimultaneousHandlers]); - - const shouldRenderHandle = useMemo( - () => _providedHandleComponent !== null, - [_providedHandleComponent] - ); //#endregion //#region callbacks @@ -96,6 +91,7 @@ function BottomSheetHandleContainerComponent({ ); }, [animatedIndex, animatedPosition, _providedHandleComponent]); + const shouldRenderHandle = _providedHandleComponent !== null; return shouldRenderHandle ? ( ( ref={scrollableRef} overScrollMode={overScrollMode} scrollEventThrottle={16} - onScrollBeginDrag={handleScrollEvent} + onScroll={handleScrollEvent} animatedProps={scrollableAnimatedProps} style={containerStyle} /> diff --git a/src/hooks/useScrollableInternal.ts b/src/hooks/useScrollableInternal.ts index 195f7eafb..def0f4889 100644 --- a/src/hooks/useScrollableInternal.ts +++ b/src/hooks/useScrollableInternal.ts @@ -109,7 +109,6 @@ export const useScrollableInternal = () => { : 0; // @ts-ignore scrollTo(scrollableRef, 0, lockPosition, false); - scrollableContentOffsetY.value = lockPosition; scrollableContentOffsetY.value = 0; return; } diff --git a/src/utilities/normalizeSnapPoint.ts b/src/utilities/normalizeSnapPoint.ts index 406fcd1cc..a63e4cc3e 100644 --- a/src/utilities/normalizeSnapPoint.ts +++ b/src/utilities/normalizeSnapPoint.ts @@ -16,5 +16,5 @@ export const normalizeSnapPoint = ( normalizedSnapPoint = (Number(normalizedSnapPoint.split('%')[0]) * containerHeight) / 100; } - return Math.max(0, containerHeight - normalizedSnapPoint); + return Math.round(Math.max(0, containerHeight - normalizedSnapPoint)); }; From 85b7b5f9dc6593f7a185c9977283c7272a4517c7 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Wed, 2 Jun 2021 23:36:35 +0200 Subject: [PATCH 2/3] remove rounding --- src/utilities/normalizeSnapPoint.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities/normalizeSnapPoint.ts b/src/utilities/normalizeSnapPoint.ts index a63e4cc3e..406fcd1cc 100644 --- a/src/utilities/normalizeSnapPoint.ts +++ b/src/utilities/normalizeSnapPoint.ts @@ -16,5 +16,5 @@ export const normalizeSnapPoint = ( normalizedSnapPoint = (Number(normalizedSnapPoint.split('%')[0]) * containerHeight) / 100; } - return Math.round(Math.max(0, containerHeight - normalizedSnapPoint)); + return Math.max(0, containerHeight - normalizedSnapPoint); }; From e3d9f502e4a84d7986673e89db5bda72e1e3f90c Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Wed, 2 Jun 2021 23:46:34 +0200 Subject: [PATCH 3/3] chore: changes done by yarn lint --fix --- .../contactListContainer/ContactListContainer.tsx | 7 ++++--- example/src/screens/advanced/BackdropExample.tsx | 5 ++--- example/src/screens/modal/BackdropExample.tsx | 5 ++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/example/src/components/contactListContainer/ContactListContainer.tsx b/example/src/components/contactListContainer/ContactListContainer.tsx index f260ae786..6c5b0334a 100644 --- a/example/src/components/contactListContainer/ContactListContainer.tsx +++ b/example/src/components/contactListContainer/ContactListContainer.tsx @@ -14,9 +14,10 @@ const ContactListContainerComponent = ({ headerStyle: _headerStyle, onItemPress, }: ContactListContainerProps) => { - const headerStyle = useMemo(() => [styles.headerContainer, _headerStyle], [ - _headerStyle, - ]); + const headerStyle = useMemo( + () => [styles.headerContainer, _headerStyle], + [_headerStyle] + ); return ( <> diff --git a/example/src/screens/advanced/BackdropExample.tsx b/example/src/screens/advanced/BackdropExample.tsx index 1b9cef270..0eb829481 100644 --- a/example/src/screens/advanced/BackdropExample.tsx +++ b/example/src/screens/advanced/BackdropExample.tsx @@ -6,9 +6,8 @@ import ContactListContainer from '../../components/contactListContainer'; const BackdropExample = () => { // state - const [backdropPressBehavior, setBackdropPressBehavior] = useState< - 'none' | 'close' | 'collapse' - >('collapse'); + const [backdropPressBehavior, setBackdropPressBehavior] = + useState<'none' | 'close' | 'collapse'>('collapse'); // hooks const bottomSheetRef = useRef(null); diff --git a/example/src/screens/modal/BackdropExample.tsx b/example/src/screens/modal/BackdropExample.tsx index d8309ca09..8b770b3fb 100644 --- a/example/src/screens/modal/BackdropExample.tsx +++ b/example/src/screens/modal/BackdropExample.tsx @@ -11,9 +11,8 @@ import withModalProvider from '../withModalProvider'; const BackdropExample = () => { // state - const [backdropPressBehavior, setBackdropPressBehavior] = useState< - 'none' | 'close' | 'collapse' - >('collapse'); + const [backdropPressBehavior, setBackdropPressBehavior] = + useState<'none' | 'close' | 'collapse'>('collapse'); // refs const bottomSheetRef = useRef(null);