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,36 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { ActivityIndicator, Text, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { listStyles } from './styles';
|
|
5
|
+
|
|
6
|
+
type ListEmptyProps = {
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
icon?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const ListEmpty = ({
|
|
14
|
+
loading = false,
|
|
15
|
+
title = 'No items found',
|
|
16
|
+
description = 'There is nothing to show in this list yet.',
|
|
17
|
+
icon,
|
|
18
|
+
}: ListEmptyProps) => {
|
|
19
|
+
if (loading) {
|
|
20
|
+
return (
|
|
21
|
+
<View style={listStyles.initialLoader}>
|
|
22
|
+
<ActivityIndicator size="large" color="#0d6efd" />
|
|
23
|
+
</View>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<View style={listStyles.emptyContainer}>
|
|
29
|
+
{icon}
|
|
30
|
+
<Text style={listStyles.emptyTitle}>{title}</Text>
|
|
31
|
+
<Text style={listStyles.emptyDescription}>{description}</Text>
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default ListEmpty;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ActivityIndicator, View } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { listStyles } from './styles';
|
|
4
|
+
|
|
5
|
+
const ListFooterLoader = () => (
|
|
6
|
+
<View style={listStyles.footerLoader}>
|
|
7
|
+
<ActivityIndicator size="small" color="#0d6efd" />
|
|
8
|
+
</View>
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
export default ListFooterLoader;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
|
|
3
|
+
type FlashListComponent = ComponentType<Record<string, unknown>>;
|
|
4
|
+
|
|
5
|
+
let cachedFlashList: FlashListComponent | null | undefined;
|
|
6
|
+
|
|
7
|
+
export const getFlashList = (): FlashListComponent | null => {
|
|
8
|
+
if (cachedFlashList !== undefined) {
|
|
9
|
+
return cachedFlashList;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
// Optional peer dependency — only required when engine="flashList"
|
|
14
|
+
|
|
15
|
+
const module = require('@shopify/flash-list') as {
|
|
16
|
+
FlashList: FlashListComponent;
|
|
17
|
+
};
|
|
18
|
+
cachedFlashList = module.FlashList;
|
|
19
|
+
} catch {
|
|
20
|
+
cachedFlashList = null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return cachedFlashList;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const isFlashListAvailable = () => getFlashList() !== null;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { forwardRef, useMemo, type ReactElement } from 'react';
|
|
2
|
+
import { FlatList, View, type FlatListProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { defaultKeyExtractor } from './defaultKeyExtractor';
|
|
5
|
+
import { getFlashList } from './getFlashList';
|
|
6
|
+
import ListEmpty from './ListEmpty';
|
|
7
|
+
import ListFooterLoader from './ListFooterLoader';
|
|
8
|
+
import { listStyles } from './styles';
|
|
9
|
+
import type { CustomListProps } from './types';
|
|
10
|
+
|
|
11
|
+
const DEFAULT_ESTIMATED_ITEM_SIZE = 72;
|
|
12
|
+
|
|
13
|
+
const ItemSeparator = () => <View style={listStyles.separator} />;
|
|
14
|
+
|
|
15
|
+
function CustomListInner<T>(
|
|
16
|
+
{
|
|
17
|
+
data,
|
|
18
|
+
renderItem,
|
|
19
|
+
engine = 'flatList',
|
|
20
|
+
keyExtractor = defaultKeyExtractor,
|
|
21
|
+
horizontal = false,
|
|
22
|
+
numColumns = 1,
|
|
23
|
+
loading = false,
|
|
24
|
+
loadingMore = false,
|
|
25
|
+
refreshing = false,
|
|
26
|
+
onRefresh,
|
|
27
|
+
onEndReached,
|
|
28
|
+
onEndReachedThreshold = 0.4,
|
|
29
|
+
estimatedItemSize = DEFAULT_ESTIMATED_ITEM_SIZE,
|
|
30
|
+
emptyTitle,
|
|
31
|
+
emptyDescription,
|
|
32
|
+
emptyIcon,
|
|
33
|
+
showSeparator = false,
|
|
34
|
+
separatorStyle,
|
|
35
|
+
ListHeaderComponent,
|
|
36
|
+
ListFooterComponent,
|
|
37
|
+
ListEmptyComponent,
|
|
38
|
+
ItemSeparatorComponent,
|
|
39
|
+
contentContainerStyle,
|
|
40
|
+
style,
|
|
41
|
+
showsVerticalScrollIndicator = false,
|
|
42
|
+
showsHorizontalScrollIndicator = false,
|
|
43
|
+
...rest
|
|
44
|
+
}: CustomListProps<T>,
|
|
45
|
+
ref: React.Ref<FlatList<T>>
|
|
46
|
+
) {
|
|
47
|
+
const resolvedSeparator = useMemo(() => {
|
|
48
|
+
if (ItemSeparatorComponent) {
|
|
49
|
+
return ItemSeparatorComponent;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!showSeparator || horizontal) {
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (separatorStyle) {
|
|
57
|
+
return () => <View style={[listStyles.separator, separatorStyle]} />;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return ItemSeparator;
|
|
61
|
+
}, [ItemSeparatorComponent, showSeparator, horizontal, separatorStyle]);
|
|
62
|
+
|
|
63
|
+
const resolvedEmpty = useMemo(() => {
|
|
64
|
+
if (ListEmptyComponent) {
|
|
65
|
+
return ListEmptyComponent;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<ListEmpty
|
|
70
|
+
loading={loading}
|
|
71
|
+
title={emptyTitle}
|
|
72
|
+
description={emptyDescription}
|
|
73
|
+
icon={emptyIcon}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
}, [ListEmptyComponent, loading, emptyTitle, emptyDescription, emptyIcon]);
|
|
77
|
+
|
|
78
|
+
const resolvedFooter = useMemo(() => {
|
|
79
|
+
if (loadingMore) {
|
|
80
|
+
return ListFooterComponent ?? <ListFooterLoader />;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return ListFooterComponent;
|
|
84
|
+
}, [ListFooterComponent, loadingMore]);
|
|
85
|
+
|
|
86
|
+
const commonProps = {
|
|
87
|
+
data: loading && data.length === 0 ? [] : data,
|
|
88
|
+
renderItem,
|
|
89
|
+
keyExtractor,
|
|
90
|
+
horizontal,
|
|
91
|
+
numColumns: horizontal ? 1 : numColumns,
|
|
92
|
+
refreshing,
|
|
93
|
+
onRefresh,
|
|
94
|
+
onEndReached,
|
|
95
|
+
onEndReachedThreshold,
|
|
96
|
+
ListHeaderComponent,
|
|
97
|
+
ListFooterComponent: resolvedFooter,
|
|
98
|
+
ListEmptyComponent: resolvedEmpty,
|
|
99
|
+
ItemSeparatorComponent: resolvedSeparator,
|
|
100
|
+
contentContainerStyle: [
|
|
101
|
+
data.length === 0 && listStyles.emptyContainer,
|
|
102
|
+
contentContainerStyle,
|
|
103
|
+
],
|
|
104
|
+
style: [listStyles.list, style],
|
|
105
|
+
showsVerticalScrollIndicator,
|
|
106
|
+
showsHorizontalScrollIndicator,
|
|
107
|
+
...rest,
|
|
108
|
+
} satisfies Partial<FlatListProps<T>>;
|
|
109
|
+
|
|
110
|
+
if (engine === 'flashList') {
|
|
111
|
+
const FlashListComponent = getFlashList();
|
|
112
|
+
|
|
113
|
+
if (!FlashListComponent) {
|
|
114
|
+
console.warn(
|
|
115
|
+
'[CustomList] @shopify/flash-list is not installed. Falling back to FlatList.'
|
|
116
|
+
);
|
|
117
|
+
} else {
|
|
118
|
+
const flashEstimatedSize = horizontal
|
|
119
|
+
? Math.max(estimatedItemSize, 120)
|
|
120
|
+
: estimatedItemSize;
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<FlashListComponent
|
|
124
|
+
{...commonProps}
|
|
125
|
+
ref={ref as never}
|
|
126
|
+
estimatedItemSize={flashEstimatedSize}
|
|
127
|
+
/>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return <FlatList {...commonProps} ref={ref} />;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const CustomList = forwardRef(CustomListInner) as <T>(
|
|
136
|
+
props: CustomListProps<T> & { ref?: React.Ref<FlatList<T>> }
|
|
137
|
+
) => ReactElement;
|
|
138
|
+
|
|
139
|
+
export default CustomList;
|
|
140
|
+
export { defaultKeyExtractor } from './defaultKeyExtractor';
|
|
141
|
+
export { getFlashList, isFlashListAvailable } from './getFlashList';
|
|
142
|
+
export type { CustomListProps, ListEngine } from './types';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const listStyles = StyleSheet.create({
|
|
4
|
+
list: {
|
|
5
|
+
flex: 1,
|
|
6
|
+
},
|
|
7
|
+
separator: {
|
|
8
|
+
height: 1,
|
|
9
|
+
backgroundColor: '#e9ecef',
|
|
10
|
+
marginHorizontal: 16,
|
|
11
|
+
},
|
|
12
|
+
emptyContainer: {
|
|
13
|
+
flexGrow: 1,
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
justifyContent: 'center',
|
|
16
|
+
paddingHorizontal: 24,
|
|
17
|
+
paddingVertical: 48,
|
|
18
|
+
gap: 8,
|
|
19
|
+
},
|
|
20
|
+
emptyTitle: {
|
|
21
|
+
fontSize: 16,
|
|
22
|
+
fontWeight: '600',
|
|
23
|
+
color: '#212529',
|
|
24
|
+
textAlign: 'center',
|
|
25
|
+
},
|
|
26
|
+
emptyDescription: {
|
|
27
|
+
fontSize: 14,
|
|
28
|
+
lineHeight: 20,
|
|
29
|
+
color: '#6c757d',
|
|
30
|
+
textAlign: 'center',
|
|
31
|
+
},
|
|
32
|
+
footerLoader: {
|
|
33
|
+
paddingVertical: 16,
|
|
34
|
+
alignItems: 'center',
|
|
35
|
+
justifyContent: 'center',
|
|
36
|
+
},
|
|
37
|
+
initialLoader: {
|
|
38
|
+
flex: 1,
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
justifyContent: 'center',
|
|
41
|
+
paddingVertical: 48,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ReactNode, Ref } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
FlatList,
|
|
4
|
+
FlatListProps,
|
|
5
|
+
ListRenderItem,
|
|
6
|
+
StyleProp,
|
|
7
|
+
ViewStyle,
|
|
8
|
+
} from 'react-native';
|
|
9
|
+
|
|
10
|
+
export type ListEngine = 'flatList' | 'flashList';
|
|
11
|
+
|
|
12
|
+
export type CustomListProps<T> = {
|
|
13
|
+
data: T[];
|
|
14
|
+
renderItem: ListRenderItem<T>;
|
|
15
|
+
engine?: ListEngine;
|
|
16
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
17
|
+
horizontal?: boolean;
|
|
18
|
+
numColumns?: number;
|
|
19
|
+
loading?: boolean;
|
|
20
|
+
loadingMore?: boolean;
|
|
21
|
+
refreshing?: boolean;
|
|
22
|
+
onRefresh?: () => void;
|
|
23
|
+
onEndReached?: () => void;
|
|
24
|
+
onEndReachedThreshold?: number;
|
|
25
|
+
estimatedItemSize?: number;
|
|
26
|
+
emptyTitle?: string;
|
|
27
|
+
emptyDescription?: string;
|
|
28
|
+
emptyIcon?: ReactNode;
|
|
29
|
+
showSeparator?: boolean;
|
|
30
|
+
separatorStyle?: StyleProp<ViewStyle>;
|
|
31
|
+
ListHeaderComponent?: FlatListProps<T>['ListHeaderComponent'];
|
|
32
|
+
ListFooterComponent?: FlatListProps<T>['ListFooterComponent'];
|
|
33
|
+
ListEmptyComponent?: FlatListProps<T>['ListEmptyComponent'];
|
|
34
|
+
ItemSeparatorComponent?: FlatListProps<T>['ItemSeparatorComponent'];
|
|
35
|
+
contentContainerStyle?: StyleProp<ViewStyle>;
|
|
36
|
+
style?: StyleProp<ViewStyle>;
|
|
37
|
+
showsVerticalScrollIndicator?: boolean;
|
|
38
|
+
showsHorizontalScrollIndicator?: boolean;
|
|
39
|
+
} & Omit<
|
|
40
|
+
FlatListProps<T>,
|
|
41
|
+
| 'data'
|
|
42
|
+
| 'renderItem'
|
|
43
|
+
| 'keyExtractor'
|
|
44
|
+
| 'horizontal'
|
|
45
|
+
| 'numColumns'
|
|
46
|
+
| 'refreshing'
|
|
47
|
+
| 'onRefresh'
|
|
48
|
+
| 'onEndReached'
|
|
49
|
+
| 'onEndReachedThreshold'
|
|
50
|
+
| 'ListHeaderComponent'
|
|
51
|
+
| 'ListFooterComponent'
|
|
52
|
+
| 'ListEmptyComponent'
|
|
53
|
+
| 'ItemSeparatorComponent'
|
|
54
|
+
| 'contentContainerStyle'
|
|
55
|
+
| 'style'
|
|
56
|
+
| 'showsVerticalScrollIndicator'
|
|
57
|
+
| 'showsHorizontalScrollIndicator'
|
|
58
|
+
>;
|
|
59
|
+
|
|
60
|
+
export type CustomListRef<T> = Ref<FlatList<T>>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { View, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import CustomButton from '../customButton';
|
|
5
|
+
import { styles } from './styles';
|
|
6
|
+
import type { ModalAction } from './types';
|
|
7
|
+
|
|
8
|
+
type ModalFooterProps = {
|
|
9
|
+
footer?: ReactNode;
|
|
10
|
+
primaryAction?: ModalAction;
|
|
11
|
+
secondaryAction?: ModalAction;
|
|
12
|
+
footerStyle?: StyleProp<ViewStyle>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const ModalFooter = ({
|
|
16
|
+
footer,
|
|
17
|
+
primaryAction,
|
|
18
|
+
secondaryAction,
|
|
19
|
+
footerStyle,
|
|
20
|
+
}: ModalFooterProps) => {
|
|
21
|
+
if (footer) {
|
|
22
|
+
return <View style={[styles.footer, footerStyle]}>{footer}</View>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!primaryAction && !secondaryAction) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<View style={[styles.footer, footerStyle]}>
|
|
31
|
+
{secondaryAction && (
|
|
32
|
+
<CustomButton
|
|
33
|
+
text={secondaryAction.label}
|
|
34
|
+
variant={secondaryAction.variant ?? 'outline'}
|
|
35
|
+
disabled={secondaryAction.disabled}
|
|
36
|
+
isLoading={secondaryAction.isLoading}
|
|
37
|
+
borderRadius={8}
|
|
38
|
+
buttonStyles={styles.footerButton}
|
|
39
|
+
onPress={secondaryAction.onPress}
|
|
40
|
+
/>
|
|
41
|
+
)}
|
|
42
|
+
{primaryAction && (
|
|
43
|
+
<CustomButton
|
|
44
|
+
text={primaryAction.label}
|
|
45
|
+
variant={primaryAction.variant ?? 'primary'}
|
|
46
|
+
disabled={primaryAction.disabled}
|
|
47
|
+
isLoading={primaryAction.isLoading}
|
|
48
|
+
borderRadius={8}
|
|
49
|
+
buttonStyles={styles.footerButton}
|
|
50
|
+
onPress={primaryAction.onPress}
|
|
51
|
+
/>
|
|
52
|
+
)}
|
|
53
|
+
</View>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default ModalFooter;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { Modal, Pressable, ScrollView, Text, View } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import CloseButton from '../closeButton';
|
|
5
|
+
import ModalFooter from './ModalFooter';
|
|
6
|
+
import { presentationStyles, styles } from './styles';
|
|
7
|
+
import type { CustomModalProps } from './types';
|
|
8
|
+
|
|
9
|
+
const CustomModal = ({
|
|
10
|
+
visible,
|
|
11
|
+
onClose,
|
|
12
|
+
title,
|
|
13
|
+
description,
|
|
14
|
+
children,
|
|
15
|
+
presentation = 'center',
|
|
16
|
+
showCloseButton = true,
|
|
17
|
+
closeOnBackdropPress = true,
|
|
18
|
+
animationType,
|
|
19
|
+
scrollable = false,
|
|
20
|
+
containerStyle,
|
|
21
|
+
backdropStyle,
|
|
22
|
+
contentStyle,
|
|
23
|
+
headerStyle,
|
|
24
|
+
titleStyle,
|
|
25
|
+
descriptionStyle,
|
|
26
|
+
bodyStyle,
|
|
27
|
+
footerStyle,
|
|
28
|
+
footer,
|
|
29
|
+
primaryAction,
|
|
30
|
+
secondaryAction,
|
|
31
|
+
closeImage,
|
|
32
|
+
supportedOrientations = ['landscape', 'portrait'],
|
|
33
|
+
statusBarTranslucent,
|
|
34
|
+
testID,
|
|
35
|
+
}: CustomModalProps) => {
|
|
36
|
+
const presentationStyle = presentationStyles[presentation];
|
|
37
|
+
const resolvedAnimationType =
|
|
38
|
+
animationType ?? presentationStyle.animationType;
|
|
39
|
+
|
|
40
|
+
const contentInnerStyle = useMemo(() => {
|
|
41
|
+
if (presentation === 'fullscreen') {
|
|
42
|
+
return styles.fullscreenContentInner;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (presentation === 'bottom') {
|
|
46
|
+
return styles.bottomContentInner;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return styles.contentInner;
|
|
50
|
+
}, [presentation]);
|
|
51
|
+
|
|
52
|
+
const showHeader = Boolean(title || description || showCloseButton);
|
|
53
|
+
|
|
54
|
+
const handleBackdropPress = () => {
|
|
55
|
+
if (closeOnBackdropPress) {
|
|
56
|
+
onClose();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const renderBody = () => {
|
|
61
|
+
if (!children) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (scrollable) {
|
|
66
|
+
return (
|
|
67
|
+
<ScrollView
|
|
68
|
+
style={[styles.body, styles.scrollBody, bodyStyle]}
|
|
69
|
+
showsVerticalScrollIndicator={false}
|
|
70
|
+
bounces={false}
|
|
71
|
+
>
|
|
72
|
+
{children}
|
|
73
|
+
</ScrollView>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return <View style={[styles.body, bodyStyle]}>{children}</View>;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const renderContent = () => (
|
|
81
|
+
<Pressable
|
|
82
|
+
style={[presentationStyle.content, contentStyle]}
|
|
83
|
+
onPress={() => {}}
|
|
84
|
+
>
|
|
85
|
+
<View style={contentInnerStyle}>
|
|
86
|
+
{presentation === 'bottom' && <View style={styles.handle} />}
|
|
87
|
+
|
|
88
|
+
{showHeader && (
|
|
89
|
+
<View style={[styles.header, headerStyle]}>
|
|
90
|
+
<View style={styles.headerText}>
|
|
91
|
+
{!!title && (
|
|
92
|
+
<Text style={[styles.title, titleStyle]}>{title}</Text>
|
|
93
|
+
)}
|
|
94
|
+
{!!description && (
|
|
95
|
+
<Text style={[styles.description, descriptionStyle]}>
|
|
96
|
+
{description}
|
|
97
|
+
</Text>
|
|
98
|
+
)}
|
|
99
|
+
</View>
|
|
100
|
+
{showCloseButton && (
|
|
101
|
+
<CloseButton
|
|
102
|
+
closeImage={closeImage}
|
|
103
|
+
containerStyle={styles.closeButton}
|
|
104
|
+
onPress={onClose}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
</View>
|
|
108
|
+
)}
|
|
109
|
+
|
|
110
|
+
{renderBody()}
|
|
111
|
+
|
|
112
|
+
<ModalFooter
|
|
113
|
+
footer={footer}
|
|
114
|
+
footerStyle={footerStyle}
|
|
115
|
+
primaryAction={primaryAction}
|
|
116
|
+
secondaryAction={secondaryAction}
|
|
117
|
+
/>
|
|
118
|
+
</View>
|
|
119
|
+
</Pressable>
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<Modal
|
|
124
|
+
transparent={presentation !== 'fullscreen'}
|
|
125
|
+
visible={visible}
|
|
126
|
+
animationType={resolvedAnimationType}
|
|
127
|
+
supportedOrientations={supportedOrientations}
|
|
128
|
+
statusBarTranslucent={statusBarTranslucent}
|
|
129
|
+
testID={testID}
|
|
130
|
+
onRequestClose={onClose}
|
|
131
|
+
>
|
|
132
|
+
<View style={[presentationStyle.backdrop, backdropStyle, containerStyle]}>
|
|
133
|
+
{presentation === 'bottom' ? (
|
|
134
|
+
<>
|
|
135
|
+
{closeOnBackdropPress && (
|
|
136
|
+
<Pressable
|
|
137
|
+
style={styles.backdropDismiss}
|
|
138
|
+
onPress={handleBackdropPress}
|
|
139
|
+
/>
|
|
140
|
+
)}
|
|
141
|
+
{renderContent()}
|
|
142
|
+
</>
|
|
143
|
+
) : presentation === 'center' ? (
|
|
144
|
+
<Pressable
|
|
145
|
+
style={[
|
|
146
|
+
styles.backdropDismiss,
|
|
147
|
+
{
|
|
148
|
+
justifyContent: 'center',
|
|
149
|
+
alignItems: 'center',
|
|
150
|
+
},
|
|
151
|
+
]}
|
|
152
|
+
onPress={handleBackdropPress}
|
|
153
|
+
>
|
|
154
|
+
<Pressable onPress={() => {}}>{renderContent()}</Pressable>
|
|
155
|
+
</Pressable>
|
|
156
|
+
) : (
|
|
157
|
+
renderContent()
|
|
158
|
+
)}
|
|
159
|
+
</View>
|
|
160
|
+
</Modal>
|
|
161
|
+
);
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export default CustomModal;
|
|
165
|
+
export { useCustomModal } from './useCustomModal';
|
|
166
|
+
export type { CustomModalProps, ModalAction, ModalPresentation } from './types';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { StyleSheet, type ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { ModalPresentation } from './types';
|
|
4
|
+
|
|
5
|
+
export const presentationStyles: Record<
|
|
6
|
+
ModalPresentation,
|
|
7
|
+
{
|
|
8
|
+
backdrop: ViewStyle;
|
|
9
|
+
content: ViewStyle;
|
|
10
|
+
animationType: 'none' | 'slide' | 'fade';
|
|
11
|
+
}
|
|
12
|
+
> = {
|
|
13
|
+
center: {
|
|
14
|
+
backdrop: {
|
|
15
|
+
flex: 1,
|
|
16
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
17
|
+
justifyContent: 'center',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
padding: 20,
|
|
20
|
+
},
|
|
21
|
+
content: {
|
|
22
|
+
width: '100%',
|
|
23
|
+
maxWidth: 400,
|
|
24
|
+
maxHeight: '80%',
|
|
25
|
+
backgroundColor: '#FFFFFF',
|
|
26
|
+
borderRadius: 12,
|
|
27
|
+
overflow: 'hidden',
|
|
28
|
+
},
|
|
29
|
+
animationType: 'fade',
|
|
30
|
+
},
|
|
31
|
+
bottom: {
|
|
32
|
+
backdrop: {
|
|
33
|
+
flex: 1,
|
|
34
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
35
|
+
justifyContent: 'flex-end',
|
|
36
|
+
},
|
|
37
|
+
content: {
|
|
38
|
+
width: '100%',
|
|
39
|
+
maxHeight: '85%',
|
|
40
|
+
backgroundColor: '#FFFFFF',
|
|
41
|
+
borderTopLeftRadius: 16,
|
|
42
|
+
borderTopRightRadius: 16,
|
|
43
|
+
overflow: 'hidden',
|
|
44
|
+
},
|
|
45
|
+
animationType: 'slide',
|
|
46
|
+
},
|
|
47
|
+
fullscreen: {
|
|
48
|
+
backdrop: {
|
|
49
|
+
flex: 1,
|
|
50
|
+
backgroundColor: '#FFFFFF',
|
|
51
|
+
},
|
|
52
|
+
content: {
|
|
53
|
+
flex: 1,
|
|
54
|
+
width: '100%',
|
|
55
|
+
backgroundColor: '#FFFFFF',
|
|
56
|
+
},
|
|
57
|
+
animationType: 'slide',
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const styles = StyleSheet.create({
|
|
62
|
+
backdropDismiss: {
|
|
63
|
+
...StyleSheet.absoluteFill,
|
|
64
|
+
},
|
|
65
|
+
contentInner: {
|
|
66
|
+
paddingHorizontal: 20,
|
|
67
|
+
paddingTop: 20,
|
|
68
|
+
paddingBottom: 16,
|
|
69
|
+
},
|
|
70
|
+
bottomContentInner: {
|
|
71
|
+
paddingHorizontal: 20,
|
|
72
|
+
paddingTop: 12,
|
|
73
|
+
paddingBottom: 24,
|
|
74
|
+
},
|
|
75
|
+
fullscreenContentInner: {
|
|
76
|
+
flex: 1,
|
|
77
|
+
paddingHorizontal: 20,
|
|
78
|
+
paddingTop: 56,
|
|
79
|
+
paddingBottom: 20,
|
|
80
|
+
},
|
|
81
|
+
handle: {
|
|
82
|
+
alignSelf: 'center',
|
|
83
|
+
width: 40,
|
|
84
|
+
height: 4,
|
|
85
|
+
borderRadius: 2,
|
|
86
|
+
backgroundColor: '#DEE2E6',
|
|
87
|
+
marginTop: 12,
|
|
88
|
+
marginBottom: 8,
|
|
89
|
+
},
|
|
90
|
+
header: {
|
|
91
|
+
flexDirection: 'row',
|
|
92
|
+
alignItems: 'flex-start',
|
|
93
|
+
justifyContent: 'space-between',
|
|
94
|
+
gap: 12,
|
|
95
|
+
marginBottom: 12,
|
|
96
|
+
},
|
|
97
|
+
headerText: {
|
|
98
|
+
flex: 1,
|
|
99
|
+
gap: 6,
|
|
100
|
+
},
|
|
101
|
+
title: {
|
|
102
|
+
fontSize: 18,
|
|
103
|
+
fontWeight: '700',
|
|
104
|
+
color: '#212529',
|
|
105
|
+
},
|
|
106
|
+
description: {
|
|
107
|
+
fontSize: 14,
|
|
108
|
+
color: '#6C757D',
|
|
109
|
+
lineHeight: 20,
|
|
110
|
+
},
|
|
111
|
+
closeButton: {
|
|
112
|
+
position: 'relative',
|
|
113
|
+
top: 0,
|
|
114
|
+
right: 0,
|
|
115
|
+
},
|
|
116
|
+
body: {
|
|
117
|
+
flexGrow: 0,
|
|
118
|
+
},
|
|
119
|
+
scrollBody: {
|
|
120
|
+
maxHeight: 320,
|
|
121
|
+
},
|
|
122
|
+
footer: {
|
|
123
|
+
flexDirection: 'row',
|
|
124
|
+
gap: 10,
|
|
125
|
+
marginTop: 16,
|
|
126
|
+
},
|
|
127
|
+
footerButton: {
|
|
128
|
+
flex: 1,
|
|
129
|
+
alignSelf: 'auto',
|
|
130
|
+
},
|
|
131
|
+
});
|