@bigbinary/neetoui-rn 0.0.123 → 0.0.126

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.
Files changed (66) hide show
  1. package/assets/fonts/SFProText-Bold.ttf +0 -0
  2. package/assets/fonts/SFProText-Medium.ttf +0 -0
  3. package/assets/fonts/SFProText-Regular.ttf +0 -0
  4. package/assets/fonts/SFProText-Semibold.ttf +0 -0
  5. package/assets/icons/apple-logo.svg +3 -0
  6. package/assets/icons/error.svg +4 -0
  7. package/assets/icons/google-logo.svg +6 -0
  8. package/assets/icons/info.svg +7 -0
  9. package/assets/icons/success.svg +3 -0
  10. package/assets/icons/warning.svg +5 -0
  11. package/lib/components/Alert.js +1 -1
  12. package/lib/components/Avatar.js +1 -1
  13. package/lib/components/Badge.js +1 -1
  14. package/lib/components/BottomSheet.js +1 -1
  15. package/lib/components/Button.js +1 -1
  16. package/lib/components/Carousel.js +1 -0
  17. package/lib/components/CheckBox.js +1 -1
  18. package/lib/components/Chip.js +1 -1
  19. package/lib/components/Input.js +1 -1
  20. package/lib/components/ListItem.js +1 -0
  21. package/lib/components/MultiSelect.js +1 -1
  22. package/lib/components/OnBoarding.js +1 -0
  23. package/lib/components/OtpInputs.js +1 -1
  24. package/lib/components/Popover.js +1 -1
  25. package/lib/components/RadioButton.js +1 -1
  26. package/lib/components/SearchBar.js +1 -0
  27. package/lib/components/SegmentPicker.js +1 -0
  28. package/lib/components/Select.js +1 -1
  29. package/lib/components/SocialButton.js +1 -0
  30. package/lib/components/Toast.js +1 -1
  31. package/lib/components/ToggleSwitch.js +1 -1
  32. package/lib/components/index.js +1 -1
  33. package/lib/config/toasterConfig.js +1 -1
  34. package/lib/hooks/index.js +1 -1
  35. package/lib/hooks/useDebounce.js +1 -0
  36. package/lib/theme/index.js +1 -1
  37. package/package.json +5 -3
  38. package/src/components/Alert.js +5 -5
  39. package/src/components/Avatar.js +1 -1
  40. package/src/components/Badge.js +1 -1
  41. package/src/components/BottomSheet.js +114 -74
  42. package/src/components/Button.js +66 -64
  43. package/src/components/Carousel.js +112 -0
  44. package/src/components/CheckBox.js +87 -81
  45. package/src/components/Chip.js +1 -1
  46. package/src/components/Input.js +147 -241
  47. package/src/components/ListItem.js +59 -0
  48. package/src/components/MultiSelect.js +10 -8
  49. package/src/components/OnBoarding.js +116 -0
  50. package/src/components/OtpInputs.js +1 -1
  51. package/src/components/Popover.js +13 -1
  52. package/src/components/RadioButton.js +88 -114
  53. package/src/components/SearchBar.js +134 -0
  54. package/src/components/SegmentPicker.js +210 -0
  55. package/src/components/Select.js +9 -7
  56. package/src/components/SocialButton.js +89 -0
  57. package/src/components/Toast.js +85 -30
  58. package/src/components/ToggleSwitch.js +49 -97
  59. package/src/components/Typography.js +2 -2
  60. package/src/components/index.js +6 -0
  61. package/src/config/toasterConfig.js +2 -2
  62. package/src/hooks/index.js +1 -0
  63. package/src/hooks/useDebounce.js +16 -0
  64. package/src/theme/index.js +65 -34
  65. package/assets/fonts/Inter-Bold.ttf +0 -0
  66. package/assets/fonts/Inter-Regular.ttf +0 -0
@@ -0,0 +1,210 @@
1
+ import PropTypes from "prop-types";
2
+ import React, { useEffect, useCallback } from "react";
3
+ import { Dimensions, StyleSheet } from "react-native";
4
+ import Animated, {
5
+ useAnimatedStyle,
6
+ useSharedValue,
7
+ withSpring,
8
+ } from "react-native-reanimated";
9
+ import { Typography, Touchable } from "@components";
10
+
11
+ const defaultShadowStyle = {
12
+ shadowColor: "#000",
13
+ shadowOffset: {
14
+ width: 0,
15
+ height: 2,
16
+ },
17
+ shadowOpacity: 0.23,
18
+ shadowRadius: 2.62,
19
+
20
+ elevation: 4,
21
+ };
22
+
23
+ // eslint-disable-next-line neeto/no-dangling-constants
24
+ const DEFAULT_SPRING_CONFIG = {
25
+ stiffness: 150,
26
+ damping: 20,
27
+ mass: 1,
28
+ overshootClamping: false,
29
+ restSpeedThreshold: 0.001,
30
+ restDisplacementThreshold: 0.001,
31
+ };
32
+
33
+ // So that it stretches in landscape mode.
34
+ const width = Dimensions.get("screen").width - 32;
35
+
36
+ /**
37
+ *
38
+ * A Segment Picker component that provides toggling between two or more views.
39
+ *
40
+ * <div class="screenshots">
41
+ * <img src="screenshots/segmentPicker/segmentpickers.png" />
42
+ * </div>
43
+ *
44
+ * ## Usage
45
+ * ```js
46
+ * import * as React from 'react';
47
+ * import { Container, SegmentPicker } from '@bigbinary/neetoui-rn';
48
+ *
49
+ * export default function Main(){
50
+ * const [tabIndex, setTabIndex] = useState(1);
51
+ *
52
+ * return (
53
+ * <Container flex={1} alignItems="center" justifyContent="center">
54
+ * <Container my={3}>
55
+ * <SegmentPicker
56
+ * tabs={["On", "Off"]}
57
+ * currentIndex={tabIndex}
58
+ * onChange={setTabIndex}
59
+ * />
60
+ * </Container>
61
+ * </Container>
62
+ * );
63
+ * }
64
+ * ```
65
+ */
66
+
67
+ export const SegmentPicker = ({
68
+ tabs,
69
+ onChange,
70
+ currentIndex,
71
+ inactiveSegmentStyle,
72
+ activeSegmentStyle,
73
+ activeTextStyle,
74
+ inactiveTextStyle,
75
+ py,
76
+ }) => {
77
+ const translateValue = (width - 4) / tabs?.length;
78
+ const tabTranslateValue = useSharedValue(0);
79
+
80
+ // useCallBack with an empty array as input, which will call inner lambda only once and memoize the reference for future calls
81
+ const memoizedTabPressCallback = useCallback(
82
+ index => {
83
+ onChange(index);
84
+ },
85
+ [onChange]
86
+ );
87
+
88
+ useEffect(() => {
89
+ tabTranslateValue.value = withSpring(
90
+ currentIndex * (translateValue * 1),
91
+ DEFAULT_SPRING_CONFIG
92
+ );
93
+ // eslint-disable-next-line react-hooks/exhaustive-deps
94
+ }, [currentIndex]);
95
+
96
+ const tabTranslateAnimatedStyles = useAnimatedStyle(() => {
97
+ return {
98
+ transform: [{ translateX: tabTranslateValue.value }],
99
+ };
100
+ });
101
+
102
+ return (
103
+ <Animated.View
104
+ style={[styles.defaultSegmentedControlWrapper, inactiveSegmentStyle]}
105
+ >
106
+ <Animated.View
107
+ style={[
108
+ styles.movingSegmentStyle,
109
+ activeSegmentStyle,
110
+ defaultShadowStyle,
111
+ StyleSheet.absoluteFill,
112
+ {
113
+ width: width / tabs?.length,
114
+ },
115
+ tabTranslateAnimatedStyles,
116
+ ]}
117
+ />
118
+
119
+ {tabs.map((label, index) => {
120
+ const currentIndexTextStyle =
121
+ currentIndex === index ? activeTextStyle : inactiveTextStyle;
122
+ return (
123
+ <Touchable
124
+ key={index}
125
+ flex={1}
126
+ elevation={6}
127
+ onPress={() => memoizedTabPressCallback(index)}
128
+ py={py}
129
+ activeOpacity={0.7}
130
+ >
131
+ <Typography
132
+ fontSize="xs"
133
+ textAlign="center"
134
+ color="font.grey800"
135
+ fontFamily="sf500"
136
+ {...currentIndexTextStyle}
137
+ >
138
+ {label}
139
+ </Typography>
140
+ </Touchable>
141
+ );
142
+ })}
143
+ </Animated.View>
144
+ );
145
+ };
146
+
147
+ const styles = StyleSheet.create({
148
+ segmentedControlWrapper: {
149
+ display: "flex",
150
+ flexDirection: "row",
151
+ alignItems: "center",
152
+ borderRadius: 8,
153
+ width: width,
154
+ },
155
+ defaultSegmentedControlWrapper: {
156
+ position: "relative",
157
+ display: "flex",
158
+ flexDirection: "row",
159
+ alignItems: "center",
160
+ borderRadius: 8,
161
+ backgroundColor: "#E5E5EA",
162
+ width: width,
163
+ },
164
+ movingSegmentStyle: {
165
+ top: 0,
166
+ marginVertical: 2,
167
+ marginHorizontal: 2,
168
+ borderRadius: 6,
169
+ backgroundColor: "#FFFFFF",
170
+ },
171
+ });
172
+
173
+ SegmentPicker.propTypes = {
174
+ /**
175
+ * Array of texts for the labels of each Segment/Tab.
176
+ */
177
+ tabs: PropTypes.arrayOf(PropTypes.string).isRequired,
178
+ /**
179
+ * Callback called with the new value when it changes.
180
+ */
181
+ onChange: PropTypes.func.isRequired,
182
+ /**
183
+ * Index value of the currently selected Segment/Tab.
184
+ */
185
+ currentIndex: PropTypes.number.isRequired,
186
+ /**
187
+ * To change the inactive segment container style.
188
+ */
189
+ inactiveSegmentStyle: PropTypes.object,
190
+ /**
191
+ * To change the active segment container style.
192
+ */
193
+ activeSegmentStyle: PropTypes.object,
194
+ /**
195
+ * To change the inactive segment font style.
196
+ */
197
+ inactiveTextStyle: PropTypes.object,
198
+ /**
199
+ * To change the active segment font style.
200
+ */
201
+ activeTextStyle: PropTypes.object,
202
+ py: PropTypes.number,
203
+ };
204
+
205
+ SegmentPicker.defaultProps = {
206
+ tabs: [],
207
+ onChange: () => {},
208
+ currentIndex: 0,
209
+ py: 12,
210
+ };
@@ -37,7 +37,7 @@ const DropdownItem = ({
37
37
  {...(isSelectedItem && selectedItemContainerStyle)}
38
38
  >
39
39
  <Typography
40
- fontFamily="inter400"
40
+ fontFamily="sf400"
41
41
  fontSize="s"
42
42
  color={isSelectedItem ? "font.white" : "font.grey"}
43
43
  {...itemLabelStyle}
@@ -158,7 +158,9 @@ export const Select = ({
158
158
  dropdownContainerStyle?.maxHeight ||
159
159
  defaultDropdownItemHeight * Math.min(filteredOptions?.length, 6) +
160
160
  (isSearchable ? searchInputHeight + 10 : 0) +
161
- (isOptionsEmpty ? emptyOptionsPlaceholderHeight : 0) +
161
+ (isOptionsEmpty && !(isSearchedOptionsEmpty && showCreateOption)
162
+ ? emptyOptionsPlaceholderHeight
163
+ : 0) +
162
164
  (isSearchedOptionsEmpty && showCreateOption
163
165
  ? emptySearchedOptionsHeight
164
166
  : 0);
@@ -213,7 +215,7 @@ export const Select = ({
213
215
  return (
214
216
  <Container {...containerStyle}>
215
217
  <Typography
216
- fontFamily="inter400"
218
+ fontFamily="sf400"
217
219
  mb={1}
218
220
  fontSize="s"
219
221
  color="font.base"
@@ -235,7 +237,7 @@ export const Select = ({
235
237
  {...inputContainerStyle}
236
238
  {...rest}
237
239
  >
238
- <Typography fontFamily="inter400" fontSize="s" color="font.grey">
240
+ <Typography fontFamily="sf400" fontSize="s" color="font.grey">
239
241
  {selectedOptionLabel || placeholder}
240
242
  </Typography>
241
243
  {isLoading ? (
@@ -277,7 +279,7 @@ export const Select = ({
277
279
  />
278
280
  </Container>
279
281
  )}
280
- {isOptionsEmpty && (
282
+ {isOptionsEmpty && !(isSearchedOptionsEmpty && showCreateOption) && (
281
283
  <Container
282
284
  height={emptyOptionsPlaceholderHeight}
283
285
  justifyContent="center"
@@ -285,7 +287,7 @@ export const Select = ({
285
287
  {...emptyOptionsContainerStyle}
286
288
  >
287
289
  <Typography
288
- fontFamily="inter400"
290
+ fontFamily="sf400"
289
291
  fontSize="s"
290
292
  color="font.grey"
291
293
  {...emptyOptionsLabelStyle}
@@ -309,7 +311,7 @@ export const Select = ({
309
311
  />
310
312
  ) : (
311
313
  <Typography
312
- fontFamily="inter400"
314
+ fontFamily="sf400"
313
315
  fontSize="s"
314
316
  color="font.grey"
315
317
  {...createSearchedOptionLabelStyle}
@@ -0,0 +1,89 @@
1
+ import React, { useContext } from "react";
2
+ import propTypes from "@styled-system/prop-types";
3
+ import PropTypes from "prop-types";
4
+ import { ThemeContext } from "styled-components/native";
5
+
6
+ import AppleLogo from "@assets/icons/apple-logo.svg";
7
+ import GoogleLogo from "@assets/icons/google-logo.svg";
8
+ import { Container, Typography, Touchable } from "@components";
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/button/socialButtons.png" />
16
+ * </div>
17
+ *
18
+ * ## Usage
19
+ * ```js
20
+ * import * as React from 'react';
21
+ * import { Container, SocialButton } from '@bigbinary/neetoui-rn';
22
+ *
23
+ * export default function Main() {
24
+ * return (
25
+ * <Container>
26
+ * <SocialButton variant="apple" my={9} />
27
+ * <SocialButton variant="google" />
28
+ * </Container>
29
+ * );
30
+ * }
31
+ * ```
32
+ *
33
+ */
34
+
35
+ export const SocialButton = props => {
36
+ const { variant, disabled, labelStyle, ...rest } = props;
37
+ const theme = useContext(ThemeContext);
38
+ const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`;
39
+
40
+ return (
41
+ <Touchable
42
+ rippleColor="black"
43
+ disabled={disabled}
44
+ bg="transparent"
45
+ height={45}
46
+ width="100%"
47
+ borderRadius={8}
48
+ borderWidth={1}
49
+ borderColor={theme.colors.border.black}
50
+ alignItems="center"
51
+ justifyContent="center"
52
+ {...rest}
53
+ >
54
+ <Container position="absolute" left={17}>
55
+ {variant === "apple" && <AppleLogo />}
56
+ {variant === "google" && <GoogleLogo />}
57
+ </Container>
58
+ <Typography
59
+ color={theme.colors.font.primary}
60
+ fontSize="m"
61
+ fontFamily={theme.fonts.sf500}
62
+ {...labelStyle}
63
+ >
64
+ Continue with {capitalize(variant)}
65
+ </Typography>
66
+ </Touchable>
67
+ );
68
+ };
69
+
70
+ SocialButton.propTypes = {
71
+ ...propTypes.buttonStyle,
72
+ ...propTypes.flexbox,
73
+ ...propTypes.space,
74
+ ...propTypes.border,
75
+ ...propTypes.layout,
76
+ ...propTypes.color,
77
+ /**
78
+ * Supported Type: 'apple' | 'google'
79
+ */
80
+ variant: PropTypes.oneOf(["apple", "google"]),
81
+ /**
82
+ * Enable or Disable the button
83
+ */
84
+ disabled: PropTypes.bool,
85
+ /**
86
+ * Customize label style of the button
87
+ */
88
+ labelStyle: PropTypes.object,
89
+ };
@@ -2,7 +2,82 @@ import * as React from "react";
2
2
  import PropTypes from "prop-types";
3
3
  import T from "react-native-toast-message";
4
4
  import { defaultToasterConfig } from "@config";
5
- import { useKeyboard } from "@react-native-community/hooks";
5
+ import { useContext } from "react";
6
+ import { ThemeContext } from "styled-components/native";
7
+ import { useWindowDimensions } from "react-native";
8
+
9
+ import SuccessIcon from "@assets/icons/success.svg";
10
+ import WarningIcon from "@assets/icons/warning.svg";
11
+ import InfoIcon from "@assets/icons/info.svg";
12
+ import ErrorIcon from "@assets/icons/error.svg";
13
+ import { Container, Typography } from "@components";
14
+
15
+ const ToastComponent = ({ type, text1, text2 }) => {
16
+ const theme = useContext(ThemeContext);
17
+ const { width } = useWindowDimensions();
18
+ const Icon = () => {
19
+ switch (type) {
20
+ case "success":
21
+ return <SuccessIcon />;
22
+ case "warning":
23
+ return <WarningIcon />;
24
+ case "info":
25
+ return <InfoIcon />;
26
+ case "error":
27
+ return <ErrorIcon />;
28
+ }
29
+ };
30
+ return (
31
+ <Container
32
+ width={width - 20}
33
+ height={60}
34
+ borderRadius={16}
35
+ bg={theme.colors.background.secondary}
36
+ flexDirection="row"
37
+ alignItems="center"
38
+ px={10}
39
+ mx={10}
40
+ >
41
+ <Container
42
+ height={42}
43
+ width={42}
44
+ borderRadius={10}
45
+ bg={theme.colors.toast[type]}
46
+ alignItems="center"
47
+ justifyContent="center"
48
+ >
49
+ <Icon />
50
+ </Container>
51
+
52
+ <Container ml={10}>
53
+ {text1 && (
54
+ <Typography
55
+ fontFamily={theme.fonts.sf600}
56
+ fontSize="m"
57
+ fontColor={theme.colors.font.primary}
58
+ >
59
+ {text1}
60
+ </Typography>
61
+ )}
62
+ {text2 && (
63
+ <Typography
64
+ fontFamily={theme.fonts.sf400}
65
+ fontSize="xs"
66
+ fontColor={theme.colors.font.secondary}
67
+ >
68
+ {text2}
69
+ </Typography>
70
+ )}
71
+ </Container>
72
+ </Container>
73
+ );
74
+ };
75
+
76
+ ToastComponent.propTypes = {
77
+ type: PropTypes.string,
78
+ text1: PropTypes.string,
79
+ text2: PropTypes.string,
80
+ };
6
81
 
7
82
  /**
8
83
  * Toast component is a wrapper over https://github.com/calintamas/react-native-toast-message.
@@ -32,7 +107,6 @@ import { useKeyboard } from "@react-native-community/hooks";
32
107
  * onPress={() => {
33
108
  * Toast.show({
34
109
  * type: "error",
35
- * position: "bottom",
36
110
  * text1: "Yay!",
37
111
  * text2: "Have a nice day! 😄",
38
112
  * });
@@ -45,43 +119,24 @@ import { useKeyboard } from "@react-native-community/hooks";
45
119
  * @extends StyledSystems props /styled-system
46
120
  */
47
121
 
48
- let globalKeyboardState;
49
- // let toastOffsetValue;
50
-
51
122
  export const Toast = ({ toasterConfig, ...rest }) => {
52
- const keyboard = useKeyboard();
53
- // const screenDimensions = useDimensions().screen;
54
-
55
- React.useEffect(() => {
56
- globalKeyboardState = keyboard;
57
- // toastOffsetValue =
58
- // Platform.OS === "ios"
59
- // ? screenDimensions.height - (globalKeyboardState.keyboardHeight + 50)
60
- // : screenDimensions.height - (globalKeyboardState.keyboardHeight + 130);
61
- }, [keyboard]);
123
+ const customConfig = {
124
+ success: ToastComponent,
125
+ warning: ToastComponent,
126
+ info: ToastComponent,
127
+ error: ToastComponent,
128
+ };
62
129
 
63
130
  return (
64
131
  <T
65
132
  {...rest}
66
- config={{ ...defaultToasterConfig, ...toasterConfig }}
67
- position="bottom"
133
+ config={{ ...defaultToasterConfig, ...customConfig, ...toasterConfig }}
134
+ position="top"
68
135
  />
69
136
  );
70
137
  };
71
138
 
72
- Toast.show = params => {
73
- // Rendering Toasts on top whenever keyboard is active.
74
- if (globalKeyboardState.keyboardShown) {
75
- T.show({
76
- ...params,
77
- position: "top",
78
- // topOffset: toastOffsetValue,
79
- });
80
- } else {
81
- T.show(params);
82
- }
83
- };
84
-
139
+ Toast.show = T.show;
85
140
  Toast.hide = T.hide;
86
141
 
87
142
  Toast.propTypes = {
@@ -1,13 +1,13 @@
1
- import React, { useContext } from "react";
2
- import SwitchToggle from "react-native-switch-toggle";
1
+ import React, { useContext, useEffect, useRef } from "react";
3
2
  import { ThemeContext } from "styled-components/native";
4
- import { StyleSheet } from "react-native";
3
+ import { Animated } from "react-native";
5
4
  import PropTypes from "prop-types";
5
+ import Icon from "react-native-remix-icon";
6
6
 
7
- import { Typography, Container } from "@components";
7
+ import { Container, Touchable } from "@components";
8
8
 
9
9
  /**
10
- * ToggleSwitch component is a simple switch toggle component from react-native-switch-toggle along with a label which describes what is being switched ON/OFF.
10
+ * ToggleSwitch component is a simple switch toggle component describes what is being switched ON/OFF.
11
11
  *
12
12
  * <div class="screenshots">
13
13
  * <img src="screenshots/toggleswitch/switchstyles.png" />
@@ -26,7 +26,6 @@ import { Typography, Container } from "@components";
26
26
  * <ToggleSwitch
27
27
  * value={switchOne}
28
28
  * setValue={() => setSwitchOne(prevValue => !prevValue)}
29
- * label="Conversation assigned to my group"
30
29
  * />
31
30
  * </Container>
32
31
  * );
@@ -34,75 +33,59 @@ import { Typography, Container } from "@components";
34
33
  * ```
35
34
  */
36
35
 
37
- const Label = ({ label, textStyles }) => {
38
- return (
39
- <Typography textStyle="subtext" {...textStyles}>
40
- {label}
41
- </Typography>
42
- );
43
- };
44
-
45
- export const ToggleSwitch = ({
46
- value,
47
- onValueChange,
48
- label,
49
- disabled,
50
- labelPosition,
51
- ...rest
52
- }) => {
36
+ export const ToggleSwitch = ({ value, onValueChange, disabled }) => {
53
37
  const theme = useContext(ThemeContext);
38
+ const animatedPosition = useRef(new Animated.Value(value ? 1 : 0)).current;
39
+
40
+ useEffect(() => {
41
+ startAnimation();
42
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43
+ }, [value]);
44
+
45
+ const startAnimation = () => {
46
+ Animated.timing(animatedPosition, {
47
+ toValue: value ? 20 : 0,
48
+ duration: 300,
49
+ useNativeDriver: false,
50
+ }).start();
51
+ };
54
52
 
55
- const circleColorOn = disabled
56
- ? theme.colors.background.grey500
57
- : theme.colors.background.white;
58
- const circleColorOff = disabled
59
- ? theme.colors.background.menubackground
60
- : theme.colors.background.white;
53
+ const containerBg = value ? "#5E5CE6" : "background.grey300";
54
+ const iconColor = value ? "#5E5CE6" : theme.colors.font.grey500;
61
55
 
62
56
  return (
63
- <Container
64
- flexDirection="row"
65
- borderColor={theme.colors.border.primary}
66
- alignItems="center"
67
- {...rest.wrapperStyles}
57
+ <Touchable
58
+ disabled={disabled}
59
+ onPress={() => onValueChange(!value)}
60
+ width={44}
61
+ height={24}
62
+ bg={containerBg}
63
+ justifyContent="center"
64
+ px={1}
65
+ borderRadius={70}
66
+ opacity={disabled ? 0.5 : 1}
68
67
  >
69
- {labelPosition === "left" && (
70
- <Label label={label} textStyles={rest.textStyles} />
71
- )}
72
- <SwitchToggle
73
- switchOn={value}
74
- onPress={() => !disabled && onValueChange()}
75
- circleColorOn={circleColorOn}
76
- circleColorOff={circleColorOff}
77
- backgroundColorOff={theme.colors.background.grey200}
78
- backgroundColorOn={theme.colors.background.grey800}
79
- containerStyle={styles.containerStyle}
80
- circleStyle={styles.circleStyle}
81
- {...rest.switchStyles}
82
- />
83
- {labelPosition === "right" && (
84
- <Label label={label} textStyles={rest.textStyles} />
85
- )}
86
- </Container>
68
+ <Animated.View style={{ transform: [{ translateX: animatedPosition }] }}>
69
+ <Container
70
+ bg="background.white"
71
+ width={16}
72
+ height={16}
73
+ borderRadius={8}
74
+ justifyContent="center"
75
+ alignItems="center"
76
+ >
77
+ <Icon
78
+ name={`ri-${value ? "check" : "close"}-line`}
79
+ size={12}
80
+ color={iconColor}
81
+ />
82
+ </Container>
83
+ </Animated.View>
84
+ </Touchable>
87
85
  );
88
86
  };
89
87
 
90
- ToggleSwitch.defaultProps = {
91
- labelPosition: "left",
92
- wrapperStyles: {},
93
- switchStyles: {},
94
- textStyles: { mr: 2 },
95
- };
96
-
97
88
  ToggleSwitch.propTypes = {
98
- /**
99
- * The text to use for the floating label.
100
- */
101
- label: PropTypes.string,
102
- /**
103
- * Prop that handles the label position.
104
- */
105
- labelPosition: PropTypes.string,
106
89
  /**
107
90
  * Value of the switch, true means 'on', false means 'off'.
108
91
  */
@@ -115,35 +98,4 @@ ToggleSwitch.propTypes = {
115
98
  * Disable toggling the switch.
116
99
  */
117
100
  disabled: PropTypes.bool,
118
- /**
119
- * Prop to handle custom wrapper styles.
120
- */
121
- wrapperStyles: PropTypes.object,
122
- /**
123
- * Prop to handle custom switch styles.
124
- */
125
- switchStyles: PropTypes.object,
126
- /**
127
- * Prop to handle custom text styles.
128
- */
129
- textStyles: PropTypes.object,
130
101
  };
131
-
132
- Label.propTypes = {
133
- label: PropTypes.string,
134
- textStyles: PropTypes.object,
135
- };
136
-
137
- const styles = StyleSheet.create({
138
- containerStyle: {
139
- width: 38,
140
- height: 18,
141
- borderRadius: 10,
142
- padding: 2,
143
- },
144
- circleStyle: {
145
- width: 14,
146
- height: 14,
147
- borderRadius: 7,
148
- },
149
- });
@@ -45,8 +45,8 @@ export const Text = styled.Text`
45
45
  * </ul>
46
46
  *
47
47
  * <div class="screenshots">
48
- * <img src="screenshots/typography/fontsizes.png" />
49
- * <img src="screenshots/typography/textstyles.png" />
48
+ * <img src="screenshots/typography/colors.png" />
49
+ * <img src="screenshots/typography/fontfamilies.png" />
50
50
  * </div>
51
51
  *
52
52
  * <div class="screenshots">