@codeleap/mobile 2.1.10 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AutoComplete/styles.js +1 -1
- package/dist/components/AutoComplete/styles.js.map +1 -1
- package/dist/components/Drawer/index.js +13 -2
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/styles.js +2 -4
- package/dist/components/Drawer/styles.js.map +1 -1
- package/dist/components/EmptyPlaceholder/styles.js +1 -1
- package/dist/components/EmptyPlaceholder/styles.js.map +1 -1
- package/dist/components/Grid/index.d.ts +3 -1
- package/dist/components/Grid/index.js +19 -4
- package/dist/components/Grid/index.js.map +1 -1
- package/dist/components/ImageView/Spotlight.js +1 -2
- package/dist/components/ImageView/Spotlight.js.map +1 -1
- package/dist/components/List/index.d.ts +2 -1
- package/dist/components/List/index.js +19 -5
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/Modal/index.d.ts +1 -0
- package/dist/components/Modal/index.js +7 -1
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/styles.js +15 -18
- package/dist/components/Modal/styles.js.map +1 -1
- package/dist/components/Pager/styles.js +7 -7
- package/dist/components/Pager/styles.js.map +1 -1
- package/dist/components/Scroll/index.d.ts +4 -2
- package/dist/components/Scroll/index.js +5 -5
- package/dist/components/Scroll/index.js.map +1 -1
- package/dist/components/Scroll/styles.js +12 -4
- package/dist/components/Scroll/styles.js.map +1 -1
- package/dist/components/SegmentedControl/index.js +3 -1
- package/dist/components/SegmentedControl/index.js.map +1 -1
- package/dist/components/Select/index.js +2 -4
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/styles.js +5 -1
- package/dist/components/Select/styles.js.map +1 -1
- package/dist/components/Select/types.d.ts +2 -1
- package/dist/components/legacy/Modal/index.d.ts +2 -1
- package/dist/components/legacy/Modal/index.js +1 -1
- package/dist/components/legacy/Modal/index.js.map +1 -1
- package/dist/components/legacy/Modal/styles.js +9 -9
- package/dist/components/legacy/Modal/styles.js.map +1 -1
- package/dist/utils/KeyboardAware/keyboardHooks.d.ts +22 -6
- package/dist/utils/KeyboardAware/keyboardHooks.js +63 -29
- package/dist/utils/KeyboardAware/keyboardHooks.js.map +1 -1
- package/dist/utils/hooks.d.ts +1 -0
- package/dist/utils/hooks.js +17 -1
- package/dist/utils/hooks.js.map +1 -1
- package/package.json +1 -1
- package/src/components/AutoComplete/styles.ts +1 -1
- package/src/components/Drawer/index.tsx +11 -1
- package/src/components/Drawer/styles.ts +3 -3
- package/src/components/EmptyPlaceholder/styles.ts +1 -1
- package/src/components/Grid/index.tsx +28 -18
- package/src/components/ImageView/Spotlight.tsx +0 -1
- package/src/components/List/index.tsx +31 -24
- package/src/components/Modal/index.tsx +11 -1
- package/src/components/Modal/styles.ts +28 -28
- package/src/components/Pager/styles.ts +7 -7
- package/src/components/Scroll/index.tsx +15 -8
- package/src/components/Scroll/styles.ts +1 -2
- package/src/components/SegmentedControl/index.tsx +3 -0
- package/src/components/Select/index.tsx +3 -6
- package/src/components/Select/styles.ts +2 -2
- package/src/components/Select/types.ts +2 -1
- package/src/components/legacy/Modal/index.tsx +3 -2
- package/src/components/legacy/Modal/styles.ts +17 -17
- package/src/utils/KeyboardAware/keyboardHooks.ts +102 -38
- package/src/utils/hooks.ts +19 -1
|
@@ -11,7 +11,7 @@ import { View, ViewProps } from '../View'
|
|
|
11
11
|
import { EmptyPlaceholder, EmptyPlaceholderProps } from '../EmptyPlaceholder'
|
|
12
12
|
import { GridComposition, GridStyles } from './styles'
|
|
13
13
|
import { StylesOf } from '../../types'
|
|
14
|
-
import {
|
|
14
|
+
import { GetKeyboardAwarePropsOptions, useKeyboardAwareView } from '../../utils'
|
|
15
15
|
|
|
16
16
|
export type DataboundFlatGridPropsTypes = 'data' | 'renderItem' | 'keyExtractor' | 'getItemLayout'
|
|
17
17
|
|
|
@@ -28,8 +28,6 @@ export type ReplaceFlatGridProps<P, T> = Omit<P, DataboundFlatGridPropsTypes> &
|
|
|
28
28
|
|
|
29
29
|
export * from './styles'
|
|
30
30
|
|
|
31
|
-
const KeyboardAwareFlatGrid = listenToKeyboardEvents(FlatGrid)
|
|
32
|
-
|
|
33
31
|
export type GridProps<
|
|
34
32
|
T = any[],
|
|
35
33
|
Data = T extends Array<infer D> ? D : never
|
|
@@ -37,7 +35,8 @@ export type GridProps<
|
|
|
37
35
|
Omit<ViewProps, 'variants'> & {
|
|
38
36
|
separators?: boolean
|
|
39
37
|
placeholder?: EmptyPlaceholderProps
|
|
40
|
-
keyboardAware?:
|
|
38
|
+
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
39
|
+
debugName?: string
|
|
41
40
|
styles?: StylesOf<GridComposition>
|
|
42
41
|
refreshControlProps?: Partial<RefreshControlProps>
|
|
43
42
|
} & ComponentVariants<typeof GridStyles>
|
|
@@ -51,7 +50,8 @@ const GridCP = forwardRef<FlatGrid, GridProps>(
|
|
|
51
50
|
onRefresh,
|
|
52
51
|
refreshing,
|
|
53
52
|
placeholder,
|
|
54
|
-
keyboardAware
|
|
53
|
+
keyboardAware,
|
|
54
|
+
debugName,
|
|
55
55
|
refreshControlProps = {},
|
|
56
56
|
...props
|
|
57
57
|
} = flatGridProps
|
|
@@ -73,16 +73,15 @@ const GridCP = forwardRef<FlatGrid, GridProps>(
|
|
|
73
73
|
const isEmpty = !props.data || !props.data.length
|
|
74
74
|
const separator = !isEmpty && separatorProp == true && renderSeparator
|
|
75
75
|
|
|
76
|
-
const Component = keyboardAware ? KeyboardAwareFlatGrid : FlatGrid
|
|
77
76
|
const refreshStyles = StyleSheet.flatten([variantStyles.refreshControl, styles.refreshControl])
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
const Component = FlatGrid
|
|
78
|
+
|
|
79
|
+
const _gridProps = {
|
|
80
|
+
style: [variantStyles.wrapper, style],
|
|
81
|
+
contentContainerStyle: variantStyles.content,
|
|
82
|
+
ref: ref as unknown as FlatGrid,
|
|
83
|
+
ItemSeparatorComponent: separator,
|
|
84
|
+
refreshControl:
|
|
86
85
|
!!onRefresh && (
|
|
87
86
|
<RefreshControl
|
|
88
87
|
refreshing={refreshing}
|
|
@@ -91,11 +90,22 @@ const GridCP = forwardRef<FlatGrid, GridProps>(
|
|
|
91
90
|
colors={[refreshStyles?.color]}
|
|
92
91
|
{...refreshControlProps}
|
|
93
92
|
/>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
93
|
+
),
|
|
96
94
|
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
ListEmptyComponent: <EmptyPlaceholder {...placeholder}/>,
|
|
96
|
+
...props,
|
|
97
|
+
}
|
|
98
|
+
const keyboard = useKeyboardAwareView({
|
|
99
|
+
debugName,
|
|
100
|
+
})
|
|
101
|
+
const gridProps = keyboard.getKeyboardAwareProps(_gridProps, {
|
|
102
|
+
baseStyleProp: 'contentContainerStyle',
|
|
103
|
+
adapt: 'paddingBottom',
|
|
104
|
+
...keyboardAware,
|
|
105
|
+
})
|
|
106
|
+
return (
|
|
107
|
+
<Component
|
|
108
|
+
{...gridProps}
|
|
99
109
|
/>
|
|
100
110
|
)
|
|
101
111
|
},
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
useDefaultComponentStyle,
|
|
6
6
|
|
|
7
7
|
ComponentVariants,
|
|
8
|
+
useCallback,
|
|
8
9
|
} from '@codeleap/common'
|
|
9
10
|
|
|
10
11
|
import { RefreshControl, FlatList, FlatListProps as RNFlatListProps, ListRenderItemInfo, StyleSheet, RefreshControlProps } from 'react-native'
|
|
@@ -12,7 +13,7 @@ import { View, ViewProps } from '../View'
|
|
|
12
13
|
import { EmptyPlaceholder, EmptyPlaceholderProps } from '../EmptyPlaceholder'
|
|
13
14
|
import { ListComposition, ListStyles } from './styles'
|
|
14
15
|
import { StylesOf } from '../../types'
|
|
15
|
-
import {
|
|
16
|
+
import { GetKeyboardAwarePropsOptions, useKeyboardAwareView } from '../../utils'
|
|
16
17
|
|
|
17
18
|
export type DataboundFlatListPropsTypes = 'data' | 'renderItem' | 'keyExtractor' | 'getItemLayout'
|
|
18
19
|
|
|
@@ -37,7 +38,7 @@ export type FlatListProps<
|
|
|
37
38
|
Omit<ViewProps, 'variants'> & {
|
|
38
39
|
separators?: boolean
|
|
39
40
|
placeholder?: EmptyPlaceholderProps
|
|
40
|
-
keyboardAware?:
|
|
41
|
+
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
41
42
|
styles?: StylesOf<ListComposition>
|
|
42
43
|
refreshControlProps?: Partial<RefreshControlProps>
|
|
43
44
|
} & ComponentVariants<typeof ListStyles>
|
|
@@ -52,7 +53,7 @@ const ListCP = forwardRef<FlatList, FlatListProps>(
|
|
|
52
53
|
component,
|
|
53
54
|
refreshing,
|
|
54
55
|
placeholder,
|
|
55
|
-
keyboardAware
|
|
56
|
+
keyboardAware,
|
|
56
57
|
refreshControlProps = {},
|
|
57
58
|
...props
|
|
58
59
|
} = flatListProps
|
|
@@ -64,39 +65,45 @@ const ListCP = forwardRef<FlatList, FlatListProps>(
|
|
|
64
65
|
|
|
65
66
|
})
|
|
66
67
|
|
|
67
|
-
const renderSeparator = () => {
|
|
68
|
+
const renderSeparator = useCallback(() => {
|
|
68
69
|
return (
|
|
69
70
|
<View variants={['separator']}></View>
|
|
70
71
|
)
|
|
71
|
-
}
|
|
72
|
+
}, [])
|
|
72
73
|
|
|
73
74
|
const separatorProp = props.separators
|
|
74
75
|
const isEmpty = !props.data || !props.data.length
|
|
75
76
|
const separator = !isEmpty && separatorProp == true && renderSeparator
|
|
76
77
|
|
|
77
|
-
const Component:any = component ||
|
|
78
|
+
const Component:any = component || FlatList
|
|
78
79
|
const refreshStyles = StyleSheet.flatten([variantStyles.refreshControl, styles.refreshControl])
|
|
79
80
|
|
|
81
|
+
const _listProps = {
|
|
82
|
+
style: [variantStyles.wrapper, style],
|
|
83
|
+
contentContainerStyle: variantStyles.content,
|
|
84
|
+
ref: ref as unknown as FlatList,
|
|
85
|
+
ItemSeparatorComponent: separator,
|
|
86
|
+
refreshControl: !!onRefresh && (
|
|
87
|
+
<RefreshControl
|
|
88
|
+
refreshing={refreshing}
|
|
89
|
+
onRefresh={onRefresh}
|
|
90
|
+
tintColor={refreshStyles?.color}
|
|
91
|
+
colors={[refreshStyles?.color]}
|
|
92
|
+
{...refreshControlProps}
|
|
93
|
+
/>
|
|
94
|
+
),
|
|
95
|
+
ListEmptyComponent: <EmptyPlaceholder {...placeholder}/>,
|
|
96
|
+
...props,
|
|
97
|
+
}
|
|
98
|
+
const keyboard = useKeyboardAwareView()
|
|
99
|
+
const listProps = keyboard.getKeyboardAwareProps(_listProps, {
|
|
100
|
+
adapt: 'paddingBottom',
|
|
101
|
+
baseStyleProp: 'contentContainerStyle',
|
|
102
|
+
...keyboardAware,
|
|
103
|
+
})
|
|
80
104
|
return (
|
|
81
105
|
<Component
|
|
82
|
-
|
|
83
|
-
contentContainerStyle={variantStyles.content}
|
|
84
|
-
ref={ref as unknown as FlatList}
|
|
85
|
-
ItemSeparatorComponent={separator}
|
|
86
|
-
refreshControl={
|
|
87
|
-
!!onRefresh && (
|
|
88
|
-
<RefreshControl
|
|
89
|
-
refreshing={refreshing}
|
|
90
|
-
onRefresh={onRefresh}
|
|
91
|
-
tintColor={refreshStyles?.color}
|
|
92
|
-
colors={[refreshStyles?.color]}
|
|
93
|
-
{...refreshControlProps}
|
|
94
|
-
/>
|
|
95
|
-
)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
ListEmptyComponent={<EmptyPlaceholder {...placeholder}/>}
|
|
99
|
-
{...props}
|
|
106
|
+
{...listProps}
|
|
100
107
|
/>
|
|
101
108
|
)
|
|
102
109
|
},
|
|
@@ -21,7 +21,7 @@ import { StylesOf } from '../../types/utility'
|
|
|
21
21
|
|
|
22
22
|
import { useDynamicAnimation } from 'moti'
|
|
23
23
|
import { Backdrop } from '../Backdrop'
|
|
24
|
-
import { useStaticAnimationStyles } from '../../utils/hooks'
|
|
24
|
+
import { useBackButton, useStaticAnimationStyles } from '../../utils/hooks'
|
|
25
25
|
import { Text, TextProps } from '../Text'
|
|
26
26
|
import { Touchable } from '../Touchable'
|
|
27
27
|
|
|
@@ -44,6 +44,7 @@ export type ModalProps = Omit<ViewProps, 'variants' | 'styles'> & {
|
|
|
44
44
|
zIndex?: number
|
|
45
45
|
scroll?: boolean
|
|
46
46
|
header?: React.ReactElement
|
|
47
|
+
closeOnHardwareBackPress?: boolean
|
|
47
48
|
renderHeader?: (props: ModalHeaderProps) => React.ReactElement
|
|
48
49
|
scrollProps?: PropsOf<typeof Scroll>
|
|
49
50
|
}
|
|
@@ -98,6 +99,7 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
98
99
|
renderHeader,
|
|
99
100
|
zIndex = null,
|
|
100
101
|
scrollProps = {},
|
|
102
|
+
closeOnHardwareBackPress = true,
|
|
101
103
|
...props
|
|
102
104
|
} = modalProps
|
|
103
105
|
|
|
@@ -139,6 +141,14 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
139
141
|
},
|
|
140
142
|
}
|
|
141
143
|
const Header = renderHeader || DefaultHeader
|
|
144
|
+
|
|
145
|
+
useBackButton(() => {
|
|
146
|
+
if (visible && closeOnHardwareBackPress) {
|
|
147
|
+
toggle()
|
|
148
|
+
return true
|
|
149
|
+
}
|
|
150
|
+
}, [visible, toggle, closeOnHardwareBackPress])
|
|
151
|
+
|
|
142
152
|
return (
|
|
143
153
|
<View
|
|
144
154
|
style={[wrapperStyle, { zIndex: TypeGuards.isNumber(zIndex) ? zIndex : wrapperStyle?.zIndex }]}
|
|
@@ -34,9 +34,9 @@ const presets = includePresets((style) => createModalStyle(() => ({ body: style
|
|
|
34
34
|
export const ModalStyles = {
|
|
35
35
|
|
|
36
36
|
...presets,
|
|
37
|
-
default: createModalStyle((
|
|
37
|
+
default: createModalStyle((theme) => {
|
|
38
38
|
const fullSize = {
|
|
39
|
-
...
|
|
39
|
+
...theme.presets.whole,
|
|
40
40
|
position: 'absolute',
|
|
41
41
|
width: '100%',
|
|
42
42
|
height: '100%',
|
|
@@ -45,28 +45,30 @@ export const ModalStyles = {
|
|
|
45
45
|
return {
|
|
46
46
|
wrapper: {
|
|
47
47
|
zIndex: 1,
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
height: theme.values.height,
|
|
49
|
+
width: theme.values.width,
|
|
50
|
+
...theme.presets.whole,
|
|
51
|
+
position: 'absolute',
|
|
50
52
|
},
|
|
51
53
|
'box:transition': {
|
|
52
54
|
scale: {
|
|
53
|
-
duration:
|
|
55
|
+
duration: theme.values.transitions.modal.duration,
|
|
54
56
|
type: 'timing',
|
|
55
57
|
},
|
|
56
58
|
opacity: {
|
|
57
|
-
duration:
|
|
59
|
+
duration: theme.values.transitions.modal.duration,
|
|
58
60
|
type: 'timing',
|
|
59
61
|
},
|
|
60
62
|
},
|
|
61
63
|
'backdrop:transition': {
|
|
62
64
|
opacity: {
|
|
63
|
-
duration:
|
|
65
|
+
duration: theme.values.transitions.modal.duration,
|
|
64
66
|
type: 'timing',
|
|
65
67
|
},
|
|
66
68
|
},
|
|
67
69
|
backdrop: {
|
|
68
70
|
|
|
69
|
-
backgroundColor:
|
|
71
|
+
backgroundColor: theme.colors.black,
|
|
70
72
|
...fullSize,
|
|
71
73
|
},
|
|
72
74
|
backdropTouchable: {
|
|
@@ -79,26 +81,24 @@ export const ModalStyles = {
|
|
|
79
81
|
opacity: 0,
|
|
80
82
|
},
|
|
81
83
|
innerWrapper: {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
...
|
|
85
|
-
...
|
|
84
|
+
...theme.presets.alignCenter,
|
|
85
|
+
...theme.presets.justifyCenter,
|
|
86
|
+
...theme.presets.fullHeight,
|
|
87
|
+
...theme.presets.fullWidth,
|
|
86
88
|
},
|
|
87
89
|
scroll: {
|
|
88
|
-
|
|
89
|
-
width: '100%',
|
|
90
|
+
...fullSize,
|
|
90
91
|
},
|
|
91
92
|
scrollContent: {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
...
|
|
95
|
-
...Theme.presets.fullHeight,
|
|
93
|
+
...theme.presets.alignCenter,
|
|
94
|
+
...theme.presets.justifyCenter,
|
|
95
|
+
...theme.presets.full,
|
|
96
96
|
},
|
|
97
97
|
box: {
|
|
98
98
|
width: '80%',
|
|
99
|
-
backgroundColor:
|
|
100
|
-
borderRadius:
|
|
101
|
-
...
|
|
99
|
+
backgroundColor: theme.colors.background,
|
|
100
|
+
borderRadius: theme.borderRadius.medium,
|
|
101
|
+
...theme.spacing.padding(2),
|
|
102
102
|
},
|
|
103
103
|
|
|
104
104
|
'box:hidden': {
|
|
@@ -112,17 +112,17 @@ export const ModalStyles = {
|
|
|
112
112
|
},
|
|
113
113
|
header: {
|
|
114
114
|
flexDirection: 'row',
|
|
115
|
-
...
|
|
116
|
-
...
|
|
115
|
+
...theme.presets.justifySpaceBetween,
|
|
116
|
+
...theme.presets.alignCenter,
|
|
117
117
|
},
|
|
118
118
|
closeButtonWrapper: {
|
|
119
119
|
alignSelf: 'center',
|
|
120
|
-
...
|
|
120
|
+
...theme.spacing.marginLeft('auto'),
|
|
121
121
|
},
|
|
122
122
|
title: {
|
|
123
|
-
...
|
|
124
|
-
...assignTextStyle('h3')(
|
|
125
|
-
...
|
|
123
|
+
...theme.presets.textCenter,
|
|
124
|
+
...assignTextStyle('h3')(theme).text,
|
|
125
|
+
...theme.spacing.paddingBottom(1),
|
|
126
126
|
flex: 1,
|
|
127
127
|
},
|
|
128
128
|
}
|
|
@@ -139,7 +139,7 @@ export const ModalStyles = {
|
|
|
139
139
|
flex: 1,
|
|
140
140
|
borderRadius: 0,
|
|
141
141
|
width: theme.values.width,
|
|
142
|
-
height: theme.values.height,
|
|
142
|
+
height: theme.values.window.height,
|
|
143
143
|
...theme.presets.center,
|
|
144
144
|
},
|
|
145
145
|
})),
|
|
@@ -53,7 +53,7 @@ export const PagerStyles = {
|
|
|
53
53
|
...presets,
|
|
54
54
|
default: createPagerStyle((theme) => {
|
|
55
55
|
const width = theme.values.width
|
|
56
|
-
const height = theme.values.height * 0.8
|
|
56
|
+
const height = theme.values.window.height * 0.8
|
|
57
57
|
return {
|
|
58
58
|
...pagerAnimation(height, width, 'X'),
|
|
59
59
|
page: {
|
|
@@ -67,15 +67,15 @@ export const PagerStyles = {
|
|
|
67
67
|
},
|
|
68
68
|
}
|
|
69
69
|
}),
|
|
70
|
-
horizontal: createPagerStyle((
|
|
70
|
+
horizontal: createPagerStyle((theme) => {
|
|
71
71
|
|
|
72
|
-
const width =
|
|
73
|
-
const height =
|
|
72
|
+
const width = theme.values.width
|
|
73
|
+
const height = theme.values.window.height * 0.8
|
|
74
74
|
return pagerAnimation(height, width, 'X')
|
|
75
75
|
}),
|
|
76
|
-
vertical: createPagerStyle((
|
|
77
|
-
const height =
|
|
78
|
-
const width =
|
|
76
|
+
vertical: createPagerStyle((theme) => {
|
|
77
|
+
const height = theme.values.window.height * 0.8
|
|
78
|
+
const width = theme.values.width
|
|
79
79
|
return pagerAnimation(height, width, 'Y')
|
|
80
80
|
}),
|
|
81
81
|
}
|
|
@@ -5,7 +5,6 @@ import {
|
|
|
5
5
|
onUpdate,
|
|
6
6
|
useDefaultComponentStyle,
|
|
7
7
|
usePrevious,
|
|
8
|
-
useCodeleapContext,
|
|
9
8
|
} from '@codeleap/common'
|
|
10
9
|
|
|
11
10
|
import { RefreshControl, RefreshControlProps, ScrollView, StyleSheet } from 'react-native'
|
|
@@ -13,7 +12,7 @@ import { ViewProps } from '../View'
|
|
|
13
12
|
import { KeyboardAwareScrollViewTypes } from '../../modules'
|
|
14
13
|
import { StylesOf } from '../../types'
|
|
15
14
|
import { ScrollComposition, ScrollStyles } from './styles'
|
|
16
|
-
import {
|
|
15
|
+
import { GetKeyboardAwarePropsOptions, useKeyboardAwareView } from '../../utils'
|
|
17
16
|
// import { KeyboardAwareScrollView } from '../../utils'
|
|
18
17
|
|
|
19
18
|
type KeyboardAwareScrollViewProps = KeyboardAwareScrollViewTypes.KeyboardAwareScrollViewProps
|
|
@@ -23,10 +22,11 @@ export type ScrollProps = KeyboardAwareScrollViewProps &
|
|
|
23
22
|
onRefresh?: () => void
|
|
24
23
|
refreshTimeout?: number
|
|
25
24
|
changeData?: any
|
|
26
|
-
keyboardAware?:
|
|
25
|
+
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
27
26
|
refreshing?: boolean
|
|
28
27
|
styles?: StylesOf<ScrollComposition>
|
|
29
28
|
refreshControlProps?: Partial<RefreshControlProps>
|
|
29
|
+
debugName?: string
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
@@ -40,7 +40,8 @@ export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
|
40
40
|
styles = {},
|
|
41
41
|
refreshControlProps = {},
|
|
42
42
|
contentContainerStyle,
|
|
43
|
-
keyboardAware
|
|
43
|
+
keyboardAware,
|
|
44
|
+
debugName = '',
|
|
44
45
|
...props
|
|
45
46
|
} = scrollProps
|
|
46
47
|
const hasRefresh = !!props.onRefresh
|
|
@@ -71,7 +72,6 @@ export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
}, [refreshingDisplay, changeData])
|
|
74
|
-
const { Theme } = useCodeleapContext()
|
|
75
75
|
|
|
76
76
|
const variantStyles = useDefaultComponentStyle<'u:Scroll', typeof ScrollStyles>('u:Scroll', {
|
|
77
77
|
variants,
|
|
@@ -96,9 +96,16 @@ export const Scroll = forwardRef<ScrollView, ScrollProps>(
|
|
|
96
96
|
),
|
|
97
97
|
...props,
|
|
98
98
|
}
|
|
99
|
-
const keyboard =
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const keyboard = useKeyboardAwareView({
|
|
100
|
+
debugName,
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
const rootProps = keyboard.getKeyboardAwareProps(_scrollProps, {
|
|
104
|
+
adapt: 'marginBottom',
|
|
105
|
+
baseStyleProp: 'style',
|
|
106
|
+
...keyboardAware,
|
|
107
|
+
|
|
108
|
+
})
|
|
102
109
|
|
|
103
110
|
return (
|
|
104
111
|
<ScrollView
|
|
@@ -131,6 +131,9 @@ const _SegmentedControl = React.forwardRef<SegmentedControlRef, SegmentedControl
|
|
|
131
131
|
style={variantStyles.scroll}
|
|
132
132
|
contentContainerStyle={variantStyles.scrollContent}
|
|
133
133
|
{...scrollProps}
|
|
134
|
+
keyboardAware={{
|
|
135
|
+
enabled: false,
|
|
136
|
+
}}
|
|
134
137
|
ref={scrollRef}
|
|
135
138
|
>
|
|
136
139
|
<View style={variantStyles.wrapper}>
|
|
@@ -10,7 +10,7 @@ import { TextInput } from '../TextInput'
|
|
|
10
10
|
import { Touchable } from '../Touchable'
|
|
11
11
|
import { SelectStyles } from './styles'
|
|
12
12
|
import { CustomSelectProps } from './types'
|
|
13
|
-
import { ModalManager,
|
|
13
|
+
import { ModalManager, useKeyboardAwareView } from '../../utils'
|
|
14
14
|
import { Icon } from '../Icon'
|
|
15
15
|
|
|
16
16
|
export const SelectItem = ({ item, icon = null, isSelected, styles, onPress }) => {
|
|
@@ -46,7 +46,7 @@ export const Select = <T extends string|number = string>(selectProps:CustomSelec
|
|
|
46
46
|
selectedIcon = 'selectMarker',
|
|
47
47
|
inputProps = {},
|
|
48
48
|
hideInput = false,
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
...drawerProps
|
|
51
51
|
} = selectProps
|
|
52
52
|
|
|
@@ -113,9 +113,6 @@ export const Select = <T extends string|number = string>(selectProps:CustomSelec
|
|
|
113
113
|
...listProps,
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
const keyboard = useKeyboardScrollView()
|
|
117
|
-
const _listProps = keyboardAware ? keyboard.getScrollProps(baseListProps, 'contentContainerStyle', 'paddingBottom') : baseListProps
|
|
118
|
-
|
|
119
116
|
return <>
|
|
120
117
|
{
|
|
121
118
|
!hideInput && (
|
|
@@ -146,7 +143,7 @@ export const Select = <T extends string|number = string>(selectProps:CustomSelec
|
|
|
146
143
|
|
|
147
144
|
<ModalManager.Drawer scroll={false} title={label} {...drawerProps} styles={variantStyles}>
|
|
148
145
|
<List<CustomSelectProps<any>['options']>
|
|
149
|
-
{...
|
|
146
|
+
{...baseListProps}
|
|
150
147
|
/>
|
|
151
148
|
</ModalManager.Drawer>
|
|
152
149
|
|
|
@@ -49,8 +49,8 @@ export const SelectStyles = {
|
|
|
49
49
|
list: {
|
|
50
50
|
height: 'auto',
|
|
51
51
|
|
|
52
|
-
maxHeight: theme.values.height * 0.7,
|
|
53
|
-
...theme.presets.safeAreaBottom(),
|
|
52
|
+
maxHeight: theme.values.window.height * 0.7,
|
|
53
|
+
// ...theme.presets.safeAreaBottom(),
|
|
54
54
|
},
|
|
55
55
|
listContent: {
|
|
56
56
|
paddingBottom: theme.values.bottomNavHeight + theme.spacing.value(1),
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
IconPlaceholder,
|
|
5
5
|
} from '@codeleap/common'
|
|
6
6
|
import { StylesOf } from '../../types/utility'
|
|
7
|
+
import { GetKeyboardAwarePropsOptions } from '../../utils'
|
|
7
8
|
import { DrawerProps } from '../Drawer'
|
|
8
9
|
import { FlatListProps } from '../List'
|
|
9
10
|
import { TextInputProps } from '../TextInput'
|
|
@@ -37,6 +38,6 @@ export type CustomSelectProps<T> = SelectDrawerProps & {
|
|
|
37
38
|
listProps?: Partial<FlatListProps>
|
|
38
39
|
clearable?: boolean
|
|
39
40
|
clearIconName?: IconPlaceholder
|
|
40
|
-
keyboardAware?:
|
|
41
|
+
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
41
42
|
} & ComponentVariants<typeof SelectStyles>
|
|
42
43
|
|
|
@@ -19,6 +19,7 @@ import { StylesOf } from '../../../types/utility'
|
|
|
19
19
|
import { Touchable } from '../../Touchable'
|
|
20
20
|
import { Text } from '../../Text'
|
|
21
21
|
import { Animated } from '../../Animated'
|
|
22
|
+
import { GetKeyboardAwarePropsOptions } from '../../../utils'
|
|
22
23
|
|
|
23
24
|
export * from './styles'
|
|
24
25
|
|
|
@@ -38,7 +39,7 @@ export type ModalProps = Omit<ViewProps, 'variants' | 'styles'> & {
|
|
|
38
39
|
toggle?: () => void
|
|
39
40
|
zIndex?: number
|
|
40
41
|
scroll?: boolean
|
|
41
|
-
keyboardAware?:
|
|
42
|
+
keyboardAware?: GetKeyboardAwarePropsOptions
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
@@ -56,7 +57,7 @@ export const Modal: React.FC<ModalProps> = (modalProps) => {
|
|
|
56
57
|
closeIconName = 'close',
|
|
57
58
|
debugName,
|
|
58
59
|
scroll = true,
|
|
59
|
-
keyboardAware
|
|
60
|
+
keyboardAware,
|
|
60
61
|
zIndex = null,
|
|
61
62
|
...props
|
|
62
63
|
} = modalProps
|
|
@@ -39,12 +39,12 @@ const defaultModalStyles = ModalStyles
|
|
|
39
39
|
export const MobileModalStyles = {
|
|
40
40
|
...defaultModalStyles,
|
|
41
41
|
...presets,
|
|
42
|
-
default: createModalStyle((
|
|
42
|
+
default: createModalStyle((theme) => {
|
|
43
43
|
const fullSize = {
|
|
44
|
-
...
|
|
44
|
+
...theme.presets.whole,
|
|
45
45
|
position: 'absolute',
|
|
46
|
-
width:
|
|
47
|
-
height:
|
|
46
|
+
width: theme?.values?.width,
|
|
47
|
+
height: theme?.values?.height,
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
return {
|
|
@@ -57,7 +57,7 @@ export const MobileModalStyles = {
|
|
|
57
57
|
overlay: {
|
|
58
58
|
opacity: 0,
|
|
59
59
|
|
|
60
|
-
backgroundColor:
|
|
60
|
+
backgroundColor: theme.colors.black,
|
|
61
61
|
...fullSize,
|
|
62
62
|
},
|
|
63
63
|
'overlay:visible': {
|
|
@@ -67,14 +67,14 @@ export const MobileModalStyles = {
|
|
|
67
67
|
innerWrapperScroll: {
|
|
68
68
|
display: 'flex',
|
|
69
69
|
alignItems: 'center',
|
|
70
|
-
...
|
|
71
|
-
minHeight:
|
|
70
|
+
...theme.presets.justifyCenter,
|
|
71
|
+
minHeight: theme.values.window.height,
|
|
72
72
|
},
|
|
73
73
|
box: {
|
|
74
74
|
width: '80%',
|
|
75
|
-
backgroundColor:
|
|
76
|
-
borderRadius:
|
|
77
|
-
...
|
|
75
|
+
backgroundColor: theme.colors.background,
|
|
76
|
+
borderRadius: theme.borderRadius.medium,
|
|
77
|
+
...theme.spacing.padding(2),
|
|
78
78
|
},
|
|
79
79
|
touchableBackdrop: {
|
|
80
80
|
...fullSize,
|
|
@@ -91,17 +91,17 @@ export const MobileModalStyles = {
|
|
|
91
91
|
},
|
|
92
92
|
header: {
|
|
93
93
|
flexDirection: 'row',
|
|
94
|
-
...
|
|
95
|
-
...
|
|
94
|
+
...theme.presets.justifySpaceBetween,
|
|
95
|
+
...theme.presets.alignCenter,
|
|
96
96
|
},
|
|
97
97
|
closeButtonWrapper: {
|
|
98
98
|
alignSelf: 'center',
|
|
99
|
-
...
|
|
99
|
+
...theme.spacing.marginLeft('auto'),
|
|
100
100
|
},
|
|
101
101
|
title: {
|
|
102
|
-
...
|
|
103
|
-
...assignTextStyle('h3')(
|
|
104
|
-
...
|
|
102
|
+
...theme.presets.textCenter,
|
|
103
|
+
...assignTextStyle('h3')(theme).text,
|
|
104
|
+
...theme.spacing.paddingBottom(1),
|
|
105
105
|
flex: 1,
|
|
106
106
|
},
|
|
107
107
|
}
|
|
@@ -118,7 +118,7 @@ export const MobileModalStyles = {
|
|
|
118
118
|
flex: 1,
|
|
119
119
|
borderRadius: 0,
|
|
120
120
|
width: theme.values.width,
|
|
121
|
-
height: theme.values.height,
|
|
121
|
+
height: theme.values.window.height,
|
|
122
122
|
...theme.presets.center,
|
|
123
123
|
},
|
|
124
124
|
})),
|