@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
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
createRef,
|
|
3
|
-
useState,
|
|
4
|
-
useMemo,
|
|
5
|
-
useRef,
|
|
6
|
-
useLayoutEffect,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { StyleSheet, View } from "react-native";
|
|
9
|
-
|
|
10
|
-
import PropTypes from "prop-types";
|
|
11
|
-
import { moderateScale } from "react-native-size-matters";
|
|
12
|
-
|
|
13
|
-
import { theme } from "@theme";
|
|
14
|
-
|
|
15
|
-
import { Indicator } from "./Indicator";
|
|
16
|
-
import { Tab } from "./Tab";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* A Segment Picker component that provides toggling between two or more views.
|
|
21
|
-
*
|
|
22
|
-
* <div class="screenshots">
|
|
23
|
-
* <img src="screenshots/toptabbar/toptabbar-1.png" />
|
|
24
|
-
* <img src="screenshots/toptabbar/toptabbar-2.png" />
|
|
25
|
-
* </div>
|
|
26
|
-
*
|
|
27
|
-
* ## Usage
|
|
28
|
-
* ```js
|
|
29
|
-
* import * as React from 'react';
|
|
30
|
-
* import { createMaterialTopTabNavigator } from "@react-navigation/material-top-tabs";
|
|
31
|
-
* import { NavigationContainer } from "@react-navigation/native";
|
|
32
|
-
*
|
|
33
|
-
* import { SegmentedTopBar } from '@bigbinary/neetoui-rn';
|
|
34
|
-
*
|
|
35
|
-
* const Tab = createMaterialTopTabNavigator();
|
|
36
|
-
*
|
|
37
|
-
* export default function Main(){
|
|
38
|
-
*
|
|
39
|
-
* return (
|
|
40
|
-
* <NavigationContainer>
|
|
41
|
-
* <Tab.Navigator tabBar={props => <SegmentedTopBar {...props} />} >
|
|
42
|
-
* <Tab.Screen
|
|
43
|
-
* name="Home"
|
|
44
|
-
* component={HomeScreen}
|
|
45
|
-
* />
|
|
46
|
-
*
|
|
47
|
-
* <Tab.Screen
|
|
48
|
-
* name="Settings"
|
|
49
|
-
* component={SettingsScreen}
|
|
50
|
-
* />
|
|
51
|
-
* </Tab.Navigator>
|
|
52
|
-
* </NavigationContainer>
|
|
53
|
-
* );
|
|
54
|
-
* }
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
export const SegmentedTopBar = ({
|
|
59
|
-
state: { routes, index },
|
|
60
|
-
navigation,
|
|
61
|
-
height,
|
|
62
|
-
descriptors,
|
|
63
|
-
}) => {
|
|
64
|
-
const containerRef = useRef();
|
|
65
|
-
|
|
66
|
-
const [measures, setMeasures] = useState([]);
|
|
67
|
-
|
|
68
|
-
const tabsData = useMemo(
|
|
69
|
-
() =>
|
|
70
|
-
routes.map(({ key, name }) => {
|
|
71
|
-
const { options } = descriptors[key];
|
|
72
|
-
const label = options.tabBarLabel ?? options.title ?? name;
|
|
73
|
-
|
|
74
|
-
return { label, value: name, ref: createRef() };
|
|
75
|
-
}),
|
|
76
|
-
[]
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
useLayoutEffect(() => {
|
|
80
|
-
const _measures = [];
|
|
81
|
-
|
|
82
|
-
tabsData.forEach(({ ref }) => {
|
|
83
|
-
ref.current.measureLayout(containerRef.current, (x, y, width, height) => {
|
|
84
|
-
_measures.push({ x, y, width, height });
|
|
85
|
-
|
|
86
|
-
if (_measures.length === tabsData.length) {
|
|
87
|
-
setMeasures(_measures);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
}, [measures.length]);
|
|
92
|
-
|
|
93
|
-
return (
|
|
94
|
-
<View height={height} ref={containerRef} style={styles.container}>
|
|
95
|
-
{measures.length > 0 && <Indicator measure={measures[index]} />}
|
|
96
|
-
{tabsData.map(({ label, value, ref }) => (
|
|
97
|
-
<Tab
|
|
98
|
-
flex={tabsData.length > 3 ? label.length : 1}
|
|
99
|
-
key={value}
|
|
100
|
-
label={label}
|
|
101
|
-
navigation={navigation}
|
|
102
|
-
ref={ref}
|
|
103
|
-
value={value}
|
|
104
|
-
/>
|
|
105
|
-
))}
|
|
106
|
-
</View>
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const styles = StyleSheet.create({
|
|
111
|
-
container: {
|
|
112
|
-
flexDirection: "row",
|
|
113
|
-
borderRadius: moderateScale(6),
|
|
114
|
-
backgroundColor: theme.colors.background.secondary,
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
SegmentedTopBar.propTypes = {
|
|
119
|
-
state: PropTypes.object,
|
|
120
|
-
height: PropTypes.number,
|
|
121
|
-
navigation: PropTypes.object,
|
|
122
|
-
descriptors: PropTypes.object,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
SegmentedTopBar.defaultProps = {
|
|
126
|
-
tabs: [],
|
|
127
|
-
height: moderateScale(36),
|
|
128
|
-
};
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from "react";
|
|
2
|
-
|
|
3
|
-
import propTypes from "@styled-system/prop-types";
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import { moderateScale } from "react-native-size-matters";
|
|
6
|
-
import { ThemeContext } from "styled-components/native";
|
|
7
|
-
|
|
8
|
-
import AppleLogo from "@assets/icons/apple-logo.svg";
|
|
9
|
-
import GoogleLogo from "@assets/icons/google-logo.svg";
|
|
10
|
-
import { Container, Typography, Touchable, Loader } from "@components";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* Buttons are touchable elements used to interact with the screen and to trigger an action.
|
|
15
|
-
*
|
|
16
|
-
* <div class="screenshots">
|
|
17
|
-
* <img src="screenshots/socialButton/socialButtons.png" />
|
|
18
|
-
* </div>
|
|
19
|
-
*
|
|
20
|
-
* ## Usage
|
|
21
|
-
* ```js
|
|
22
|
-
* import * as React from 'react';
|
|
23
|
-
* import { Container, SocialButton } from '@bigbinary/neetoui-rn';
|
|
24
|
-
*
|
|
25
|
-
* export default function Main() {
|
|
26
|
-
* return (
|
|
27
|
-
* <Container>
|
|
28
|
-
* <SocialButton variant="apple" my={moderateScale(9)} />
|
|
29
|
-
* <SocialButton variant="google" />
|
|
30
|
-
* </Container>
|
|
31
|
-
* );
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
*/
|
|
36
|
-
|
|
37
|
-
export const SocialButton = ({
|
|
38
|
-
variant,
|
|
39
|
-
disabled,
|
|
40
|
-
labelStyle,
|
|
41
|
-
isLoading,
|
|
42
|
-
...rest
|
|
43
|
-
}) => {
|
|
44
|
-
const theme = useContext(ThemeContext);
|
|
45
|
-
const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<Touchable
|
|
49
|
-
alignItems="center"
|
|
50
|
-
bg="transparent"
|
|
51
|
-
borderColor={theme.colors.border.grey800}
|
|
52
|
-
borderRadius={moderateScale(8)}
|
|
53
|
-
borderWidth={moderateScale(1)}
|
|
54
|
-
disabled={disabled}
|
|
55
|
-
height={moderateScale(48)}
|
|
56
|
-
justifyContent="center"
|
|
57
|
-
rippleConfig={{ color: theme.colors.background.grey800 }}
|
|
58
|
-
width="100%"
|
|
59
|
-
{...rest}
|
|
60
|
-
>
|
|
61
|
-
{isLoading ? (
|
|
62
|
-
<Loader color={theme.colors.background.grey800} />
|
|
63
|
-
) : (
|
|
64
|
-
<>
|
|
65
|
-
<Container left={moderateScale(17)} position="absolute">
|
|
66
|
-
{variant === "apple" && <AppleLogo />}
|
|
67
|
-
{variant === "google" && <GoogleLogo />}
|
|
68
|
-
</Container>
|
|
69
|
-
<Typography
|
|
70
|
-
color={theme.colors.font.primary}
|
|
71
|
-
fontFamily={theme.fonts.sf500}
|
|
72
|
-
fontSize="m"
|
|
73
|
-
{...labelStyle}
|
|
74
|
-
>
|
|
75
|
-
Continue with {capitalize(variant)}
|
|
76
|
-
</Typography>
|
|
77
|
-
</>
|
|
78
|
-
)}
|
|
79
|
-
</Touchable>
|
|
80
|
-
);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
SocialButton.propTypes = {
|
|
84
|
-
...propTypes.buttonStyle,
|
|
85
|
-
...propTypes.flexbox,
|
|
86
|
-
...propTypes.space,
|
|
87
|
-
...propTypes.border,
|
|
88
|
-
...propTypes.layout,
|
|
89
|
-
...propTypes.color,
|
|
90
|
-
/**
|
|
91
|
-
* Supported Type: 'apple' | 'google'
|
|
92
|
-
*/
|
|
93
|
-
variant: PropTypes.oneOf(["apple", "google"]),
|
|
94
|
-
/**
|
|
95
|
-
* Enable or Disable the button
|
|
96
|
-
*/
|
|
97
|
-
disabled: PropTypes.bool,
|
|
98
|
-
/**
|
|
99
|
-
* Customize label style of the button
|
|
100
|
-
*/
|
|
101
|
-
labelStyle: PropTypes.object,
|
|
102
|
-
/**
|
|
103
|
-
* Button loading status
|
|
104
|
-
*/
|
|
105
|
-
isLoading: PropTypes.bool,
|
|
106
|
-
};
|
package/src/components/Toast.jsx
DELETED
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { useContext, useEffect } from "react";
|
|
3
|
-
import { useWindowDimensions } from "react-native";
|
|
4
|
-
|
|
5
|
-
import { Close } from "@bigbinary/neeto-icons-rn";
|
|
6
|
-
import PropTypes from "prop-types";
|
|
7
|
-
import DeviceInfo from "react-native-device-info";
|
|
8
|
-
import { moderateScale } from "react-native-size-matters";
|
|
9
|
-
import T from "react-native-toast-message";
|
|
10
|
-
import { ThemeContext } from "styled-components/native";
|
|
11
|
-
|
|
12
|
-
import ErrorIcon from "@assets/icons/error.svg";
|
|
13
|
-
import InfoIcon from "@assets/icons/info.svg";
|
|
14
|
-
import SuccessIcon from "@assets/icons/success.svg";
|
|
15
|
-
import WarningIcon from "@assets/icons/warning.svg";
|
|
16
|
-
import { Container, Typography, Card, Touchable } from "@components";
|
|
17
|
-
import { defaultToasterConfig } from "@config";
|
|
18
|
-
|
|
19
|
-
let timer;
|
|
20
|
-
const ToastComponent = ({ type, text1, text2, hide, isVisible }) => {
|
|
21
|
-
const theme = useContext(ThemeContext);
|
|
22
|
-
const { width } = useWindowDimensions();
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
if (isVisible) {
|
|
26
|
-
timer = setTimeout(() => {
|
|
27
|
-
hide();
|
|
28
|
-
}, 4000);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return;
|
|
32
|
-
}, [isVisible, hide]);
|
|
33
|
-
|
|
34
|
-
const Icon = () => {
|
|
35
|
-
switch (type) {
|
|
36
|
-
case "success":
|
|
37
|
-
return <SuccessIcon />;
|
|
38
|
-
case "warning":
|
|
39
|
-
return <WarningIcon />;
|
|
40
|
-
case "info":
|
|
41
|
-
return <InfoIcon />;
|
|
42
|
-
case "error":
|
|
43
|
-
return <ErrorIcon />;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return null;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<Card
|
|
51
|
-
alignItems="center"
|
|
52
|
-
bg={theme.colors.background.secondary}
|
|
53
|
-
borderRadius={moderateScale(16)}
|
|
54
|
-
elevation={10}
|
|
55
|
-
flexDirection="row"
|
|
56
|
-
minHeight={moderateScale(60)}
|
|
57
|
-
mt={DeviceInfo.hasDynamicIsland() ? moderateScale(10) : 0}
|
|
58
|
-
mx={moderateScale(10)}
|
|
59
|
-
px={moderateScale(10)}
|
|
60
|
-
width={width - moderateScale(20)}
|
|
61
|
-
onPressIn={() => {
|
|
62
|
-
clearTimeout(timer);
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
<Container
|
|
66
|
-
alignItems="center"
|
|
67
|
-
bg={theme.colors.toast[type]}
|
|
68
|
-
borderRadius={moderateScale(10)}
|
|
69
|
-
height={moderateScale(42)}
|
|
70
|
-
justifyContent="center"
|
|
71
|
-
width={moderateScale(42)}
|
|
72
|
-
>
|
|
73
|
-
<Icon />
|
|
74
|
-
</Container>
|
|
75
|
-
<Container flex={1} ml={moderateScale(10)} py={moderateScale(3)}>
|
|
76
|
-
{text1 && (
|
|
77
|
-
<Typography
|
|
78
|
-
fontColor={theme.colors.font.primary}
|
|
79
|
-
fontFamily={theme.fonts.sf600}
|
|
80
|
-
fontSize="l"
|
|
81
|
-
>
|
|
82
|
-
{text1}
|
|
83
|
-
</Typography>
|
|
84
|
-
)}
|
|
85
|
-
{text2 && (
|
|
86
|
-
<Typography
|
|
87
|
-
fontColor={theme.colors.font.secondary}
|
|
88
|
-
fontFamily={theme.fonts.sf400}
|
|
89
|
-
fontSize="xs"
|
|
90
|
-
>
|
|
91
|
-
{text2}
|
|
92
|
-
</Typography>
|
|
93
|
-
)}
|
|
94
|
-
</Container>
|
|
95
|
-
<Touchable
|
|
96
|
-
hitSlop={{
|
|
97
|
-
top: moderateScale(5),
|
|
98
|
-
right: moderateScale(5),
|
|
99
|
-
bottom: moderateScale(5),
|
|
100
|
-
left: moderateScale(5),
|
|
101
|
-
}}
|
|
102
|
-
onPress={() => {
|
|
103
|
-
clearTimeout(timer);
|
|
104
|
-
hide();
|
|
105
|
-
}}
|
|
106
|
-
>
|
|
107
|
-
<Close color={theme.colors.font.grey500} size={moderateScale(22)} />
|
|
108
|
-
</Touchable>
|
|
109
|
-
</Card>
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
ToastComponent.propTypes = {
|
|
114
|
-
type: PropTypes.string,
|
|
115
|
-
text1: PropTypes.string,
|
|
116
|
-
text2: PropTypes.string,
|
|
117
|
-
hide: PropTypes.func,
|
|
118
|
-
isVisible: PropTypes.bool,
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Toast component is a wrapper over https://github.com/calintamas/react-native-toast-message.
|
|
123
|
-
*
|
|
124
|
-
* <div class="screenshots">
|
|
125
|
-
* <img src="screenshots/toast/toast-1.png" />
|
|
126
|
-
* <img src="screenshots/toast/toast-2.png" />
|
|
127
|
-
* <img src="screenshots/toast/toast-3.png" />
|
|
128
|
-
* <img src="screenshots/toast/toast-4.png" />
|
|
129
|
-
* </div>
|
|
130
|
-
*
|
|
131
|
-
* ## Usage
|
|
132
|
-
* ```js
|
|
133
|
-
*import { Toast } from "@bigbinary/neetoui-rn";
|
|
134
|
-
*
|
|
135
|
-
*export function App(props) {
|
|
136
|
-
* return (
|
|
137
|
-
* <>
|
|
138
|
-
* // Render at root component.
|
|
139
|
-
* <Toast />
|
|
140
|
-
* </>
|
|
141
|
-
* );
|
|
142
|
-
*}
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*import * as React from "react";
|
|
146
|
-
*import { moderateScale } from "react-native-size-matters";
|
|
147
|
-
*import { Toast, Container, Button } from "@bigbinary/neetoui-rn";
|
|
148
|
-
*
|
|
149
|
-
*export default function Main() {
|
|
150
|
-
* return (
|
|
151
|
-
* <Container>
|
|
152
|
-
* <Button
|
|
153
|
-
* label="Error Test"
|
|
154
|
-
* onPress={() => {
|
|
155
|
-
* Toast.show({
|
|
156
|
-
* type: "error",
|
|
157
|
-
* text1: "Yay!",
|
|
158
|
-
* text2: "Have a nice day! 😄",
|
|
159
|
-
* });
|
|
160
|
-
* }}
|
|
161
|
-
* />
|
|
162
|
-
* </Container>
|
|
163
|
-
* );
|
|
164
|
-
*}
|
|
165
|
-
* ```
|
|
166
|
-
* @extends StyledSystems props /styled-system
|
|
167
|
-
*/
|
|
168
|
-
|
|
169
|
-
export const Toast = ({ toasterConfig, ...rest }) => {
|
|
170
|
-
const customConfig = {
|
|
171
|
-
success: ToastComponent,
|
|
172
|
-
warning: ToastComponent,
|
|
173
|
-
info: ToastComponent,
|
|
174
|
-
error: ToastComponent,
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
return (
|
|
178
|
-
<T
|
|
179
|
-
{...rest}
|
|
180
|
-
autoHide={false}
|
|
181
|
-
config={{ ...defaultToasterConfig, ...customConfig, ...toasterConfig }}
|
|
182
|
-
position="top"
|
|
183
|
-
/>
|
|
184
|
-
);
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
Toast.show = T.show;
|
|
188
|
-
Toast.hide = T.hide;
|
|
189
|
-
|
|
190
|
-
Toast.propTypes = {
|
|
191
|
-
/**
|
|
192
|
-
* configuration
|
|
193
|
-
*/
|
|
194
|
-
toasterConfig: PropTypes.object,
|
|
195
|
-
};
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import React, { useContext, useEffect, useRef } from "react";
|
|
2
|
-
import { Animated } from "react-native";
|
|
3
|
-
|
|
4
|
-
import { Check, Close } from "@bigbinary/neeto-icons-rn";
|
|
5
|
-
import PropTypes from "prop-types";
|
|
6
|
-
import { moderateScale } from "react-native-size-matters";
|
|
7
|
-
import { ThemeContext } from "styled-components/native";
|
|
8
|
-
|
|
9
|
-
import { Container, Touchable } from "@components";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* ToggleSwitch component is a simple switch toggle component describes what is being switched ON/OFF.
|
|
13
|
-
*
|
|
14
|
-
* <div class="screenshots">
|
|
15
|
-
* <img src="screenshots/toggleswitch/switchstyles.png" />
|
|
16
|
-
* </div>
|
|
17
|
-
*
|
|
18
|
-
* ## Usage
|
|
19
|
-
* ```js
|
|
20
|
-
* import * as React, {useState} from 'react';
|
|
21
|
-
* import { Typography, Container } from '@bigbinary/neetoui-rn';
|
|
22
|
-
*
|
|
23
|
-
* export default function Main() {
|
|
24
|
-
* const [switchOne, setSwitchOne] = useState(true);
|
|
25
|
-
*
|
|
26
|
-
* return (
|
|
27
|
-
* <Container>
|
|
28
|
-
* <ToggleSwitch
|
|
29
|
-
* value={switchOne}
|
|
30
|
-
* setValue={() => setSwitchOne(prevValue => !prevValue)}
|
|
31
|
-
* />
|
|
32
|
-
* </Container>
|
|
33
|
-
* );
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
export const ToggleSwitch = ({ value, onValueChange, disabled }) => {
|
|
39
|
-
const theme = useContext(ThemeContext);
|
|
40
|
-
const animatedPosition = useRef(
|
|
41
|
-
new Animated.Value(value ? moderateScale(1) : 0)
|
|
42
|
-
).current;
|
|
43
|
-
|
|
44
|
-
useEffect(() => {
|
|
45
|
-
startAnimation();
|
|
46
|
-
}, [value]);
|
|
47
|
-
|
|
48
|
-
const startAnimation = () => {
|
|
49
|
-
Animated.timing(animatedPosition, {
|
|
50
|
-
toValue: value ? moderateScale(18) : 0,
|
|
51
|
-
duration: 300,
|
|
52
|
-
useNativeDriver: false,
|
|
53
|
-
}).start();
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const containerBg = value
|
|
57
|
-
? theme.colors.background.purple500
|
|
58
|
-
: "background.grey300";
|
|
59
|
-
|
|
60
|
-
const iconColor = value
|
|
61
|
-
? theme.colors.background.purple500
|
|
62
|
-
: theme.colors.font.grey500;
|
|
63
|
-
|
|
64
|
-
const Icon = value ? Check : Close;
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<Touchable
|
|
68
|
-
bg={containerBg}
|
|
69
|
-
borderRadius={moderateScale(70)}
|
|
70
|
-
disabled={disabled}
|
|
71
|
-
height={moderateScale(24)}
|
|
72
|
-
hitSlop={10}
|
|
73
|
-
justifyContent="center"
|
|
74
|
-
opacity={disabled ? 0.5 : 1}
|
|
75
|
-
px={moderateScale(5)}
|
|
76
|
-
width={moderateScale(44)}
|
|
77
|
-
onPress={() => onValueChange(!value)}
|
|
78
|
-
>
|
|
79
|
-
<Animated.View style={{ transform: [{ translateX: animatedPosition }] }}>
|
|
80
|
-
<Container
|
|
81
|
-
alignItems="center"
|
|
82
|
-
bg="background.white"
|
|
83
|
-
borderRadius={moderateScale(8)}
|
|
84
|
-
height={moderateScale(16)}
|
|
85
|
-
justifyContent="center"
|
|
86
|
-
width={moderateScale(16)}
|
|
87
|
-
>
|
|
88
|
-
<Icon
|
|
89
|
-
color={iconColor}
|
|
90
|
-
size={moderateScale(18)}
|
|
91
|
-
viewBox={value ? "0 0 22 27" : "0 0 25 25"}
|
|
92
|
-
/>
|
|
93
|
-
</Container>
|
|
94
|
-
</Animated.View>
|
|
95
|
-
</Touchable>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
ToggleSwitch.propTypes = {
|
|
100
|
-
/**
|
|
101
|
-
* Value of the switch, true means 'on', false means 'off'.
|
|
102
|
-
*/
|
|
103
|
-
value: PropTypes.bool.isRequired,
|
|
104
|
-
/**
|
|
105
|
-
* Callback called with the new value when it changes.
|
|
106
|
-
*/
|
|
107
|
-
onValueChange: PropTypes.func,
|
|
108
|
-
/**
|
|
109
|
-
* Disable toggling the switch.
|
|
110
|
-
*/
|
|
111
|
-
disabled: PropTypes.bool,
|
|
112
|
-
};
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from "react";
|
|
2
|
-
import { ScrollView, StyleSheet } from "react-native";
|
|
3
|
-
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import { moderateScale } from "react-native-size-matters";
|
|
6
|
-
|
|
7
|
-
import { Container, Touchable, Typography } from "@components";
|
|
8
|
-
import { theme } from "@theme";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* Buttons are touchable elements used to interact with the screen and to trigger an action.
|
|
13
|
-
*
|
|
14
|
-
* <div class="screenshots">
|
|
15
|
-
* <img src="screenshots/toptabbar/toptabbar-1.png" />
|
|
16
|
-
* <img src="screenshots/toptabbar/toptabbar-2.png" />
|
|
17
|
-
* </div>
|
|
18
|
-
*
|
|
19
|
-
* ## Usage
|
|
20
|
-
* ```js
|
|
21
|
-
* import * as React, { useEffect, useState } from 'react';
|
|
22
|
-
* import { Button, TopBar } from '@bigbinary/neetoui-rn';
|
|
23
|
-
*
|
|
24
|
-
* export default function Main() {
|
|
25
|
-
* const [activeTab, setActiveTab] = useState(0);
|
|
26
|
-
*
|
|
27
|
-
* useEffect(() => {
|
|
28
|
-
* console.log("Active tab is ", itemList[activeTab]);
|
|
29
|
-
* }, [activeTab]);
|
|
30
|
-
*
|
|
31
|
-
* return (
|
|
32
|
-
* <>
|
|
33
|
-
* <TopBar
|
|
34
|
-
* data={itemList}
|
|
35
|
-
* activeIndex={activeTab}
|
|
36
|
-
* onActiveTabChange={index => {
|
|
37
|
-
* setActiveTab(index);
|
|
38
|
-
* }}
|
|
39
|
-
* />
|
|
40
|
-
*
|
|
41
|
-
* <Button label="Switch to `Expired` tab" onPress={() => setActiveTab(2)} />
|
|
42
|
-
* </>
|
|
43
|
-
* );
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
|
-
export const TopBar = ({
|
|
50
|
-
data,
|
|
51
|
-
activeIndex = 0,
|
|
52
|
-
onActiveTabChange = () => {},
|
|
53
|
-
activeTabTextStyle,
|
|
54
|
-
activeTabContainerStyle,
|
|
55
|
-
inActiveTabTextStyle,
|
|
56
|
-
inActiveTabContainerStyle,
|
|
57
|
-
tabContainerStyle,
|
|
58
|
-
}) => {
|
|
59
|
-
const [selectedIndex, setSelectedIndex] = useState(activeIndex);
|
|
60
|
-
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
onActiveTabChange(selectedIndex);
|
|
63
|
-
}, [selectedIndex]);
|
|
64
|
-
|
|
65
|
-
useEffect(() => {
|
|
66
|
-
setSelectedIndex(activeIndex);
|
|
67
|
-
}, [activeIndex]);
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<Container
|
|
71
|
-
height={moderateScale(50)}
|
|
72
|
-
style={[styles.defaultTabContainerStyle, tabContainerStyle]}
|
|
73
|
-
>
|
|
74
|
-
<ScrollView horizontal showsHorizontalScrollIndicator={false}>
|
|
75
|
-
{data.map((item, index) => (
|
|
76
|
-
<Touchable
|
|
77
|
-
alignItems="center"
|
|
78
|
-
justifyContent="center"
|
|
79
|
-
key={index}
|
|
80
|
-
style={
|
|
81
|
-
selectedIndex === index
|
|
82
|
-
? {
|
|
83
|
-
...styles.defaultActiveContainerStyle,
|
|
84
|
-
...activeTabContainerStyle,
|
|
85
|
-
}
|
|
86
|
-
: {
|
|
87
|
-
...styles.defaultInActiveTabContainerStyle,
|
|
88
|
-
...inActiveTabContainerStyle,
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
onPress={() => setSelectedIndex(index)}
|
|
92
|
-
>
|
|
93
|
-
<Typography
|
|
94
|
-
style={
|
|
95
|
-
selectedIndex === index
|
|
96
|
-
? {
|
|
97
|
-
...styles.defaultActiveTabTextStyle,
|
|
98
|
-
...activeTabTextStyle,
|
|
99
|
-
}
|
|
100
|
-
: {
|
|
101
|
-
...styles.defaultInActiveTabTextStyle,
|
|
102
|
-
...inActiveTabTextStyle,
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
>
|
|
106
|
-
{item}
|
|
107
|
-
</Typography>
|
|
108
|
-
</Touchable>
|
|
109
|
-
))}
|
|
110
|
-
</ScrollView>
|
|
111
|
-
</Container>
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const styles = StyleSheet.create({
|
|
116
|
-
defaultActiveContainerStyle: {
|
|
117
|
-
backgroundColor: theme.colors.background.grey800,
|
|
118
|
-
marginHorizontal: moderateScale(10),
|
|
119
|
-
paddingHorizontal: moderateScale(10),
|
|
120
|
-
marginVertical: moderateScale(5),
|
|
121
|
-
borderRadius: moderateScale(5),
|
|
122
|
-
},
|
|
123
|
-
defaultInActiveTabContainerStyle: {
|
|
124
|
-
backgroundColor: theme.colors.background.white,
|
|
125
|
-
marginHorizontal: moderateScale(20),
|
|
126
|
-
},
|
|
127
|
-
defaultActiveTabTextStyle: {
|
|
128
|
-
color: theme.colors.font.white,
|
|
129
|
-
},
|
|
130
|
-
defaultInActiveTabTextStyle: {
|
|
131
|
-
color: theme.colors.font.grey800,
|
|
132
|
-
},
|
|
133
|
-
defaultTabContainerStyle: {
|
|
134
|
-
backgroundColor: theme.colors.font.white,
|
|
135
|
-
},
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
TopBar.propTypes = {
|
|
139
|
-
data: PropTypes.array.isRequired,
|
|
140
|
-
activeIndex: PropTypes.number,
|
|
141
|
-
onActiveTabChange: PropTypes.func.isRequired,
|
|
142
|
-
activeTabTextStyle: PropTypes.object,
|
|
143
|
-
activeTabContainerStyle: PropTypes.object,
|
|
144
|
-
inActiveTabTextStyle: PropTypes.object,
|
|
145
|
-
inActiveTabContainerStyle: PropTypes.object,
|
|
146
|
-
tabContainerStyle: PropTypes.object,
|
|
147
|
-
};
|