@aws-amplify/ui-react-native 1.1.2 → 1.1.4
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/CHANGELOG.md +20 -0
- package/dist/Authenticator/common/DefaultContent/DefaultContent.js +1 -1
- package/dist/Authenticator/common/DefaultContent/styles.js +2 -1
- package/dist/Authenticator/common/DefaultContent/types.d.ts +2 -1
- package/dist/Authenticator/common/FederatedProviderButton/FederatedProviderButton.js +8 -7
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/usePressableContainerStyles/index.d.ts +1 -0
- package/dist/hooks/usePressableContainerStyles/index.js +1 -0
- package/dist/hooks/usePressableContainerStyles/usePressableContainerStyles.d.ts +19 -0
- package/dist/hooks/usePressableContainerStyles/usePressableContainerStyles.js +14 -0
- package/dist/primitives/Button/Button.js +13 -12
- package/dist/primitives/ErrorMessage/ErrorMessage.d.ts +1 -1
- package/dist/primitives/ErrorMessage/ErrorMessage.js +2 -2
- package/dist/primitives/ErrorMessage/styles.js +4 -2
- package/dist/primitives/ErrorMessage/types.d.ts +2 -0
- package/dist/primitives/IconButton/IconButton.js +12 -11
- package/dist/primitives/Radio/Radio.js +12 -10
- package/dist/primitives/Radio/styles.js +4 -0
- package/dist/primitives/Radio/types.d.ts +1 -0
- package/dist/primitives/Tabs/Tab.js +13 -13
- package/dist/primitives/Tabs/styles.js +4 -0
- package/dist/primitives/Tabs/types.d.ts +1 -0
- package/package.json +3 -3
- package/src/Authenticator/Defaults/ConfirmResetPassword/__tests__/__snapshots__/ConfirmResetPassword.spec.tsx.snap +24 -37
- package/src/Authenticator/Defaults/ConfirmSignIn/__tests__/__snapshots__/ConfirmSignIn.spec.tsx.snap +16 -23
- package/src/Authenticator/Defaults/ConfirmSignUp/__tests__/__snapshots__/ConfirmSignUp.spec.tsx.snap +25 -41
- package/src/Authenticator/Defaults/ConfirmVerifyUser/__tests__/__snapshots__/ConfirmVerifyUser.spec.tsx.snap +19 -32
- package/src/Authenticator/Defaults/ForceNewPassword/__tests__/__snapshots__/ForceNewPassword.spec.tsx.snap +22 -38
- package/src/Authenticator/Defaults/ResetPassword/__tests__/__snapshots__/ResetPassword.spec.tsx.snap +16 -23
- package/src/Authenticator/Defaults/SetupTOTP/__tests__/__snapshots__/SetupTOTP.spec.tsx.snap +16 -23
- package/src/Authenticator/Defaults/SignIn/__tests__/__snapshots__/SignIn.spec.tsx.snap +24 -44
- package/src/Authenticator/Defaults/SignUp/__tests__/__snapshots__/SignUp.spec.tsx.snap +34 -67
- package/src/Authenticator/Defaults/VerifyUser/__tests__/__snapshots__/VerifyUser.spec.tsx.snap +20 -23
- package/src/Authenticator/common/DefaultContainer/__tests__/__snapshots__/DefaultContainer.spec.tsx.snap +3 -6
- package/src/Authenticator/common/DefaultContent/DefaultContent.tsx +2 -1
- package/src/Authenticator/common/DefaultContent/styles.ts +2 -1
- package/src/Authenticator/common/DefaultContent/types.ts +2 -1
- package/src/Authenticator/common/DefaultFooter/__tests__/__snapshots__/DefaultFooter.spec.tsx.snap +3 -6
- package/src/Authenticator/common/FederatedProviderButton/FederatedProviderButton.tsx +8 -12
- package/src/Authenticator/common/FederatedProviderButton/__tests__/FederatedProviderButton.spec.tsx +34 -3
- package/src/Authenticator/common/FederatedProviderButton/__tests__/__snapshots__/FederatedProviderButton.spec.tsx.snap +94 -3
- package/src/Authenticator/common/FederatedProviderButtons/__tests__/__snapshots__/FederatedProviderButtons.spec.tsx.snap +4 -6
- package/src/InAppMessaging/components/BannerMessage/__tests__/__snapshots__/BannerMessage.spec.tsx.snap +2 -4
- package/src/InAppMessaging/components/ModalMessage/__tests__/ModalMessage.spec.tsx +1 -1
- package/src/InAppMessaging/components/ModalMessage/__tests__/__snapshots__/ModalMessage.spec.tsx.snap +3 -6
- package/src/hooks/index.ts +1 -0
- package/src/hooks/usePressableContainerStyles/__tests__/usePressableContainerStyles.spec.ts +68 -0
- package/src/hooks/usePressableContainerStyles/index.ts +1 -0
- package/src/hooks/usePressableContainerStyles/usePressableContainerStyles.ts +51 -0
- package/src/primitives/Button/Button.tsx +16 -23
- package/src/primitives/Button/__tests__/__snapshots__/Button.spec.tsx.snap +9 -18
- package/src/primitives/ErrorMessage/ErrorMessage.tsx +6 -1
- package/src/primitives/ErrorMessage/__tests__/__snapshots__/ErrorMessage.spec.tsx.snap +18 -8
- package/src/primitives/ErrorMessage/styles.ts +4 -2
- package/src/primitives/ErrorMessage/types.ts +3 -0
- package/src/primitives/IconButton/IconButton.tsx +16 -19
- package/src/primitives/IconButton/__tests__/IconButton.spec.tsx +6 -6
- package/src/primitives/IconButton/__tests__/__snapshots__/IconButton.spec.tsx.snap +4 -8
- package/src/primitives/PasswordField/__tests__/__snapshots__/PasswordField.spec.tsx.snap +4 -8
- package/src/primitives/Radio/Radio.tsx +15 -16
- package/src/primitives/Radio/__tests__/Radio.spec.tsx +1 -0
- package/src/primitives/Radio/__tests__/__snapshots__/Radio.spec.tsx.snap +9 -0
- package/src/primitives/Radio/styles.ts +4 -0
- package/src/primitives/Radio/types.ts +1 -0
- package/src/primitives/RadioGroup/__tests__/__snapshots__/RadioGroup.spec.tsx.snap +24 -0
- package/src/primitives/Tabs/Tab.tsx +17 -18
- package/src/primitives/Tabs/__tests__/Tab.spec.tsx +20 -13
- package/src/primitives/Tabs/__tests__/__snapshots__/Tab.spec.tsx.snap +23 -43
- package/src/primitives/Tabs/__tests__/__snapshots__/Tabs.spec.tsx.snap +14 -26
- package/src/primitives/Tabs/styles.ts +4 -0
- package/src/primitives/Tabs/types.ts +1 -0
|
@@ -10,7 +10,7 @@ exports[`ErrorMessage applies theme and style props 1`] = `
|
|
|
10
10
|
"backgroundColor": "hsl(0, 75%, 85%)",
|
|
11
11
|
"flexDirection": "row",
|
|
12
12
|
"paddingHorizontal": 8,
|
|
13
|
-
"paddingVertical":
|
|
13
|
+
"paddingVertical": 12,
|
|
14
14
|
},
|
|
15
15
|
Object {
|
|
16
16
|
"backgroundColor": "blue",
|
|
@@ -33,9 +33,13 @@ exports[`ErrorMessage applies theme and style props 1`] = `
|
|
|
33
33
|
"tintColor": undefined,
|
|
34
34
|
"width": 20,
|
|
35
35
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
Array [
|
|
37
|
+
Object {
|
|
38
|
+
"margin": 8,
|
|
39
|
+
"tintColor": "hsl(0, 100%, 20%)",
|
|
40
|
+
},
|
|
41
|
+
undefined,
|
|
42
|
+
],
|
|
39
43
|
]
|
|
40
44
|
}
|
|
41
45
|
/>
|
|
@@ -45,6 +49,7 @@ exports[`ErrorMessage applies theme and style props 1`] = `
|
|
|
45
49
|
Object {
|
|
46
50
|
"color": "hsl(0, 100%, 20%)",
|
|
47
51
|
"flex": 1,
|
|
52
|
+
"fontSize": 16,
|
|
48
53
|
"paddingHorizontal": 8,
|
|
49
54
|
},
|
|
50
55
|
Object {
|
|
@@ -68,7 +73,7 @@ exports[`ErrorMessage renders default ErrorMessage as expected 1`] = `
|
|
|
68
73
|
"backgroundColor": "hsl(0, 75%, 85%)",
|
|
69
74
|
"flexDirection": "row",
|
|
70
75
|
"paddingHorizontal": 8,
|
|
71
|
-
"paddingVertical":
|
|
76
|
+
"paddingVertical": 12,
|
|
72
77
|
},
|
|
73
78
|
undefined,
|
|
74
79
|
]
|
|
@@ -89,9 +94,13 @@ exports[`ErrorMessage renders default ErrorMessage as expected 1`] = `
|
|
|
89
94
|
"tintColor": undefined,
|
|
90
95
|
"width": 20,
|
|
91
96
|
},
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
97
|
+
Array [
|
|
98
|
+
Object {
|
|
99
|
+
"margin": 8,
|
|
100
|
+
"tintColor": "hsl(0, 100%, 20%)",
|
|
101
|
+
},
|
|
102
|
+
undefined,
|
|
103
|
+
],
|
|
95
104
|
]
|
|
96
105
|
}
|
|
97
106
|
/>
|
|
@@ -101,6 +110,7 @@ exports[`ErrorMessage renders default ErrorMessage as expected 1`] = `
|
|
|
101
110
|
Object {
|
|
102
111
|
"color": "hsl(0, 100%, 20%)",
|
|
103
112
|
"flex": 1,
|
|
113
|
+
"fontSize": 16,
|
|
104
114
|
"paddingHorizontal": 8,
|
|
105
115
|
},
|
|
106
116
|
undefined,
|
|
@@ -5,7 +5,7 @@ import { ErrorMessageStyles } from './types';
|
|
|
5
5
|
|
|
6
6
|
export const getThemedStyles = (theme: StrictTheme): ErrorMessageStyles => {
|
|
7
7
|
const {
|
|
8
|
-
tokens: { colors, space },
|
|
8
|
+
tokens: { colors, fontSizes, space },
|
|
9
9
|
components,
|
|
10
10
|
} = theme;
|
|
11
11
|
|
|
@@ -15,16 +15,18 @@ export const getThemedStyles = (theme: StrictTheme): ErrorMessageStyles => {
|
|
|
15
15
|
backgroundColor: colors.background.error,
|
|
16
16
|
flexDirection: 'row',
|
|
17
17
|
paddingHorizontal: space.xs,
|
|
18
|
-
paddingVertical: space.
|
|
18
|
+
paddingVertical: space.small,
|
|
19
19
|
...components?.errorMessage?.container,
|
|
20
20
|
},
|
|
21
21
|
icon: {
|
|
22
22
|
margin: space.xs,
|
|
23
|
+
tintColor: colors.font.error,
|
|
23
24
|
...components?.errorMessage?.icon,
|
|
24
25
|
},
|
|
25
26
|
label: {
|
|
26
27
|
color: colors.font.error,
|
|
27
28
|
flex: 1,
|
|
29
|
+
fontSize: fontSizes.medium,
|
|
28
30
|
paddingHorizontal: space.xs,
|
|
29
31
|
...components?.errorMessage?.label,
|
|
30
32
|
},
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
3
|
-
Pressable,
|
|
4
|
-
PressableStateCallbackType,
|
|
5
|
-
StyleProp,
|
|
6
|
-
ViewStyle,
|
|
7
|
-
} from 'react-native';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Pressable, ViewStyle } from 'react-native';
|
|
8
3
|
|
|
9
4
|
import { useTheme } from '../../theme';
|
|
5
|
+
import { usePressableContainerStyles } from '../../hooks';
|
|
6
|
+
|
|
10
7
|
import { getThemedStyles } from './styles';
|
|
11
8
|
import { Icon, iconSizes } from '../Icon';
|
|
12
9
|
import { IconButtonProps } from './types';
|
|
@@ -24,20 +21,20 @@ export default function IconButton({
|
|
|
24
21
|
const theme = useTheme();
|
|
25
22
|
const themedStyle = getThemedStyles(theme);
|
|
26
23
|
|
|
27
|
-
const
|
|
28
|
-
(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
disabled ? themedStyle.disabled : null,
|
|
34
|
-
pressed ? themedStyle.pressed : null,
|
|
35
|
-
pressedStateStyle,
|
|
36
|
-
];
|
|
37
|
-
},
|
|
38
|
-
[disabled, style, themedStyle]
|
|
24
|
+
const containerStyle: ViewStyle = useMemo(
|
|
25
|
+
(): ViewStyle => ({
|
|
26
|
+
...themedStyle.container,
|
|
27
|
+
...(disabled && themedStyle.disabled),
|
|
28
|
+
}),
|
|
29
|
+
[disabled, themedStyle]
|
|
39
30
|
);
|
|
40
31
|
|
|
32
|
+
const pressableStyle = usePressableContainerStyles({
|
|
33
|
+
overrideStyle: style,
|
|
34
|
+
containerStyle,
|
|
35
|
+
pressedStyle: themedStyle.pressed,
|
|
36
|
+
});
|
|
37
|
+
|
|
41
38
|
return (
|
|
42
39
|
<Pressable
|
|
43
40
|
{...rest}
|
|
@@ -31,9 +31,8 @@ describe('IconButton', () => {
|
|
|
31
31
|
const themedStyle = getThemedStyles(result.current);
|
|
32
32
|
|
|
33
33
|
expect(button.props.style).toStrictEqual([
|
|
34
|
-
themedStyle.container,
|
|
35
|
-
|
|
36
|
-
null,
|
|
34
|
+
{ ...themedStyle.container, ...themedStyle.disabled },
|
|
35
|
+
undefined,
|
|
37
36
|
undefined,
|
|
38
37
|
]);
|
|
39
38
|
expect(toJSON()).toMatchSnapshot();
|
|
@@ -61,9 +60,10 @@ describe('IconButton', () => {
|
|
|
61
60
|
const themedStyle = getThemedStyles(result.current);
|
|
62
61
|
|
|
63
62
|
expect(getByRole('button').props.style).toStrictEqual([
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
{
|
|
64
|
+
...themedStyle.container,
|
|
65
|
+
},
|
|
66
|
+
undefined,
|
|
67
67
|
customStyle,
|
|
68
68
|
]);
|
|
69
69
|
expect(toJSON()).toMatchSnapshot();
|
|
@@ -18,8 +18,7 @@ exports[`IconButton applies theme and style props 1`] = `
|
|
|
18
18
|
style={
|
|
19
19
|
Array [
|
|
20
20
|
Object {},
|
|
21
|
-
|
|
22
|
-
null,
|
|
21
|
+
undefined,
|
|
23
22
|
Object {
|
|
24
23
|
"backgroundColor": "blue",
|
|
25
24
|
},
|
|
@@ -70,11 +69,10 @@ exports[`IconButton handles disabled state 1`] = `
|
|
|
70
69
|
onStartShouldSetResponder={[Function]}
|
|
71
70
|
style={
|
|
72
71
|
Array [
|
|
73
|
-
Object {},
|
|
74
72
|
Object {
|
|
75
73
|
"opacity": 0.6,
|
|
76
74
|
},
|
|
77
|
-
|
|
75
|
+
undefined,
|
|
78
76
|
undefined,
|
|
79
77
|
]
|
|
80
78
|
}
|
|
@@ -119,8 +117,7 @@ exports[`IconButton renders as expected 1`] = `
|
|
|
119
117
|
style={
|
|
120
118
|
Array [
|
|
121
119
|
Object {},
|
|
122
|
-
|
|
123
|
-
null,
|
|
120
|
+
undefined,
|
|
124
121
|
undefined,
|
|
125
122
|
]
|
|
126
123
|
}
|
|
@@ -165,8 +162,7 @@ exports[`IconButton renders as expected with custom icon style 1`] = `
|
|
|
165
162
|
style={
|
|
166
163
|
Array [
|
|
167
164
|
Object {},
|
|
168
|
-
|
|
169
|
-
null,
|
|
165
|
+
undefined,
|
|
170
166
|
undefined,
|
|
171
167
|
]
|
|
172
168
|
}
|
|
@@ -100,8 +100,7 @@ exports[`PasswordField applies theme and style props 1`] = `
|
|
|
100
100
|
style={
|
|
101
101
|
Array [
|
|
102
102
|
Object {},
|
|
103
|
-
|
|
104
|
-
null,
|
|
103
|
+
undefined,
|
|
105
104
|
undefined,
|
|
106
105
|
]
|
|
107
106
|
}
|
|
@@ -235,8 +234,7 @@ exports[`PasswordField renders as expected 1`] = `
|
|
|
235
234
|
style={
|
|
236
235
|
Array [
|
|
237
236
|
Object {},
|
|
238
|
-
|
|
239
|
-
null,
|
|
237
|
+
undefined,
|
|
240
238
|
undefined,
|
|
241
239
|
]
|
|
242
240
|
}
|
|
@@ -373,11 +371,10 @@ exports[`PasswordField renders as expected when disabled 1`] = `
|
|
|
373
371
|
onStartShouldSetResponder={[Function]}
|
|
374
372
|
style={
|
|
375
373
|
Array [
|
|
376
|
-
Object {},
|
|
377
374
|
Object {
|
|
378
375
|
"opacity": 0.6,
|
|
379
376
|
},
|
|
380
|
-
|
|
377
|
+
undefined,
|
|
381
378
|
undefined,
|
|
382
379
|
]
|
|
383
380
|
}
|
|
@@ -593,8 +590,7 @@ exports[`PasswordField should be able to obscure text programmatically 1`] = `
|
|
|
593
590
|
style={
|
|
594
591
|
Array [
|
|
595
592
|
Object {},
|
|
596
|
-
|
|
597
|
-
null,
|
|
593
|
+
undefined,
|
|
598
594
|
undefined,
|
|
599
595
|
]
|
|
600
596
|
}
|
|
@@ -2,8 +2,6 @@ import React, { useCallback, useMemo } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
GestureResponderEvent,
|
|
4
4
|
Pressable,
|
|
5
|
-
PressableStateCallbackType,
|
|
6
|
-
StyleProp,
|
|
7
5
|
View,
|
|
8
6
|
ViewStyle,
|
|
9
7
|
} from 'react-native';
|
|
@@ -11,6 +9,7 @@ import {
|
|
|
11
9
|
import { useTheme } from '../../theme';
|
|
12
10
|
import { Label } from '../Label';
|
|
13
11
|
import { getFlexDirectionFromLabelPosition } from '../Label/utils';
|
|
12
|
+
import { usePressableContainerStyles } from '../../hooks';
|
|
14
13
|
|
|
15
14
|
import { getThemedStyles } from './styles';
|
|
16
15
|
import { RadioProps } from './types';
|
|
@@ -48,21 +47,21 @@ export default function Radio<T>({
|
|
|
48
47
|
[disabled, onChange, onPress, value]
|
|
49
48
|
);
|
|
50
49
|
|
|
51
|
-
const containerStyle =
|
|
52
|
-
(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const pressedStateStyle =
|
|
60
|
-
typeof style === 'function' ? style({ pressed }) : style;
|
|
61
|
-
return [containerStyle, pressedStateStyle];
|
|
62
|
-
},
|
|
63
|
-
[disabled, labelPosition, style, themedStyle]
|
|
50
|
+
const containerStyle: ViewStyle = useMemo(
|
|
51
|
+
(): ViewStyle => ({
|
|
52
|
+
...themedStyle.container,
|
|
53
|
+
flexDirection: getFlexDirectionFromLabelPosition(labelPosition),
|
|
54
|
+
...(disabled && themedStyle.disabled),
|
|
55
|
+
}),
|
|
56
|
+
[disabled, labelPosition, themedStyle]
|
|
64
57
|
);
|
|
65
58
|
|
|
59
|
+
const pressableStyle = usePressableContainerStyles({
|
|
60
|
+
overrideStyle: style,
|
|
61
|
+
containerStyle,
|
|
62
|
+
pressedStyle: themedStyle.pressed,
|
|
63
|
+
});
|
|
64
|
+
|
|
66
65
|
const { radioContainerDimensions, radioDotDimensions } = useMemo(
|
|
67
66
|
() => getRadioDimensions(size, themedStyle),
|
|
68
67
|
[size, themedStyle]
|
|
@@ -73,7 +72,7 @@ export default function Radio<T>({
|
|
|
73
72
|
{...rest}
|
|
74
73
|
accessibilityRole={accessibilityRole}
|
|
75
74
|
onPress={handleOnChange}
|
|
76
|
-
style={
|
|
75
|
+
style={pressableStyle}
|
|
77
76
|
>
|
|
78
77
|
<View
|
|
79
78
|
style={[
|
|
@@ -21,6 +21,7 @@ exports[`Radio applies theme and custom styles 1`] = `
|
|
|
21
21
|
"alignItems": "center",
|
|
22
22
|
"flexDirection": "row",
|
|
23
23
|
},
|
|
24
|
+
undefined,
|
|
24
25
|
Object {
|
|
25
26
|
"margin": 10,
|
|
26
27
|
},
|
|
@@ -94,6 +95,7 @@ exports[`Radio renders as expected when disabled 1`] = `
|
|
|
94
95
|
"opacity": 0.6,
|
|
95
96
|
},
|
|
96
97
|
undefined,
|
|
98
|
+
undefined,
|
|
97
99
|
]
|
|
98
100
|
}
|
|
99
101
|
>
|
|
@@ -159,6 +161,7 @@ exports[`Radio renders as expected when passing a number to the size prop 1`] =
|
|
|
159
161
|
"flexDirection": "row",
|
|
160
162
|
},
|
|
161
163
|
undefined,
|
|
164
|
+
undefined,
|
|
162
165
|
]
|
|
163
166
|
}
|
|
164
167
|
>
|
|
@@ -241,6 +244,7 @@ exports[`Radio renders as expected when selected is false 1`] = `
|
|
|
241
244
|
"flexDirection": "row",
|
|
242
245
|
},
|
|
243
246
|
undefined,
|
|
247
|
+
undefined,
|
|
244
248
|
]
|
|
245
249
|
}
|
|
246
250
|
>
|
|
@@ -306,6 +310,7 @@ exports[`Radio renders as expected when selected is true 1`] = `
|
|
|
306
310
|
"flexDirection": "row",
|
|
307
311
|
},
|
|
308
312
|
undefined,
|
|
313
|
+
undefined,
|
|
309
314
|
]
|
|
310
315
|
}
|
|
311
316
|
>
|
|
@@ -388,6 +393,7 @@ exports[`Radio renders as expected when size is large 1`] = `
|
|
|
388
393
|
"flexDirection": "row",
|
|
389
394
|
},
|
|
390
395
|
undefined,
|
|
396
|
+
undefined,
|
|
391
397
|
]
|
|
392
398
|
}
|
|
393
399
|
>
|
|
@@ -470,6 +476,7 @@ exports[`Radio renders as expected when size is medium 1`] = `
|
|
|
470
476
|
"flexDirection": "row",
|
|
471
477
|
},
|
|
472
478
|
undefined,
|
|
479
|
+
undefined,
|
|
473
480
|
]
|
|
474
481
|
}
|
|
475
482
|
>
|
|
@@ -552,6 +559,7 @@ exports[`Radio renders as expected when size is small 1`] = `
|
|
|
552
559
|
"flexDirection": "row",
|
|
553
560
|
},
|
|
554
561
|
undefined,
|
|
562
|
+
undefined,
|
|
555
563
|
]
|
|
556
564
|
}
|
|
557
565
|
>
|
|
@@ -634,6 +642,7 @@ exports[`Radio renders as expected with accessibilityRole 1`] = `
|
|
|
634
642
|
"flexDirection": "row",
|
|
635
643
|
},
|
|
636
644
|
undefined,
|
|
645
|
+
undefined,
|
|
637
646
|
]
|
|
638
647
|
}
|
|
639
648
|
>
|
|
@@ -21,6 +21,10 @@ export const getThemedStyles = (theme: StrictTheme): Required<RadioStyles> => {
|
|
|
21
21
|
opacity: opacities[60],
|
|
22
22
|
...components?.radio?.disabled,
|
|
23
23
|
},
|
|
24
|
+
pressed: {
|
|
25
|
+
opacity: opacities[60],
|
|
26
|
+
...components?.radio?.pressed,
|
|
27
|
+
},
|
|
24
28
|
radioContainer: {
|
|
25
29
|
alignItems: 'center',
|
|
26
30
|
borderColor: colors.border.primary,
|
|
@@ -22,6 +22,7 @@ export type RadioDimensions = Pick<ViewStyle, 'height' | 'width'>;
|
|
|
22
22
|
export interface RadioStyles {
|
|
23
23
|
container?: ViewStyle;
|
|
24
24
|
disabled?: ViewStyle;
|
|
25
|
+
pressed?: ViewStyle;
|
|
25
26
|
radioContainer?: ViewStyle;
|
|
26
27
|
radioContainerLarge?: RadioDimensions;
|
|
27
28
|
radioContainerMedium?: RadioDimensions;
|
|
@@ -41,6 +41,7 @@ exports[`RadioGroup renders as expected when direction is horizontal 1`] = `
|
|
|
41
41
|
"flexDirection": "row",
|
|
42
42
|
},
|
|
43
43
|
undefined,
|
|
44
|
+
undefined,
|
|
44
45
|
]
|
|
45
46
|
}
|
|
46
47
|
>
|
|
@@ -120,6 +121,7 @@ exports[`RadioGroup renders as expected when direction is horizontal 1`] = `
|
|
|
120
121
|
"flexDirection": "row",
|
|
121
122
|
},
|
|
122
123
|
undefined,
|
|
124
|
+
undefined,
|
|
123
125
|
]
|
|
124
126
|
}
|
|
125
127
|
>
|
|
@@ -182,6 +184,7 @@ exports[`RadioGroup renders as expected when direction is horizontal 1`] = `
|
|
|
182
184
|
"flexDirection": "row",
|
|
183
185
|
},
|
|
184
186
|
undefined,
|
|
187
|
+
undefined,
|
|
185
188
|
]
|
|
186
189
|
}
|
|
187
190
|
>
|
|
@@ -245,6 +248,7 @@ exports[`RadioGroup renders as expected when direction is horizontal 1`] = `
|
|
|
245
248
|
"opacity": 0.6,
|
|
246
249
|
},
|
|
247
250
|
undefined,
|
|
251
|
+
undefined,
|
|
248
252
|
]
|
|
249
253
|
}
|
|
250
254
|
>
|
|
@@ -331,6 +335,7 @@ exports[`RadioGroup renders as expected when direction is vertical 1`] = `
|
|
|
331
335
|
"flexDirection": "row",
|
|
332
336
|
},
|
|
333
337
|
undefined,
|
|
338
|
+
undefined,
|
|
334
339
|
]
|
|
335
340
|
}
|
|
336
341
|
>
|
|
@@ -410,6 +415,7 @@ exports[`RadioGroup renders as expected when direction is vertical 1`] = `
|
|
|
410
415
|
"flexDirection": "row",
|
|
411
416
|
},
|
|
412
417
|
undefined,
|
|
418
|
+
undefined,
|
|
413
419
|
]
|
|
414
420
|
}
|
|
415
421
|
>
|
|
@@ -472,6 +478,7 @@ exports[`RadioGroup renders as expected when direction is vertical 1`] = `
|
|
|
472
478
|
"flexDirection": "row",
|
|
473
479
|
},
|
|
474
480
|
undefined,
|
|
481
|
+
undefined,
|
|
475
482
|
]
|
|
476
483
|
}
|
|
477
484
|
>
|
|
@@ -535,6 +542,7 @@ exports[`RadioGroup renders as expected when direction is vertical 1`] = `
|
|
|
535
542
|
"opacity": 0.6,
|
|
536
543
|
},
|
|
537
544
|
undefined,
|
|
545
|
+
undefined,
|
|
538
546
|
]
|
|
539
547
|
}
|
|
540
548
|
>
|
|
@@ -621,6 +629,7 @@ exports[`RadioGroup renders as expected when size is large 1`] = `
|
|
|
621
629
|
"flexDirection": "row",
|
|
622
630
|
},
|
|
623
631
|
undefined,
|
|
632
|
+
undefined,
|
|
624
633
|
]
|
|
625
634
|
}
|
|
626
635
|
>
|
|
@@ -700,6 +709,7 @@ exports[`RadioGroup renders as expected when size is large 1`] = `
|
|
|
700
709
|
"flexDirection": "row",
|
|
701
710
|
},
|
|
702
711
|
undefined,
|
|
712
|
+
undefined,
|
|
703
713
|
]
|
|
704
714
|
}
|
|
705
715
|
>
|
|
@@ -762,6 +772,7 @@ exports[`RadioGroup renders as expected when size is large 1`] = `
|
|
|
762
772
|
"flexDirection": "row",
|
|
763
773
|
},
|
|
764
774
|
undefined,
|
|
775
|
+
undefined,
|
|
765
776
|
]
|
|
766
777
|
}
|
|
767
778
|
>
|
|
@@ -825,6 +836,7 @@ exports[`RadioGroup renders as expected when size is large 1`] = `
|
|
|
825
836
|
"opacity": 0.6,
|
|
826
837
|
},
|
|
827
838
|
undefined,
|
|
839
|
+
undefined,
|
|
828
840
|
]
|
|
829
841
|
}
|
|
830
842
|
>
|
|
@@ -911,6 +923,7 @@ exports[`RadioGroup renders as expected when size is medium 1`] = `
|
|
|
911
923
|
"flexDirection": "row",
|
|
912
924
|
},
|
|
913
925
|
undefined,
|
|
926
|
+
undefined,
|
|
914
927
|
]
|
|
915
928
|
}
|
|
916
929
|
>
|
|
@@ -990,6 +1003,7 @@ exports[`RadioGroup renders as expected when size is medium 1`] = `
|
|
|
990
1003
|
"flexDirection": "row",
|
|
991
1004
|
},
|
|
992
1005
|
undefined,
|
|
1006
|
+
undefined,
|
|
993
1007
|
]
|
|
994
1008
|
}
|
|
995
1009
|
>
|
|
@@ -1052,6 +1066,7 @@ exports[`RadioGroup renders as expected when size is medium 1`] = `
|
|
|
1052
1066
|
"flexDirection": "row",
|
|
1053
1067
|
},
|
|
1054
1068
|
undefined,
|
|
1069
|
+
undefined,
|
|
1055
1070
|
]
|
|
1056
1071
|
}
|
|
1057
1072
|
>
|
|
@@ -1115,6 +1130,7 @@ exports[`RadioGroup renders as expected when size is medium 1`] = `
|
|
|
1115
1130
|
"opacity": 0.6,
|
|
1116
1131
|
},
|
|
1117
1132
|
undefined,
|
|
1133
|
+
undefined,
|
|
1118
1134
|
]
|
|
1119
1135
|
}
|
|
1120
1136
|
>
|
|
@@ -1201,6 +1217,7 @@ exports[`RadioGroup renders as expected when size is small 1`] = `
|
|
|
1201
1217
|
"flexDirection": "row",
|
|
1202
1218
|
},
|
|
1203
1219
|
undefined,
|
|
1220
|
+
undefined,
|
|
1204
1221
|
]
|
|
1205
1222
|
}
|
|
1206
1223
|
>
|
|
@@ -1280,6 +1297,7 @@ exports[`RadioGroup renders as expected when size is small 1`] = `
|
|
|
1280
1297
|
"flexDirection": "row",
|
|
1281
1298
|
},
|
|
1282
1299
|
undefined,
|
|
1300
|
+
undefined,
|
|
1283
1301
|
]
|
|
1284
1302
|
}
|
|
1285
1303
|
>
|
|
@@ -1342,6 +1360,7 @@ exports[`RadioGroup renders as expected when size is small 1`] = `
|
|
|
1342
1360
|
"flexDirection": "row",
|
|
1343
1361
|
},
|
|
1344
1362
|
undefined,
|
|
1363
|
+
undefined,
|
|
1345
1364
|
]
|
|
1346
1365
|
}
|
|
1347
1366
|
>
|
|
@@ -1405,6 +1424,7 @@ exports[`RadioGroup renders as expected when size is small 1`] = `
|
|
|
1405
1424
|
"opacity": 0.6,
|
|
1406
1425
|
},
|
|
1407
1426
|
undefined,
|
|
1427
|
+
undefined,
|
|
1408
1428
|
]
|
|
1409
1429
|
}
|
|
1410
1430
|
>
|
|
@@ -1491,6 +1511,7 @@ exports[`RadioGroup renders default RadioGroup as expected 1`] = `
|
|
|
1491
1511
|
"flexDirection": "row",
|
|
1492
1512
|
},
|
|
1493
1513
|
undefined,
|
|
1514
|
+
undefined,
|
|
1494
1515
|
]
|
|
1495
1516
|
}
|
|
1496
1517
|
>
|
|
@@ -1570,6 +1591,7 @@ exports[`RadioGroup renders default RadioGroup as expected 1`] = `
|
|
|
1570
1591
|
"flexDirection": "row",
|
|
1571
1592
|
},
|
|
1572
1593
|
undefined,
|
|
1594
|
+
undefined,
|
|
1573
1595
|
]
|
|
1574
1596
|
}
|
|
1575
1597
|
>
|
|
@@ -1632,6 +1654,7 @@ exports[`RadioGroup renders default RadioGroup as expected 1`] = `
|
|
|
1632
1654
|
"flexDirection": "row",
|
|
1633
1655
|
},
|
|
1634
1656
|
undefined,
|
|
1657
|
+
undefined,
|
|
1635
1658
|
]
|
|
1636
1659
|
}
|
|
1637
1660
|
>
|
|
@@ -1695,6 +1718,7 @@ exports[`RadioGroup renders default RadioGroup as expected 1`] = `
|
|
|
1695
1718
|
"opacity": 0.6,
|
|
1696
1719
|
},
|
|
1697
1720
|
undefined,
|
|
1721
|
+
undefined,
|
|
1698
1722
|
]
|
|
1699
1723
|
}
|
|
1700
1724
|
>
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { useTheme } from '../../theme';
|
|
5
|
+
import { usePressableContainerStyles } from '../../hooks';
|
|
5
6
|
import { Button } from '../Button';
|
|
6
7
|
import { getThemedStyles } from './styles';
|
|
7
8
|
import { TabProps } from './types';
|
|
@@ -19,28 +20,26 @@ export default function Tab({
|
|
|
19
20
|
|
|
20
21
|
const selectedStyles = selected ? themedStyle.selected : null;
|
|
21
22
|
|
|
22
|
-
const containerStyle =
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return [
|
|
30
|
-
themedStyle.tab,
|
|
31
|
-
readonlyStyle,
|
|
32
|
-
selectedStyles,
|
|
33
|
-
pressedStateStyle,
|
|
34
|
-
];
|
|
35
|
-
},
|
|
36
|
-
[selected, selectedStyles, style, themedStyle]
|
|
23
|
+
const containerStyle: ViewStyle = useMemo(
|
|
24
|
+
(): ViewStyle => ({
|
|
25
|
+
...themedStyle.tab,
|
|
26
|
+
...(selected && themedStyle.readonly),
|
|
27
|
+
...selectedStyles,
|
|
28
|
+
}),
|
|
29
|
+
[selected, selectedStyles, themedStyle]
|
|
37
30
|
);
|
|
38
31
|
|
|
32
|
+
const pressableStyle = usePressableContainerStyles({
|
|
33
|
+
overrideStyle: style,
|
|
34
|
+
containerStyle,
|
|
35
|
+
pressedStyle: themedStyle.pressed,
|
|
36
|
+
});
|
|
37
|
+
|
|
39
38
|
return (
|
|
40
39
|
<Button
|
|
41
40
|
{...rest}
|
|
42
41
|
accessibilityRole="tab"
|
|
43
|
-
style={
|
|
42
|
+
style={pressableStyle}
|
|
44
43
|
textStyle={[themedStyle.tabText, textStyle, selectedStyles]}
|
|
45
44
|
>
|
|
46
45
|
{children}
|