@bigbinary/neetoui-rn 0.0.268 → 0.0.270
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/package.json +2 -3
- package/src/components/Accordion.jsx +0 -266
- package/src/components/ActionIcon.jsx +0 -76
- package/src/components/Alert.jsx +0 -262
- package/src/components/AnimatedImage.jsx +0 -140
- package/src/components/Avatar.jsx +0 -144
- package/src/components/Badge.jsx +0 -97
- package/src/components/BottomSheet.jsx +0 -487
- package/src/components/BottomTabBar.jsx +0 -232
- package/src/components/Button.jsx +0 -275
- package/src/components/ButtonGroup.jsx +0 -120
- package/src/components/Calendar.jsx +0 -128
- package/src/components/Card.jsx +0 -90
- package/src/components/Carousel.jsx +0 -116
- package/src/components/ChatInput/AttachmentsView.jsx +0 -51
- package/src/components/ChatInput/Badge.jsx +0 -24
- package/src/components/ChatInput/ChatInput.jsx +0 -564
- package/src/components/ChatInput/EmailFields.jsx +0 -122
- package/src/components/ChatInput/IconButton.jsx +0 -34
- package/src/components/ChatInput/MentionsInputWrapper.jsx +0 -155
- package/src/components/CheckBox.jsx +0 -150
- package/src/components/Chip.jsx +0 -180
- package/src/components/Container.jsx +0 -31
- package/src/components/Divider.jsx +0 -79
- package/src/components/FAB.jsx +0 -113
- package/src/components/FlashList.jsx +0 -189
- package/src/components/FlatList.js +0 -10
- package/src/components/Input.jsx +0 -357
- package/src/components/InputEmailChip.jsx +0 -246
- package/src/components/LineLoader.jsx +0 -46
- package/src/components/ListItem.jsx +0 -68
- package/src/components/Loader.jsx +0 -122
- package/src/components/MultiSelect.jsx +0 -631
- package/src/components/NotificationIcon.jsx +0 -38
- package/src/components/NotificationPreferenceList.jsx +0 -208
- package/src/components/OnBoarding.jsx +0 -134
- package/src/components/OrganizationItem.jsx +0 -110
- package/src/components/OtpInputs.jsx +0 -194
- package/src/components/ParentView.jsx +0 -139
- package/src/components/Popover.jsx +0 -221
- package/src/components/RadioButton.jsx +0 -155
- package/src/components/RichTextEditor.jsx +0 -163
- package/src/components/Ripple.jsx +0 -281
- package/src/components/ScrollView.js +0 -14
- package/src/components/SearchBar.jsx +0 -207
- package/src/components/SegmentedTopBar/Indicator.jsx +0 -77
- package/src/components/SegmentedTopBar/Tab.jsx +0 -37
- package/src/components/SegmentedTopBar/index.jsx +0 -128
- package/src/components/SocialButton.jsx +0 -106
- package/src/components/Toast.jsx +0 -195
- package/src/components/ToggleSwitch.jsx +0 -112
- package/src/components/TopBar.jsx +0 -147
- package/src/components/Touchable.jsx +0 -133
- package/src/components/TouchableWithoutFeedback.jsx +0 -51
- package/src/components/Typography.jsx +0 -93
- package/src/components/index.js +0 -45
- package/src/config/index.js +0 -1
- package/src/config/toasterConfig.jsx +0 -142
- package/src/contexts/index.js +0 -3
- package/src/hooks/index.js +0 -3
- package/src/hooks/useDebounce.js +0 -17
- package/src/hooks/useKeyboard.js +0 -33
- package/src/hooks/useRefreshByUser.js +0 -20
- package/src/index.js +0 -2
- package/src/theme/index.js +0 -181
- package/src/utils/utils.js +0 -56
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neetoui-rn",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.270",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "BigBinary",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,7 +30,6 @@
|
|
|
30
30
|
},
|
|
31
31
|
"files": [
|
|
32
32
|
"lib",
|
|
33
|
-
"src",
|
|
34
33
|
"react-native.config.js",
|
|
35
34
|
"index.d.ts",
|
|
36
35
|
"assets"
|
|
@@ -63,7 +62,7 @@
|
|
|
63
62
|
"react-native-controlled-mentions": "^2.2.5",
|
|
64
63
|
"react-native-gesture-handler": "^2.4.0",
|
|
65
64
|
"react-native-modal": "^13.0.0",
|
|
66
|
-
"react-native-pell-rich-editor": "^1.
|
|
65
|
+
"react-native-pell-rich-editor": "^1.9.0",
|
|
67
66
|
"react-native-popover-view": "^5.1.7",
|
|
68
67
|
"react-native-safe-area-context": "^3.3.2",
|
|
69
68
|
"react-native-size-matters": "^0.4.0",
|
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
useContext,
|
|
3
|
-
useState,
|
|
4
|
-
useRef,
|
|
5
|
-
useEffect,
|
|
6
|
-
useImperativeHandle,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { Animated, StyleSheet } from "react-native";
|
|
9
|
-
|
|
10
|
-
import { Down } from "@bigbinary/neeto-icons-rn";
|
|
11
|
-
import PropTypes from "prop-types";
|
|
12
|
-
import { moderateScale } from "react-native-size-matters";
|
|
13
|
-
import styled, { ThemeContext } from "styled-components/native";
|
|
14
|
-
import {
|
|
15
|
-
buttonStyle,
|
|
16
|
-
flexbox,
|
|
17
|
-
space,
|
|
18
|
-
border,
|
|
19
|
-
color,
|
|
20
|
-
layout,
|
|
21
|
-
} from "styled-system";
|
|
22
|
-
|
|
23
|
-
import { Container } from "@components";
|
|
24
|
-
|
|
25
|
-
const TouchableOpacity = styled.TouchableOpacity`
|
|
26
|
-
${buttonStyle}
|
|
27
|
-
${flexbox}
|
|
28
|
-
${space}
|
|
29
|
-
${border}
|
|
30
|
-
${color}
|
|
31
|
-
${layout}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
const AccordionBody = ({ isExpanded, children }) => {
|
|
35
|
-
const animationController = useRef(
|
|
36
|
-
new Animated.Value(isExpanded ? 1 : 0)
|
|
37
|
-
).current;
|
|
38
|
-
|
|
39
|
-
const [viewHeight, setViewHeight] = useState(0);
|
|
40
|
-
|
|
41
|
-
useEffect(() => {
|
|
42
|
-
Animated.timing(animationController, {
|
|
43
|
-
duration: 300,
|
|
44
|
-
toValue: isExpanded ? 1 : 0,
|
|
45
|
-
useNativeDriver: false,
|
|
46
|
-
}).start();
|
|
47
|
-
}, [isExpanded]);
|
|
48
|
-
|
|
49
|
-
const bodyContentHeight = animationController.interpolate({
|
|
50
|
-
inputRange: [0, 1],
|
|
51
|
-
outputRange: [0, viewHeight],
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
const getLayout = event => {
|
|
55
|
-
const height = event.nativeEvent.layout.height;
|
|
56
|
-
setViewHeight(height);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
return (
|
|
60
|
-
<Animated.View style={{ height: bodyContentHeight, overflow: "hidden" }}>
|
|
61
|
-
<Container position="absolute" width="100%" onLayout={getLayout}>
|
|
62
|
-
{children}
|
|
63
|
-
</Container>
|
|
64
|
-
</Animated.View>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* A component used to display an expandable list item.
|
|
70
|
-
*
|
|
71
|
-
* <div class="screenshots">
|
|
72
|
-
* <img src="screenshots/accordion/accordion.png" />
|
|
73
|
-
* </div>
|
|
74
|
-
*
|
|
75
|
-
* ## Usage
|
|
76
|
-
* ```js
|
|
77
|
-
* import * as React from 'react';
|
|
78
|
-
* import { Container, Accordion } from '@bigbinary/neetoui-rn';
|
|
79
|
-
*
|
|
80
|
-
* export default function Main() {
|
|
81
|
-
* return (
|
|
82
|
-
* <Container>
|
|
83
|
-
* <Accordion
|
|
84
|
-
* header={() => (
|
|
85
|
-
* <Container flexDirection="row" alignItems="center">
|
|
86
|
-
* <Typography bg="#00BA8829" color="font.primary" p={moderateScale(1)}>
|
|
87
|
-
* Open
|
|
88
|
-
* </Typography>
|
|
89
|
-
* <Typography px={moderateScale(2)}>Low</Typography>
|
|
90
|
-
* </Container>
|
|
91
|
-
* )}
|
|
92
|
-
* iconProp={{
|
|
93
|
-
* IconLabel: () => (
|
|
94
|
-
* <Typography color="font.danger">Collapse</Typography>
|
|
95
|
-
* ),
|
|
96
|
-
* iconColor: theme.colors.font.danger,
|
|
97
|
-
* }}
|
|
98
|
-
* >
|
|
99
|
-
* <Container my={moderateScale(2)} p={moderateScale(3)} bg="background.grey100" borderRadius={moderateScale(8)}>
|
|
100
|
-
* <Typography color="font.primary">Body Content</Typography>
|
|
101
|
-
* </Container>
|
|
102
|
-
* </Accordion>
|
|
103
|
-
* </Container>
|
|
104
|
-
* );
|
|
105
|
-
* }
|
|
106
|
-
* ```
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
|
|
110
|
-
export const Accordion = React.forwardRef(
|
|
111
|
-
(
|
|
112
|
-
{
|
|
113
|
-
header,
|
|
114
|
-
noBorder = false,
|
|
115
|
-
iconProp = {},
|
|
116
|
-
onStateChanged,
|
|
117
|
-
children,
|
|
118
|
-
position = "bottom",
|
|
119
|
-
shouldShowToggle = true,
|
|
120
|
-
headerContainerProps,
|
|
121
|
-
...rest
|
|
122
|
-
},
|
|
123
|
-
ref
|
|
124
|
-
) => {
|
|
125
|
-
const { Label, size, color } = iconProp;
|
|
126
|
-
const theme = useContext(ThemeContext);
|
|
127
|
-
const [isExpanded, setIsExpanded] = useState(false);
|
|
128
|
-
const animationController = useRef(
|
|
129
|
-
new Animated.Value(isExpanded ? 1 : 0)
|
|
130
|
-
).current;
|
|
131
|
-
|
|
132
|
-
useEffect(() => {
|
|
133
|
-
Animated.timing(animationController, {
|
|
134
|
-
duration: 300,
|
|
135
|
-
toValue: isExpanded ? 1 : 0,
|
|
136
|
-
useNativeDriver: false,
|
|
137
|
-
}).start(() => {
|
|
138
|
-
!!onStateChanged && onStateChanged(isExpanded);
|
|
139
|
-
});
|
|
140
|
-
}, [isExpanded]);
|
|
141
|
-
|
|
142
|
-
const handleAnimation = () => {
|
|
143
|
-
setIsExpanded(!isExpanded);
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
useImperativeHandle(ref, () => ({
|
|
147
|
-
toggleAccordion: handleAnimation,
|
|
148
|
-
openAccordion: () => setIsExpanded(true),
|
|
149
|
-
closeAccordion: () => setIsExpanded(false),
|
|
150
|
-
}));
|
|
151
|
-
|
|
152
|
-
const arrowAngle = animationController.interpolate({
|
|
153
|
-
inputRange: [0, 1],
|
|
154
|
-
outputRange: ["0rad", `${Math.PI}rad`],
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
return (
|
|
158
|
-
<Container
|
|
159
|
-
{...(!noBorder && {
|
|
160
|
-
borderColor: "border.grey400",
|
|
161
|
-
borderWidth: moderateScale(1),
|
|
162
|
-
borderRadius: moderateScale(8),
|
|
163
|
-
})}
|
|
164
|
-
padding={moderateScale(12)}
|
|
165
|
-
width="100%"
|
|
166
|
-
{...rest}
|
|
167
|
-
>
|
|
168
|
-
{position === "top" && (
|
|
169
|
-
<AccordionBody isExpanded={isExpanded}>{children}</AccordionBody>
|
|
170
|
-
)}
|
|
171
|
-
<TouchableOpacity
|
|
172
|
-
style={styles.accordionContainer}
|
|
173
|
-
onPress={() => {
|
|
174
|
-
handleAnimation();
|
|
175
|
-
}}
|
|
176
|
-
{...headerContainerProps}
|
|
177
|
-
>
|
|
178
|
-
{!!header && <Container flexGrow={1}>{header()}</Container>}
|
|
179
|
-
{!!shouldShowToggle && (
|
|
180
|
-
<Container
|
|
181
|
-
alignItems="center"
|
|
182
|
-
flexDirection="row"
|
|
183
|
-
justifyContent="center"
|
|
184
|
-
>
|
|
185
|
-
{Label && <Label />}
|
|
186
|
-
<Animated.View
|
|
187
|
-
style={{
|
|
188
|
-
alignItems: "flex-end",
|
|
189
|
-
transform: [{ rotateZ: arrowAngle }],
|
|
190
|
-
}}
|
|
191
|
-
>
|
|
192
|
-
<Container>
|
|
193
|
-
<Down
|
|
194
|
-
color={color ?? theme.colors.font.grey700}
|
|
195
|
-
size={size ?? moderateScale(24)}
|
|
196
|
-
/>
|
|
197
|
-
</Container>
|
|
198
|
-
</Animated.View>
|
|
199
|
-
</Container>
|
|
200
|
-
)}
|
|
201
|
-
</TouchableOpacity>
|
|
202
|
-
{position === "bottom" && (
|
|
203
|
-
<AccordionBody isExpanded={isExpanded}>{children}</AccordionBody>
|
|
204
|
-
)}
|
|
205
|
-
</Container>
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
);
|
|
209
|
-
|
|
210
|
-
AccordionBody.propTypes = {
|
|
211
|
-
isExpanded: PropTypes.bool.isRequired,
|
|
212
|
-
children: PropTypes.element,
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
Accordion.propTypes = {
|
|
216
|
-
/**
|
|
217
|
-
* Render a component on the header.
|
|
218
|
-
*/
|
|
219
|
-
header: PropTypes.func,
|
|
220
|
-
/**
|
|
221
|
-
* Customize header container
|
|
222
|
-
*/
|
|
223
|
-
headerContainerProps: PropTypes.object,
|
|
224
|
-
/**
|
|
225
|
-
* Renders the child component passed in the body of the accordion.
|
|
226
|
-
*/
|
|
227
|
-
children: PropTypes.node,
|
|
228
|
-
/**
|
|
229
|
-
* Takes a boolean value based on which border is shown.
|
|
230
|
-
*/
|
|
231
|
-
noBorder: PropTypes.bool,
|
|
232
|
-
/**
|
|
233
|
-
* Function that returns the current state.
|
|
234
|
-
*/
|
|
235
|
-
onStateChanged: PropTypes.func,
|
|
236
|
-
/**
|
|
237
|
-
* Takes an object based on which the icon to expand/collapse can be customized.
|
|
238
|
-
* Label: Takes a component.
|
|
239
|
-
* size: Used to update the icon size.
|
|
240
|
-
* name: Used to update the default arrow icon.
|
|
241
|
-
* color: Used to update the default color of the icon.
|
|
242
|
-
*/
|
|
243
|
-
iconProp: PropTypes.shape({
|
|
244
|
-
name: PropTypes.string,
|
|
245
|
-
Label: PropTypes.elementType,
|
|
246
|
-
size: PropTypes.number,
|
|
247
|
-
color: PropTypes.string,
|
|
248
|
-
}),
|
|
249
|
-
/**
|
|
250
|
-
* Determine whether the body should show at the top or bottom
|
|
251
|
-
*/
|
|
252
|
-
position: PropTypes.string,
|
|
253
|
-
/**
|
|
254
|
-
* Can be set to false if custom toggle UI action item needs to be passed.
|
|
255
|
-
*/
|
|
256
|
-
shouldShowToggle: PropTypes.bool,
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
const styles = StyleSheet.create({
|
|
260
|
-
accordionContainer: {
|
|
261
|
-
flexDirection: "row",
|
|
262
|
-
alignItems: "center",
|
|
263
|
-
},
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
Accordion.displayName = "Accordion";
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import { moderateScale } from "react-native-size-matters";
|
|
5
|
-
|
|
6
|
-
import { theme } from "@theme";
|
|
7
|
-
|
|
8
|
-
import { Loader } from "./Loader";
|
|
9
|
-
import { Touchable } from "./Touchable";
|
|
10
|
-
import { Typography } from "./Typography";
|
|
11
|
-
|
|
12
|
-
export const ActionIcon = ({
|
|
13
|
-
isLoading = false,
|
|
14
|
-
icon: Icon,
|
|
15
|
-
onPress,
|
|
16
|
-
size = moderateScale(24),
|
|
17
|
-
color = theme.colors.font.grey800,
|
|
18
|
-
disabled = false,
|
|
19
|
-
label,
|
|
20
|
-
iconProps,
|
|
21
|
-
...rest
|
|
22
|
-
}) => (
|
|
23
|
-
<Touchable
|
|
24
|
-
alignItems="center"
|
|
25
|
-
aspectRatio={1}
|
|
26
|
-
disabled={disabled || isLoading}
|
|
27
|
-
height={moderateScale(40)}
|
|
28
|
-
justifyContent="center"
|
|
29
|
-
maxHeight={moderateScale(64)}
|
|
30
|
-
maxWidth={moderateScale(64)}
|
|
31
|
-
opacity={disabled ? 0.5 : 1}
|
|
32
|
-
onPress={onPress}
|
|
33
|
-
{...rest}
|
|
34
|
-
>
|
|
35
|
-
{isLoading ? <Loader /> : <Icon color={color} size={size} {...iconProps} />}
|
|
36
|
-
{!!label && (
|
|
37
|
-
<Typography
|
|
38
|
-
color="font.grey600"
|
|
39
|
-
fontFamily="sf400"
|
|
40
|
-
fontSize="4xs"
|
|
41
|
-
mt={moderateScale(2)}
|
|
42
|
-
>
|
|
43
|
-
{label}
|
|
44
|
-
</Typography>
|
|
45
|
-
)}
|
|
46
|
-
</Touchable>
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
ActionIcon.propTypes = {
|
|
50
|
-
/**
|
|
51
|
-
* The icon that should be displayed
|
|
52
|
-
*/
|
|
53
|
-
icon: PropTypes.elementType,
|
|
54
|
-
/**
|
|
55
|
-
* The Func that should be triggered on click of the action icon
|
|
56
|
-
*/
|
|
57
|
-
onPress: PropTypes.func,
|
|
58
|
-
/** To customize the size of the icon
|
|
59
|
-
*/
|
|
60
|
-
size: PropTypes.number,
|
|
61
|
-
/** To customize the color of the icon
|
|
62
|
-
*/
|
|
63
|
-
color: PropTypes.string,
|
|
64
|
-
/** To set the disabled state
|
|
65
|
-
*/
|
|
66
|
-
disabled: PropTypes.bool,
|
|
67
|
-
/** The label that should be displayed next to the icon
|
|
68
|
-
*/
|
|
69
|
-
label: PropTypes.string,
|
|
70
|
-
/** To display the loading state
|
|
71
|
-
*/
|
|
72
|
-
isLoading: PropTypes.bool,
|
|
73
|
-
/** To additionally customize the icon
|
|
74
|
-
*/
|
|
75
|
-
iconProps: PropTypes.object,
|
|
76
|
-
};
|
package/src/components/Alert.jsx
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { StyleSheet } from "react-native";
|
|
3
|
-
|
|
4
|
-
import Modal from "react-native-modal";
|
|
5
|
-
import { moderateScale } from "react-native-size-matters";
|
|
6
|
-
|
|
7
|
-
import { Typography, Container, Button } from "@components";
|
|
8
|
-
|
|
9
|
-
const useAlertHook = () => {
|
|
10
|
-
const [isVisible, setIsVisible] = React.useState(false);
|
|
11
|
-
const [params, setParams] = useState({});
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
title = "",
|
|
15
|
-
description = "",
|
|
16
|
-
isCancelable = true,
|
|
17
|
-
onDismiss,
|
|
18
|
-
buttons = [],
|
|
19
|
-
} = params;
|
|
20
|
-
|
|
21
|
-
const show = React.useCallback(params => {
|
|
22
|
-
setParams(params);
|
|
23
|
-
setIsVisible(true);
|
|
24
|
-
}, []);
|
|
25
|
-
|
|
26
|
-
const hide = React.useCallback(() => {
|
|
27
|
-
setIsVisible(false);
|
|
28
|
-
}, []);
|
|
29
|
-
|
|
30
|
-
const hideOnBackPressDrop = React.useCallback(() => {
|
|
31
|
-
if (isCancelable) {
|
|
32
|
-
hide();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (onDismiss && isCancelable) {
|
|
36
|
-
onDismiss();
|
|
37
|
-
}
|
|
38
|
-
}, [hide, isCancelable, onDismiss]);
|
|
39
|
-
|
|
40
|
-
return {
|
|
41
|
-
isVisible,
|
|
42
|
-
show,
|
|
43
|
-
hide,
|
|
44
|
-
hideOnBackPressDrop,
|
|
45
|
-
title,
|
|
46
|
-
description,
|
|
47
|
-
isCancelable,
|
|
48
|
-
buttons,
|
|
49
|
-
};
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
let rootLevelRef = null;
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Launches an alert dialog with the specified title and message.
|
|
56
|
-
* Optionally provide a list of buttons.
|
|
57
|
-
* Tapping any button will fire the respective onPress callback and dismiss the alert.
|
|
58
|
-
* By default, the only button will be an 'OK' button.
|
|
59
|
-
* <div class="screenshots">
|
|
60
|
-
* <img src="screenshots/alert/alert-1.png" />
|
|
61
|
-
* <img src="screenshots/alert/alert-2.png" />
|
|
62
|
-
* <img src="screenshots/alert/alert-3.png" />
|
|
63
|
-
* <img src="screenshots/alert/alert-4.png" />
|
|
64
|
-
* <img src="screenshots/alert/alert-5.png" />
|
|
65
|
-
* <img src="screenshots/alert/alert-6.png" />
|
|
66
|
-
* </div>
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* ## Usage
|
|
70
|
-
* ```js
|
|
71
|
-
*import * as React from "react";
|
|
72
|
-
*import { moderateScale } from "react-native-size-matters";
|
|
73
|
-
*import { Alert } from "@bigbinary/neetoui-rn";
|
|
74
|
-
*export function App(props) {
|
|
75
|
-
* return (
|
|
76
|
-
* <>
|
|
77
|
-
* // Render at root component.
|
|
78
|
-
* <Alert />
|
|
79
|
-
* </>
|
|
80
|
-
* );
|
|
81
|
-
*}
|
|
82
|
-
*
|
|
83
|
-
*import * as React from "react";
|
|
84
|
-
*import { moderateScale } from "react-native-size-matters";
|
|
85
|
-
*import { Alert, Button } from "@bigbinary/neetoui-rn";
|
|
86
|
-
*
|
|
87
|
-
*export default function Main() {
|
|
88
|
-
* return (
|
|
89
|
-
* <Button
|
|
90
|
-
* width={moderateScale(200)}
|
|
91
|
-
* my={moderateScale(10)}
|
|
92
|
-
* label="Three Buttons"
|
|
93
|
-
* onPress={() => {
|
|
94
|
-
* Alert.show({
|
|
95
|
-
* title: "Enjoying our app ?",
|
|
96
|
-
* description: "Do you wannna rate us on app store ?",
|
|
97
|
-
* buttons: [
|
|
98
|
-
* {
|
|
99
|
-
* label: "Yay!",
|
|
100
|
-
* onPress: () => {},
|
|
101
|
-
* },
|
|
102
|
-
* {
|
|
103
|
-
* label: "No",
|
|
104
|
-
* onPress: () => {},
|
|
105
|
-
* },
|
|
106
|
-
* {
|
|
107
|
-
* label: "Ask me later",
|
|
108
|
-
* onPress: () => {},
|
|
109
|
-
* },
|
|
110
|
-
* ],
|
|
111
|
-
* isCancelable: false,
|
|
112
|
-
* onDismiss: () => {},
|
|
113
|
-
* });
|
|
114
|
-
* }}
|
|
115
|
-
* />
|
|
116
|
-
* );
|
|
117
|
-
*}
|
|
118
|
-
*
|
|
119
|
-
* ```
|
|
120
|
-
*/
|
|
121
|
-
|
|
122
|
-
export const Alert = () => {
|
|
123
|
-
const {
|
|
124
|
-
isVisible,
|
|
125
|
-
show,
|
|
126
|
-
hide,
|
|
127
|
-
buttons,
|
|
128
|
-
hideOnBackPressDrop,
|
|
129
|
-
title,
|
|
130
|
-
description,
|
|
131
|
-
} = useAlertHook();
|
|
132
|
-
|
|
133
|
-
const [
|
|
134
|
-
button1 = {
|
|
135
|
-
label: "OK",
|
|
136
|
-
onPress: () => {},
|
|
137
|
-
variant: "solid",
|
|
138
|
-
},
|
|
139
|
-
button2,
|
|
140
|
-
button3,
|
|
141
|
-
] = buttons;
|
|
142
|
-
|
|
143
|
-
const ref = React.useRef(null);
|
|
144
|
-
|
|
145
|
-
React.useImperativeHandle(
|
|
146
|
-
ref,
|
|
147
|
-
React.useCallback(
|
|
148
|
-
() => ({
|
|
149
|
-
show,
|
|
150
|
-
}),
|
|
151
|
-
[show]
|
|
152
|
-
)
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
React.useEffect(() => {
|
|
156
|
-
rootLevelRef = ref.current;
|
|
157
|
-
}, [ref]);
|
|
158
|
-
|
|
159
|
-
return (
|
|
160
|
-
<Modal
|
|
161
|
-
hideModalContentWhileAnimating
|
|
162
|
-
useNativeDriver
|
|
163
|
-
isVisible={isVisible}
|
|
164
|
-
style={styles.modalStyle}
|
|
165
|
-
onBackdropPress={hideOnBackPressDrop}
|
|
166
|
-
>
|
|
167
|
-
<Container
|
|
168
|
-
alignItems="center"
|
|
169
|
-
bg="background.primary"
|
|
170
|
-
borderRadius={moderateScale(8)}
|
|
171
|
-
justifyContent="center"
|
|
172
|
-
padding={moderateScale(18)}
|
|
173
|
-
width="90%"
|
|
174
|
-
>
|
|
175
|
-
<Typography color="font.grey800" fontFamily="sf600" fontSize="3xl">
|
|
176
|
-
{title}
|
|
177
|
-
</Typography>
|
|
178
|
-
<Container alignItems="center" justifyContent="center">
|
|
179
|
-
<Typography
|
|
180
|
-
color="font.grey500"
|
|
181
|
-
fontFamily="sf400"
|
|
182
|
-
fontSize="s"
|
|
183
|
-
py={moderateScale(20)}
|
|
184
|
-
textAlign="center"
|
|
185
|
-
>
|
|
186
|
-
{description}
|
|
187
|
-
</Typography>
|
|
188
|
-
</Container>
|
|
189
|
-
<Container
|
|
190
|
-
flexDirection="row"
|
|
191
|
-
justifyContent="space-around"
|
|
192
|
-
width="100%"
|
|
193
|
-
>
|
|
194
|
-
{button2 && (
|
|
195
|
-
<Button
|
|
196
|
-
borderRadius={moderateScale(8)}
|
|
197
|
-
borderWidth={moderateScale(1)}
|
|
198
|
-
fontFamily="sf400"
|
|
199
|
-
fontSize="m"
|
|
200
|
-
height={moderateScale(35)}
|
|
201
|
-
label={button2.label}
|
|
202
|
-
minWidth={moderateScale(110)}
|
|
203
|
-
p={0}
|
|
204
|
-
variant={button2.variant || "text"}
|
|
205
|
-
width={undefined}
|
|
206
|
-
onPress={() => {
|
|
207
|
-
button2.onPress?.();
|
|
208
|
-
hide();
|
|
209
|
-
}}
|
|
210
|
-
/>
|
|
211
|
-
)}
|
|
212
|
-
{button1 && (
|
|
213
|
-
<Button
|
|
214
|
-
borderRadius={moderateScale(8)}
|
|
215
|
-
fontFamily="sf400"
|
|
216
|
-
fontSize="m"
|
|
217
|
-
height={moderateScale(35)}
|
|
218
|
-
label={button1.label}
|
|
219
|
-
minWidth={moderateScale(110)}
|
|
220
|
-
p={0}
|
|
221
|
-
variant={button1.variant}
|
|
222
|
-
width={undefined}
|
|
223
|
-
onPress={() => {
|
|
224
|
-
button1.onPress?.();
|
|
225
|
-
hide();
|
|
226
|
-
}}
|
|
227
|
-
/>
|
|
228
|
-
)}
|
|
229
|
-
</Container>
|
|
230
|
-
{button3 && (
|
|
231
|
-
<Button
|
|
232
|
-
borderRadius={moderateScale(8)}
|
|
233
|
-
borderWidth={moderateScale(1)}
|
|
234
|
-
fontFamily="sf400"
|
|
235
|
-
fontSize="m"
|
|
236
|
-
height={moderateScale(35)}
|
|
237
|
-
label={button3.label}
|
|
238
|
-
minWidth={moderateScale(110)}
|
|
239
|
-
mt={moderateScale(20)}
|
|
240
|
-
p={0}
|
|
241
|
-
variant={button3.variant}
|
|
242
|
-
onPress={() => {
|
|
243
|
-
button3.onPress?.();
|
|
244
|
-
hide();
|
|
245
|
-
}}
|
|
246
|
-
/>
|
|
247
|
-
)}
|
|
248
|
-
</Container>
|
|
249
|
-
</Modal>
|
|
250
|
-
);
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
const styles = StyleSheet.create({
|
|
254
|
-
modalStyle: {
|
|
255
|
-
alignItems: "center",
|
|
256
|
-
justifyContent: "center",
|
|
257
|
-
},
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
Alert.show = params => {
|
|
261
|
-
rootLevelRef.show(params);
|
|
262
|
-
};
|