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,288 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Image,
|
|
3
|
+
Text,
|
|
4
|
+
TouchableOpacity,
|
|
5
|
+
View,
|
|
6
|
+
type ColorValue,
|
|
7
|
+
} from 'react-native';
|
|
8
|
+
import { useMemo } from 'react';
|
|
9
|
+
|
|
10
|
+
import type { CustomButtonProps } from './types';
|
|
11
|
+
import {
|
|
12
|
+
iconOnlySizeStyles,
|
|
13
|
+
sizeStyles,
|
|
14
|
+
contentAlignStyles,
|
|
15
|
+
styles,
|
|
16
|
+
variantTheme,
|
|
17
|
+
} from './styles';
|
|
18
|
+
import Loader from '../loading';
|
|
19
|
+
|
|
20
|
+
const toColorString = (color: ColorValue | undefined, fallback: string) =>
|
|
21
|
+
typeof color === 'string' ? color : fallback;
|
|
22
|
+
|
|
23
|
+
const CustomButton = ({
|
|
24
|
+
text = 'Submit',
|
|
25
|
+
children,
|
|
26
|
+
variant = 'default',
|
|
27
|
+
size = 'md',
|
|
28
|
+
contentAlign = 'center',
|
|
29
|
+
iconOnly = false,
|
|
30
|
+
iconOnlyShape = 'square',
|
|
31
|
+
rightImage,
|
|
32
|
+
leftImage,
|
|
33
|
+
style,
|
|
34
|
+
buttonStyles,
|
|
35
|
+
textStyles,
|
|
36
|
+
opacity = 0.7,
|
|
37
|
+
onPress,
|
|
38
|
+
imageStyles,
|
|
39
|
+
imageOuterStyle,
|
|
40
|
+
rotateRight = '0deg',
|
|
41
|
+
rotateLeft = '0deg',
|
|
42
|
+
disabled = false,
|
|
43
|
+
isLoading = false,
|
|
44
|
+
itemCount,
|
|
45
|
+
showCount = false,
|
|
46
|
+
isCapital = false,
|
|
47
|
+
borderRadius = 0,
|
|
48
|
+
RightIcon,
|
|
49
|
+
LeftIcon,
|
|
50
|
+
rightIconColor,
|
|
51
|
+
leftIconColor,
|
|
52
|
+
rightIconSize,
|
|
53
|
+
leftIconSize,
|
|
54
|
+
rightIconProps = {},
|
|
55
|
+
leftIconProps = {},
|
|
56
|
+
accessibilityRole = 'button',
|
|
57
|
+
accessibilityLabel,
|
|
58
|
+
accessibilityState,
|
|
59
|
+
...touchableProps
|
|
60
|
+
}: CustomButtonProps) => {
|
|
61
|
+
const iconOnlyMetrics = iconOnlySizeStyles[size];
|
|
62
|
+
const theme = variantTheme[variant];
|
|
63
|
+
const fallbackIconColor = toColorString(theme.text.color, '#000000');
|
|
64
|
+
const resolvedLeftIconColor = leftIconColor ?? fallbackIconColor;
|
|
65
|
+
const resolvedRightIconColor = rightIconColor ?? fallbackIconColor;
|
|
66
|
+
const resolvedLeftIconSize =
|
|
67
|
+
leftIconSize ?? (iconOnly ? iconOnlyMetrics.iconSize : 20);
|
|
68
|
+
const resolvedRightIconSize =
|
|
69
|
+
rightIconSize ?? (iconOnly ? iconOnlyMetrics.iconSize : 20);
|
|
70
|
+
const resolvedImageSize = iconOnly ? iconOnlyMetrics.imageSize : undefined;
|
|
71
|
+
|
|
72
|
+
const IconComponent = LeftIcon ?? RightIcon;
|
|
73
|
+
const imageSource = leftImage ?? rightImage;
|
|
74
|
+
const hasIconOnlyContent = Boolean(IconComponent || imageSource || children);
|
|
75
|
+
|
|
76
|
+
if (__DEV__ && iconOnly && !hasIconOnlyContent) {
|
|
77
|
+
console.warn(
|
|
78
|
+
'CustomButton: iconOnly requires LeftIcon, RightIcon, leftImage, rightImage, or children.'
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (__DEV__ && iconOnly && !accessibilityLabel && !text) {
|
|
83
|
+
console.warn(
|
|
84
|
+
'CustomButton: iconOnly buttons should include accessibilityLabel for screen readers.'
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const alignment = iconOnly
|
|
89
|
+
? contentAlignStyles.center
|
|
90
|
+
: contentAlignStyles[contentAlign];
|
|
91
|
+
|
|
92
|
+
const iconOnlyBorderRadius =
|
|
93
|
+
iconOnly && iconOnlyShape === 'circle'
|
|
94
|
+
? (iconOnlyMetrics.button.width as number) / 2
|
|
95
|
+
: borderRadius;
|
|
96
|
+
|
|
97
|
+
const buttonStyle = useMemo(
|
|
98
|
+
() => [
|
|
99
|
+
styles.button,
|
|
100
|
+
theme.button,
|
|
101
|
+
!iconOnly && sizeStyles[size],
|
|
102
|
+
iconOnly && iconOnlyMetrics.button,
|
|
103
|
+
disabled && styles.disabledButton,
|
|
104
|
+
buttonStyles,
|
|
105
|
+
style,
|
|
106
|
+
{ borderRadius: iconOnly ? iconOnlyBorderRadius : borderRadius },
|
|
107
|
+
],
|
|
108
|
+
[
|
|
109
|
+
theme.button,
|
|
110
|
+
size,
|
|
111
|
+
iconOnly,
|
|
112
|
+
iconOnlyMetrics.button,
|
|
113
|
+
disabled,
|
|
114
|
+
buttonStyles,
|
|
115
|
+
style,
|
|
116
|
+
iconOnlyBorderRadius,
|
|
117
|
+
borderRadius,
|
|
118
|
+
]
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
const labelStyle = useMemo(
|
|
122
|
+
() => [
|
|
123
|
+
styles.text,
|
|
124
|
+
alignment.text,
|
|
125
|
+
theme.text,
|
|
126
|
+
textStyles,
|
|
127
|
+
disabled && styles.disabledText,
|
|
128
|
+
],
|
|
129
|
+
[alignment.text, theme.text, textStyles, disabled]
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
const imageTintStyle = theme.imageTint
|
|
133
|
+
? { tintColor: theme.imageTint }
|
|
134
|
+
: undefined;
|
|
135
|
+
|
|
136
|
+
const getLabel = () => {
|
|
137
|
+
if (typeof text !== 'string') {
|
|
138
|
+
return text;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return isCapital ? text.toUpperCase() : text;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const renderLabel = () => {
|
|
145
|
+
if (iconOnly) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (children) {
|
|
150
|
+
return children;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const label = getLabel();
|
|
154
|
+
|
|
155
|
+
if (!label) {
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return <Text style={labelStyle}>{label}</Text>;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const renderIconOnlyContent = () => {
|
|
163
|
+
if (!iconOnly) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (children) {
|
|
168
|
+
return children;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (IconComponent) {
|
|
172
|
+
return (
|
|
173
|
+
<IconComponent
|
|
174
|
+
size={LeftIcon ? resolvedLeftIconSize : resolvedRightIconSize}
|
|
175
|
+
color={LeftIcon ? resolvedLeftIconColor : resolvedRightIconColor}
|
|
176
|
+
{...(LeftIcon ? leftIconProps : rightIconProps)}
|
|
177
|
+
/>
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (imageSource) {
|
|
182
|
+
return (
|
|
183
|
+
<Image
|
|
184
|
+
resizeMode="contain"
|
|
185
|
+
source={imageSource}
|
|
186
|
+
style={[
|
|
187
|
+
iconOnly &&
|
|
188
|
+
resolvedImageSize != null && {
|
|
189
|
+
width: resolvedImageSize,
|
|
190
|
+
height: resolvedImageSize,
|
|
191
|
+
},
|
|
192
|
+
imageTintStyle,
|
|
193
|
+
imageStyles,
|
|
194
|
+
]}
|
|
195
|
+
/>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return null;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
return (
|
|
203
|
+
<TouchableOpacity
|
|
204
|
+
{...touchableProps}
|
|
205
|
+
accessibilityRole={accessibilityRole}
|
|
206
|
+
accessibilityLabel={accessibilityLabel ?? text}
|
|
207
|
+
accessibilityState={{
|
|
208
|
+
disabled: disabled || isLoading,
|
|
209
|
+
busy: isLoading,
|
|
210
|
+
...accessibilityState,
|
|
211
|
+
}}
|
|
212
|
+
disabled={disabled || isLoading}
|
|
213
|
+
activeOpacity={opacity}
|
|
214
|
+
style={buttonStyle}
|
|
215
|
+
onPress={onPress}
|
|
216
|
+
>
|
|
217
|
+
{showCount && (
|
|
218
|
+
<View style={styles.countContainer}>
|
|
219
|
+
<Text style={styles.countText}>{itemCount}</Text>
|
|
220
|
+
</View>
|
|
221
|
+
)}
|
|
222
|
+
<View
|
|
223
|
+
style={[
|
|
224
|
+
styles.container,
|
|
225
|
+
alignment.container,
|
|
226
|
+
iconOnly && styles.iconOnlyContainer,
|
|
227
|
+
imageOuterStyle,
|
|
228
|
+
]}
|
|
229
|
+
>
|
|
230
|
+
{iconOnly ? (
|
|
231
|
+
renderIconOnlyContent()
|
|
232
|
+
) : (
|
|
233
|
+
<>
|
|
234
|
+
{LeftIcon && (
|
|
235
|
+
<LeftIcon
|
|
236
|
+
size={resolvedLeftIconSize}
|
|
237
|
+
color={resolvedLeftIconColor}
|
|
238
|
+
{...leftIconProps}
|
|
239
|
+
/>
|
|
240
|
+
)}
|
|
241
|
+
{leftImage && (
|
|
242
|
+
<Image
|
|
243
|
+
resizeMode="contain"
|
|
244
|
+
source={leftImage}
|
|
245
|
+
style={[
|
|
246
|
+
styles.leftImage,
|
|
247
|
+
imageTintStyle,
|
|
248
|
+
imageStyles,
|
|
249
|
+
{ transform: [{ rotate: rotateLeft }] },
|
|
250
|
+
]}
|
|
251
|
+
/>
|
|
252
|
+
)}
|
|
253
|
+
{renderLabel()}
|
|
254
|
+
{RightIcon && (
|
|
255
|
+
<RightIcon
|
|
256
|
+
size={resolvedRightIconSize}
|
|
257
|
+
color={resolvedRightIconColor}
|
|
258
|
+
{...rightIconProps}
|
|
259
|
+
/>
|
|
260
|
+
)}
|
|
261
|
+
{rightImage && (
|
|
262
|
+
<Image
|
|
263
|
+
resizeMode="contain"
|
|
264
|
+
source={rightImage}
|
|
265
|
+
style={[
|
|
266
|
+
styles.rightImage,
|
|
267
|
+
imageTintStyle,
|
|
268
|
+
imageStyles,
|
|
269
|
+
{ transform: [{ rotate: rotateRight }] },
|
|
270
|
+
]}
|
|
271
|
+
/>
|
|
272
|
+
)}
|
|
273
|
+
</>
|
|
274
|
+
)}
|
|
275
|
+
</View>
|
|
276
|
+
{isLoading && <Loader small color={theme.loaderColor} />}
|
|
277
|
+
</TouchableOpacity>
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
export default CustomButton;
|
|
282
|
+
export type {
|
|
283
|
+
ButtonContentAlign,
|
|
284
|
+
ButtonSize,
|
|
285
|
+
ButtonVariant,
|
|
286
|
+
CustomButtonProps,
|
|
287
|
+
IconOnlyShape,
|
|
288
|
+
} from './types';
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { StyleSheet, type TextStyle, type ViewStyle } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import type { ButtonContentAlign, ButtonSize, ButtonVariant } from './types';
|
|
4
|
+
|
|
5
|
+
const baseButton: ViewStyle = {
|
|
6
|
+
paddingHorizontal: 20,
|
|
7
|
+
paddingVertical: 15,
|
|
8
|
+
alignItems: 'center',
|
|
9
|
+
justifyContent: 'center',
|
|
10
|
+
alignSelf: 'stretch',
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const sizeStyles: Record<ButtonSize, ViewStyle> = {
|
|
14
|
+
sm: {
|
|
15
|
+
paddingHorizontal: 12,
|
|
16
|
+
paddingVertical: 8,
|
|
17
|
+
},
|
|
18
|
+
md: {},
|
|
19
|
+
lg: {
|
|
20
|
+
paddingHorizontal: 24,
|
|
21
|
+
paddingVertical: 18,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const iconOnlySizeStyles: Record<
|
|
26
|
+
ButtonSize,
|
|
27
|
+
{ button: ViewStyle; iconSize: number; imageSize: number }
|
|
28
|
+
> = {
|
|
29
|
+
sm: {
|
|
30
|
+
button: {
|
|
31
|
+
width: 36,
|
|
32
|
+
height: 36,
|
|
33
|
+
paddingHorizontal: 0,
|
|
34
|
+
paddingVertical: 0,
|
|
35
|
+
alignSelf: 'flex-start',
|
|
36
|
+
},
|
|
37
|
+
iconSize: 16,
|
|
38
|
+
imageSize: 18,
|
|
39
|
+
},
|
|
40
|
+
md: {
|
|
41
|
+
button: {
|
|
42
|
+
width: 44,
|
|
43
|
+
height: 44,
|
|
44
|
+
paddingHorizontal: 0,
|
|
45
|
+
paddingVertical: 0,
|
|
46
|
+
alignSelf: 'flex-start',
|
|
47
|
+
},
|
|
48
|
+
iconSize: 20,
|
|
49
|
+
imageSize: 22,
|
|
50
|
+
},
|
|
51
|
+
lg: {
|
|
52
|
+
button: {
|
|
53
|
+
width: 52,
|
|
54
|
+
height: 52,
|
|
55
|
+
paddingHorizontal: 0,
|
|
56
|
+
paddingVertical: 0,
|
|
57
|
+
alignSelf: 'flex-start',
|
|
58
|
+
},
|
|
59
|
+
iconSize: 24,
|
|
60
|
+
imageSize: 26,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const variantTheme: Record<
|
|
65
|
+
ButtonVariant,
|
|
66
|
+
{
|
|
67
|
+
button: ViewStyle;
|
|
68
|
+
text: TextStyle;
|
|
69
|
+
imageTint?: string;
|
|
70
|
+
loaderColor: string;
|
|
71
|
+
}
|
|
72
|
+
> = {
|
|
73
|
+
default: {
|
|
74
|
+
button: { backgroundColor: '#FFFFFF' },
|
|
75
|
+
text: { color: '#000000', fontWeight: '600' },
|
|
76
|
+
loaderColor: '#000000',
|
|
77
|
+
},
|
|
78
|
+
primary: {
|
|
79
|
+
button: { backgroundColor: '#0D6EFD' },
|
|
80
|
+
text: { color: '#FFFFFF', fontWeight: '600' },
|
|
81
|
+
imageTint: '#FFFFFF',
|
|
82
|
+
loaderColor: '#FFFFFF',
|
|
83
|
+
},
|
|
84
|
+
danger: {
|
|
85
|
+
button: { backgroundColor: '#DC3545' },
|
|
86
|
+
text: { color: '#FFFFFF', fontWeight: '600' },
|
|
87
|
+
imageTint: '#FFFFFF',
|
|
88
|
+
loaderColor: '#FFFFFF',
|
|
89
|
+
},
|
|
90
|
+
warning: {
|
|
91
|
+
button: { backgroundColor: '#FFC107' },
|
|
92
|
+
text: { color: '#212529', fontWeight: '600' },
|
|
93
|
+
imageTint: '#212529',
|
|
94
|
+
loaderColor: '#212529',
|
|
95
|
+
},
|
|
96
|
+
info: {
|
|
97
|
+
button: { backgroundColor: '#407BFF' },
|
|
98
|
+
text: { color: '#FFFFFF', fontWeight: '600' },
|
|
99
|
+
imageTint: '#FFFFFF',
|
|
100
|
+
loaderColor: '#FFFFFF',
|
|
101
|
+
},
|
|
102
|
+
success: {
|
|
103
|
+
button: { backgroundColor: '#198754' },
|
|
104
|
+
text: { color: '#FFFFFF', fontWeight: '600' },
|
|
105
|
+
imageTint: '#FFFFFF',
|
|
106
|
+
loaderColor: '#FFFFFF',
|
|
107
|
+
},
|
|
108
|
+
secondary: {
|
|
109
|
+
button: { backgroundColor: '#6C757D' },
|
|
110
|
+
text: { color: '#FFFFFF', fontWeight: '600' },
|
|
111
|
+
imageTint: '#FFFFFF',
|
|
112
|
+
loaderColor: '#FFFFFF',
|
|
113
|
+
},
|
|
114
|
+
light: {
|
|
115
|
+
button: { backgroundColor: '#F8F9FA' },
|
|
116
|
+
text: { color: '#212529', fontWeight: '600' },
|
|
117
|
+
imageTint: '#212529',
|
|
118
|
+
loaderColor: '#212529',
|
|
119
|
+
},
|
|
120
|
+
dark: {
|
|
121
|
+
button: { backgroundColor: '#212529' },
|
|
122
|
+
text: { color: '#FFFFFF', fontWeight: '600' },
|
|
123
|
+
imageTint: '#FFFFFF',
|
|
124
|
+
loaderColor: '#FFFFFF',
|
|
125
|
+
},
|
|
126
|
+
link: {
|
|
127
|
+
button: {
|
|
128
|
+
backgroundColor: 'transparent',
|
|
129
|
+
paddingHorizontal: 4,
|
|
130
|
+
paddingVertical: 4,
|
|
131
|
+
},
|
|
132
|
+
text: {
|
|
133
|
+
color: '#0D6EFD',
|
|
134
|
+
fontWeight: '600',
|
|
135
|
+
textDecorationLine: 'underline',
|
|
136
|
+
},
|
|
137
|
+
loaderColor: '#0D6EFD',
|
|
138
|
+
},
|
|
139
|
+
outline: {
|
|
140
|
+
button: {
|
|
141
|
+
backgroundColor: 'transparent',
|
|
142
|
+
borderWidth: 1,
|
|
143
|
+
borderColor: '#0D6EFD',
|
|
144
|
+
},
|
|
145
|
+
text: { color: '#0D6EFD', fontWeight: '600' },
|
|
146
|
+
imageTint: '#0D6EFD',
|
|
147
|
+
loaderColor: '#0D6EFD',
|
|
148
|
+
},
|
|
149
|
+
ghost: {
|
|
150
|
+
button: {
|
|
151
|
+
backgroundColor: 'transparent',
|
|
152
|
+
borderWidth: 1,
|
|
153
|
+
borderColor: '#DEE2E6',
|
|
154
|
+
},
|
|
155
|
+
text: { color: '#212529', fontWeight: '600' },
|
|
156
|
+
imageTint: '#212529',
|
|
157
|
+
loaderColor: '#212529',
|
|
158
|
+
},
|
|
159
|
+
text: {
|
|
160
|
+
button: {
|
|
161
|
+
backgroundColor: 'transparent',
|
|
162
|
+
paddingHorizontal: 4,
|
|
163
|
+
paddingVertical: 4,
|
|
164
|
+
},
|
|
165
|
+
text: { color: '#212529', fontWeight: '600' },
|
|
166
|
+
imageTint: '#212529',
|
|
167
|
+
loaderColor: '#212529',
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export const contentAlignStyles: Record<
|
|
172
|
+
ButtonContentAlign,
|
|
173
|
+
{ container: ViewStyle; text: TextStyle }
|
|
174
|
+
> = {
|
|
175
|
+
left: {
|
|
176
|
+
container: {
|
|
177
|
+
alignSelf: 'stretch',
|
|
178
|
+
justifyContent: 'flex-start',
|
|
179
|
+
},
|
|
180
|
+
text: {
|
|
181
|
+
textAlign: 'left',
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
center: {
|
|
185
|
+
container: {
|
|
186
|
+
justifyContent: 'center',
|
|
187
|
+
},
|
|
188
|
+
text: {
|
|
189
|
+
textAlign: 'center',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
right: {
|
|
193
|
+
container: {
|
|
194
|
+
alignSelf: 'stretch',
|
|
195
|
+
justifyContent: 'flex-end',
|
|
196
|
+
},
|
|
197
|
+
text: {
|
|
198
|
+
textAlign: 'right',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export const styles = StyleSheet.create({
|
|
204
|
+
button: baseButton,
|
|
205
|
+
container: {
|
|
206
|
+
flexDirection: 'row',
|
|
207
|
+
alignItems: 'center',
|
|
208
|
+
justifyContent: 'center',
|
|
209
|
+
gap: 8,
|
|
210
|
+
},
|
|
211
|
+
iconOnlyContainer: {
|
|
212
|
+
gap: 0,
|
|
213
|
+
},
|
|
214
|
+
text: {},
|
|
215
|
+
leftImage: {
|
|
216
|
+
height: 20,
|
|
217
|
+
width: 25,
|
|
218
|
+
marginRight: 2,
|
|
219
|
+
},
|
|
220
|
+
rightImage: {
|
|
221
|
+
height: 20,
|
|
222
|
+
width: 20,
|
|
223
|
+
marginLeft: 2,
|
|
224
|
+
},
|
|
225
|
+
disabledButton: {
|
|
226
|
+
opacity: 0.55,
|
|
227
|
+
},
|
|
228
|
+
disabledText: {
|
|
229
|
+
opacity: 0.7,
|
|
230
|
+
},
|
|
231
|
+
countContainer: {
|
|
232
|
+
position: 'absolute',
|
|
233
|
+
top: -10,
|
|
234
|
+
right: -10,
|
|
235
|
+
height: 35,
|
|
236
|
+
width: 35,
|
|
237
|
+
borderRadius: 17.5,
|
|
238
|
+
backgroundColor: '#FFFFFF',
|
|
239
|
+
justifyContent: 'center',
|
|
240
|
+
alignItems: 'center',
|
|
241
|
+
zIndex: 2,
|
|
242
|
+
},
|
|
243
|
+
countText: {
|
|
244
|
+
color: '#000000',
|
|
245
|
+
fontWeight: '600',
|
|
246
|
+
},
|
|
247
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
ImageSourcePropType,
|
|
4
|
+
ImageStyle,
|
|
5
|
+
StyleProp,
|
|
6
|
+
TextStyle,
|
|
7
|
+
TouchableOpacityProps,
|
|
8
|
+
ViewStyle,
|
|
9
|
+
} from 'react-native';
|
|
10
|
+
|
|
11
|
+
export type ButtonVariant =
|
|
12
|
+
| 'default'
|
|
13
|
+
| 'primary'
|
|
14
|
+
| 'danger'
|
|
15
|
+
| 'warning'
|
|
16
|
+
| 'info'
|
|
17
|
+
| 'success'
|
|
18
|
+
| 'secondary'
|
|
19
|
+
| 'light'
|
|
20
|
+
| 'dark'
|
|
21
|
+
| 'link'
|
|
22
|
+
| 'outline'
|
|
23
|
+
| 'ghost'
|
|
24
|
+
| 'text';
|
|
25
|
+
|
|
26
|
+
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
27
|
+
|
|
28
|
+
export type ButtonContentAlign = 'left' | 'center' | 'right';
|
|
29
|
+
|
|
30
|
+
export type IconOnlyShape = 'square' | 'circle';
|
|
31
|
+
|
|
32
|
+
export type IconComponent = ComponentType<{
|
|
33
|
+
size?: number;
|
|
34
|
+
color?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
export type CustomButtonProps = Omit<TouchableOpacityProps, 'children'> & {
|
|
39
|
+
variant?: ButtonVariant;
|
|
40
|
+
size?: ButtonSize;
|
|
41
|
+
contentAlign?: ButtonContentAlign;
|
|
42
|
+
/** Square icon-only button — requires LeftIcon/RightIcon/leftImage/rightImage and accessibilityLabel */
|
|
43
|
+
iconOnly?: boolean;
|
|
44
|
+
iconOnlyShape?: IconOnlyShape;
|
|
45
|
+
text?: string;
|
|
46
|
+
children?: ReactNode;
|
|
47
|
+
rightImage?: ImageSourcePropType;
|
|
48
|
+
leftImage?: ImageSourcePropType;
|
|
49
|
+
buttonStyles?: StyleProp<ViewStyle>;
|
|
50
|
+
imageOuterStyle?: StyleProp<ViewStyle>;
|
|
51
|
+
textStyles?: StyleProp<TextStyle>;
|
|
52
|
+
opacity?: number;
|
|
53
|
+
onPress?: () => void;
|
|
54
|
+
imageStyles?: StyleProp<ImageStyle>;
|
|
55
|
+
rotateRight?: string;
|
|
56
|
+
rotateLeft?: string;
|
|
57
|
+
disabled?: boolean;
|
|
58
|
+
isLoading?: boolean;
|
|
59
|
+
itemCount?: number;
|
|
60
|
+
showCount?: boolean;
|
|
61
|
+
isCapital?: boolean;
|
|
62
|
+
borderRadius?: number;
|
|
63
|
+
RightIcon?: IconComponent;
|
|
64
|
+
LeftIcon?: IconComponent;
|
|
65
|
+
rightIconColor?: string;
|
|
66
|
+
leftIconColor?: string;
|
|
67
|
+
rightIconSize?: number;
|
|
68
|
+
leftIconSize?: number;
|
|
69
|
+
rightIconProps?: Record<string, unknown>;
|
|
70
|
+
leftIconProps?: Record<string, unknown>;
|
|
71
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Modal, Pressable, Text, View } from 'react-native';
|
|
2
|
+
import type { ImageStyle, StyleProp, TextStyle } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import DropDownList from './DropDownList';
|
|
5
|
+
import { dropdownStyles } from './styles';
|
|
6
|
+
import type { DropDownItemImageAlign, DropDownListItem } from './types';
|
|
7
|
+
|
|
8
|
+
type DropDownBottomSheetProps = {
|
|
9
|
+
data: DropDownListItem[];
|
|
10
|
+
visible: boolean;
|
|
11
|
+
title?: string;
|
|
12
|
+
selectedText?: string;
|
|
13
|
+
onClose: () => void;
|
|
14
|
+
onSelect: (item: string, index: number) => void;
|
|
15
|
+
maxListHeight?: number;
|
|
16
|
+
itemImageAlign?: DropDownItemImageAlign;
|
|
17
|
+
itemImageGap?: number;
|
|
18
|
+
itemTextStyle?: StyleProp<TextStyle>;
|
|
19
|
+
itemImageStyle?: StyleProp<ImageStyle>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const DropDownBottomSheet = ({
|
|
23
|
+
data,
|
|
24
|
+
visible,
|
|
25
|
+
title,
|
|
26
|
+
selectedText,
|
|
27
|
+
onClose,
|
|
28
|
+
onSelect,
|
|
29
|
+
maxListHeight,
|
|
30
|
+
itemImageAlign,
|
|
31
|
+
itemImageGap,
|
|
32
|
+
itemTextStyle,
|
|
33
|
+
itemImageStyle,
|
|
34
|
+
}: DropDownBottomSheetProps) => {
|
|
35
|
+
return (
|
|
36
|
+
<Modal
|
|
37
|
+
transparent
|
|
38
|
+
visible={visible}
|
|
39
|
+
supportedOrientations={['landscape', 'portrait']}
|
|
40
|
+
animationType="slide"
|
|
41
|
+
onRequestClose={onClose}
|
|
42
|
+
>
|
|
43
|
+
<View style={dropdownStyles.bottomSheetBackdrop}>
|
|
44
|
+
<Pressable style={dropdownStyles.backdropDismiss} onPress={onClose} />
|
|
45
|
+
<View style={dropdownStyles.bottomSheetContent}>
|
|
46
|
+
<View style={dropdownStyles.bottomSheetHandle} />
|
|
47
|
+
{!!title && (
|
|
48
|
+
<Text style={dropdownStyles.bottomSheetTitle}>{title}</Text>
|
|
49
|
+
)}
|
|
50
|
+
<DropDownList
|
|
51
|
+
data={data}
|
|
52
|
+
selectedText={selectedText}
|
|
53
|
+
maxHeight={maxListHeight}
|
|
54
|
+
itemImageAlign={itemImageAlign}
|
|
55
|
+
itemImageGap={itemImageGap}
|
|
56
|
+
itemTextStyle={itemTextStyle}
|
|
57
|
+
itemImageStyle={itemImageStyle}
|
|
58
|
+
containerStyle={dropdownStyles.bottomSheetList}
|
|
59
|
+
onSelect={(item, index) => {
|
|
60
|
+
onSelect(item, index);
|
|
61
|
+
onClose();
|
|
62
|
+
}}
|
|
63
|
+
/>
|
|
64
|
+
</View>
|
|
65
|
+
</View>
|
|
66
|
+
</Modal>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default DropDownBottomSheet;
|