rn-custom-ui 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +477 -0
- package/lib/module/assets/images/close.png +0 -0
- package/lib/module/components/CustomCheckbox/index.js +99 -0
- package/lib/module/components/CustomCheckbox/index.js.map +1 -0
- package/lib/module/components/CustomCheckbox/styles.js +213 -0
- package/lib/module/components/CustomCheckbox/styles.js.map +1 -0
- package/lib/module/components/CustomCheckbox/types.js +4 -0
- package/lib/module/components/CustomCheckbox/types.js.map +1 -0
- package/lib/module/components/closeButton/index.js +45 -0
- package/lib/module/components/closeButton/index.js.map +1 -0
- package/lib/module/components/closeButton/types.js +4 -0
- package/lib/module/components/closeButton/types.js.map +1 -0
- package/lib/module/components/customButton/index.js +176 -0
- package/lib/module/components/customButton/index.js.map +1 -0
- package/lib/module/components/customButton/styles.js +282 -0
- package/lib/module/components/customButton/styles.js.map +1 -0
- package/lib/module/components/customButton/types.js +4 -0
- package/lib/module/components/customButton/types.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownBottomSheet.js +57 -0
- package/lib/module/components/customDropDown/DropDownBottomSheet.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownList.js +51 -0
- package/lib/module/components/customDropDown/DropDownList.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownListItem.js +38 -0
- package/lib/module/components/customDropDown/DropDownListItem.js.map +1 -0
- package/lib/module/components/customDropDown/DropDownListModal.js +63 -0
- package/lib/module/components/customDropDown/DropDownListModal.js.map +1 -0
- package/lib/module/components/customDropDown/index.js +143 -0
- package/lib/module/components/customDropDown/index.js.map +1 -0
- package/lib/module/components/customDropDown/styles.js +189 -0
- package/lib/module/components/customDropDown/styles.js.map +1 -0
- package/lib/module/components/customDropDown/types.js +4 -0
- package/lib/module/components/customDropDown/types.js.map +1 -0
- package/lib/module/components/customDropDown/utils.js +17 -0
- package/lib/module/components/customDropDown/utils.js.map +1 -0
- package/lib/module/components/customList/ListEmpty.js +33 -0
- package/lib/module/components/customList/ListEmpty.js.map +1 -0
- package/lib/module/components/customList/ListFooterLoader.js +14 -0
- package/lib/module/components/customList/ListFooterLoader.js.map +1 -0
- package/lib/module/components/customList/defaultKeyExtractor.js +9 -0
- package/lib/module/components/customList/defaultKeyExtractor.js.map +1 -0
- package/lib/module/components/customList/getFlashList.js +19 -0
- package/lib/module/components/customList/getFlashList.js.map +1 -0
- package/lib/module/components/customList/index.js +117 -0
- package/lib/module/components/customList/index.js.map +1 -0
- package/lib/module/components/customList/styles.js +45 -0
- package/lib/module/components/customList/styles.js.map +1 -0
- package/lib/module/components/customList/types.js +4 -0
- package/lib/module/components/customList/types.js.map +1 -0
- package/lib/module/components/customModal/ModalFooter.js +44 -0
- package/lib/module/components/customModal/ModalFooter.js.map +1 -0
- package/lib/module/components/customModal/index.js +132 -0
- package/lib/module/components/customModal/index.js.map +1 -0
- package/lib/module/components/customModal/styles.js +123 -0
- package/lib/module/components/customModal/styles.js.map +1 -0
- package/lib/module/components/customModal/types.js +4 -0
- package/lib/module/components/customModal/types.js.map +1 -0
- package/lib/module/components/customModal/useCustomModal.js +23 -0
- package/lib/module/components/customModal/useCustomModal.js.map +1 -0
- package/lib/module/components/customNumberPad/NumberPadKey.js +39 -0
- package/lib/module/components/customNumberPad/NumberPadKey.js.map +1 -0
- package/lib/module/components/customNumberPad/index.js +156 -0
- package/lib/module/components/customNumberPad/index.js.map +1 -0
- package/lib/module/components/customNumberPad/styles.js +131 -0
- package/lib/module/components/customNumberPad/styles.js.map +1 -0
- package/lib/module/components/customNumberPad/types.js +4 -0
- package/lib/module/components/customNumberPad/types.js.map +1 -0
- package/lib/module/components/customNumberPad/useNumberPadInput.js +44 -0
- package/lib/module/components/customNumberPad/useNumberPadInput.js.map +1 -0
- package/lib/module/components/customNumberPad/utils.js +38 -0
- package/lib/module/components/customNumberPad/utils.js.map +1 -0
- package/lib/module/components/customSlideTabs/AnimatedTabIndicator.js +66 -0
- package/lib/module/components/customSlideTabs/AnimatedTabIndicator.js.map +1 -0
- package/lib/module/components/customSlideTabs/TabBarItem.js +61 -0
- package/lib/module/components/customSlideTabs/TabBarItem.js.map +1 -0
- package/lib/module/components/customSlideTabs/TabScene.js +88 -0
- package/lib/module/components/customSlideTabs/TabScene.js.map +1 -0
- package/lib/module/components/customSlideTabs/index.js +277 -0
- package/lib/module/components/customSlideTabs/index.js.map +1 -0
- package/lib/module/components/customSlideTabs/styles.js +132 -0
- package/lib/module/components/customSlideTabs/styles.js.map +1 -0
- package/lib/module/components/customSlideTabs/tabBarScroll.js +65 -0
- package/lib/module/components/customSlideTabs/tabBarScroll.js.map +1 -0
- package/lib/module/components/customSlideTabs/types.js +4 -0
- package/lib/module/components/customSlideTabs/types.js.map +1 -0
- package/lib/module/components/loading/index.js +34 -0
- package/lib/module/components/loading/index.js.map +1 -0
- package/lib/module/customFunctions/array.js +61 -0
- package/lib/module/customFunctions/array.js.map +1 -0
- package/lib/module/customFunctions/async.js +62 -0
- package/lib/module/customFunctions/async.js.map +1 -0
- package/lib/module/customFunctions/date.js +109 -0
- package/lib/module/customFunctions/date.js.map +1 -0
- package/lib/module/customFunctions/general.js +29 -0
- package/lib/module/customFunctions/general.js.map +1 -0
- package/lib/module/customFunctions/id.js +20 -0
- package/lib/module/customFunctions/id.js.map +1 -0
- package/lib/module/customFunctions/index.js +29 -0
- package/lib/module/customFunctions/index.js.map +1 -0
- package/lib/module/customFunctions/number.js +94 -0
- package/lib/module/customFunctions/number.js.map +1 -0
- package/lib/module/customFunctions/object.js +39 -0
- package/lib/module/customFunctions/object.js.map +1 -0
- package/lib/module/customFunctions/string.js +63 -0
- package/lib/module/customFunctions/string.js.map +1 -0
- package/lib/module/customFunctions/types.js +2 -0
- package/lib/module/customFunctions/types.js.map +1 -0
- package/lib/module/customFunctions/validation.js +34 -0
- package/lib/module/customFunctions/validation.js.map +1 -0
- package/lib/module/customHooks/errors.js +61 -0
- package/lib/module/customHooks/errors.js.map +1 -0
- package/lib/module/customHooks/fetchJson.js +36 -0
- package/lib/module/customHooks/fetchJson.js.map +1 -0
- package/lib/module/customHooks/index.js +10 -0
- package/lib/module/customHooks/index.js.map +1 -0
- package/lib/module/customHooks/internal.js +49 -0
- package/lib/module/customHooks/internal.js.map +1 -0
- package/lib/module/customHooks/types.js +2 -0
- package/lib/module/customHooks/types.js.map +1 -0
- package/lib/module/customHooks/useApi.js +91 -0
- package/lib/module/customHooks/useApi.js.map +1 -0
- package/lib/module/customHooks/useLazyApi.js +80 -0
- package/lib/module/customHooks/useLazyApi.js.map +1 -0
- package/lib/module/customHooks/useMutation.js +69 -0
- package/lib/module/customHooks/useMutation.js.map +1 -0
- package/lib/module/customHooks/usePaginatedApi.js +127 -0
- package/lib/module/customHooks/usePaginatedApi.js.map +1 -0
- package/lib/module/customHooks/usePollingApi.js +37 -0
- package/lib/module/customHooks/usePollingApi.js.map +1 -0
- package/lib/module/index.js +13 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/multiply.js +6 -0
- package/lib/module/multiply.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/components/CustomCheckbox/index.d.ts +5 -0
- package/lib/typescript/src/components/CustomCheckbox/index.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomCheckbox/styles.d.ts +67 -0
- package/lib/typescript/src/components/CustomCheckbox/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/CustomCheckbox/types.d.ts +28 -0
- package/lib/typescript/src/components/CustomCheckbox/types.d.ts.map +1 -0
- package/lib/typescript/src/components/closeButton/index.d.ts +4 -0
- package/lib/typescript/src/components/closeButton/index.d.ts.map +1 -0
- package/lib/typescript/src/components/closeButton/types.d.ts +8 -0
- package/lib/typescript/src/components/closeButton/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/index.d.ts +5 -0
- package/lib/typescript/src/components/customButton/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/styles.d.ts +231 -0
- package/lib/typescript/src/components/customButton/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customButton/types.d.ts +46 -0
- package/lib/typescript/src/components/customButton/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownBottomSheet.d.ts +18 -0
- package/lib/typescript/src/components/customDropDown/DropDownBottomSheet.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownList.d.ts +17 -0
- package/lib/typescript/src/components/customDropDown/DropDownList.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownListItem.d.ts +15 -0
- package/lib/typescript/src/components/customDropDown/DropDownListItem.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/DropDownListModal.d.ts +19 -0
- package/lib/typescript/src/components/customDropDown/DropDownListModal.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/index.d.ts +5 -0
- package/lib/typescript/src/components/customDropDown/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/styles.d.ts +190 -0
- package/lib/typescript/src/components/customDropDown/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/types.d.ts +37 -0
- package/lib/typescript/src/components/customDropDown/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customDropDown/utils.d.ts +4 -0
- package/lib/typescript/src/components/customDropDown/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/ListEmpty.d.ts +10 -0
- package/lib/typescript/src/components/customList/ListEmpty.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/ListFooterLoader.d.ts +3 -0
- package/lib/typescript/src/components/customList/ListFooterLoader.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/defaultKeyExtractor.d.ts +2 -0
- package/lib/typescript/src/components/customList/defaultKeyExtractor.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/getFlashList.d.ts +6 -0
- package/lib/typescript/src/components/customList/getFlashList.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/index.d.ts +11 -0
- package/lib/typescript/src/components/customList/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/styles.d.ts +42 -0
- package/lib/typescript/src/components/customList/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customList/types.d.ts +33 -0
- package/lib/typescript/src/components/customList/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/ModalFooter.d.ts +12 -0
- package/lib/typescript/src/components/customModal/ModalFooter.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/index.d.ts +6 -0
- package/lib/typescript/src/components/customModal/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/styles.d.ts +83 -0
- package/lib/typescript/src/components/customModal/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/types.d.ts +36 -0
- package/lib/typescript/src/components/customModal/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customModal/useCustomModal.d.ts +8 -0
- package/lib/typescript/src/components/customModal/useCustomModal.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/NumberPadKey.d.ts +23 -0
- package/lib/typescript/src/components/customNumberPad/NumberPadKey.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/index.d.ts +7 -0
- package/lib/typescript/src/components/customNumberPad/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/styles.d.ts +37 -0
- package/lib/typescript/src/components/customNumberPad/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/types.d.ts +47 -0
- package/lib/typescript/src/components/customNumberPad/types.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/useNumberPadInput.d.ts +16 -0
- package/lib/typescript/src/components/customNumberPad/useNumberPadInput.d.ts.map +1 -0
- package/lib/typescript/src/components/customNumberPad/utils.d.ts +4 -0
- package/lib/typescript/src/components/customNumberPad/utils.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/AnimatedTabIndicator.d.ts +16 -0
- package/lib/typescript/src/components/customSlideTabs/AnimatedTabIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/TabBarItem.d.ts +23 -0
- package/lib/typescript/src/components/customSlideTabs/TabBarItem.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/TabScene.d.ts +21 -0
- package/lib/typescript/src/components/customSlideTabs/TabScene.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/index.d.ts +5 -0
- package/lib/typescript/src/components/customSlideTabs/index.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/styles.d.ts +130 -0
- package/lib/typescript/src/components/customSlideTabs/styles.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/tabBarScroll.d.ts +15 -0
- package/lib/typescript/src/components/customSlideTabs/tabBarScroll.d.ts.map +1 -0
- package/lib/typescript/src/components/customSlideTabs/types.d.ts +68 -0
- package/lib/typescript/src/components/customSlideTabs/types.d.ts.map +1 -0
- package/lib/typescript/src/components/loading/index.d.ts +7 -0
- package/lib/typescript/src/components/loading/index.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/array.d.ts +7 -0
- package/lib/typescript/src/customFunctions/array.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/async.d.ts +9 -0
- package/lib/typescript/src/customFunctions/async.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/date.d.ts +18 -0
- package/lib/typescript/src/customFunctions/date.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/general.d.ts +7 -0
- package/lib/typescript/src/customFunctions/general.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/id.d.ts +4 -0
- package/lib/typescript/src/customFunctions/id.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/index.d.ts +26 -0
- package/lib/typescript/src/customFunctions/index.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/number.d.ts +15 -0
- package/lib/typescript/src/customFunctions/number.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/object.d.ts +6 -0
- package/lib/typescript/src/customFunctions/object.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/string.d.ts +20 -0
- package/lib/typescript/src/customFunctions/string.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/types.d.ts +22 -0
- package/lib/typescript/src/customFunctions/types.d.ts.map +1 -0
- package/lib/typescript/src/customFunctions/validation.d.ts +11 -0
- package/lib/typescript/src/customFunctions/validation.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/errors.d.ts +16 -0
- package/lib/typescript/src/customHooks/errors.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/fetchJson.d.ts +5 -0
- package/lib/typescript/src/customHooks/fetchJson.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/index.d.ts +9 -0
- package/lib/typescript/src/customHooks/index.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/internal.d.ts +12 -0
- package/lib/typescript/src/customHooks/internal.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/types.d.ts +49 -0
- package/lib/typescript/src/customHooks/types.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useApi.d.ts +13 -0
- package/lib/typescript/src/customHooks/useApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useLazyApi.d.ts +14 -0
- package/lib/typescript/src/customHooks/useLazyApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/useMutation.d.ts +15 -0
- package/lib/typescript/src/customHooks/useMutation.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/usePaginatedApi.d.ts +19 -0
- package/lib/typescript/src/customHooks/usePaginatedApi.d.ts.map +1 -0
- package/lib/typescript/src/customHooks/usePollingApi.d.ts +13 -0
- package/lib/typescript/src/customHooks/usePollingApi.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +11 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/multiply.d.ts +2 -0
- package/lib/typescript/src/multiply.d.ts.map +1 -0
- package/package.json +181 -0
- package/src/assets/images/close.png +0 -0
- package/src/components/CustomCheckbox/index.tsx +143 -0
- package/src/components/CustomCheckbox/styles.ts +146 -0
- package/src/components/CustomCheckbox/types.ts +33 -0
- package/src/components/closeButton/index.tsx +40 -0
- package/src/components/closeButton/types.ts +13 -0
- package/src/components/customButton/index.tsx +288 -0
- package/src/components/customButton/styles.ts +247 -0
- package/src/components/customButton/types.ts +71 -0
- package/src/components/customDropDown/DropDownBottomSheet.tsx +70 -0
- package/src/components/customDropDown/DropDownList.tsx +88 -0
- package/src/components/customDropDown/DropDownListItem.tsx +74 -0
- package/src/components/customDropDown/DropDownListModal.tsx +86 -0
- package/src/components/customDropDown/index.tsx +213 -0
- package/src/components/customDropDown/styles.ts +184 -0
- package/src/components/customDropDown/types.ts +48 -0
- package/src/components/customDropDown/utils.ts +24 -0
- package/src/components/customList/ListEmpty.tsx +36 -0
- package/src/components/customList/ListFooterLoader.tsx +11 -0
- package/src/components/customList/defaultKeyExtractor.ts +7 -0
- package/src/components/customList/getFlashList.ts +26 -0
- package/src/components/customList/index.tsx +142 -0
- package/src/components/customList/styles.ts +43 -0
- package/src/components/customList/types.ts +60 -0
- package/src/components/customModal/ModalFooter.tsx +57 -0
- package/src/components/customModal/index.tsx +166 -0
- package/src/components/customModal/styles.ts +131 -0
- package/src/components/customModal/types.ts +48 -0
- package/src/components/customModal/useCustomModal.ts +25 -0
- package/src/components/customNumberPad/NumberPadKey.tsx +81 -0
- package/src/components/customNumberPad/index.tsx +204 -0
- package/src/components/customNumberPad/styles.ts +146 -0
- package/src/components/customNumberPad/types.ts +53 -0
- package/src/components/customNumberPad/useNumberPadInput.ts +56 -0
- package/src/components/customNumberPad/utils.ts +54 -0
- package/src/components/customSlideTabs/AnimatedTabIndicator.tsx +103 -0
- package/src/components/customSlideTabs/TabBarItem.tsx +118 -0
- package/src/components/customSlideTabs/TabScene.tsx +136 -0
- package/src/components/customSlideTabs/index.tsx +385 -0
- package/src/components/customSlideTabs/styles.ts +136 -0
- package/src/components/customSlideTabs/tabBarScroll.ts +92 -0
- package/src/components/customSlideTabs/types.ts +87 -0
- package/src/components/loading/index.tsx +34 -0
- package/src/customFunctions/array.ts +83 -0
- package/src/customFunctions/async.ts +85 -0
- package/src/customFunctions/date.ts +158 -0
- package/src/customFunctions/general.ts +35 -0
- package/src/customFunctions/id.ts +25 -0
- package/src/customFunctions/index.ts +91 -0
- package/src/customFunctions/number.ts +139 -0
- package/src/customFunctions/object.ts +59 -0
- package/src/customFunctions/string.ts +119 -0
- package/src/customFunctions/types.ts +25 -0
- package/src/customFunctions/validation.ts +49 -0
- package/src/customHooks/errors.ts +87 -0
- package/src/customHooks/fetchJson.ts +49 -0
- package/src/customHooks/index.ts +20 -0
- package/src/customHooks/internal.ts +67 -0
- package/src/customHooks/types.ts +71 -0
- package/src/customHooks/useApi.ts +107 -0
- package/src/customHooks/useLazyApi.ts +92 -0
- package/src/customHooks/useMutation.ts +97 -0
- package/src/customHooks/usePaginatedApi.ts +168 -0
- package/src/customHooks/usePollingApi.ts +48 -0
- package/src/index.tsx +63 -0
- package/src/multiply.tsx +3 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { styles } from './styles';
|
|
5
|
+
import { getIndicatorAtProgress, type TabLayoutMetric } from './tabBarScroll';
|
|
6
|
+
|
|
7
|
+
type AnimatedTabIndicatorProps = {
|
|
8
|
+
metrics: TabLayoutMetric[];
|
|
9
|
+
pagerScrollX: Animated.Value;
|
|
10
|
+
tabBarScrollX: Animated.Value;
|
|
11
|
+
pageWidth: number;
|
|
12
|
+
initialScrollX?: number;
|
|
13
|
+
showPill?: boolean;
|
|
14
|
+
showUnderline?: boolean;
|
|
15
|
+
pillStyle?: StyleProp<ViewStyle>;
|
|
16
|
+
underlineStyle?: StyleProp<ViewStyle>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const AnimatedTabIndicator = ({
|
|
20
|
+
metrics,
|
|
21
|
+
pagerScrollX,
|
|
22
|
+
tabBarScrollX,
|
|
23
|
+
pageWidth,
|
|
24
|
+
initialScrollX = 0,
|
|
25
|
+
showPill = true,
|
|
26
|
+
showUnderline = true,
|
|
27
|
+
pillStyle,
|
|
28
|
+
underlineStyle,
|
|
29
|
+
}: AnimatedTabIndicatorProps) => {
|
|
30
|
+
const indicatorLeft = useRef(new Animated.Value(0)).current;
|
|
31
|
+
const indicatorWidth = useRef(new Animated.Value(0)).current;
|
|
32
|
+
const hasMetrics = metrics.some((metric) => metric.width > 0);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!hasMetrics || pageWidth <= 0) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const updateIndicator = (scrollValue: number) => {
|
|
40
|
+
const progress = scrollValue / pageWidth;
|
|
41
|
+
const { left, width } = getIndicatorAtProgress(progress, metrics);
|
|
42
|
+
indicatorLeft.setValue(left);
|
|
43
|
+
indicatorWidth.setValue(width);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
updateIndicator(initialScrollX);
|
|
47
|
+
|
|
48
|
+
const listenerId = pagerScrollX.addListener(({ value }) => {
|
|
49
|
+
updateIndicator(value);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
pagerScrollX.removeListener(listenerId);
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
hasMetrics,
|
|
57
|
+
indicatorLeft,
|
|
58
|
+
indicatorWidth,
|
|
59
|
+
initialScrollX,
|
|
60
|
+
metrics,
|
|
61
|
+
pageWidth,
|
|
62
|
+
pagerScrollX,
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
if (!hasMetrics) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const animatedLeft = Animated.subtract(indicatorLeft, tabBarScrollX);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<>
|
|
73
|
+
{showPill && (
|
|
74
|
+
<Animated.View
|
|
75
|
+
pointerEvents="none"
|
|
76
|
+
style={[
|
|
77
|
+
styles.indicatorPill,
|
|
78
|
+
pillStyle,
|
|
79
|
+
{
|
|
80
|
+
left: animatedLeft,
|
|
81
|
+
width: indicatorWidth,
|
|
82
|
+
},
|
|
83
|
+
]}
|
|
84
|
+
/>
|
|
85
|
+
)}
|
|
86
|
+
{showUnderline && (
|
|
87
|
+
<Animated.View
|
|
88
|
+
pointerEvents="none"
|
|
89
|
+
style={[
|
|
90
|
+
styles.indicatorUnderline,
|
|
91
|
+
underlineStyle,
|
|
92
|
+
{
|
|
93
|
+
left: animatedLeft,
|
|
94
|
+
width: indicatorWidth,
|
|
95
|
+
},
|
|
96
|
+
]}
|
|
97
|
+
/>
|
|
98
|
+
)}
|
|
99
|
+
</>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export default AnimatedTabIndicator;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Image,
|
|
4
|
+
Pressable,
|
|
5
|
+
Text,
|
|
6
|
+
View,
|
|
7
|
+
type ImageStyle,
|
|
8
|
+
type LayoutChangeEvent,
|
|
9
|
+
type StyleProp,
|
|
10
|
+
type TextStyle,
|
|
11
|
+
type ViewStyle,
|
|
12
|
+
} from 'react-native';
|
|
13
|
+
|
|
14
|
+
import { styles } from './styles';
|
|
15
|
+
import type { SlideTabItem } from './types';
|
|
16
|
+
|
|
17
|
+
type TabBarItemProps = {
|
|
18
|
+
item: SlideTabItem;
|
|
19
|
+
index: number;
|
|
20
|
+
isActive: boolean;
|
|
21
|
+
showUnderline?: boolean;
|
|
22
|
+
useAnimatedIndicator?: boolean;
|
|
23
|
+
onPress: (index: number) => void;
|
|
24
|
+
onMeasure?: (index: number, width: number) => void;
|
|
25
|
+
renderTab?: (
|
|
26
|
+
tab: SlideTabItem,
|
|
27
|
+
index: number,
|
|
28
|
+
isActive: boolean
|
|
29
|
+
) => ReactNode;
|
|
30
|
+
tabStyle?: StyleProp<ViewStyle>;
|
|
31
|
+
activeTabStyle?: StyleProp<ViewStyle>;
|
|
32
|
+
tabTextStyle?: StyleProp<TextStyle>;
|
|
33
|
+
activeTabTextStyle?: StyleProp<TextStyle>;
|
|
34
|
+
tabImageStyle?: StyleProp<ImageStyle>;
|
|
35
|
+
activeTabImageStyle?: StyleProp<ImageStyle>;
|
|
36
|
+
underlineStyle?: StyleProp<ViewStyle>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const TabBarItem = ({
|
|
40
|
+
item,
|
|
41
|
+
index,
|
|
42
|
+
isActive,
|
|
43
|
+
showUnderline = true,
|
|
44
|
+
useAnimatedIndicator = true,
|
|
45
|
+
onPress,
|
|
46
|
+
onMeasure,
|
|
47
|
+
renderTab,
|
|
48
|
+
tabStyle,
|
|
49
|
+
activeTabStyle,
|
|
50
|
+
tabTextStyle,
|
|
51
|
+
activeTabTextStyle,
|
|
52
|
+
tabImageStyle,
|
|
53
|
+
activeTabImageStyle,
|
|
54
|
+
underlineStyle,
|
|
55
|
+
}: TabBarItemProps) => {
|
|
56
|
+
const Icon = item.LeftIcon;
|
|
57
|
+
|
|
58
|
+
const handleLayout = (event: LayoutChangeEvent) => {
|
|
59
|
+
onMeasure?.(index, event.nativeEvent.layout.width);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<Pressable
|
|
64
|
+
accessibilityRole="tab"
|
|
65
|
+
accessibilityState={{ selected: isActive }}
|
|
66
|
+
accessibilityLabel={item.title}
|
|
67
|
+
onLayout={handleLayout}
|
|
68
|
+
onPress={() => onPress(index)}
|
|
69
|
+
style={[
|
|
70
|
+
styles.tabItem,
|
|
71
|
+
useAnimatedIndicator && styles.tabItemTransparent,
|
|
72
|
+
tabStyle,
|
|
73
|
+
!useAnimatedIndicator && isActive && styles.tabItemActive,
|
|
74
|
+
!useAnimatedIndicator && isActive && activeTabStyle,
|
|
75
|
+
]}
|
|
76
|
+
>
|
|
77
|
+
{renderTab ? (
|
|
78
|
+
renderTab(item, index, isActive)
|
|
79
|
+
) : (
|
|
80
|
+
<View style={styles.tabContent}>
|
|
81
|
+
{item.image && (
|
|
82
|
+
<Image
|
|
83
|
+
resizeMode="contain"
|
|
84
|
+
source={item.image}
|
|
85
|
+
style={[
|
|
86
|
+
styles.tabImage,
|
|
87
|
+
tabImageStyle,
|
|
88
|
+
isActive && styles.tabImageActive,
|
|
89
|
+
isActive && activeTabImageStyle,
|
|
90
|
+
]}
|
|
91
|
+
/>
|
|
92
|
+
)}
|
|
93
|
+
{Icon && <Icon size={18} color={isActive ? '#0D6EFD' : '#6C757D'} />}
|
|
94
|
+
<Text
|
|
95
|
+
style={[
|
|
96
|
+
styles.tabText,
|
|
97
|
+
tabTextStyle,
|
|
98
|
+
isActive && styles.tabTextActive,
|
|
99
|
+
isActive && activeTabTextStyle,
|
|
100
|
+
]}
|
|
101
|
+
>
|
|
102
|
+
{item.title}
|
|
103
|
+
</Text>
|
|
104
|
+
{item.badge != null && (
|
|
105
|
+
<View style={styles.badge}>
|
|
106
|
+
<Text style={styles.badgeText}>{item.badge}</Text>
|
|
107
|
+
</View>
|
|
108
|
+
)}
|
|
109
|
+
</View>
|
|
110
|
+
)}
|
|
111
|
+
{showUnderline && isActive && !renderTab && !useAnimatedIndicator && (
|
|
112
|
+
<View style={[styles.underline, underlineStyle]} />
|
|
113
|
+
)}
|
|
114
|
+
</Pressable>
|
|
115
|
+
);
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export default TabBarItem;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { Text, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { useApi } from '../../customHooks/useApi';
|
|
5
|
+
import { styles } from './styles';
|
|
6
|
+
import type {
|
|
7
|
+
CustomSlideTabsProps,
|
|
8
|
+
SlideTabItem,
|
|
9
|
+
SlideTabSceneState,
|
|
10
|
+
} from './types';
|
|
11
|
+
|
|
12
|
+
type TabSceneProps<TData, TError> = {
|
|
13
|
+
tab: SlideTabItem;
|
|
14
|
+
index: number;
|
|
15
|
+
isActive: boolean;
|
|
16
|
+
shouldMount: boolean;
|
|
17
|
+
fetchSceneData?: CustomSlideTabsProps<TData, TError>['fetchSceneData'];
|
|
18
|
+
fetchWhenActive: boolean;
|
|
19
|
+
refetchOnRevisit: boolean;
|
|
20
|
+
keepPreviousSceneData: boolean;
|
|
21
|
+
renderScene: CustomSlideTabsProps<TData, TError>['renderScene'];
|
|
22
|
+
renderSceneHeader?: CustomSlideTabsProps<TData, TError>['renderSceneHeader'];
|
|
23
|
+
showSceneHeading?: boolean;
|
|
24
|
+
sceneStyle?: CustomSlideTabsProps<TData, TError>['sceneStyle'];
|
|
25
|
+
sceneHeaderStyle?: CustomSlideTabsProps<TData, TError>['sceneHeaderStyle'];
|
|
26
|
+
sceneHeadingStyle?: CustomSlideTabsProps<TData, TError>['sceneHeadingStyle'];
|
|
27
|
+
sceneSubtitleStyle?: CustomSlideTabsProps<
|
|
28
|
+
TData,
|
|
29
|
+
TError
|
|
30
|
+
>['sceneSubtitleStyle'];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const TabScene = <TData, TError = unknown>({
|
|
34
|
+
tab,
|
|
35
|
+
index,
|
|
36
|
+
isActive,
|
|
37
|
+
shouldMount,
|
|
38
|
+
fetchSceneData,
|
|
39
|
+
fetchWhenActive,
|
|
40
|
+
refetchOnRevisit,
|
|
41
|
+
keepPreviousSceneData,
|
|
42
|
+
renderScene,
|
|
43
|
+
renderSceneHeader,
|
|
44
|
+
showSceneHeading = true,
|
|
45
|
+
sceneStyle,
|
|
46
|
+
sceneHeaderStyle,
|
|
47
|
+
sceneHeadingStyle,
|
|
48
|
+
sceneSubtitleStyle,
|
|
49
|
+
}: TabSceneProps<TData, TError>) => {
|
|
50
|
+
const hasFetchedRef = useRef(false);
|
|
51
|
+
|
|
52
|
+
const shouldFetch =
|
|
53
|
+
Boolean(fetchSceneData) &&
|
|
54
|
+
fetchWhenActive &&
|
|
55
|
+
isActive &&
|
|
56
|
+
shouldMount &&
|
|
57
|
+
(refetchOnRevisit || !hasFetchedRef.current);
|
|
58
|
+
|
|
59
|
+
const api = useApi<TData, TError>(
|
|
60
|
+
(signal) => fetchSceneData!(tab, index, signal),
|
|
61
|
+
{
|
|
62
|
+
enabled: shouldFetch && Boolean(fetchSceneData),
|
|
63
|
+
keepPreviousData: keepPreviousSceneData,
|
|
64
|
+
deps: [tab.key, index],
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
if (api.isSuccess) {
|
|
70
|
+
hasFetchedRef.current = true;
|
|
71
|
+
}
|
|
72
|
+
}, [api.isSuccess]);
|
|
73
|
+
|
|
74
|
+
if (!shouldMount) {
|
|
75
|
+
return (
|
|
76
|
+
<View style={[styles.scene, sceneStyle]}>
|
|
77
|
+
<View style={styles.scenePlaceholder}>
|
|
78
|
+
<Text style={styles.scenePlaceholderText}>
|
|
79
|
+
Swipe to open this tab
|
|
80
|
+
</Text>
|
|
81
|
+
</View>
|
|
82
|
+
</View>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const sceneState: SlideTabSceneState<TData, TError> = {
|
|
87
|
+
tab,
|
|
88
|
+
index,
|
|
89
|
+
isActive,
|
|
90
|
+
data: api.data,
|
|
91
|
+
error: api.error,
|
|
92
|
+
isIdle: api.isIdle,
|
|
93
|
+
isLoading: api.isLoading,
|
|
94
|
+
isSuccess: api.isSuccess,
|
|
95
|
+
isError: api.isError,
|
|
96
|
+
refetch: api.refetch,
|
|
97
|
+
reset: api.reset,
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const heading = tab.heading ?? tab.title;
|
|
101
|
+
const hasDefaultHeader = showSceneHeading && (heading || tab.subtitle);
|
|
102
|
+
|
|
103
|
+
const renderHeader = () => {
|
|
104
|
+
if (renderSceneHeader) {
|
|
105
|
+
return renderSceneHeader(sceneState);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (!hasDefaultHeader) {
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<View style={[styles.sceneHeader, sceneHeaderStyle]}>
|
|
114
|
+
{!!heading && (
|
|
115
|
+
<Text style={[styles.sceneHeading, sceneHeadingStyle]}>
|
|
116
|
+
{heading}
|
|
117
|
+
</Text>
|
|
118
|
+
)}
|
|
119
|
+
{!!tab.subtitle && (
|
|
120
|
+
<Text style={[styles.sceneSubtitle, sceneSubtitleStyle]}>
|
|
121
|
+
{tab.subtitle}
|
|
122
|
+
</Text>
|
|
123
|
+
)}
|
|
124
|
+
</View>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<View style={[styles.scene, sceneStyle]}>
|
|
130
|
+
{renderHeader()}
|
|
131
|
+
{renderScene(sceneState)}
|
|
132
|
+
</View>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default TabScene;
|