@chem-po/react-native 0.0.52 → 0.0.53

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 (98) hide show
  1. package/package.json +5 -20
  2. package/src/components/box/Center.tsx +0 -19
  3. package/src/components/box/CollapseHorizontal.tsx +0 -44
  4. package/src/components/box/ContentBox.tsx +0 -24
  5. package/src/components/box/DropShadow.tsx +0 -28
  6. package/src/components/box/ExpandOnMount.tsx +0 -74
  7. package/src/components/box/Expandable.tsx +0 -143
  8. package/src/components/box/FullSizeContainer.tsx +0 -64
  9. package/src/components/box/index.ts +0 -7
  10. package/src/components/button/ActionButton.tsx +0 -196
  11. package/src/components/button/ButtonText.tsx +0 -60
  12. package/src/components/button/DeleteButton.tsx +0 -288
  13. package/src/components/button/LoadingButton.tsx +0 -41
  14. package/src/components/button/Toggle.tsx +0 -109
  15. package/src/components/button/hooks.ts +0 -66
  16. package/src/components/button/index.ts +0 -5
  17. package/src/components/feed/FeedContentPane.tsx +0 -97
  18. package/src/components/feed/MediaFeed.tsx +0 -199
  19. package/src/components/feed/MediaFeedBackground.tsx +0 -136
  20. package/src/components/feed/MediaFeedRefresh.tsx +0 -113
  21. package/src/components/feed/constants.ts +0 -2
  22. package/src/components/feed/context.tsx +0 -19
  23. package/src/components/feed/hooks.ts +0 -279
  24. package/src/components/feed/index.ts +0 -2
  25. package/src/components/form/Condition.tsx +0 -27
  26. package/src/components/form/Field.tsx +0 -44
  27. package/src/components/form/Form.tsx +0 -452
  28. package/src/components/form/FormFooter.tsx +0 -164
  29. package/src/components/form/UploadProgress/index.tsx +0 -50
  30. package/src/components/form/index.ts +0 -3
  31. package/src/components/form/input/Editable.tsx +0 -206
  32. package/src/components/form/input/InputSlider.tsx +0 -71
  33. package/src/components/form/input/OptionalTag.tsx +0 -43
  34. package/src/components/form/input/StandaloneInput.tsx +0 -49
  35. package/src/components/form/input/boolean/index.tsx +0 -53
  36. package/src/components/form/input/color/index.tsx +0 -145
  37. package/src/components/form/input/common/InputClearButton.tsx +0 -57
  38. package/src/components/form/input/date/index.tsx +0 -125
  39. package/src/components/form/input/datetime/index.tsx +0 -176
  40. package/src/components/form/input/file/index.tsx +0 -310
  41. package/src/components/form/input/hooks/index.ts +0 -2
  42. package/src/components/form/input/hooks/useInputColor.ts +0 -7
  43. package/src/components/form/input/hooks/useInputImperativeHandle.ts +0 -22
  44. package/src/components/form/input/hooks/useInputStyles.ts +0 -114
  45. package/src/components/form/input/index.ts +0 -4
  46. package/src/components/form/input/input.tsx +0 -218
  47. package/src/components/form/input/multipleSelect/index.tsx +0 -221
  48. package/src/components/form/input/number/index.tsx +0 -108
  49. package/src/components/form/input/select/index.tsx +0 -152
  50. package/src/components/form/input/socialMedia/index.tsx +0 -235
  51. package/src/components/form/input/text/AutoResizeTextarea.tsx +0 -41
  52. package/src/components/form/input/text/index.tsx +0 -99
  53. package/src/components/form/input/text/textarea.tsx +0 -32
  54. package/src/components/form/input/text/useWebAutoResize.tsx +0 -73
  55. package/src/components/form/input/time/index.tsx +0 -125
  56. package/src/components/form/types.ts +0 -8
  57. package/src/components/form/view/file.tsx +0 -80
  58. package/src/components/form/view/index.tsx +0 -125
  59. package/src/components/form/view/multipleSelect.tsx +0 -85
  60. package/src/components/form/view/select.tsx +0 -83
  61. package/src/components/form/view/styles.ts +0 -12
  62. package/src/components/icons/index.tsx +0 -28
  63. package/src/components/image/ImageViewModal.tsx +0 -319
  64. package/src/components/image/index.ts +0 -1
  65. package/src/components/index.ts +0 -8
  66. package/src/components/layout/CollapseHorizontal.tsx +0 -92
  67. package/src/components/loading/CircularProgress.tsx +0 -56
  68. package/src/components/loading/Loading.tsx +0 -146
  69. package/src/components/loading/LoadingImage.tsx +0 -163
  70. package/src/components/loading/LoadingOverlay.tsx +0 -74
  71. package/src/components/loading/LoadingSwitch.tsx +0 -110
  72. package/src/components/loading/ProgressBar.tsx +0 -75
  73. package/src/components/loading/index.ts +0 -6
  74. package/src/components/text/AnimatedText.tsx +0 -68
  75. package/src/components/text/Txt.tsx +0 -12
  76. package/src/components/text/index.ts +0 -1
  77. package/src/components/theme/colorMode/DarkModeToggle.tsx +0 -47
  78. package/src/components/theme/colorMode/index.ts +0 -1
  79. package/src/components/theme/index.ts +0 -1
  80. package/src/constants/index.ts +0 -1
  81. package/src/constants/toast.ts +0 -24
  82. package/src/contexts/fonts.tsx +0 -23
  83. package/src/contexts/index.ts +0 -1
  84. package/src/contexts/root.tsx +0 -190
  85. package/src/hooks/index.ts +0 -3
  86. package/src/hooks/useFadeIn.ts +0 -48
  87. package/src/hooks/useFont.ts +0 -25
  88. package/src/hooks/useRefreshFontScale.ts +0 -39
  89. package/src/hooks/useThemeState.ts +0 -43
  90. package/src/index.ts +0 -6
  91. package/src/store/index.ts +0 -2
  92. package/src/store/useFontScale.ts +0 -8
  93. package/src/store/useScreen.ts +0 -25
  94. package/src/styles/fill.ts +0 -19
  95. package/src/types/forms.ts +0 -14
  96. package/src/types/index.ts +0 -1
  97. package/src/utils/downloadFile.ts +0 -61
  98. package/src/utils/downloadFileLegacy.ts +0 -66
package/package.json CHANGED
@@ -2,32 +2,17 @@
2
2
  "name": "@chem-po/react-native",
3
3
  "author": "Elan Canfield",
4
4
  "license": "MIT",
5
- "version": "0.0.52",
5
+ "version": "0.0.53",
6
6
  "main": "lib/commonjs/index.js",
7
7
  "types": "lib/typescript/index.d.ts",
8
8
  "source": "src/index.ts",
9
9
  "publishConfig": {
10
10
  "access": "public",
11
- "react-native": "src/index.ts"
11
+ "react-native": "lib/module/index.js"
12
12
  },
13
13
  "sideEffects": false,
14
14
  "files": [
15
- "src",
16
- "lib",
17
- "android",
18
- "cpp",
19
- "*.podspec",
20
- "!lib/typescript/example",
21
- "!ios/build",
22
- "!android/build",
23
- "!android/gradle",
24
- "!android/gradlew",
25
- "!android/gradlew.bat",
26
- "!android/local.properties",
27
- "!**/__tests__",
28
- "!**/__fixtures__",
29
- "!**/__mocks__",
30
- "!**/.*"
15
+ "lib"
31
16
  ],
32
17
  "dependencies": {
33
18
  "@lottiefiles/dotlottie-react": "^0.13.5",
@@ -71,8 +56,8 @@
71
56
  "expo-file-system": "~19.0.0",
72
57
  "expo-image-picker": "~17.0.0",
73
58
  "expo-sharing": "~14.0.0",
74
- "@chem-po/core": "0.0.52",
75
- "@chem-po/react": "0.0.52"
59
+ "@chem-po/core": "0.0.53",
60
+ "@chem-po/react": "0.0.53"
76
61
  },
77
62
  "react-native-builder-bob": {
78
63
  "source": "src",
@@ -1,19 +0,0 @@
1
- import React, { forwardRef } from 'react'
2
- import { Animated, StyleSheet, View, ViewProps } from 'react-native'
3
-
4
- export type CenterProps = ViewProps
5
- export const Center = forwardRef<View, CenterProps>(({ style, ...props }, ref) => {
6
- return <View ref={ref} style={[styles.center, style]} {...props} />
7
- })
8
-
9
- export const AnimatedCenter = forwardRef<View, CenterProps>(({ style, ...props }, ref) => {
10
- return <Animated.View ref={ref} style={[styles.center, style]} {...props} />
11
- })
12
-
13
- const styles = StyleSheet.create({
14
- center: {
15
- flex: 1,
16
- justifyContent: 'center',
17
- alignItems: 'center',
18
- },
19
- })
@@ -1,44 +0,0 @@
1
- import React, { useEffect, useMemo, useRef } from 'react'
2
- import { Animated, StyleProp, ViewStyle } from 'react-native'
3
- import { AnimatedCenter, CenterProps } from './Center'
4
-
5
- export const CollapseHorizontal = ({
6
- width,
7
- children,
8
- active,
9
- duration = 400,
10
- style: styleProp,
11
- ...props
12
- }: CenterProps & { width: number; active: boolean; duration?: number }) => {
13
- const widthValue = useRef(new Animated.Value(active ? width : 0)).current
14
- const opacityValue = useRef(new Animated.Value(active ? 1 : 0)).current
15
-
16
- useEffect(() => {
17
- Animated.parallel([
18
- Animated.timing(widthValue, {
19
- toValue: active ? width : 0,
20
- duration,
21
- useNativeDriver: false,
22
- }),
23
- Animated.timing(opacityValue, {
24
- toValue: active ? 1 : 0,
25
- duration,
26
- useNativeDriver: true,
27
- }),
28
- ]).start()
29
- }, [active, widthValue, opacityValue, width, duration])
30
-
31
- const style: StyleProp<ViewStyle> = useMemo(() => {
32
- return {
33
- width: widthValue,
34
- opacity: opacityValue,
35
- overflow: 'hidden',
36
- }
37
- }, [widthValue, opacityValue])
38
-
39
- return (
40
- <AnimatedCenter style={[style, styleProp]} {...props}>
41
- {children}
42
- </AnimatedCenter>
43
- )
44
- }
@@ -1,24 +0,0 @@
1
- import React, { forwardRef } from 'react'
2
- import { StyleSheet, View, ViewProps } from 'react-native'
3
-
4
- const ContentBoxBase = (props: ViewProps, ref: any) => {
5
- return <View ref={ref} style={[styles.container, props.style]} {...props} />
6
- }
7
-
8
- const styles = StyleSheet.create({
9
- container: {
10
- backgroundColor: '#FFFFFF',
11
- padding: 12,
12
- borderRadius: 6,
13
- shadowColor: '#000000',
14
- shadowOffset: {
15
- width: 1,
16
- height: 1,
17
- },
18
- shadowOpacity: 0.4,
19
- shadowRadius: 4,
20
- elevation: 4,
21
- },
22
- })
23
-
24
- export const ContentBox = forwardRef<View, ViewProps>(ContentBoxBase)
@@ -1,28 +0,0 @@
1
- import React, { PropsWithChildren } from 'react'
2
- import { Platform, StyleProp, View, ViewStyle } from 'react-native'
3
-
4
- // Method 1: Wrapping in a View
5
- export const DropShadow = ({
6
- children,
7
- style,
8
- }: PropsWithChildren<{ style: StyleProp<ViewStyle> }>) => (
9
- <View
10
- style={[
11
- {
12
- ...Platform.select({
13
- ios: {
14
- shadowColor: '#000',
15
- shadowOffset: { width: 0, height: 2 },
16
- shadowOpacity: 0.25,
17
- shadowRadius: 3.84,
18
- },
19
- android: {
20
- elevation: 5,
21
- },
22
- }),
23
- },
24
- style,
25
- ]}>
26
- {children}
27
- </View>
28
- )
@@ -1,74 +0,0 @@
1
- import React, { FC, useEffect, useMemo, useRef, useState } from 'react'
2
- import { Animated, View, ViewProps } from 'react-native'
3
-
4
- export const ExpandOnMount: FC<
5
- ViewProps & { in?: boolean; animateOpacity?: boolean; duration?: number; onExited?: () => void }
6
- > = ({ animateOpacity, duration = 300, children, in: isIn = true, onExited, style, ...props }) => {
7
- const [mounted, setMounted] = useState(false)
8
- useEffect(() => {
9
- setMounted(true)
10
- }, [])
11
-
12
- const [bodyHeight, setBodyHeight] = useState<number>(0)
13
- const bodyRef = useRef<View>(null)
14
-
15
- const expanded = useMemo(() => mounted && isIn, [isIn, mounted])
16
-
17
- const heightAnim = useRef(new Animated.Value(0)).current
18
- const opacityAnim = useRef(new Animated.Value(0)).current
19
-
20
- useEffect(() => {
21
- if (bodyRef.current) {
22
- bodyRef.current.measure((x, y, width, height) => {
23
- setBodyHeight(height)
24
- })
25
- }
26
- }, [children])
27
-
28
- useEffect(() => {
29
- const animations = [
30
- Animated.timing(heightAnim, {
31
- toValue: expanded ? bodyHeight : 0,
32
- duration,
33
- useNativeDriver: false,
34
- }),
35
- ]
36
-
37
- if (animateOpacity) {
38
- animations.push(
39
- Animated.timing(opacityAnim, {
40
- toValue: expanded ? 1 : 0,
41
- duration,
42
- delay: expanded ? duration : 0,
43
- useNativeDriver: true,
44
- }),
45
- )
46
- }
47
-
48
- Animated.parallel(animations).start(() => {
49
- if (!expanded && onExited) {
50
- onExited()
51
- }
52
- })
53
- }, [expanded, bodyHeight, duration, heightAnim, opacityAnim, animateOpacity, onExited])
54
-
55
- return (
56
- <Animated.View
57
- style={[
58
- {
59
- overflow: 'hidden',
60
- width: '100%',
61
- height: heightAnim,
62
- },
63
- style,
64
- ]}
65
- {...props}>
66
- <View
67
- ref={bodyRef}
68
- style={[{ width: '100%' }, animateOpacity && { opacity: opacityAnim }, style]}
69
- {...props}>
70
- {children}
71
- </View>
72
- </Animated.View>
73
- )
74
- }
@@ -1,143 +0,0 @@
1
- import React, { FC, PropsWithChildren, useCallback, useEffect, useRef } from 'react'
2
- import { Animated, Pressable, StyleSheet, View, ViewStyle } from 'react-native'
3
- import { Txt } from '../text/Txt'
4
- import { AnimatedCenter } from './Center'
5
- type ExpandableProps = PropsWithChildren<{
6
- header: string | FC<{ isOpen: boolean; onClose: () => void }>
7
- footer?: FC<{ isOpen: boolean; onClose: () => void }>
8
- nested?: boolean
9
- alwaysExpanded?: boolean
10
- initExpanded?: boolean
11
- isOpen?: boolean
12
- onClose?: () => void
13
- iconColor?: string
14
- onOpen?: () => void
15
- style?: ViewStyle
16
- }>
17
-
18
- export const Expandable = ({
19
- header: Header,
20
- children,
21
- initExpanded = false,
22
- nested,
23
- alwaysExpanded,
24
- iconColor = '#000',
25
- footer: Footer,
26
- isOpen: isOpenProp,
27
- onClose: onCloseProp,
28
- onOpen: onOpenProp,
29
- style,
30
- }: ExpandableProps) => {
31
- const [isOpen, setIsOpen] = React.useState(alwaysExpanded ?? initExpanded)
32
- const heightAnim = useRef(new Animated.Value(0)).current
33
- const rotateAnim = useRef(new Animated.Value(0)).current
34
-
35
- useEffect(() => {
36
- if (typeof isOpenProp !== 'undefined') {
37
- setIsOpen(isOpenProp)
38
- }
39
- }, [isOpenProp])
40
-
41
- const onClose = useCallback(() => {
42
- setIsOpen(false)
43
- onCloseProp?.()
44
- }, [onCloseProp])
45
-
46
- const onOpen = useCallback(() => {
47
- setIsOpen(true)
48
- onOpenProp?.()
49
- }, [onOpenProp])
50
-
51
- const handleOpenClick = useCallback(() => {
52
- if (alwaysExpanded) return
53
- if (isOpen) {
54
- onClose()
55
- } else {
56
- onOpen()
57
- }
58
- }, [alwaysExpanded, onOpen, onClose, isOpen])
59
-
60
- useEffect(() => {
61
- Animated.parallel([
62
- Animated.timing(heightAnim, {
63
- toValue: isOpen ? 1 : 0,
64
- duration: 300,
65
- useNativeDriver: false,
66
- }),
67
- Animated.timing(rotateAnim, {
68
- toValue: isOpen ? 1 : 0,
69
- duration: 300,
70
- useNativeDriver: true,
71
- }),
72
- ]).start()
73
- }, [isOpen, heightAnim, rotateAnim])
74
-
75
- const rotate = rotateAnim.interpolate({
76
- inputRange: [0, 1],
77
- outputRange: ['0deg', '180deg'],
78
- })
79
-
80
- return (
81
- <View style={[styles.container, style]}>
82
- <Pressable onPress={handleOpenClick} style={styles.header}>
83
- <View style={styles.headerContent}>
84
- {typeof Header === 'string' ? (
85
- <Txt style={styles.headerText}>{Header}</Txt>
86
- ) : (
87
- <Header isOpen={isOpen} onClose={onClose} />
88
- )}
89
- </View>
90
- {!alwaysExpanded && (
91
- <Animated.Text style={[styles.arrow, { transform: [{ rotate }], color: iconColor }]}>
92
-
93
- </Animated.Text>
94
- )}
95
- </Pressable>
96
-
97
- <AnimatedCenter
98
- style={[
99
- styles.content,
100
- nested && styles.nested,
101
- {
102
- maxHeight: heightAnim.interpolate({
103
- inputRange: [0, 1],
104
- outputRange: [0, 1000],
105
- }),
106
- },
107
- ]}>
108
- {children}
109
- </AnimatedCenter>
110
-
111
- {Footer ? <Footer isOpen={isOpen} onClose={onClose} /> : null}
112
- </View>
113
- )
114
- }
115
- const styles = StyleSheet.create({
116
- container: {
117
- width: '100%',
118
- },
119
- header: {
120
- flexDirection: 'row',
121
- padding: 8,
122
- alignItems: 'center',
123
- },
124
- headerContent: {
125
- flex: 1,
126
- },
127
- headerText: {
128
- fontWeight: '600',
129
- color: '#666',
130
- },
131
- arrow: {
132
- fontSize: 12,
133
- marginLeft: 8,
134
- },
135
- content: {
136
- width: '100%',
137
- overflow: 'hidden',
138
- },
139
- nested: {
140
- borderLeftWidth: 4,
141
- borderLeftColor: 'rgba(0,0,0,0.2)',
142
- },
143
- })
@@ -1,64 +0,0 @@
1
- import React, { createContext, FC, useCallback, useContext, useMemo, useRef, useState } from 'react'
2
- import { View, ViewProps } from 'react-native'
3
-
4
- export const FullSizeContainer = ({
5
- children: Children,
6
- ...props
7
- }: Omit<ViewProps, 'children'> & { children: FC<{ width: number; height: number }> }) => {
8
- const [width, setWidth] = useState(0)
9
- const [height, setHeight] = useState(0)
10
-
11
- const ref = useRef<View>(null)
12
- const handleLayout = useCallback((event: any) => {
13
- const { width: newWidth, height: newHeight } = event.nativeEvent.layout
14
- setWidth(newWidth)
15
- setHeight(newHeight)
16
- }, [])
17
-
18
- return (
19
- <View
20
- ref={ref}
21
- {...props}
22
- style={[{ width: '100%', height: '100%' }, props.style]}
23
- onLayout={handleLayout}>
24
- <Children width={width} height={height} />
25
- </View>
26
- )
27
- }
28
-
29
- interface FullSizeContextType {
30
- width: number
31
- height: number
32
- }
33
-
34
- const FullSizeContext = createContext<FullSizeContextType>({
35
- width: 0,
36
- height: 0,
37
- })
38
-
39
- // same as FullSizeContainer, but provides the width and height in a context instead of a render prop
40
- export const FullSizeProvider = ({ children, ...props }: ViewProps) => {
41
- const [width, setWidth] = useState(0)
42
- const [height, setHeight] = useState(0)
43
-
44
- const ref = useRef<View>(null)
45
- const handleLayout = useCallback((event: any) => {
46
- const { width: newWidth, height: newHeight } = event.nativeEvent.layout
47
- setWidth(newWidth)
48
- setHeight(newHeight)
49
- }, [])
50
-
51
- const contextValue = useMemo(() => ({ width, height }), [width, height])
52
-
53
- return (
54
- <View
55
- ref={ref}
56
- {...props}
57
- style={[{ width: '100%', height: '100%' }, props.style]}
58
- onLayout={handleLayout}>
59
- <FullSizeContext.Provider value={contextValue}>{children}</FullSizeContext.Provider>
60
- </View>
61
- )
62
- }
63
-
64
- export const useFullSize = () => useContext(FullSizeContext)
@@ -1,7 +0,0 @@
1
- export * from './Center'
2
- export * from './CollapseHorizontal'
3
- export * from './ContentBox'
4
- export * from './DropShadow'
5
- export * from './Expandable'
6
- export * from './ExpandOnMount'
7
- export * from './FullSizeContainer'
@@ -1,196 +0,0 @@
1
- import { ElementSize } from '@chem-po/core'
2
- import { Ionicons } from '@expo/vector-icons'
3
- import React, { PropsWithChildren, useMemo } from 'react'
4
- import { StyleProp, StyleSheet, TextStyle, View, ViewStyle } from 'react-native'
5
- import { Pressable } from 'react-native-gesture-handler'
6
- import { useFontScale } from '../../store/useFontScale'
7
- import { CircularProgressProps } from '../loading'
8
- import { WithLoadingOverlay } from '../loading/LoadingOverlay'
9
- import { ButtonText } from './ButtonText'
10
- import {
11
- useButtonBackgroundColor,
12
- useButtonBorderColor,
13
- useButtonColors,
14
- useButtonTextColor,
15
- } from './hooks'
16
-
17
- export interface ActionButtonProps extends PropsWithChildren {
18
- icon?: {
19
- name: React.ComponentProps<typeof Ionicons>['name']
20
- size?: number
21
- }
22
- iconProps?: React.ComponentProps<typeof Ionicons>
23
- style?: StyleProp<ViewStyle>
24
- onPress: () => void
25
- disabled?: boolean
26
- textStyle?: StyleProp<TextStyle>
27
- size?: ElementSize
28
- color?: string
29
- rippleColor?: string
30
- variant?: 'outline' | 'solid'
31
- disabledColor?: string
32
- loading?: boolean
33
- }
34
-
35
- const getIndicatorSize = (size: ElementSize) => {
36
- switch (size) {
37
- case 'sm':
38
- return 18
39
- case 'md':
40
- return 22
41
- case 'lg':
42
- return 26
43
- }
44
- }
45
-
46
- const getContentGap = (size: ElementSize) => {
47
- switch (size) {
48
- case 'sm':
49
- return 4
50
- case 'lg':
51
- return 8
52
- default:
53
- return 6
54
- }
55
- }
56
-
57
- export const ActionButton = ({
58
- children,
59
- onPress,
60
- style,
61
- textStyle,
62
- disabled = false,
63
- loading,
64
- size = 'md',
65
- disabledColor,
66
- color: colorProp,
67
- icon,
68
- iconProps,
69
- variant = 'solid',
70
- rippleColor: rippleColorProp,
71
- }: ActionButtonProps) => {
72
- const colors = useButtonColors(variant)
73
- const rippleColor = useMemo(
74
- () => rippleColorProp ?? colors.ripple,
75
- [rippleColorProp, colors.ripple],
76
- )
77
- const fontScale = useFontScale(s => s.fontScale)
78
- const textColor = useButtonTextColor(colors, variant, colorProp, disabled, disabledColor)
79
- const backgroundColor = useButtonBackgroundColor(
80
- colors,
81
- variant,
82
- colorProp,
83
- disabled,
84
- disabledColor,
85
- )
86
- const borderColor = useButtonBorderColor(colors, variant, colorProp, disabled, disabledColor)
87
- const indicatorProps = useMemo<CircularProgressProps>(() => {
88
- return { color: textColor, size: getIndicatorSize(size) * fontScale }
89
- }, [textColor, size, fontScale])
90
-
91
- const body =
92
- typeof children === 'string' ? (
93
- <ButtonText
94
- variant={variant}
95
- color={colorProp}
96
- disabledColor={disabledColor}
97
- disabled={disabled}
98
- size={size}
99
- style={textStyle}>
100
- {children}
101
- </ButtonText>
102
- ) : (
103
- children
104
- )
105
-
106
- const content = (
107
- <View style={[styles.content, { gap: getContentGap(size) }]}>
108
- {icon ? (
109
- <Ionicons
110
- name={icon.name}
111
- size={(icon.size ?? 20) * fontScale}
112
- color={textColor}
113
- {...iconProps}
114
- style={[variant === 'solid' ? styles.iconShadow : {}, iconProps?.style]}
115
- />
116
- ) : null}
117
- {body}
118
- </View>
119
- )
120
-
121
- return (
122
- <Pressable
123
- style={[
124
- containerStyles.base,
125
- containerStyles[size],
126
- variant === 'solid' ? styles.buttonShadow : { borderWidth: 1 },
127
- { backgroundColor, borderColor },
128
- style,
129
- ]}
130
- onPress={onPress}
131
- android_ripple={{ color: rippleColor }}
132
- disabled={disabled || loading}>
133
- {loading !== undefined ? (
134
- <WithLoadingOverlay loading={loading} indicatorProps={indicatorProps}>
135
- {content}
136
- </WithLoadingOverlay>
137
- ) : (
138
- content
139
- )}
140
- </Pressable>
141
- )
142
- }
143
-
144
- export const RoundedButton = ({ style, ...props }: ActionButtonProps) => {
145
- return <ActionButton style={[styles.rounded, style]} {...props} />
146
- }
147
-
148
- const styles = StyleSheet.create({
149
- rounded: {
150
- borderRadius: 100,
151
- },
152
- content: {
153
- flexDirection: 'row',
154
- alignItems: 'center',
155
- justifyContent: 'center',
156
- },
157
- buttonShadow: {
158
- shadowColor: '#000000',
159
- shadowOffset: { width: 1, height: 1 },
160
- shadowRadius: 6,
161
- shadowOpacity: 0.25,
162
- elevation: 2,
163
- },
164
- iconShadow: {
165
- textShadowColor: 'rgba(0, 0, 0, 0.3)',
166
- textShadowOffset: { width: 1, height: 1 },
167
- textShadowRadius: 4,
168
- },
169
- })
170
-
171
- const containerStyles = StyleSheet.create({
172
- base: {
173
- justifyContent: 'center',
174
- alignItems: 'center',
175
- },
176
- lg: {
177
- paddingVertical: 10,
178
- paddingHorizontal: 16,
179
- borderRadius: 5,
180
- },
181
- md: {
182
- paddingVertical: 6,
183
- paddingHorizontal: 12,
184
- borderRadius: 4,
185
- },
186
- sm: {
187
- paddingVertical: 4,
188
- paddingHorizontal: 8,
189
- borderRadius: 3,
190
- },
191
- xs: {
192
- paddingVertical: 4,
193
- paddingHorizontal: 8,
194
- borderRadius: 2,
195
- },
196
- })