@estuary-solutions/rn-core-ui 0.0.3
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 +743 -0
- package/dist/Accordion/Accordion.d.ts +5 -0
- package/dist/Accordion/Accordion.d.ts.map +1 -0
- package/dist/Accordion/Accordion.js +19 -0
- package/dist/Accordion/AccordionContext.d.ts +7 -0
- package/dist/Accordion/AccordionContext.d.ts.map +1 -0
- package/dist/Accordion/AccordionContext.js +3 -0
- package/dist/Accordion/AccordionGroup.d.ts +7 -0
- package/dist/Accordion/AccordionGroup.d.ts.map +1 -0
- package/dist/Accordion/AccordionGroup.js +32 -0
- package/dist/Accordion/AccordionItem.d.ts +5 -0
- package/dist/Accordion/AccordionItem.d.ts.map +1 -0
- package/dist/Accordion/AccordionItem.js +12 -0
- package/dist/Accordion/AccordionTree.d.ts +6 -0
- package/dist/Accordion/AccordionTree.d.ts.map +1 -0
- package/dist/Accordion/AccordionTree.js +4 -0
- package/dist/Accordion/AccordionTreeInternal.d.ts +5 -0
- package/dist/Accordion/AccordionTreeInternal.d.ts.map +1 -0
- package/dist/Accordion/AccordionTreeInternal.js +36 -0
- package/dist/Accordion/AccordionTreeWithGroup.d.ts +8 -0
- package/dist/Accordion/AccordionTreeWithGroup.d.ts.map +1 -0
- package/dist/Accordion/AccordionTreeWithGroup.js +11 -0
- package/dist/Accordion/index.d.ts +5 -0
- package/dist/Accordion/index.d.ts.map +1 -0
- package/dist/Accordion/index.js +4 -0
- package/dist/Accordion/types/AccordionTypes.d.ts +65 -0
- package/dist/Accordion/types/AccordionTypes.d.ts.map +1 -0
- package/dist/Accordion/types/AccordionTypes.js +1 -0
- package/dist/Avatars/Avatar.d.ts +20 -0
- package/dist/Avatars/Avatar.d.ts.map +1 -0
- package/dist/Avatars/Avatar.js +63 -0
- package/dist/Badges/Badge.d.ts +25 -0
- package/dist/Badges/Badge.d.ts.map +1 -0
- package/dist/Badges/Badge.js +75 -0
- package/dist/Breadcrumbs/Breadcrumb.d.ts +13 -0
- package/dist/Breadcrumbs/Breadcrumb.d.ts.map +1 -0
- package/dist/Breadcrumbs/Breadcrumb.js +63 -0
- package/dist/Button/Button.d.ts +7 -0
- package/dist/Button/Button.d.ts.map +1 -0
- package/dist/Button/Button.js +62 -0
- package/dist/Button/ButtonGradient.d.ts +5 -0
- package/dist/Button/ButtonGradient.d.ts.map +1 -0
- package/dist/Button/ButtonGradient.js +61 -0
- package/dist/Button/index.d.ts +4 -0
- package/dist/Button/index.d.ts.map +1 -0
- package/dist/Button/index.js +3 -0
- package/dist/Button/types/ButtonGradientTypes.d.ts +80 -0
- package/dist/Button/types/ButtonGradientTypes.d.ts.map +1 -0
- package/dist/Button/types/ButtonGradientTypes.js +1 -0
- package/dist/Button/types/ButtonTypes.d.ts +65 -0
- package/dist/Button/types/ButtonTypes.d.ts.map +1 -0
- package/dist/Button/types/ButtonTypes.js +1 -0
- package/dist/Buttons/Button.d.ts +23 -0
- package/dist/Buttons/Button.d.ts.map +1 -0
- package/dist/Buttons/Button.js +66 -0
- package/dist/Cards/Card.d.ts +22 -0
- package/dist/Cards/Card.d.ts.map +1 -0
- package/dist/Cards/Card.js +26 -0
- package/dist/Cards/CardActionArea.d.ts +13 -0
- package/dist/Cards/CardActionArea.d.ts.map +1 -0
- package/dist/Cards/CardActionArea.js +30 -0
- package/dist/Cards/CardActions.d.ts +14 -0
- package/dist/Cards/CardActions.d.ts.map +1 -0
- package/dist/Cards/CardActions.js +41 -0
- package/dist/Cards/CardContent.d.ts +13 -0
- package/dist/Cards/CardContent.d.ts.map +1 -0
- package/dist/Cards/CardContent.js +19 -0
- package/dist/Cards/CardHeader.d.ts +16 -0
- package/dist/Cards/CardHeader.d.ts.map +1 -0
- package/dist/Cards/CardHeader.js +61 -0
- package/dist/Cards/CardMedia.d.ts +23 -0
- package/dist/Cards/CardMedia.d.ts.map +1 -0
- package/dist/Cards/CardMedia.js +16 -0
- package/dist/Cards/Paper.d.ts +13 -0
- package/dist/Cards/Paper.d.ts.map +1 -0
- package/dist/Cards/Paper.js +42 -0
- package/dist/DraggableFlatList/CellDecorators.d.ts +21 -0
- package/dist/DraggableFlatList/CellDecorators.d.ts.map +1 -0
- package/dist/DraggableFlatList/CellDecorators.js +66 -0
- package/dist/DraggableFlatList/CellRendererComponent.d.ts +20 -0
- package/dist/DraggableFlatList/CellRendererComponent.d.ts.map +1 -0
- package/dist/DraggableFlatList/CellRendererComponent.js +146 -0
- package/dist/DraggableFlatList/DraggableFlatList.d.ts +9 -0
- package/dist/DraggableFlatList/DraggableFlatList.d.ts.map +1 -0
- package/dist/DraggableFlatList/DraggableFlatList.js +282 -0
- package/dist/DraggableFlatList/DraggableFlatList.web.d.ts +4 -0
- package/dist/DraggableFlatList/DraggableFlatList.web.d.ts.map +1 -0
- package/dist/DraggableFlatList/DraggableFlatList.web.js +248 -0
- package/dist/DraggableFlatList/NestableDraggableFlatList.d.ts +9 -0
- package/dist/DraggableFlatList/NestableDraggableFlatList.d.ts.map +1 -0
- package/dist/DraggableFlatList/NestableDraggableFlatList.js +66 -0
- package/dist/DraggableFlatList/NestableScrollContainer.d.ts +5 -0
- package/dist/DraggableFlatList/NestableScrollContainer.d.ts.map +1 -0
- package/dist/DraggableFlatList/NestableScrollContainer.js +28 -0
- package/dist/DraggableFlatList/PlaceholderItem.d.ts +8 -0
- package/dist/DraggableFlatList/PlaceholderItem.d.ts.map +1 -0
- package/dist/DraggableFlatList/PlaceholderItem.js +44 -0
- package/dist/DraggableFlatList/RowItem.d.ts +13 -0
- package/dist/DraggableFlatList/RowItem.d.ts.map +1 -0
- package/dist/DraggableFlatList/RowItem.js +45 -0
- package/dist/DraggableFlatList/ScrollOffsetListener.d.ts +8 -0
- package/dist/DraggableFlatList/ScrollOffsetListener.d.ts.map +1 -0
- package/dist/DraggableFlatList/ScrollOffsetListener.js +13 -0
- package/dist/Flex/Flex.d.ts +12 -0
- package/dist/Flex/Flex.d.ts.map +1 -0
- package/dist/Flex/Flex.js +28 -0
- package/dist/Flex/Flex.types.d.ts +10 -0
- package/dist/Flex/Flex.types.d.ts.map +1 -0
- package/dist/Flex/Flex.types.js +1 -0
- package/dist/Flex/index.d.ts +4 -0
- package/dist/Flex/index.d.ts.map +1 -0
- package/dist/Flex/index.js +3 -0
- package/dist/LICENSE +20 -0
- package/dist/README.md +743 -0
- package/dist/SvgIcon/SvgIcon.d.ts +9 -0
- package/dist/SvgIcon/SvgIcon.d.ts.map +1 -0
- package/dist/SvgIcon/SvgIcon.js +39 -0
- package/dist/SvgIcon/components/IconAlertCircle.d.ts +4 -0
- package/dist/SvgIcon/components/IconAlertCircle.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconAlertCircle.js +6 -0
- package/dist/SvgIcon/components/IconAngleLeft.d.ts +4 -0
- package/dist/SvgIcon/components/IconAngleLeft.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconAngleLeft.js +6 -0
- package/dist/SvgIcon/components/IconAngleRight.d.ts +4 -0
- package/dist/SvgIcon/components/IconAngleRight.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconAngleRight.js +6 -0
- package/dist/SvgIcon/components/IconCheckBox.d.ts +4 -0
- package/dist/SvgIcon/components/IconCheckBox.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconCheckBox.js +6 -0
- package/dist/SvgIcon/components/IconCheckBoxOutlineBlank.d.ts +4 -0
- package/dist/SvgIcon/components/IconCheckBoxOutlineBlank.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconCheckBoxOutlineBlank.js +6 -0
- package/dist/SvgIcon/components/IconCheckBoxWithBg.d.ts +4 -0
- package/dist/SvgIcon/components/IconCheckBoxWithBg.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconCheckBoxWithBg.js +6 -0
- package/dist/SvgIcon/components/IconChevronDown.d.ts +4 -0
- package/dist/SvgIcon/components/IconChevronDown.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconChevronDown.js +6 -0
- package/dist/SvgIcon/components/IconChevronUp.d.ts +4 -0
- package/dist/SvgIcon/components/IconChevronUp.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconChevronUp.js +6 -0
- package/dist/SvgIcon/components/IconHome.d.ts +4 -0
- package/dist/SvgIcon/components/IconHome.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconHome.js +6 -0
- package/dist/SvgIcon/components/IconPerson.d.ts +4 -0
- package/dist/SvgIcon/components/IconPerson.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconPerson.js +6 -0
- package/dist/SvgIcon/components/IconPlayCircle.d.ts +4 -0
- package/dist/SvgIcon/components/IconPlayCircle.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconPlayCircle.js +9 -0
- package/dist/SvgIcon/components/IconPlus.d.ts +4 -0
- package/dist/SvgIcon/components/IconPlus.d.ts.map +1 -0
- package/dist/SvgIcon/components/IconPlus.js +6 -0
- package/dist/SvgIcon/components/index.d.ts +13 -0
- package/dist/SvgIcon/components/index.d.ts.map +1 -0
- package/dist/SvgIcon/components/index.js +12 -0
- package/dist/SvgIcon/types/SvgIconTypes.d.ts +46 -0
- package/dist/SvgIcon/types/SvgIconTypes.d.ts.map +1 -0
- package/dist/SvgIcon/types/SvgIconTypes.js +1 -0
- package/dist/TextFields/TextField.d.ts +34 -0
- package/dist/TextFields/TextField.d.ts.map +1 -0
- package/dist/TextFields/TextField.js +400 -0
- package/dist/TextFields/index.d.ts +2 -0
- package/dist/TextFields/index.d.ts.map +1 -0
- package/dist/TextFields/index.js +1 -0
- package/dist/Texts/Text.d.ts +21 -0
- package/dist/Texts/Text.d.ts.map +1 -0
- package/dist/Texts/Text.js +49 -0
- package/dist/constants/DraggableFlatList/constants.d.ts +28 -0
- package/dist/constants/DraggableFlatList/constants.d.ts.map +1 -0
- package/dist/constants/DraggableFlatList/constants.js +25 -0
- package/dist/constants/DraggableFlatList/types.d.ts +65 -0
- package/dist/constants/DraggableFlatList/types.d.ts.map +1 -0
- package/dist/constants/DraggableFlatList/types.js +1 -0
- package/dist/constants/DraggableFlatList/types.web.d.ts +7 -0
- package/dist/constants/DraggableFlatList/types.web.d.ts.map +1 -0
- package/dist/constants/DraggableFlatList/types.web.js +1 -0
- package/dist/constants/consts.d.ts +16 -0
- package/dist/constants/consts.d.ts.map +1 -0
- package/dist/constants/consts.js +15 -0
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.d.ts.map +1 -0
- package/dist/constants/index.js +2 -0
- package/dist/constants/types.d.ts +22 -0
- package/dist/constants/types.d.ts.map +1 -0
- package/dist/constants/types.js +21 -0
- package/dist/context/DraggableFlatList/animatedValueContext.d.ts +29 -0
- package/dist/context/DraggableFlatList/animatedValueContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/animatedValueContext.js +154 -0
- package/dist/context/DraggableFlatList/cellContext.d.ts +10 -0
- package/dist/context/DraggableFlatList/cellContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/cellContext.js +18 -0
- package/dist/context/DraggableFlatList/draggableFlatListContext.d.ts +13 -0
- package/dist/context/DraggableFlatList/draggableFlatListContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/draggableFlatListContext.js +19 -0
- package/dist/context/DraggableFlatList/nestableScrollContainerContext.d.ts +23 -0
- package/dist/context/DraggableFlatList/nestableScrollContainerContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/nestableScrollContainerContext.js +36 -0
- package/dist/context/DraggableFlatList/propsContext.d.ts +9 -0
- package/dist/context/DraggableFlatList/propsContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/propsContext.js +25 -0
- package/dist/context/DraggableFlatList/refContext.d.ts +20 -0
- package/dist/context/DraggableFlatList/refContext.d.ts.map +1 -0
- package/dist/context/DraggableFlatList/refContext.js +55 -0
- package/dist/hooks/DraggableFlatList/useAutoScroll.d.ts +2 -0
- package/dist/hooks/DraggableFlatList/useAutoScroll.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useAutoScroll.js +77 -0
- package/dist/hooks/DraggableFlatList/useCellTranslate.d.ts +9 -0
- package/dist/hooks/DraggableFlatList/useCellTranslate.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useCellTranslate.js +72 -0
- package/dist/hooks/DraggableFlatList/useNestedAutoScroll.d.ts +12 -0
- package/dist/hooks/DraggableFlatList/useNestedAutoScroll.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useNestedAutoScroll.js +77 -0
- package/dist/hooks/DraggableFlatList/useOnCellActiveAnimation.d.ts +15 -0
- package/dist/hooks/DraggableFlatList/useOnCellActiveAnimation.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useOnCellActiveAnimation.js +29 -0
- package/dist/hooks/DraggableFlatList/useStableCallback.d.ts +2 -0
- package/dist/hooks/DraggableFlatList/useStableCallback.d.ts.map +1 -0
- package/dist/hooks/DraggableFlatList/useStableCallback.js +11 -0
- package/dist/hooks/useTheme.d.ts +17 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +12 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/themes/colors.d.ts +9 -0
- package/dist/themes/colors.d.ts.map +1 -0
- package/dist/themes/colors.js +201 -0
- package/dist/themes/elevationOverlay.d.ts +2 -0
- package/dist/themes/elevationOverlay.d.ts.map +1 -0
- package/dist/themes/elevationOverlay.js +12 -0
- package/dist/themes/fontSize.d.ts +23 -0
- package/dist/themes/fontSize.d.ts.map +1 -0
- package/dist/themes/fontSize.js +22 -0
- package/dist/themes/index.d.ts +5 -0
- package/dist/themes/index.d.ts.map +1 -0
- package/dist/themes/index.js +4 -0
- package/dist/themes/types/colorTypes.d.ts +665 -0
- package/dist/themes/types/colorTypes.d.ts.map +1 -0
- package/dist/themes/types/colorTypes.js +1 -0
- package/dist/utils/DraggableFlatList/typedMemo.d.ts +2 -0
- package/dist/utils/DraggableFlatList/typedMemo.d.ts.map +1 -0
- package/dist/utils/DraggableFlatList/typedMemo.js +2 -0
- package/dist/utils/cleanTagHTML.d.ts +22 -0
- package/dist/utils/cleanTagHTML.d.ts.map +1 -0
- package/dist/utils/cleanTagHTML.js +36 -0
- package/dist/utils/colors/color.d.ts +2 -0
- package/dist/utils/colors/color.d.ts.map +1 -0
- package/dist/utils/colors/color.js +6 -0
- package/dist/utils/colors/elevation.d.ts +7 -0
- package/dist/utils/colors/elevation.d.ts.map +1 -0
- package/dist/utils/colors/elevation.js +29 -0
- package/dist/utils/colors/index.d.ts +9 -0
- package/dist/utils/colors/index.d.ts.map +1 -0
- package/dist/utils/colors/index.js +7 -0
- package/dist/utils/converter.d.ts +47 -0
- package/dist/utils/converter.d.ts.map +1 -0
- package/dist/utils/converter.js +54 -0
- package/dist/utils/debounce.d.ts +36 -0
- package/dist/utils/debounce.d.ts.map +1 -0
- package/dist/utils/debounce.js +54 -0
- package/dist/utils/filters.d.ts +3 -0
- package/dist/utils/filters.d.ts.map +1 -0
- package/dist/utils/filters.js +10 -0
- package/dist/utils/fixedDistance.d.ts +16 -0
- package/dist/utils/fixedDistance.d.ts.map +1 -0
- package/dist/utils/fixedDistance.js +17 -0
- package/dist/utils/formatMoney.d.ts +30 -0
- package/dist/utils/formatMoney.d.ts.map +1 -0
- package/dist/utils/formatMoney.js +33 -0
- package/dist/utils/getOS.d.ts +6 -0
- package/dist/utils/getOS.d.ts.map +1 -0
- package/dist/utils/getOS.js +6 -0
- package/dist/utils/index.d.ts +13 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +12 -0
- package/dist/utils/limitedString.d.ts +15 -0
- package/dist/utils/limitedString.d.ts.map +1 -0
- package/dist/utils/limitedString.js +19 -0
- package/dist/utils/resolutions.d.ts +65 -0
- package/dist/utils/resolutions.d.ts.map +1 -0
- package/dist/utils/resolutions.js +79 -0
- package/dist/utils/scale.d.ts +141 -0
- package/dist/utils/scale.d.ts.map +1 -0
- package/dist/utils/scale.js +141 -0
- package/documents/build.js +102 -0
- package/documents/buildFromRoot.js +49 -0
- package/documents/buildFromSample.js +40 -0
- package/documents/buildV2.js +98 -0
- package/documents/copyPackageToExample.js +31 -0
- package/example/RNCoreUISample/.eslintrc.js +10 -0
- package/example/RNCoreUISample/.prettierrc.js +7 -0
- package/example/RNCoreUISample/App.js +26 -0
- package/example/RNCoreUISample/README.md +104 -0
- package/example/RNCoreUISample/android/app/debug.keystore +0 -0
- package/example/RNCoreUISample/babel.config.js +29 -0
- package/example/RNCoreUISample/documents/storybook/manager.js +5 -0
- package/example/RNCoreUISample/fix_node_modules.js +12 -0
- package/example/RNCoreUISample/index.js +20 -0
- package/example/RNCoreUISample/jest.config.js +3 -0
- package/example/RNCoreUISample/metro.config.js +30 -0
- package/package.json +101 -0
- package/src/constants/DraggableFlatList/draggable.d.ts +12 -0
package/dist/README.md
ADDED
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
# Estuary RN Core UI
|
|
2
|
+
|
|
3
|
+
[![NPM Version][npm-image]][npm-url]
|
|
4
|
+
[![Build Status][build-image]][build-url]
|
|
5
|
+
[![License][license-image]][license-url]
|
|
6
|
+
|
|
7
|
+
`estuary-rn-core-ui` provides a collection of core, reusable, and easily customizable User Interface (UI) Components built for React Native applications. Our goal is to help you build beautiful and consistent user interfaces quickly.
|
|
8
|
+
|
|
9
|
+
**Note:** If you are new to this project just follow this command:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
# If you are currently in root package folder
|
|
13
|
+
# Run yarn install for the first time
|
|
14
|
+
yarn install
|
|
15
|
+
|
|
16
|
+
# Run yarn build for apply you local changes -> build -> copy to example/RNCoreUISample/node_modules
|
|
17
|
+
yarn build
|
|
18
|
+
|
|
19
|
+
# From now if you are in example/RNCoreUISample. Just run yarn install
|
|
20
|
+
# All your changes in package will be packed and copy to example/RNCoreUISample/node_modules
|
|
21
|
+
yarn install
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Table of Contents
|
|
25
|
+
|
|
26
|
+
- [Installation](#installation)
|
|
27
|
+
- [Custom components](#custom-components)
|
|
28
|
+
- [Text](#text)
|
|
29
|
+
- [GalleryBottomSheet](#gallerybottomsheet)
|
|
30
|
+
- [Custom hooks](#custom-hooks)
|
|
31
|
+
- [useGalleryAssets](#usegalleryassetsdefaultassettype-assettype)
|
|
32
|
+
- [ScrollPercentage (Future)](#scrollpercentage)
|
|
33
|
+
- [Color pallete](#colors)
|
|
34
|
+
- [Font size template](#fontsize)
|
|
35
|
+
- [Scaling Function](#scaling-function)
|
|
36
|
+
- [scale(size: number)](#scalesize-number)
|
|
37
|
+
- [scaleH(size: number)](#scalehsize-number)
|
|
38
|
+
- [moderateScale(size: number, factor?: number)](#moderatescalesize-number-factor-number)
|
|
39
|
+
- [moderateHeightScale(size: number, factor?: number)](#moderateheightscalesize-number-factor-number)
|
|
40
|
+
- [scaleFont(size: number)](#scalefontsize-number)
|
|
41
|
+
- [IPHONE_12_WIDTH](#iphone_12_width)
|
|
42
|
+
- [IPHONE_12_HEIGHT](#iphone_12_heigth)
|
|
43
|
+
- [Resolution Function](#resolution-function)
|
|
44
|
+
- [getPaddingTop()](#getpaddingtop)
|
|
45
|
+
- [getPaddingBottom()](#getpaddingbottom)
|
|
46
|
+
- [isTablet](#istablet)
|
|
47
|
+
- [StylePlatform](#styleplatform)
|
|
48
|
+
- [statusBarHeight](#statusbarheight)
|
|
49
|
+
- [Converter and format](#converter-and-format)
|
|
50
|
+
- [convertString(value: any)](#convertstring)
|
|
51
|
+
- [convertNumber(value: any)](#convertnumber)
|
|
52
|
+
- [convertSeconds(seconds: number)](#convertseconds)
|
|
53
|
+
- [formatHours(seconds: number)](#formathour)
|
|
54
|
+
- [fixedDistance(distance?: number, toFixed?: number)](#fixeddistance)
|
|
55
|
+
- [formatMoney(num: number, maximumFractionDigits: number, lang: string)](#formatmoney)
|
|
56
|
+
- [Debounce](#debounce)
|
|
57
|
+
- [Others](#others)
|
|
58
|
+
- [cleanTagHTML(str: string)](#cleantaghtml)
|
|
59
|
+
- [limitedString(str: string, maxLength: number)](#limitedstring)
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Please install required packages:
|
|
64
|
+
|
|
65
|
+
- @react-native-camera-roll/camera-roll: ">=7.10.0" => For access devices media support [GalleryBottomSheet](#gallerybottomsheet) & [useGalleryAssets](#usegalleryassetsdefaultassettype-assettype). `Note`: This package should be upper then 7.10.0. Due to error in v7.7.0 and lowwer version this package won't work correct in [GalleryBottomSheet](#gallerybottomsheet) & [useGalleryAssets](#usegalleryassetsdefaultassettype-assettype)
|
|
66
|
+
- react-native-device-info: ">=8.1.3", => Use for knowing device is table or not
|
|
67
|
+
- react-native-gesture-handler: ">=2.9.0", => Support handling gesture for [GalleryBottomSheet](#gallerybottomsheet)
|
|
68
|
+
- react-native-reanimated: ">=2.8.0", => For handling package animation
|
|
69
|
+
- react-native-svg: ">=12.1.1", => For custom svg
|
|
70
|
+
- react-native-vector-icons: ">=8.1.0", => Please config correct [installation guidline](https://www.npmjs.com/package/react-native-vector-icons#installation) for not handling icon error
|
|
71
|
+
|
|
72
|
+
## Custom components
|
|
73
|
+
|
|
74
|
+
### Text
|
|
75
|
+
|
|
76
|
+
Text component for displaying text with custom styles and loading state. This component also have its own view and can easily be customized.
|
|
77
|
+
|
|
78
|
+
#### Props
|
|
79
|
+
|
|
80
|
+
| Prop | Type | Default | Description |
|
|
81
|
+
| --------------- | ---------------------- | ----------- | ----------------------------------------------------------------------- |
|
|
82
|
+
| **`style`** | `StyleProp<TextStyle>` | _None_ | Style of the Text component, just like [Text Style Props](https://reactnative.dev/docs/text-style-props) |
|
|
83
|
+
| **`color`** | `ColorValue` | `"black"` | Color of the text |
|
|
84
|
+
| **`bold`** | `boolean` | `false` | Choose to bold the text |
|
|
85
|
+
| **`children`** | `React.ReactNode` | _None_ | Provide the text string or another Text component |
|
|
86
|
+
| **`load`** | `boolean` | `false` | Waiting before show Text |
|
|
87
|
+
| **`styleView`** | `StyleProp<ViewStyle>` | _None_ | For custom a View outside Text component |
|
|
88
|
+
|
|
89
|
+
### GalleryBottomSheet
|
|
90
|
+
|
|
91
|
+
A bottom sheet component for displaying a gallery of images and videos. It allows users to select multiple assets and provides a filter for albums.
|
|
92
|
+
|
|
93
|
+
<p align="center">
|
|
94
|
+
<img src="https://s4.gifyu.com/images/bLfMU.gif" width="200" style="display: inline-block; margin-right: 10px;" />
|
|
95
|
+
<img src="https://s4.gifyu.com/images/bLfzY.gif" width="200" style="display: inline-block; margin-right: 10px;" />
|
|
96
|
+
<img src="https://s4.gifyu.com/images/bLfMT.gif" width="200" style="display: inline-block;" />
|
|
97
|
+
</p>
|
|
98
|
+
|
|
99
|
+
#### Permissions
|
|
100
|
+
|
|
101
|
+
##### Android
|
|
102
|
+
|
|
103
|
+
Add this permission to your AndroidManifest.xml:
|
|
104
|
+
```xml
|
|
105
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
|
|
106
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
|
|
107
|
+
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
|
108
|
+
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
##### iOS
|
|
112
|
+
|
|
113
|
+
Add this perission to your Info.plist:
|
|
114
|
+
```xml
|
|
115
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
116
|
+
<string>App request permission for access your gallery</string>
|
|
117
|
+
<key>NSPhotoLibraryAddUsageDescription</key>
|
|
118
|
+
<string>App request permission for create assets in your gallery</string>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### Props
|
|
122
|
+
|
|
123
|
+
| Prop | Type | Default | Description |
|
|
124
|
+
|--------------------------|---------------------------------------------------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
125
|
+
| **`isOpen`** | `boolean` | `false` | Define to open gallery or not. |
|
|
126
|
+
| **`openHeight`** | `number` | `ScreenHeight / 2` | Define the position to open gallery. **Note:** y coordinate of the top of the bottom sheet from the top of the screen |
|
|
127
|
+
| **`closeHeight`** | `number` | `ScreenHeight` | Define the position when closed gallery. **Note:** y coordinate of the top of the bottom sheet from the top of the screen |
|
|
128
|
+
| **`maxHeight`** | `number` | `0` | Define the maximum y coordinate that gallery should snapped at after finger release. **Note:** y coordinate of the top of the bottom sheet from the top of the screen |
|
|
129
|
+
| **`headerBarColor`** | `ColorValue` | `"#FFFFFF"` | Define the background color of the header bar. **Note:** Full control over the look at each position. Whether it's beautiful or ugly is up to you. |
|
|
130
|
+
| **`barIconColor`** | `ColorValue` | `"#000000"` | Define the header bar icon color. **Note:** Full control over the look at each position. Whether it's beautiful or ugly is up to you. |
|
|
131
|
+
| **`headerTitleStyle`** | `Pick<TextStyle, "color" \| "fontFamily" \| "fontWeight">` | `{ color: '#000000' }` | Define styling for the header title. Only supports: `color`, `fontFamily`, `fontWeight`. |
|
|
132
|
+
| **`headerTitle`** | `string` | `'Tất cả ảnh'` | Define the header title. Will be overridden by folder name when one is selected. Will be truncated if too long. |
|
|
133
|
+
| **`headerTitleIconColor`** | `ColorValue` | `"#000000"` | Define the header title icon color. |
|
|
134
|
+
| **`backgroundColor`** | `ColorValue` | `"#FFFFFF"` | Define the background color of the gallery bottom sheet. |
|
|
135
|
+
| **`emptyGalleryMsg`** | `string` | `'Không có hình ảnh để hiển thị'` | Message shown when there are no media items available. Please provide meaningful content. |
|
|
136
|
+
| **`emptyGalleryMsgStyle`** | `Pick<TextStyle, "color" \| "fontFamily" \| "fontWeight">` | `{ color: '#000000' }` | Define styling for the empty message. Only supports: `color`, `fontFamily`, `fontWeight`. [See example](#headertitlestyle) |
|
|
137
|
+
| **`videoIconStyle`** | `{ circleStyle?: CircleStyleProps; polygonStyle?: CircleStyleProps }` | [See example](#videoiconstyle) | Define styling for the video icon shown for video items. Full control over circle and polygon styles. |
|
|
138
|
+
| **`albumItemStyle`** | `AlbumFilterStyleProps` | `{ titleColor: '#000000', countColor: '#A0A0A0' }` | Define style for album filter items. Full control over title and count colors. [See example](#albumitemstyle) |
|
|
139
|
+
| **`assetType`** | `'All'` \| `'Photos'` \| `'Videos'` | `'All'` | Asset types to display. Can be dynamically changed with setState. |
|
|
140
|
+
| **`maxSelectable`** | `number` | `5` | Max number of items selectable. Min: `0`, Max: `10`. Large values may cause performance issues. |
|
|
141
|
+
| **`onSelectedAssetsChange`** | `(assets: PhotoIdentifier[]) => void` | `undefined` | Define function for handling selected assets data. This function will be called when the user select an asset. |
|
|
142
|
+
|
|
143
|
+
##### headerTitleStyle
|
|
144
|
+
|
|
145
|
+
Only support: `color`, `fontFamily`, `fontWeight`.
|
|
146
|
+
```jsx
|
|
147
|
+
import { GalleryBottomSheet, Text } from '@estuary-solutions/rn-core-ui';
|
|
148
|
+
|
|
149
|
+
<GalleryBottomSheet
|
|
150
|
+
isOpen={isOpen}
|
|
151
|
+
...
|
|
152
|
+
headerTitleStyle={{
|
|
153
|
+
color: '#000000',
|
|
154
|
+
fontFamily: 'Arial',
|
|
155
|
+
fontWeight: 400, // Correct ✅
|
|
156
|
+
fontSize: 20 // Wrong => Unsupport ❌
|
|
157
|
+
}}
|
|
158
|
+
...
|
|
159
|
+
/>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
##### videoIconStyle
|
|
163
|
+
|
|
164
|
+
Only support: `fill`, `stroke`, `strokeWidth`.
|
|
165
|
+
For the `strokeWidth`, we accept value start from `scale(5)` to `scale(8)`
|
|
166
|
+
```jsx
|
|
167
|
+
import { GalleryBottomSheet, Text } from '@estuary-solutions/rn-core-ui';
|
|
168
|
+
|
|
169
|
+
<GalleryBottomSheet
|
|
170
|
+
isOpen={isOpen}
|
|
171
|
+
...
|
|
172
|
+
videoIconStyle={{
|
|
173
|
+
circleStyle: {
|
|
174
|
+
fill: 'rgba(0, 0, 0, 0.5)',
|
|
175
|
+
stroke: 'black',
|
|
176
|
+
strokeWidth: 7
|
|
177
|
+
},
|
|
178
|
+
polygonStyle: {
|
|
179
|
+
fill: 'rgba(0, 0, 0, 0.5)',
|
|
180
|
+
stroke: 'black',
|
|
181
|
+
strokeWidth: 7
|
|
182
|
+
},
|
|
183
|
+
}}
|
|
184
|
+
...
|
|
185
|
+
/>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
##### albumItemStyle
|
|
189
|
+
|
|
190
|
+
Only support: `titleColor`, `countColor`.
|
|
191
|
+
```jsx
|
|
192
|
+
import { GalleryBottomSheet, Text } from '@estuary-solutions/rn-core-ui';
|
|
193
|
+
|
|
194
|
+
<GalleryBottomSheet
|
|
195
|
+
isOpen={isOpen}
|
|
196
|
+
...
|
|
197
|
+
albumItemStyle={{
|
|
198
|
+
titleColor: '#000000',
|
|
199
|
+
countColor: '#A0A0A0'
|
|
200
|
+
}}
|
|
201
|
+
...
|
|
202
|
+
/>
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Custom hooks
|
|
206
|
+
|
|
207
|
+
### useGalleryAssets(defaultAssetType?: AssetType)
|
|
208
|
+
|
|
209
|
+
You can use this hook for accessing device's assets or requesting related permission.
|
|
210
|
+
|
|
211
|
+
#### Permissions
|
|
212
|
+
|
|
213
|
+
##### Android
|
|
214
|
+
|
|
215
|
+
Add this permission to your AndroidManifest.xml:
|
|
216
|
+
```xml
|
|
217
|
+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
|
|
218
|
+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="32"/>
|
|
219
|
+
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
|
220
|
+
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
##### iOS
|
|
224
|
+
|
|
225
|
+
Add this perission to your Info.plist:
|
|
226
|
+
```xml
|
|
227
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
228
|
+
<string>App request permission for access your gallery</string>
|
|
229
|
+
<key>NSPhotoLibraryAddUsageDescription</key>
|
|
230
|
+
<string>App request permission for create assets in your gallery</string>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
#### Props
|
|
234
|
+
|
|
235
|
+
| Prop | Type | Default | Description |
|
|
236
|
+
|--------------------------|---------------------------------------------------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
237
|
+
| **`defaultAssetType`** | `AssetType` | `'All'` | Initiallize the default asset type. |
|
|
238
|
+
| **`albums`** | `Album[]` | `[]` | Provide list of albums on current device. |
|
|
239
|
+
| **`assets`** | `Record<string, PhotoIdentifier[]>` | `{}` | Provide list of assets on current device grouped by album. |
|
|
240
|
+
| **`fullAssets`** | `PhotoIdentifier[]` | `[]` | Provide list of assets on current device. |
|
|
241
|
+
| **`loading`** | `boolean` | `false` | Provide loading assets state. |
|
|
242
|
+
| **`error`** | `string` | `null` | Provide string error if loading cause any error. |
|
|
243
|
+
| **`totalAssets`** | `number` | `0` | Provide the total assets that has been accessed. |
|
|
244
|
+
| **`fullAssetsPagination`** | `Pagination` | `undefined` | Provide the object related for pagination on `fullAssets`. |
|
|
245
|
+
| **`loadFullAssets`** | `Promise function` | `` | Provide function for fecth assets which not grouped by album. Return `true` if has next page. [See example](#usage) |
|
|
246
|
+
| **`loadAssets`** | `Promise function` | `` | Provide function for fecth assets which grouped by album. Return `true` if has next page. [See example](#usage) |
|
|
247
|
+
| **`pagination`** | `Pagination` | `undefined` | Provide the object related for pagination on `assets`. |
|
|
248
|
+
| **`requestPermission`** | `Promise function` | `` | Provide function for request permission. Return `true` if user provided permission. [See example](#usage) |
|
|
249
|
+
| **`checkPermission`** | `Promise function` | `` | Provide function returning if user has provided permission. [See example](#usage) |
|
|
250
|
+
| **`hasPermission`** | `boolean` | `false` | Provide a state that keep track user permisison. |
|
|
251
|
+
| **`changeAssetType`** | `function` | `` | Provide function changing with asset type that you want to fecth. Please notice that, you should provide video permision if want to access videos. Default type `'All'`. [See example](#usage) |
|
|
252
|
+
|
|
253
|
+
#### Usage
|
|
254
|
+
|
|
255
|
+
```jsx
|
|
256
|
+
import { View, Text } from 'react-native'
|
|
257
|
+
import React from 'react'
|
|
258
|
+
import { useGalleryAssets } from '@estuary-solutions/rn-core-ui';
|
|
259
|
+
|
|
260
|
+
const MyComponent = () => {
|
|
261
|
+
const [selectedAlbum, setSelectedAlbum] = React.useState<Album | null>(null);
|
|
262
|
+
const {
|
|
263
|
+
albums,
|
|
264
|
+
fullAssets,
|
|
265
|
+
fullAssetsPagination,
|
|
266
|
+
loadFullAssets,
|
|
267
|
+
totalAssets,
|
|
268
|
+
assets,
|
|
269
|
+
loadAssets,
|
|
270
|
+
pagination,
|
|
271
|
+
requestPermission,
|
|
272
|
+
hasPermission,
|
|
273
|
+
changeAssetType,
|
|
274
|
+
} = useGalleryAssets('All');
|
|
275
|
+
|
|
276
|
+
const getSelectedInfo = (item: any) => {
|
|
277
|
+
// Do your own selection logic
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const toggleAsset = (item: any) => {
|
|
281
|
+
// Do your own selection logic
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return (
|
|
285
|
+
<View>
|
|
286
|
+
{(albums.length === 0 || fullAssets.length === 0 || totalAssets == 0) ? (
|
|
287
|
+
<View>
|
|
288
|
+
<Text style={[
|
|
289
|
+
styles.noImage,
|
|
290
|
+
safeEmptyGalleryMsgStyle
|
|
291
|
+
]}>No assets</Text>
|
|
292
|
+
</View>
|
|
293
|
+
) : (
|
|
294
|
+
<FlatList
|
|
295
|
+
data={selectedAlbum == null ? fullAssets : assets[selectedAlbum.id]}
|
|
296
|
+
keyExtractor={(item) => item.node.image.uri}
|
|
297
|
+
renderItem={({ item }) => {
|
|
298
|
+
const info = getSelectedInfo(item);
|
|
299
|
+
return (
|
|
300
|
+
<TouchableOpacity
|
|
301
|
+
style={styles.image}
|
|
302
|
+
onPress={() => toggleAsset(item)}
|
|
303
|
+
activeOpacity={0.7}
|
|
304
|
+
>
|
|
305
|
+
<Image
|
|
306
|
+
source={{ uri: item.node.image.uri }}
|
|
307
|
+
style={styles.image}
|
|
308
|
+
/>
|
|
309
|
+
{
|
|
310
|
+
item.node.type === "video/mp4" &&
|
|
311
|
+
<PlayCircle size={videoIconSize} />
|
|
312
|
+
}
|
|
313
|
+
{info.isSelected && (
|
|
314
|
+
<SelectItem value={info.index + 1} />
|
|
315
|
+
)}
|
|
316
|
+
</TouchableOpacity>
|
|
317
|
+
)
|
|
318
|
+
}}
|
|
319
|
+
...
|
|
320
|
+
onEndReached={() => {
|
|
321
|
+
//Load more assets
|
|
322
|
+
if (selectedAlbum == null) {
|
|
323
|
+
loadFullAssets(15, fullAssetsPagination?.endCursor, assetTypeState);
|
|
324
|
+
} else {
|
|
325
|
+
loadAssets(selectedAlbum, 15, pagination[selectedAlbum.id].endCursor, assetTypeState);
|
|
326
|
+
}
|
|
327
|
+
}}
|
|
328
|
+
/>
|
|
329
|
+
)}
|
|
330
|
+
</View>
|
|
331
|
+
)
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export default MyComponent
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
## Colors
|
|
338
|
+
|
|
339
|
+
We provide a variety of palete `colors` and some shadows!
|
|
340
|
+
|
|
341
|
+
### Usage
|
|
342
|
+
|
|
343
|
+
```jsx
|
|
344
|
+
import { colors } from '@estuary-solutions/rn-core-ui/themes';
|
|
345
|
+
import { StyleSheet } from 'react-native';
|
|
346
|
+
|
|
347
|
+
const styles = StyleSheet.create({
|
|
348
|
+
container: {
|
|
349
|
+
flex: 1,
|
|
350
|
+
backgroundColor: colors.black,
|
|
351
|
+
},
|
|
352
|
+
});
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
## Fontsize
|
|
356
|
+
|
|
357
|
+
We provide variety of fontSize that aldready scaled by our [scaleFont](#scalefontsize-number) API
|
|
358
|
+
|
|
359
|
+
### Usage
|
|
360
|
+
|
|
361
|
+
```jsx
|
|
362
|
+
import { fontSize } from '@kietpt2003/react-native-core-ui/themes';
|
|
363
|
+
import { StyleSheet } from 'react-native';
|
|
364
|
+
|
|
365
|
+
const styles = StyleSheet.create({
|
|
366
|
+
text: {
|
|
367
|
+
fontSize: fontSize._16,
|
|
368
|
+
},
|
|
369
|
+
});
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
## Scaling Function
|
|
373
|
+
|
|
374
|
+
```jsx
|
|
375
|
+
import { scale, verticalScale, moderateScale } from '@estuary-solutions/rn-core-ui/utils';
|
|
376
|
+
import { colors, fontSize } from '@estuary-solutions/rn-core-ui/themes'
|
|
377
|
+
|
|
378
|
+
const Component = props =>
|
|
379
|
+
<View style={{
|
|
380
|
+
width: scale(30),
|
|
381
|
+
height: verticalScale(50),
|
|
382
|
+
padding: moderateScale(5)
|
|
383
|
+
}}>
|
|
384
|
+
<Text style={{
|
|
385
|
+
fontSize: fontSize._16,
|
|
386
|
+
color: colors.black
|
|
387
|
+
}}>Component</Text>
|
|
388
|
+
</View>;
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### scale(size: number)
|
|
392
|
+
|
|
393
|
+
Will return a linear scaled result of the provided size, based on your device's screen width.
|
|
394
|
+
|
|
395
|
+
#### Usage
|
|
396
|
+
|
|
397
|
+
```jsx
|
|
398
|
+
import { scale } from '@estuary-solutions/rn-core-ui/utils';
|
|
399
|
+
import { StyleSheet } from 'react-native';
|
|
400
|
+
|
|
401
|
+
const styles = StyleSheet.create({
|
|
402
|
+
container: {
|
|
403
|
+
padding: scale(5),
|
|
404
|
+
},
|
|
405
|
+
});
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### scaleH(size: number)
|
|
409
|
+
|
|
410
|
+
Will return a linear scaled result of the provided size, based on your device's screen height.
|
|
411
|
+
|
|
412
|
+
#### Usage
|
|
413
|
+
|
|
414
|
+
```jsx
|
|
415
|
+
import { scaleH } from '@estuary-solutions/rn-core-ui/utils';
|
|
416
|
+
import { StyleSheet } from 'react-native';
|
|
417
|
+
|
|
418
|
+
const styles = StyleSheet.create({
|
|
419
|
+
container: {
|
|
420
|
+
position: 'absolute',
|
|
421
|
+
top: scaleH(5),
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
### moderateScale(size: number, factor?: number)
|
|
427
|
+
|
|
428
|
+
Sometimes you don't want to scale everything in a linear manner, that's where moderateScale comes in.
|
|
429
|
+
The cool thing about it is that you can control the resize factor (default is 0.5).
|
|
430
|
+
If normal scale will increase your size by +2X, moderateScale will only increase it by +X, for example:
|
|
431
|
+
➡️ scale(10) = 20
|
|
432
|
+
➡️ moderateScale(10) = 15
|
|
433
|
+
➡️ moderateScale(10, 0.1) = 11
|
|
434
|
+
|
|
435
|
+
#### Usage
|
|
436
|
+
|
|
437
|
+
```jsx
|
|
438
|
+
import { moderateScale } from '@estuary-solutions/rn-core-ui/utils';
|
|
439
|
+
import { StyleSheet } from 'react-native';
|
|
440
|
+
|
|
441
|
+
const styles = StyleSheet.create({
|
|
442
|
+
container: {
|
|
443
|
+
padding: moderateScale(5),
|
|
444
|
+
},
|
|
445
|
+
});
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### moderateHeightScale(size: number, factor?: number)
|
|
449
|
+
|
|
450
|
+
Same as [moderateScale](#moderatescalesize-number-factor-number), but using scaleH instead of scale.
|
|
451
|
+
|
|
452
|
+
#### Usage
|
|
453
|
+
|
|
454
|
+
```jsx
|
|
455
|
+
import { moderateHeightScale } from '@estuary-solutions/rn-core-ui/utils';
|
|
456
|
+
import { StyleSheet } from 'react-native';
|
|
457
|
+
|
|
458
|
+
const styles = StyleSheet.create({
|
|
459
|
+
container: {
|
|
460
|
+
padding: moderateHeightScale(5),
|
|
461
|
+
},
|
|
462
|
+
});
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
### scaleFont(size: number)
|
|
466
|
+
|
|
467
|
+
Will return a linear scaled result of the provided size, based on PixelRatio & scaleAvg.
|
|
468
|
+
You can use [fontSize](#fontsize) from /theme instead of using scalefont().
|
|
469
|
+
|
|
470
|
+
#### Usage
|
|
471
|
+
|
|
472
|
+
```jsx
|
|
473
|
+
import { scaleFont } from '@estuary-solutions/rn-core-ui/utils';
|
|
474
|
+
import { StyleSheet } from 'react-native';
|
|
475
|
+
|
|
476
|
+
const styles = StyleSheet.create({
|
|
477
|
+
text: {
|
|
478
|
+
fontSize: scaleFont(16), // fontSize._16
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### IPHONE_12_WIDTH
|
|
484
|
+
|
|
485
|
+
Just a constants that specify iPhone 12 width.
|
|
486
|
+
```js
|
|
487
|
+
import { IPHONE_12_WIDTH } from '@estuary-solutions/rn-core-ui/utils';
|
|
488
|
+
console.log(IPHONE_12_WIDTH); // 375
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### IPHONE_12_HEIGTH
|
|
492
|
+
|
|
493
|
+
Just a constants that specify iPhone 12 height.
|
|
494
|
+
```js
|
|
495
|
+
import { IPHONE_12_HEIGTH } from '@estuary-solutions/rn-core-ui/utils';
|
|
496
|
+
console.log(IPHONE_12_HEIGTH); // 812
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
## Resolution Function
|
|
500
|
+
|
|
501
|
+
### getPaddingTop
|
|
502
|
+
|
|
503
|
+
Get the top padding based on the device type
|
|
504
|
+
- 26 OPPO
|
|
505
|
+
- 28 NOKIA
|
|
506
|
+
|
|
507
|
+
#### Usage
|
|
508
|
+
|
|
509
|
+
```jsx
|
|
510
|
+
import { getPaddingTop } from '@estuary-solutions/rn-core-ui/utils';
|
|
511
|
+
const paddingTop = getPaddingTop();
|
|
512
|
+
console.log("paddingTop:", paddingTop);
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
### getPaddingBottom
|
|
516
|
+
|
|
517
|
+
Get the bottom padding based on the device type
|
|
518
|
+
|
|
519
|
+
#### Usage
|
|
520
|
+
|
|
521
|
+
```jsx
|
|
522
|
+
import { getPaddingBottom } from '@estuary-solutions/rn-core-ui/utils';
|
|
523
|
+
const paddingBottom = getPaddingBottom();
|
|
524
|
+
console.log("paddingBottom:", paddingBottom);
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
### isTablet
|
|
528
|
+
|
|
529
|
+
Check if the device is a tablet
|
|
530
|
+
|
|
531
|
+
#### Usage
|
|
532
|
+
|
|
533
|
+
```jsx
|
|
534
|
+
import { isTablet } from '@estuary-solutions/rn-core-ui/utils';
|
|
535
|
+
console.log("isTablet", isTablet); // true/false
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### StylePlatform
|
|
539
|
+
|
|
540
|
+
Use this function to get the styles based on the device type
|
|
541
|
+
|
|
542
|
+
@param {Object} styles - StyleProp
|
|
543
|
+
@param {ViewStyle} styles.tablet - Styles for tablet
|
|
544
|
+
@param {ViewStyle} styles.phone - Styles for phone
|
|
545
|
+
|
|
546
|
+
#### Props
|
|
547
|
+
|
|
548
|
+
| Prop | Type | Default | Description |
|
|
549
|
+
|--------------------------|---------------------------------------------------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
550
|
+
| **`styles`** | `StyleProp<any>` | `undefined` | Initiallize the styles for table and phone. Its contains 2 fields: `tablet` & `phone`. [See example](#usage-11) |
|
|
551
|
+
|
|
552
|
+
#### Usage
|
|
553
|
+
|
|
554
|
+
```jsx
|
|
555
|
+
<View style={StylePlatform({
|
|
556
|
+
tablet: styles.containerTablet,
|
|
557
|
+
phone: styles.containerPhone
|
|
558
|
+
})}>
|
|
559
|
+
<Text style={StylePlatform({
|
|
560
|
+
tablet: styles.textTablet,
|
|
561
|
+
phone: styles.textPhone
|
|
562
|
+
})}>
|
|
563
|
+
Hello, Platform!
|
|
564
|
+
</Text>
|
|
565
|
+
</View>
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
### statusBarHeight
|
|
569
|
+
|
|
570
|
+
statusBarHeight of the device
|
|
571
|
+
|
|
572
|
+
#### Usage
|
|
573
|
+
|
|
574
|
+
```jsx
|
|
575
|
+
import { statusBarHeight } from '@estuary-solutions/rn-core-ui/utils';
|
|
576
|
+
console.log("statusBarHeight", statusBarHeight);
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
## Converter and format
|
|
580
|
+
|
|
581
|
+
### convertString
|
|
582
|
+
|
|
583
|
+
This function converts input into a string.
|
|
584
|
+
* If the input is null or undefined, it returns an empty string.
|
|
585
|
+
* If the input is an object, it returns a stringified version of the object.
|
|
586
|
+
* Otherwise, it returns the string representation of the input.
|
|
587
|
+
|
|
588
|
+
#### Usage
|
|
589
|
+
|
|
590
|
+
```js
|
|
591
|
+
import { convertString } from '@estuary-solutions/rn-core-ui/utils';
|
|
592
|
+
const str = convertString(2003); // "2003"
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
### convertNumber
|
|
596
|
+
|
|
597
|
+
This function converts input into a number.
|
|
598
|
+
* If the input is null or undefined, it returns 0.
|
|
599
|
+
* If the input is not a number, it returns 0.
|
|
600
|
+
* Otherwise, it returns the parsed float value of the input.
|
|
601
|
+
|
|
602
|
+
#### Usage
|
|
603
|
+
|
|
604
|
+
```js
|
|
605
|
+
import { convertNumber } from '@estuary-solutions/rn-core-ui/utils';
|
|
606
|
+
const num = convertNumber("2003"); // 2003
|
|
607
|
+
```
|
|
608
|
+
### convertSeconds
|
|
609
|
+
|
|
610
|
+
This function convert seconds to a string in the format "mm:ss".
|
|
611
|
+
|
|
612
|
+
* If the input is less than 0, it returns "00:00".
|
|
613
|
+
* If the input is greater than 3599, it returns "00:00".
|
|
614
|
+
|
|
615
|
+
#### Usage
|
|
616
|
+
|
|
617
|
+
```js
|
|
618
|
+
import { convertSeconds } from '@estuary-solutions/rn-core-ui/utils';
|
|
619
|
+
const time = convertSeconds(123); // "02:03"
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
### formatHour
|
|
623
|
+
|
|
624
|
+
Function to format seconds into a string in the format "hh:mm:ss".
|
|
625
|
+
* If the input is less than 0, it returns "00:00:00".
|
|
626
|
+
* If the input is greater than 86399, it returns "00:00:00".
|
|
627
|
+
|
|
628
|
+
#### Usage
|
|
629
|
+
|
|
630
|
+
```js
|
|
631
|
+
import { formatHour } from '@estuary-solutions/rn-core-ui/utils';
|
|
632
|
+
const time = formatHour(3661); // "01:01:01"
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
### fixedDistance
|
|
636
|
+
|
|
637
|
+
Function to format a distance value.
|
|
638
|
+
- If the input is an integer, it returns the integer value.
|
|
639
|
+
- If the input is a float, it returns the value formatted to a custom toFixed value decimal places.
|
|
640
|
+
- If the input is null or undefined, it returns 0.
|
|
641
|
+
|
|
642
|
+
*Note:* The toFixed value should be between 1 and 5, otherwise it defaults to 2.
|
|
643
|
+
|
|
644
|
+
#### Usage
|
|
645
|
+
|
|
646
|
+
```js
|
|
647
|
+
import { fixedDistance } from '@estuary-solutions/rn-core-ui/utils';
|
|
648
|
+
const distance = fixedDistance(123.456); // "123.46"
|
|
649
|
+
const distance2 = fixedDistance(123.4567, 3); // "123.457"
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
### formatMoney
|
|
653
|
+
|
|
654
|
+
Function to format money values.
|
|
655
|
+
|
|
656
|
+
#### Props
|
|
657
|
+
|
|
658
|
+
| Prop | Type | Default | Description |
|
|
659
|
+
|--------------------------|---------------------------------------------------------------------|------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
660
|
+
| **`num`** | `number` | `0` | Define the value need to be format. |
|
|
661
|
+
| **`maximumFractionDigits`** | `number` | `0` | Define the maximum fraction digits. [See example](#usage-18) |
|
|
662
|
+
| **`lang`** | `string` | `en-US` | Define the language. This should be a BCP 47 language tag (e.g., 'en-US', 'vi-VN'). [View detail](#lang-prop) |
|
|
663
|
+
|
|
664
|
+
#### lang prop
|
|
665
|
+
|
|
666
|
+
This is a string that contains a language code and an optional country code, separated by a hyphen.
|
|
667
|
+
|
|
668
|
+
*Structure:* `"[languageCode]-[countryCode]"`
|
|
669
|
+
*Example:* `'en-IN'` => en: Language English, IN: Country India
|
|
670
|
+
*Reference:*
|
|
671
|
+
- [List of ISO 639 language codes](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes)
|
|
672
|
+
- [List of ISO 3166-1 country codes](https://vi.wikipedia.org/wiki/ISO_3166-1)
|
|
673
|
+
|
|
674
|
+
#### Usage
|
|
675
|
+
|
|
676
|
+
```js
|
|
677
|
+
import { formatMoney } from '@estuary-solutions/rn-core-ui/utils';
|
|
678
|
+
const money = formatMoney(1234567.89); // "1,234,568"
|
|
679
|
+
const money2 = formatMoney(1234567.89, 2); // "1,234,567.89"
|
|
680
|
+
const money3 = formatMoney(1234567.89, 2, 'vi-VN'); // "1.234.567,89"
|
|
681
|
+
```
|
|
682
|
+
|
|
683
|
+
## Debounce
|
|
684
|
+
|
|
685
|
+
- Creates a debounced function that delays invoking the provided function until after a specified delay in milliseconds has elapsed since the last time the debounced function was invoked.
|
|
686
|
+
- The debounced function comes with `cancel` and `flush` methods to cancel the debounced invocation and to immediately invoke the function, respectively.
|
|
687
|
+
|
|
688
|
+
### Usage
|
|
689
|
+
|
|
690
|
+
```jsx
|
|
691
|
+
import { debounce } from '@estuary-solutions/rn-core-ui/utils';
|
|
692
|
+
const onChangeText = debounce(() => {
|
|
693
|
+
console.log('Function executed!');
|
|
694
|
+
}, 1000);
|
|
695
|
+
|
|
696
|
+
//Flush case
|
|
697
|
+
const debouncedLog = debounce(logMessage, 2000);
|
|
698
|
+
debouncedLog("Waiting 2s...");
|
|
699
|
+
setTimeout(() => {
|
|
700
|
+
debouncedLog.flush(); // Immediately execute the function
|
|
701
|
+
}, 1000);
|
|
702
|
+
|
|
703
|
+
//Cancel case
|
|
704
|
+
debouncedLog("Canceled");
|
|
705
|
+
setTimeout(() => {
|
|
706
|
+
debouncedLog.cancel(); // Don't execute the function
|
|
707
|
+
}, 1000);
|
|
708
|
+
```
|
|
709
|
+
|
|
710
|
+
## Others
|
|
711
|
+
|
|
712
|
+
### cleanTagHTML
|
|
713
|
+
|
|
714
|
+
Provide a function to clean HTML tags and from a string.
|
|
715
|
+
|
|
716
|
+
#### Usage
|
|
717
|
+
|
|
718
|
+
```js
|
|
719
|
+
import { cleanHTML } from '@estuary-solutions/rn-core-ui/utils';
|
|
720
|
+
const raw = `
|
|
721
|
+
<div>Hello World</div>
|
|
722
|
+
<p>This is a <strong>test</strong></p>
|
|
723
|
+
`;
|
|
724
|
+
console.log(cleanHTML(raw));
|
|
725
|
+
// Output:
|
|
726
|
+
// Hello
|
|
727
|
+
// World
|
|
728
|
+
// This is a test
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
### limitedString
|
|
732
|
+
|
|
733
|
+
Function to limit the number of words in a string.
|
|
734
|
+
- `str` - The string to limit. *Default:* str = ''
|
|
735
|
+
- `maxLength` - The maximum number of words allowed. *Default:* maxLength = 5
|
|
736
|
+
|
|
737
|
+
#### Usage
|
|
738
|
+
|
|
739
|
+
```js
|
|
740
|
+
import { limitedString } from '@estuary-solutions/rn-core-ui/utils';
|
|
741
|
+
const inputString = "Lorem Ipsum is simply dummy text of the printing and typesetting industry";
|
|
742
|
+
console.log(limitedString(inputString)); // "Lorem Ipsum is simply dummy..."
|
|
743
|
+
```
|