@teamnhz/rn-ui-toolkit 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/dist/assets/images/cancel.png +0 -0
- package/dist/assets/images/eye_off.png +0 -0
- package/dist/assets/images/eye_on.png +0 -0
- package/dist/assets/images/favourite.png +0 -0
- package/dist/assets/images/image_icon.png +0 -0
- package/dist/assets/images/upload.png +0 -0
- package/dist/assets/images/video_icon.png +0 -0
- package/dist/components/Accordion/index.d.ts +15 -0
- package/dist/components/Accordion/index.js +51 -0
- package/dist/components/BottomSheet/index.d.ts +10 -0
- package/dist/components/BottomSheet/index.js +35 -0
- package/dist/components/Buttons/index.d.ts +14 -0
- package/dist/components/Buttons/index.js +46 -0
- package/dist/components/CheckBox/index.d.ts +21 -0
- package/dist/components/CheckBox/index.js +42 -0
- package/dist/components/Container/index.d.ts +11 -0
- package/dist/components/Container/index.js +30 -0
- package/dist/components/DateTimePicker/index.d.ts +11 -0
- package/dist/components/DateTimePicker/index.js +50 -0
- package/dist/components/Dividers/index.d.ts +9 -0
- package/dist/components/Dividers/index.js +23 -0
- package/dist/components/DocumentPicker/index.d.ts +16 -0
- package/dist/components/DocumentPicker/index.js +52 -0
- package/dist/components/DropDown/index.d.ts +24 -0
- package/dist/components/DropDown/index.js +34 -0
- package/dist/components/FullSpinner/index.d.ts +6 -0
- package/dist/components/FullSpinner/index.js +22 -0
- package/dist/components/HProgressSteps/index.d.ts +15 -0
- package/dist/components/HProgressSteps/index.js +102 -0
- package/dist/components/HStack/index.d.ts +10 -0
- package/dist/components/HStack/index.js +13 -0
- package/dist/components/HorizontalFlatList/index.d.ts +10 -0
- package/dist/components/HorizontalFlatList/index.js +14 -0
- package/dist/components/Image/index.d.ts +5 -0
- package/dist/components/Image/index.js +6 -0
- package/dist/components/ImagePicker/index.d.ts +10 -0
- package/dist/components/ImagePicker/index.js +109 -0
- package/dist/components/Input/index.d.ts +26 -0
- package/dist/components/Input/index.js +118 -0
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.js +5 -0
- package/dist/components/MyStatusBar/index.d.ts +8 -0
- package/dist/components/MyStatusBar/index.js +13 -0
- package/dist/components/ProgressBar/index.d.ts +9 -0
- package/dist/components/ProgressBar/index.js +26 -0
- package/dist/components/RadioButton/index.d.ts +18 -0
- package/dist/components/RadioButton/index.js +49 -0
- package/dist/components/ScrolledContainer/index.d.ts +13 -0
- package/dist/components/ScrolledContainer/index.js +30 -0
- package/dist/components/ShouldRender/index.d.ts +6 -0
- package/dist/components/ShouldRender/index.js +5 -0
- package/dist/components/Spinner/index.d.ts +8 -0
- package/dist/components/Spinner/index.js +17 -0
- package/dist/components/Switch/index.d.ts +6 -0
- package/dist/components/Switch/index.js +23 -0
- package/dist/components/T/index.d.ts +17 -0
- package/dist/components/T/index.js +20 -0
- package/dist/components/Toast/index.d.ts +13 -0
- package/dist/components/Toast/index.js +84 -0
- package/dist/components/VProgressSteps/index.d.ts +3 -0
- package/dist/components/VProgressSteps/index.js +77 -0
- package/dist/components/VStack/index.d.ts +9 -0
- package/dist/components/VStack/index.js +15 -0
- package/dist/components/VerticalFlatList/index.d.ts +7 -0
- package/dist/components/VerticalFlatList/index.js +6 -0
- package/dist/components/index.d.ts +28 -0
- package/dist/components/index.js +28 -0
- package/dist/constants/messages.d.ts +11 -0
- package/dist/constants/messages.js +11 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles/colors.d.ts +32 -0
- package/dist/styles/colors.js +31 -0
- package/dist/styles/config.json +108 -0
- package/dist/styles/images.d.ts +9 -0
- package/dist/styles/images.js +15 -0
- package/dist/styles/index.d.ts +7 -0
- package/dist/styles/index.js +9 -0
- package/dist/styles/mixins.d.ts +64 -0
- package/dist/styles/mixins.js +68 -0
- package/dist/styles/scale.d.ts +4 -0
- package/dist/styles/scale.js +9 -0
- package/dist/styles/typography.d.ts +89 -0
- package/dist/styles/typography.js +123 -0
- package/dist/utils/permissionMessage.d.ts +12 -0
- package/dist/utils/permissionMessage.js +12 -0
- package/dist/utils/permissions.d.ts +18 -0
- package/dist/utils/permissions.js +106 -0
- package/dist/utils/regex.d.ts +2 -0
- package/dist/utils/regex.js +7 -0
- package/package.json +37 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ViewStyle } from 'react-native';
|
|
2
|
+
declare const styles: {
|
|
3
|
+
columnCenter: {
|
|
4
|
+
flexDirection: "column";
|
|
5
|
+
justifyContent: "center";
|
|
6
|
+
alignItems: "center";
|
|
7
|
+
};
|
|
8
|
+
columnCenterAlignStart: {
|
|
9
|
+
flexDirection: "column";
|
|
10
|
+
justifyContent: "center";
|
|
11
|
+
alignItems: "flex-start";
|
|
12
|
+
};
|
|
13
|
+
columnBetweenAlignTop: {
|
|
14
|
+
flexDirection: "column";
|
|
15
|
+
justifyContent: "space-between";
|
|
16
|
+
alignItems: "flex-start";
|
|
17
|
+
};
|
|
18
|
+
columnBetweenAlignEnd: {
|
|
19
|
+
flexDirection: "column";
|
|
20
|
+
justifyContent: "space-between";
|
|
21
|
+
alignItems: "flex-end";
|
|
22
|
+
};
|
|
23
|
+
rowCenter: {
|
|
24
|
+
flexDirection: "row";
|
|
25
|
+
justifyContent: "center";
|
|
26
|
+
alignItems: "center";
|
|
27
|
+
};
|
|
28
|
+
rowStart: {
|
|
29
|
+
flexDirection: "row";
|
|
30
|
+
justifyContent: "flex-start";
|
|
31
|
+
alignItems: "center";
|
|
32
|
+
};
|
|
33
|
+
rowBetween: {
|
|
34
|
+
flexDirection: "row";
|
|
35
|
+
justifyContent: "space-between";
|
|
36
|
+
alignItems: "center";
|
|
37
|
+
};
|
|
38
|
+
rowAroundAlignBase: {
|
|
39
|
+
flexDirection: "row";
|
|
40
|
+
justifyContent: "space-around";
|
|
41
|
+
alignItems: "baseline";
|
|
42
|
+
};
|
|
43
|
+
rowBetweenAlignBase: {
|
|
44
|
+
flexDirection: "row";
|
|
45
|
+
justifyContent: "space-between";
|
|
46
|
+
alignItems: "baseline";
|
|
47
|
+
};
|
|
48
|
+
rowBetweenAlignStart: {
|
|
49
|
+
flexDirection: "row";
|
|
50
|
+
justifyContent: "space-between";
|
|
51
|
+
alignItems: "flex-start";
|
|
52
|
+
};
|
|
53
|
+
indicator: {
|
|
54
|
+
alignItems: "center";
|
|
55
|
+
justifyContent: "center";
|
|
56
|
+
position: "absolute";
|
|
57
|
+
left: 0;
|
|
58
|
+
right: 0;
|
|
59
|
+
top: 0;
|
|
60
|
+
bottom: 0;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
declare const circle: (size: number, color: string) => ViewStyle;
|
|
64
|
+
export { styles, circle };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
const styles = StyleSheet.create({
|
|
3
|
+
columnCenter: {
|
|
4
|
+
flexDirection: 'column',
|
|
5
|
+
justifyContent: 'center',
|
|
6
|
+
alignItems: 'center',
|
|
7
|
+
},
|
|
8
|
+
columnCenterAlignStart: {
|
|
9
|
+
flexDirection: 'column',
|
|
10
|
+
justifyContent: 'center',
|
|
11
|
+
alignItems: 'flex-start',
|
|
12
|
+
},
|
|
13
|
+
columnBetweenAlignTop: {
|
|
14
|
+
flexDirection: 'column',
|
|
15
|
+
justifyContent: 'space-between',
|
|
16
|
+
alignItems: 'flex-start',
|
|
17
|
+
},
|
|
18
|
+
columnBetweenAlignEnd: {
|
|
19
|
+
flexDirection: 'column',
|
|
20
|
+
justifyContent: 'space-between',
|
|
21
|
+
alignItems: 'flex-end',
|
|
22
|
+
},
|
|
23
|
+
rowCenter: {
|
|
24
|
+
flexDirection: 'row',
|
|
25
|
+
justifyContent: 'center',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
},
|
|
28
|
+
rowStart: {
|
|
29
|
+
flexDirection: 'row',
|
|
30
|
+
justifyContent: 'flex-start',
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
},
|
|
33
|
+
rowBetween: {
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
justifyContent: 'space-between',
|
|
36
|
+
alignItems: 'center',
|
|
37
|
+
},
|
|
38
|
+
rowAroundAlignBase: {
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
justifyContent: 'space-around',
|
|
41
|
+
alignItems: 'baseline',
|
|
42
|
+
},
|
|
43
|
+
rowBetweenAlignBase: {
|
|
44
|
+
flexDirection: 'row',
|
|
45
|
+
justifyContent: 'space-between',
|
|
46
|
+
alignItems: 'baseline',
|
|
47
|
+
},
|
|
48
|
+
rowBetweenAlignStart: {
|
|
49
|
+
flexDirection: 'row',
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
alignItems: 'flex-start',
|
|
52
|
+
},
|
|
53
|
+
indicator: {
|
|
54
|
+
...StyleSheet.absoluteFillObject,
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
justifyContent: 'center',
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const circle = (size, color) => ({
|
|
60
|
+
width: size,
|
|
61
|
+
height: size,
|
|
62
|
+
borderRadius: size / 2,
|
|
63
|
+
backgroundColor: color,
|
|
64
|
+
flexDirection: 'column',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
});
|
|
68
|
+
export { styles, circle };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Dimensions } from 'react-native';
|
|
2
|
+
const { width, height } = Dimensions.get('window');
|
|
3
|
+
// Guideline sizes are based on standard ~5" screen mobile device
|
|
4
|
+
const guidelineBaseWidth = 350;
|
|
5
|
+
const guidelineBaseHeight = 680;
|
|
6
|
+
const scale = (size) => (width / guidelineBaseWidth) * size;
|
|
7
|
+
const verticalScale = (size) => (height / guidelineBaseHeight) * size;
|
|
8
|
+
const moderateScale = (size, factor = 0.5) => size + (scale(size) - size) * factor;
|
|
9
|
+
export { scale, verticalScale, moderateScale };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
size: {
|
|
3
|
+
xSmall: () => {
|
|
4
|
+
fontSize: number;
|
|
5
|
+
};
|
|
6
|
+
smallU: () => {
|
|
7
|
+
fontSize: number;
|
|
8
|
+
};
|
|
9
|
+
regularU: () => {
|
|
10
|
+
fontSize: number;
|
|
11
|
+
};
|
|
12
|
+
mediumU: () => {
|
|
13
|
+
fontSize: number;
|
|
14
|
+
};
|
|
15
|
+
largeU: () => {
|
|
16
|
+
fontSize: number;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
style: {
|
|
20
|
+
header1: () => {
|
|
21
|
+
fontFamily: string;
|
|
22
|
+
fontSize: number;
|
|
23
|
+
};
|
|
24
|
+
header2: () => {
|
|
25
|
+
fontFamily: string;
|
|
26
|
+
fontSize: number;
|
|
27
|
+
};
|
|
28
|
+
header3: () => {
|
|
29
|
+
fontFamily: string;
|
|
30
|
+
fontSize: number;
|
|
31
|
+
};
|
|
32
|
+
header3Bold: () => {
|
|
33
|
+
fontFamily: string;
|
|
34
|
+
fontSize: number;
|
|
35
|
+
};
|
|
36
|
+
standardU: () => {
|
|
37
|
+
fontFamily: string;
|
|
38
|
+
fontSize: number;
|
|
39
|
+
};
|
|
40
|
+
standardLight: () => {
|
|
41
|
+
fontFamily: string;
|
|
42
|
+
fontSize: number;
|
|
43
|
+
};
|
|
44
|
+
standardBold: () => {
|
|
45
|
+
fontFamily: string;
|
|
46
|
+
fontSize: number;
|
|
47
|
+
};
|
|
48
|
+
subTextU: () => {
|
|
49
|
+
fontFamily: string;
|
|
50
|
+
fontSize: number;
|
|
51
|
+
};
|
|
52
|
+
subTextBold: () => {
|
|
53
|
+
fontFamily: string;
|
|
54
|
+
fontSize: number;
|
|
55
|
+
};
|
|
56
|
+
subTextLight: () => {
|
|
57
|
+
fontFamily: string;
|
|
58
|
+
fontSize: number;
|
|
59
|
+
};
|
|
60
|
+
smallTextU: () => {
|
|
61
|
+
fontFamily: string;
|
|
62
|
+
fontSize: number;
|
|
63
|
+
};
|
|
64
|
+
smallTextBold: () => {
|
|
65
|
+
fontFamily: string;
|
|
66
|
+
fontSize: number;
|
|
67
|
+
};
|
|
68
|
+
smallTextLight: () => {
|
|
69
|
+
fontFamily: string;
|
|
70
|
+
fontSize: number;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
weights: {
|
|
74
|
+
lightU: () => {
|
|
75
|
+
fontFamily: string;
|
|
76
|
+
};
|
|
77
|
+
boldU: () => {
|
|
78
|
+
fontFamily: string;
|
|
79
|
+
};
|
|
80
|
+
normalU: () => {
|
|
81
|
+
fontFamily: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
fonts: {
|
|
85
|
+
en: string;
|
|
86
|
+
ar: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
export default _default;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { I18nManager } from 'react-native';
|
|
2
|
+
import { moderateScale } from './scale';
|
|
3
|
+
// Usedo english font family
|
|
4
|
+
const UE_FONT_LIGHT = 'Rubik-Light';
|
|
5
|
+
const UE_FONT_REGULAR = 'Rubik-Regular';
|
|
6
|
+
const UE_FONT_BOLD = 'Rubik-Bold';
|
|
7
|
+
// Usedo arabic font family
|
|
8
|
+
const UA_FONT_LIGHT = 'HelveticaNeueLTArabic-Light';
|
|
9
|
+
const UA_FONT_REGULAR = 'HelveticaNeueLTArabic-Roman';
|
|
10
|
+
const UA_FONT_BOLD = 'HelveticaNeueLTArabic-Bold';
|
|
11
|
+
// sizes
|
|
12
|
+
const xSmall = () => ({
|
|
13
|
+
fontSize: moderateScale(12),
|
|
14
|
+
});
|
|
15
|
+
const smallU = () => ({
|
|
16
|
+
fontSize: moderateScale(14),
|
|
17
|
+
});
|
|
18
|
+
const regularU = () => ({
|
|
19
|
+
fontSize: moderateScale(16),
|
|
20
|
+
});
|
|
21
|
+
const mediumU = () => ({
|
|
22
|
+
fontSize: moderateScale(18),
|
|
23
|
+
});
|
|
24
|
+
const largeU = () => ({
|
|
25
|
+
fontSize: moderateScale(20),
|
|
26
|
+
});
|
|
27
|
+
// weights
|
|
28
|
+
const lightU = () => ({
|
|
29
|
+
fontFamily: I18nManager.isRTL ? UA_FONT_LIGHT : UE_FONT_LIGHT,
|
|
30
|
+
});
|
|
31
|
+
// comment for testing
|
|
32
|
+
const normalU = () => ({
|
|
33
|
+
fontFamily: I18nManager.isRTL ? UA_FONT_REGULAR : UE_FONT_REGULAR,
|
|
34
|
+
});
|
|
35
|
+
const boldU = () => ({
|
|
36
|
+
fontFamily: I18nManager.isRTL ? UA_FONT_BOLD : UE_FONT_BOLD,
|
|
37
|
+
});
|
|
38
|
+
// styles
|
|
39
|
+
const header1 = () => ({
|
|
40
|
+
...largeU(), // 20
|
|
41
|
+
...boldU(),
|
|
42
|
+
});
|
|
43
|
+
const header2 = () => ({
|
|
44
|
+
...largeU(), // 20
|
|
45
|
+
...normalU(),
|
|
46
|
+
});
|
|
47
|
+
const header3 = () => ({
|
|
48
|
+
...mediumU(), // 18
|
|
49
|
+
...normalU(),
|
|
50
|
+
});
|
|
51
|
+
const header3Bold = () => ({
|
|
52
|
+
...mediumU(), // 18
|
|
53
|
+
...boldU(),
|
|
54
|
+
});
|
|
55
|
+
const standardU = () => ({
|
|
56
|
+
...regularU(), // 16
|
|
57
|
+
...normalU(),
|
|
58
|
+
});
|
|
59
|
+
const standardLight = () => ({
|
|
60
|
+
...regularU(), // 16
|
|
61
|
+
...lightU(),
|
|
62
|
+
});
|
|
63
|
+
const standardBold = () => ({
|
|
64
|
+
...regularU(), // 16
|
|
65
|
+
...boldU(),
|
|
66
|
+
});
|
|
67
|
+
const subTextU = () => ({
|
|
68
|
+
...smallU(), // 14
|
|
69
|
+
...normalU(),
|
|
70
|
+
});
|
|
71
|
+
const subTextBold = () => ({
|
|
72
|
+
...smallU(), // 14
|
|
73
|
+
...boldU(),
|
|
74
|
+
});
|
|
75
|
+
const subTextLight = () => ({
|
|
76
|
+
...smallU(), // 14
|
|
77
|
+
...lightU(),
|
|
78
|
+
});
|
|
79
|
+
const smallTextU = () => ({
|
|
80
|
+
...xSmall(), // 12
|
|
81
|
+
...normalU(),
|
|
82
|
+
});
|
|
83
|
+
const smallTextBold = () => ({
|
|
84
|
+
...xSmall(), // 12
|
|
85
|
+
...boldU(),
|
|
86
|
+
});
|
|
87
|
+
const smallTextLight = () => ({
|
|
88
|
+
...xSmall(), // 12
|
|
89
|
+
...lightU(),
|
|
90
|
+
});
|
|
91
|
+
export default {
|
|
92
|
+
size: {
|
|
93
|
+
xSmall,
|
|
94
|
+
smallU,
|
|
95
|
+
regularU,
|
|
96
|
+
mediumU,
|
|
97
|
+
largeU,
|
|
98
|
+
},
|
|
99
|
+
style: {
|
|
100
|
+
header1,
|
|
101
|
+
header2,
|
|
102
|
+
header3,
|
|
103
|
+
header3Bold,
|
|
104
|
+
standardU,
|
|
105
|
+
standardLight,
|
|
106
|
+
standardBold,
|
|
107
|
+
subTextU,
|
|
108
|
+
subTextBold,
|
|
109
|
+
subTextLight,
|
|
110
|
+
smallTextU,
|
|
111
|
+
smallTextBold,
|
|
112
|
+
smallTextLight,
|
|
113
|
+
},
|
|
114
|
+
weights: {
|
|
115
|
+
lightU,
|
|
116
|
+
boldU,
|
|
117
|
+
normalU,
|
|
118
|
+
},
|
|
119
|
+
fonts: {
|
|
120
|
+
en: UE_FONT_REGULAR,
|
|
121
|
+
ar: UA_FONT_REGULAR,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const messages: {
|
|
2
|
+
CAMERA_PERMISSION_DENIED: string;
|
|
3
|
+
MICROPHONE_PERMISSION_DENIED: string;
|
|
4
|
+
GALLERY_PERMISSION_DENIED: string;
|
|
5
|
+
IMAGE_PROCESSING: string;
|
|
6
|
+
VIDEO_PROCESSING: string;
|
|
7
|
+
FILE_ERROR: string;
|
|
8
|
+
VIDEO_ERROR: string;
|
|
9
|
+
LIMIT_EXCEEDED: string;
|
|
10
|
+
USER_CANCELLED: string;
|
|
11
|
+
UNKNOWN_ERROR: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const messages = {
|
|
2
|
+
CAMERA_PERMISSION_DENIED: "Camera permission is required to use this feature.",
|
|
3
|
+
MICROPHONE_PERMISSION_DENIED: "Microphone permission is required for recording videos.",
|
|
4
|
+
GALLERY_PERMISSION_DENIED: "Gallery/Storage permission is required to select files.",
|
|
5
|
+
IMAGE_PROCESSING: "Processing image, please wait...",
|
|
6
|
+
VIDEO_PROCESSING: "Processing video, please wait...",
|
|
7
|
+
FILE_ERROR: "Cannot find image data. Please select a valid file.",
|
|
8
|
+
VIDEO_ERROR: "Invalid video file. Please try again.",
|
|
9
|
+
LIMIT_EXCEEDED: "You can only select up to 5 images.",
|
|
10
|
+
USER_CANCELLED: "User cancelled the selection.",
|
|
11
|
+
UNKNOWN_ERROR: "Something went wrong. Please try again.",
|
|
12
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request storage/doc access permissions cross-platform.
|
|
3
|
+
* Handles Android < 13 and Android 13+ separately.
|
|
4
|
+
*/
|
|
5
|
+
export declare const requestDocumentPermission: () => Promise<boolean>;
|
|
6
|
+
/**
|
|
7
|
+
* ✅ Camera Permission
|
|
8
|
+
*/
|
|
9
|
+
export declare const cameraPermissions: (callback: (status: boolean) => void) => Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* 🎤 Microphone Permission (needed for video recording)
|
|
12
|
+
*/
|
|
13
|
+
export declare const checkMicroPhonePermission: () => Promise<boolean>;
|
|
14
|
+
/**
|
|
15
|
+
* 🖼️ Gallery / Storage Permission
|
|
16
|
+
* ✅ Handles Android < 13 and >= 13
|
|
17
|
+
*/
|
|
18
|
+
export declare const galleryPermissions: (callback: (status: boolean) => void) => Promise<void>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Platform, PermissionsAndroid } from 'react-native';
|
|
2
|
+
import { request, PERMISSIONS, RESULTS } from 'react-native-permissions';
|
|
3
|
+
/**
|
|
4
|
+
* Request storage/doc access permissions cross-platform.
|
|
5
|
+
* Handles Android < 13 and Android 13+ separately.
|
|
6
|
+
*/
|
|
7
|
+
export const requestDocumentPermission = async () => {
|
|
8
|
+
try {
|
|
9
|
+
if (Platform.OS === 'android') {
|
|
10
|
+
const androidVersion = Platform.Version;
|
|
11
|
+
if (androidVersion < 33) {
|
|
12
|
+
// ✅ Android 12 or below
|
|
13
|
+
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE, {
|
|
14
|
+
title: 'Storage Permission',
|
|
15
|
+
message: 'App needs access to your storage to pick documents.',
|
|
16
|
+
buttonPositive: 'OK',
|
|
17
|
+
});
|
|
18
|
+
return granted === PermissionsAndroid.RESULTS.GRANTED;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
// ✅ Android 13+ (API 33): use READ_MEDIA_* permissions
|
|
22
|
+
const result = await request(PERMISSIONS.ANDROID.READ_MEDIA_IMAGES);
|
|
23
|
+
return result === RESULTS.GRANTED;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else if (Platform.OS === 'ios') {
|
|
27
|
+
// ✅ iOS
|
|
28
|
+
const result = await request(PERMISSIONS.IOS.MEDIA_LIBRARY);
|
|
29
|
+
return result === RESULTS.GRANTED;
|
|
30
|
+
}
|
|
31
|
+
return true; // web/other fallback
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
console.warn('Permission error:', error);
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* ✅ Camera Permission
|
|
40
|
+
*/
|
|
41
|
+
export const cameraPermissions = async (callback) => {
|
|
42
|
+
try {
|
|
43
|
+
if (Platform.OS === 'ios') {
|
|
44
|
+
const result = await request(PERMISSIONS.IOS.CAMERA);
|
|
45
|
+
callback(result === RESULTS.GRANTED);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const result = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.CAMERA);
|
|
49
|
+
callback(result === PermissionsAndroid.RESULTS.GRANTED);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.log('Camera Permission Error:', error);
|
|
54
|
+
callback(false);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 🎤 Microphone Permission (needed for video recording)
|
|
59
|
+
*/
|
|
60
|
+
export const checkMicroPhonePermission = async () => {
|
|
61
|
+
try {
|
|
62
|
+
if (Platform.OS === 'ios') {
|
|
63
|
+
const result = await request(PERMISSIONS.IOS.MICROPHONE);
|
|
64
|
+
return result === RESULTS.GRANTED;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
const result = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.RECORD_AUDIO);
|
|
68
|
+
return result === PermissionsAndroid.RESULTS.GRANTED;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.log('Microphone Permission Error:', error);
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* 🖼️ Gallery / Storage Permission
|
|
78
|
+
* ✅ Handles Android < 13 and >= 13
|
|
79
|
+
*/
|
|
80
|
+
export const galleryPermissions = async (callback) => {
|
|
81
|
+
try {
|
|
82
|
+
if (Platform.OS === 'ios') {
|
|
83
|
+
const result = await request(PERMISSIONS.IOS.PHOTO_LIBRARY);
|
|
84
|
+
callback(result === RESULTS.GRANTED);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const androidVersion = Platform.Version;
|
|
88
|
+
if (androidVersion >= 33) {
|
|
89
|
+
// 👉 Android 13+ requires READ_MEDIA permissions
|
|
90
|
+
const imagePermission = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_MEDIA_IMAGES);
|
|
91
|
+
const videoPermission = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_MEDIA_VIDEO);
|
|
92
|
+
callback(imagePermission === PermissionsAndroid.RESULTS.GRANTED ||
|
|
93
|
+
videoPermission === PermissionsAndroid.RESULTS.GRANTED);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
// 👉 Below Android 13 needs old storage permission
|
|
97
|
+
const storagePermission = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE);
|
|
98
|
+
callback(storagePermission === PermissionsAndroid.RESULTS.GRANTED);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.log('Gallery Permission Error:', error);
|
|
104
|
+
callback(false);
|
|
105
|
+
}
|
|
106
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@teamnhz/rn-ui-toolkit",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"files": ["dist"],
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc && cpx \"src/**/*.json\" dist && cpx \"src/assets/images/*\" dist/assets/images",
|
|
9
|
+
"prepare": "npm run build"
|
|
10
|
+
},
|
|
11
|
+
"peerDependencies": {
|
|
12
|
+
"react": ">=19.0.0",
|
|
13
|
+
"react-native": ">=0.77.2",
|
|
14
|
+
"react-native-elements": "^3.4.3",
|
|
15
|
+
"react-native-vector-icons": "^10.3.0",
|
|
16
|
+
"react-native-fast-image": "^8.6.3",
|
|
17
|
+
"react-native-gesture-handler": "^2.26.0",
|
|
18
|
+
"react-native-reanimated": "^3.17.5",
|
|
19
|
+
"react-native-safe-area-context": "^5.6.1",
|
|
20
|
+
"react-native-svg": "^15.12.1",
|
|
21
|
+
"react-native-modal": "^14.0.0-rc.1",
|
|
22
|
+
"react-native-date-picker": "^5.0.13",
|
|
23
|
+
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
24
|
+
"react-i18next": "^15.7.2",
|
|
25
|
+
"react-native-element-dropdown": "^2.12.4",
|
|
26
|
+
"@react-native-documents/picker": "^10.1.5",
|
|
27
|
+
"react-native-permissions": "^4.1.5",
|
|
28
|
+
"react-native-video-trim": "^3.0.9",
|
|
29
|
+
"react-native-image-picker": "^8.2.0",
|
|
30
|
+
"react-native-image-crop-picker": "^0.42.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"typescript": "^5.9.2",
|
|
34
|
+
"@react-native-documents/picker": "^10.1.5",
|
|
35
|
+
"cpx": "^1.5.0"
|
|
36
|
+
}
|
|
37
|
+
}
|