@pagopa/io-app-design-system 1.0.0-9 → 1.0.0
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/README.md +39 -4
- package/lib/commonjs/components/Advice/Advice.js +5 -7
- package/lib/commonjs/components/Advice/Advice.js.map +1 -1
- package/lib/commonjs/components/Advice/__test__/advice.test.js +2 -2
- package/lib/commonjs/components/Advice/__test__/advice.test.js.map +1 -1
- package/lib/commonjs/components/accordion/RawAccordion.js.map +1 -1
- package/lib/commonjs/components/badge/__test__/badge.test.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonLink.js +4 -5
- package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButton.js +0 -2
- package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
- package/lib/commonjs/components/buttons/IconButtonContained.js +131 -0
- package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -0
- package/lib/commonjs/components/buttons/IconButtonSolid.js +109 -0
- package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -0
- package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
- package/lib/commonjs/components/buttons/__test__/button.test.js +27 -0
- package/lib/commonjs/components/buttons/__test__/button.test.js.map +1 -1
- package/lib/commonjs/components/buttons/index.js +30 -8
- package/lib/commonjs/components/buttons/index.js.map +1 -1
- package/lib/commonjs/components/checkbox/AnimatedCheckbox.js +1 -1
- package/lib/commonjs/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/commonjs/components/icons/index.js +0 -18
- package/lib/commonjs/components/icons/index.js.map +1 -1
- package/lib/commonjs/components/index.js +72 -72
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/layout/GradientBottomActions.js +90 -0
- package/lib/commonjs/components/layout/GradientBottomActions.js.map +1 -0
- package/lib/commonjs/components/layout/GradientScrollView.js +111 -0
- package/lib/commonjs/components/layout/GradientScrollView.js.map +1 -0
- package/lib/commonjs/components/layout/HeaderFirstLevel.js +62 -0
- package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -0
- package/lib/commonjs/components/layout/index.js +17 -0
- package/lib/commonjs/components/layout/index.js.map +1 -0
- package/lib/commonjs/components/listitems/ListItemCheckbox.js +135 -0
- package/lib/commonjs/components/listitems/ListItemCheckbox.js.map +1 -0
- package/lib/commonjs/components/listitems/ListItemInfo.js +3 -6
- package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemInfoCopy.js +1 -4
- package/lib/commonjs/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemRadio.js +136 -0
- package/lib/commonjs/components/listitems/ListItemRadio.js.map +1 -0
- package/lib/commonjs/components/listitems/ListItemSwitch.js +82 -0
- package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -0
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
- package/lib/commonjs/components/listitems/index.js +33 -0
- package/lib/commonjs/components/listitems/index.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentExtMaestro.js +3 -19
- package/lib/commonjs/components/logos/svg/LogoPaymentExtMaestro.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentExtMastercard.js +5 -21
- package/lib/commonjs/components/logos/svg/LogoPaymentExtMastercard.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentExtPayPal.js +9 -28
- package/lib/commonjs/components/logos/svg/LogoPaymentExtPayPal.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentMaestro.js +8 -18
- package/lib/commonjs/components/logos/svg/LogoPaymentMaestro.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentMastercard.js +7 -17
- package/lib/commonjs/components/logos/svg/LogoPaymentMastercard.js.map +1 -1
- package/lib/commonjs/components/logos/svg/LogoPaymentPayPal.js +5 -5
- package/lib/commonjs/components/logos/svg/LogoPaymentPayPal.js.map +1 -1
- package/lib/commonjs/components/radio/AnimatedRadio.js +1 -1
- package/lib/commonjs/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/commonjs/components/radio/RadioGroup.js +36 -0
- package/lib/commonjs/components/radio/RadioGroup.js.map +1 -0
- package/lib/commonjs/components/radio/index.js +11 -0
- package/lib/commonjs/components/radio/index.js.map +1 -1
- package/lib/commonjs/components/typography/H3.js +20 -49
- package/lib/commonjs/components/typography/H3.js.map +1 -1
- package/lib/commonjs/components/typography/Link.js +17 -23
- package/lib/commonjs/components/typography/Link.js.map +1 -1
- package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
- package/lib/commonjs/core/IOColors.js +1 -1
- package/lib/commonjs/core/IOColors.js.map +1 -1
- package/lib/commonjs/core/IOSpacing.js +1 -1
- package/lib/commonjs/core/IOSpacing.js.map +1 -1
- package/lib/commonjs/core/IOStyles.js +7 -1
- package/lib/commonjs/core/IOStyles.js.map +1 -1
- package/lib/commonjs/index.js +11 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/json-import.d.js +2 -0
- package/lib/commonjs/json-import.d.js.map +1 -0
- package/lib/module/components/Advice/Advice.js +4 -6
- package/lib/module/components/Advice/Advice.js.map +1 -1
- package/lib/module/components/Advice/__test__/advice.test.js +1 -1
- package/lib/module/components/Advice/__test__/advice.test.js.map +1 -1
- package/lib/module/components/accordion/RawAccordion.js +1 -1
- package/lib/module/components/accordion/RawAccordion.js.map +1 -1
- package/lib/module/components/badge/__test__/badge.test.js.map +1 -1
- package/lib/module/components/buttons/ButtonLink.js +4 -5
- package/lib/module/components/buttons/ButtonLink.js.map +1 -1
- package/lib/module/components/buttons/IconButton.js +0 -2
- package/lib/module/components/buttons/IconButton.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js +122 -0
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -0
- package/lib/module/components/buttons/IconButtonSolid.js +100 -0
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -0
- package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
- package/lib/module/components/buttons/__test__/button.test.js +27 -0
- package/lib/module/components/buttons/__test__/button.test.js.map +1 -1
- package/lib/module/components/buttons/index.js +4 -2
- package/lib/module/components/buttons/index.js.map +1 -1
- package/lib/module/components/checkbox/AnimatedCheckbox.js +3 -3
- package/lib/module/components/checkbox/AnimatedCheckbox.js.map +1 -1
- package/lib/module/components/icons/index.js +0 -1
- package/lib/module/components/icons/index.js.map +1 -1
- package/lib/module/components/index.js +13 -13
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/layout/GradientBottomActions.js +79 -0
- package/lib/module/components/layout/GradientBottomActions.js.map +1 -0
- package/lib/module/components/layout/GradientScrollView.js +100 -0
- package/lib/module/components/layout/GradientScrollView.js.map +1 -0
- package/lib/module/components/layout/HeaderFirstLevel.js +52 -0
- package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -0
- package/lib/module/components/layout/index.js +2 -0
- package/lib/module/components/layout/index.js.map +1 -0
- package/lib/module/components/listitems/ListItemCheckbox.js +126 -0
- package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -0
- package/lib/module/components/listitems/ListItemInfo.js +3 -6
- package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
- package/lib/module/components/listitems/ListItemInfoCopy.js +1 -4
- package/lib/module/components/listitems/ListItemInfoCopy.js.map +1 -1
- package/lib/module/components/listitems/ListItemRadio.js +127 -0
- package/lib/module/components/listitems/ListItemRadio.js.map +1 -0
- package/lib/module/components/listitems/ListItemSwitch.js +74 -0
- package/lib/module/components/listitems/ListItemSwitch.js.map +1 -0
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
- package/lib/module/components/listitems/index.js +3 -0
- package/lib/module/components/listitems/index.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentExtMaestro.js +3 -19
- package/lib/module/components/logos/svg/LogoPaymentExtMaestro.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentExtMastercard.js +5 -21
- package/lib/module/components/logos/svg/LogoPaymentExtMastercard.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentExtPayPal.js +10 -29
- package/lib/module/components/logos/svg/LogoPaymentExtPayPal.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentMaestro.js +9 -19
- package/lib/module/components/logos/svg/LogoPaymentMaestro.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentMastercard.js +8 -18
- package/lib/module/components/logos/svg/LogoPaymentMastercard.js.map +1 -1
- package/lib/module/components/logos/svg/LogoPaymentPayPal.js +5 -5
- package/lib/module/components/logos/svg/LogoPaymentPayPal.js.map +1 -1
- package/lib/module/components/radio/AnimatedRadio.js +3 -3
- package/lib/module/components/radio/AnimatedRadio.js.map +1 -1
- package/lib/module/components/radio/RadioGroup.js +28 -0
- package/lib/module/components/radio/RadioGroup.js.map +1 -0
- package/lib/module/components/radio/index.js +1 -0
- package/lib/module/components/radio/index.js.map +1 -1
- package/lib/module/components/typography/H3.js +19 -47
- package/lib/module/components/typography/H3.js.map +1 -1
- package/lib/module/components/typography/Link.js +17 -23
- package/lib/module/components/typography/Link.js.map +1 -1
- package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
- package/lib/module/core/IOColors.js +1 -1
- package/lib/module/core/IOColors.js.map +1 -1
- package/lib/module/core/IOSpacing.js +1 -1
- package/lib/module/core/IOSpacing.js.map +1 -1
- package/lib/module/core/IOStyles.js +5 -0
- package/lib/module/core/IOStyles.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/json-import.d.js +2 -0
- package/lib/module/json-import.d.js.map +1 -0
- package/lib/typescript/components/Advice/Advice.d.ts +7 -3
- package/lib/typescript/components/Advice/Advice.d.ts.map +1 -1
- package/lib/typescript/components/accordion/RawAccordion.d.ts +2 -2
- package/lib/typescript/components/accordion/RawAccordion.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonLink.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButton.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButtonContained.d.ts +15 -0
- package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -0
- package/lib/typescript/components/buttons/IconButtonSolid.d.ts +15 -0
- package/lib/typescript/components/buttons/IconButtonSolid.d.ts.map +1 -0
- package/lib/typescript/components/buttons/index.d.ts +4 -2
- package/lib/typescript/components/buttons/index.d.ts.map +1 -1
- package/lib/typescript/components/checkbox/AnimatedCheckbox.d.ts.map +1 -1
- package/lib/typescript/components/icons/index.d.ts +0 -1
- package/lib/typescript/components/icons/index.d.ts.map +1 -1
- package/lib/typescript/components/index.d.ts +13 -13
- package/lib/typescript/components/index.d.ts.map +1 -1
- package/lib/typescript/components/layout/GradientBottomActions.d.ts +22 -0
- package/lib/typescript/components/layout/GradientBottomActions.d.ts.map +1 -0
- package/lib/typescript/components/layout/GradientScrollView.d.ts +14 -0
- package/lib/typescript/components/layout/GradientScrollView.d.ts.map +1 -0
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts +11 -0
- package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -0
- package/lib/typescript/components/layout/index.d.ts +2 -0
- package/lib/typescript/components/layout/index.d.ts.map +1 -0
- package/lib/typescript/components/listitems/ListItemCheckbox.d.ts +21 -0
- package/lib/typescript/components/listitems/ListItemCheckbox.d.ts.map +1 -0
- package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemInfoCopy.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemRadio.d.ts +22 -0
- package/lib/typescript/components/listitems/ListItemRadio.d.ts.map +1 -0
- package/lib/typescript/components/listitems/ListItemSwitch.d.ts +18 -0
- package/lib/typescript/components/listitems/ListItemSwitch.d.ts.map +1 -0
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/index.d.ts +3 -0
- package/lib/typescript/components/listitems/index.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentExtMaestro.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentExtMastercard.d.ts +2 -2
- package/lib/typescript/components/logos/svg/LogoPaymentExtMastercard.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentExtPayPal.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentMaestro.d.ts.map +1 -1
- package/lib/typescript/components/logos/svg/LogoPaymentMastercard.d.ts.map +1 -1
- package/lib/typescript/components/radio/AnimatedRadio.d.ts.map +1 -1
- package/lib/typescript/components/radio/RadioGroup.d.ts +22 -0
- package/lib/typescript/components/radio/RadioGroup.d.ts.map +1 -0
- package/lib/typescript/components/radio/index.d.ts +1 -0
- package/lib/typescript/components/radio/index.d.ts.map +1 -1
- package/lib/typescript/components/typography/H3.d.ts +11 -30
- package/lib/typescript/components/typography/H3.d.ts.map +1 -1
- package/lib/typescript/components/typography/Link.d.ts +4 -4
- package/lib/typescript/components/typography/Link.d.ts.map +1 -1
- package/lib/typescript/core/IOColors.d.ts +2 -1
- package/lib/typescript/core/IOColors.d.ts.map +1 -1
- package/lib/typescript/core/IOSpacing.d.ts +1 -1
- package/lib/typescript/core/IOSpacing.d.ts.map +1 -1
- package/lib/typescript/core/IOStyles.d.ts +6 -2
- package/lib/typescript/core/IOStyles.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/components/Advice/Advice.tsx +19 -23
- package/src/components/Advice/__test__/advice.test.tsx +4 -2
- package/src/components/accordion/RawAccordion.tsx +6 -6
- package/src/components/badge/__test__/badge.test.tsx +4 -2
- package/src/components/buttons/ButtonLink.tsx +177 -177
- package/src/components/buttons/IconButton.tsx +9 -6
- package/src/components/buttons/IconButtonContained.tsx +201 -0
- package/src/components/buttons/IconButtonSolid.tsx +168 -0
- package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
- package/src/components/buttons/__test__/button.test.tsx +59 -4
- package/src/components/buttons/index.tsx +5 -3
- package/src/components/checkbox/AnimatedCheckbox.tsx +6 -8
- package/src/components/icons/index.tsx +1 -2
- package/src/components/index.tsx +13 -13
- package/src/components/layout/GradientBottomActions.tsx +119 -0
- package/src/components/layout/GradientScrollView.tsx +167 -0
- package/src/components/layout/HeaderFirstLevel.tsx +76 -0
- package/src/components/layout/index.tsx +1 -0
- package/src/components/listitems/ListItemCheckbox.tsx +182 -0
- package/src/components/listitems/ListItemInfo.tsx +53 -58
- package/src/components/listitems/ListItemInfoCopy.tsx +122 -127
- package/src/components/listitems/ListItemRadio.tsx +185 -0
- package/src/components/listitems/ListItemSwitch.tsx +109 -0
- package/src/components/listitems/ListItemTransaction.tsx +154 -150
- package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
- package/src/components/listitems/index.tsx +3 -0
- package/src/components/logos/svg/LogoPaymentExtMaestro.tsx +3 -20
- package/src/components/logos/svg/LogoPaymentExtMastercard.tsx +5 -22
- package/src/components/logos/svg/LogoPaymentExtPayPal.tsx +9 -31
- package/src/components/logos/svg/LogoPaymentMaestro.tsx +8 -6
- package/src/components/logos/svg/LogoPaymentMastercard.tsx +8 -6
- package/src/components/logos/svg/LogoPaymentPayPal.tsx +5 -5
- package/src/components/radio/AnimatedRadio.tsx +6 -8
- package/src/components/radio/RadioGroup.tsx +43 -0
- package/src/components/radio/index.tsx +1 -0
- package/src/components/typography/H3.tsx +25 -91
- package/src/components/typography/Link.tsx +23 -30
- package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
- package/src/core/IOColors.ts +2 -2
- package/src/core/IOSpacing.ts +2 -2
- package/src/core/IOStyles.ts +9 -0
- package/src/index.tsx +1 -0
- package/src/json-import.d.ts +13 -0
|
@@ -1,155 +1,150 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
-
import {
|
|
3
|
-
GestureResponderEvent,
|
|
4
|
-
Pressable,
|
|
5
|
-
View
|
|
6
|
-
} from "react-native";
|
|
2
|
+
import { GestureResponderEvent, Pressable, View } from "react-native";
|
|
7
3
|
import Animated, {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
Extrapolate,
|
|
5
|
+
interpolate,
|
|
6
|
+
interpolateColor,
|
|
7
|
+
useAnimatedStyle,
|
|
8
|
+
useDerivedValue,
|
|
9
|
+
useSharedValue,
|
|
10
|
+
withSpring
|
|
15
11
|
} from "react-native-reanimated";
|
|
16
12
|
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
IOColors,
|
|
14
|
+
IOListItemStyles,
|
|
15
|
+
IOListItemVisualParams,
|
|
16
|
+
IOScaleValues,
|
|
17
|
+
IOSpringValues,
|
|
18
|
+
IOStyles,
|
|
19
|
+
hexToRgba,
|
|
20
|
+
useIOTheme
|
|
24
21
|
} from "../../core";
|
|
25
22
|
import { WithTestID } from "../../utils/types";
|
|
26
23
|
import { IOIcons, Icon } from "../icons";
|
|
27
|
-
import { VSpacer } from "../spacer/Spacer";
|
|
28
24
|
import { H6, LabelSmall } from "../typography";
|
|
29
25
|
|
|
30
26
|
export type ListItemInfoCopy = WithTestID<{
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
label: string;
|
|
28
|
+
value: string | React.ReactNode;
|
|
29
|
+
numberOfLines?: number;
|
|
30
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
31
|
+
icon?: IOIcons;
|
|
32
|
+
// Accessibility
|
|
33
|
+
accessibilityLabel: string;
|
|
38
34
|
}>;
|
|
39
35
|
|
|
40
36
|
export const ListItemInfoCopy = ({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
label,
|
|
38
|
+
value,
|
|
39
|
+
numberOfLines = 2,
|
|
40
|
+
onPress,
|
|
41
|
+
icon,
|
|
42
|
+
accessibilityLabel,
|
|
43
|
+
testID
|
|
48
44
|
}: ListItemInfoCopy) => {
|
|
49
|
-
|
|
45
|
+
const isPressed = useSharedValue(0);
|
|
50
46
|
|
|
51
|
-
|
|
47
|
+
const theme = useIOTheme();
|
|
52
48
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
49
|
+
const mapBackgroundStates: Record<string, string> = {
|
|
50
|
+
default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
|
|
51
|
+
pressed: IOColors[theme["listItem-pressed"]]
|
|
52
|
+
};
|
|
57
53
|
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
// Scaling transformation applied when the button is pressed
|
|
55
|
+
const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
const progressPressed = useDerivedValue(() =>
|
|
58
|
+
withSpring(isPressed.value, IOSpringValues.button)
|
|
59
|
+
);
|
|
64
60
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
// Interpolate animation values from `isPressed` values
|
|
62
|
+
const animatedScaleStyle = useAnimatedStyle(() => {
|
|
63
|
+
const scale = interpolate(
|
|
64
|
+
progressPressed.value,
|
|
65
|
+
[0, 1],
|
|
66
|
+
[1, animationScaleValue],
|
|
67
|
+
Extrapolate.CLAMP
|
|
68
|
+
);
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
return {
|
|
71
|
+
transform: [{ scale }]
|
|
72
|
+
};
|
|
73
|
+
});
|
|
78
74
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
75
|
+
const animatedBackgroundStyle = useAnimatedStyle(() => {
|
|
76
|
+
const backgroundColor = interpolateColor(
|
|
77
|
+
progressPressed.value,
|
|
78
|
+
[0, 1],
|
|
79
|
+
[mapBackgroundStates.default, mapBackgroundStates.pressed]
|
|
80
|
+
);
|
|
85
81
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
return {
|
|
83
|
+
backgroundColor
|
|
84
|
+
};
|
|
85
|
+
});
|
|
90
86
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
87
|
+
const handlePressIn = useCallback(() => {
|
|
88
|
+
// eslint-disable-next-line functional/immutable-data
|
|
89
|
+
isPressed.value = 1;
|
|
90
|
+
}, [isPressed]);
|
|
91
|
+
const handlePressOut = useCallback(() => {
|
|
92
|
+
// eslint-disable-next-line functional/immutable-data
|
|
93
|
+
isPressed.value = 0;
|
|
94
|
+
}, [isPressed]);
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
96
|
+
return (
|
|
97
|
+
<Pressable
|
|
98
|
+
onPress={onPress}
|
|
99
|
+
onPressIn={handlePressIn}
|
|
100
|
+
onPressOut={handlePressOut}
|
|
101
|
+
accessible={true}
|
|
102
|
+
accessibilityLabel={accessibilityLabel}
|
|
103
|
+
accessibilityRole="button"
|
|
104
|
+
testID={testID}
|
|
105
|
+
>
|
|
106
|
+
<Animated.View
|
|
107
|
+
style={[IOListItemStyles.listItem, animatedBackgroundStyle]}
|
|
108
|
+
>
|
|
109
|
+
<Animated.View
|
|
110
|
+
style={[IOListItemStyles.listItemInner, animatedScaleStyle]}
|
|
109
111
|
>
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
size={IOListItemVisualParams.chevronSize}
|
|
147
|
-
/>
|
|
148
|
-
</View>
|
|
149
|
-
</Animated.View>
|
|
150
|
-
</Animated.View>
|
|
151
|
-
</Pressable>
|
|
152
|
-
);
|
|
112
|
+
{icon && (
|
|
113
|
+
<View style={{ marginRight: IOListItemVisualParams.iconMargin }}>
|
|
114
|
+
<Icon
|
|
115
|
+
name={icon}
|
|
116
|
+
color="grey-450"
|
|
117
|
+
size={IOListItemVisualParams.iconSize}
|
|
118
|
+
/>
|
|
119
|
+
</View>
|
|
120
|
+
)}
|
|
121
|
+
<View style={IOStyles.flex}>
|
|
122
|
+
<LabelSmall weight="Regular" color={theme["textBody-tertiary"]}>
|
|
123
|
+
{label}
|
|
124
|
+
</LabelSmall>
|
|
125
|
+
{/* Let developer using a custom component (e.g: skeleton) */}
|
|
126
|
+
{typeof value === "string" ? (
|
|
127
|
+
<H6
|
|
128
|
+
color={theme["interactiveElem-default"]}
|
|
129
|
+
numberOfLines={numberOfLines}
|
|
130
|
+
>
|
|
131
|
+
{value}
|
|
132
|
+
</H6>
|
|
133
|
+
) : (
|
|
134
|
+
{ value }
|
|
135
|
+
)}
|
|
136
|
+
</View>
|
|
137
|
+
<View style={{ marginLeft: IOListItemVisualParams.iconMargin }}>
|
|
138
|
+
<Icon
|
|
139
|
+
name="copy"
|
|
140
|
+
color={theme["interactiveElem-default"]}
|
|
141
|
+
size={IOListItemVisualParams.chevronSize}
|
|
142
|
+
/>
|
|
143
|
+
</View>
|
|
144
|
+
</Animated.View>
|
|
145
|
+
</Animated.View>
|
|
146
|
+
</Pressable>
|
|
147
|
+
);
|
|
153
148
|
};
|
|
154
149
|
|
|
155
150
|
export default ListItemInfoCopy;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
import { Pressable, View } from "react-native";
|
|
4
|
+
import ReactNativeHapticFeedback from "react-native-haptic-feedback";
|
|
5
|
+
import Animated, {
|
|
6
|
+
Extrapolate,
|
|
7
|
+
interpolate,
|
|
8
|
+
interpolateColor,
|
|
9
|
+
useAnimatedStyle,
|
|
10
|
+
useDerivedValue,
|
|
11
|
+
useSharedValue,
|
|
12
|
+
withSpring
|
|
13
|
+
} from "react-native-reanimated";
|
|
14
|
+
import {
|
|
15
|
+
IOColors,
|
|
16
|
+
IOScaleValues,
|
|
17
|
+
IOSelectionListItemStyles,
|
|
18
|
+
IOSelectionListItemVisualParams,
|
|
19
|
+
IOSpringValues,
|
|
20
|
+
IOStyles,
|
|
21
|
+
hexToRgba,
|
|
22
|
+
useIOTheme
|
|
23
|
+
} from "../../core";
|
|
24
|
+
import { WithTestID } from "../../utils/types";
|
|
25
|
+
import { IOIcons, Icon } from "../icons";
|
|
26
|
+
import { HSpacer, VSpacer } from "../spacer";
|
|
27
|
+
import { H6, LabelSmall } from "../typography";
|
|
28
|
+
import { AnimatedRadio } from "../radio/AnimatedRadio";
|
|
29
|
+
|
|
30
|
+
type Props = WithTestID<{
|
|
31
|
+
value: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
icon?: IOIcons;
|
|
34
|
+
selected: boolean;
|
|
35
|
+
onValueChange?: (newValue: boolean) => void;
|
|
36
|
+
}>;
|
|
37
|
+
|
|
38
|
+
const DISABLED_OPACITY = 0.5;
|
|
39
|
+
|
|
40
|
+
// disabled: the component is no longer touchable
|
|
41
|
+
// onPress:
|
|
42
|
+
type OwnProps = Props &
|
|
43
|
+
Pick<
|
|
44
|
+
React.ComponentProps<typeof Pressable>,
|
|
45
|
+
"onPress" | "accessibilityLabel" | "disabled"
|
|
46
|
+
>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* with the automatic state management that uses a {@link AnimatedCheckBox}
|
|
50
|
+
* The toggleValue change when a `onPress` event is received and dispatch the `onValueChange`.
|
|
51
|
+
*
|
|
52
|
+
* @param props
|
|
53
|
+
* @constructor
|
|
54
|
+
*/
|
|
55
|
+
export const ListItemRadio = ({
|
|
56
|
+
value,
|
|
57
|
+
description,
|
|
58
|
+
icon,
|
|
59
|
+
selected,
|
|
60
|
+
disabled,
|
|
61
|
+
onValueChange,
|
|
62
|
+
testID
|
|
63
|
+
}: OwnProps) => {
|
|
64
|
+
const [toggleValue, setToggleValue] = useState(selected ?? false);
|
|
65
|
+
// Animations
|
|
66
|
+
const isPressed: Animated.SharedValue<number> = useSharedValue(0);
|
|
67
|
+
|
|
68
|
+
// Scaling transformation applied when the button is pressed
|
|
69
|
+
const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
|
|
70
|
+
|
|
71
|
+
const progressPressed = useDerivedValue(() =>
|
|
72
|
+
withSpring(isPressed.value, IOSpringValues.button)
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Theme
|
|
76
|
+
const theme = useIOTheme();
|
|
77
|
+
|
|
78
|
+
const mapBackgroundStates: Record<string, string> = {
|
|
79
|
+
default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
|
|
80
|
+
pressed: IOColors[theme["listItem-pressed"]]
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// Interpolate animation values from `isPressed` values
|
|
84
|
+
const animatedScaleStyle = useAnimatedStyle(() => {
|
|
85
|
+
const scale = interpolate(
|
|
86
|
+
progressPressed.value,
|
|
87
|
+
[0, 1],
|
|
88
|
+
[1, animationScaleValue],
|
|
89
|
+
Extrapolate.CLAMP
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
transform: [{ scale }]
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const handlePressIn = useCallback(() => {
|
|
98
|
+
// eslint-disable-next-line functional/immutable-data
|
|
99
|
+
isPressed.value = 1;
|
|
100
|
+
}, [isPressed]);
|
|
101
|
+
const handlePressOut = useCallback(() => {
|
|
102
|
+
// eslint-disable-next-line functional/immutable-data
|
|
103
|
+
isPressed.value = 0;
|
|
104
|
+
}, [isPressed]);
|
|
105
|
+
|
|
106
|
+
const animatedBackgroundStyle = useAnimatedStyle(() => {
|
|
107
|
+
const backgroundColor = interpolateColor(
|
|
108
|
+
progressPressed.value,
|
|
109
|
+
[0, 1],
|
|
110
|
+
[mapBackgroundStates.default, mapBackgroundStates.pressed]
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
backgroundColor
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const toggleRadioItem = () => {
|
|
119
|
+
ReactNativeHapticFeedback.trigger("impactLight");
|
|
120
|
+
setToggleValue(!toggleValue);
|
|
121
|
+
if (onValueChange !== undefined) {
|
|
122
|
+
onValueChange(!toggleValue);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<Pressable
|
|
128
|
+
onPress={toggleRadioItem}
|
|
129
|
+
onPressIn={handlePressIn}
|
|
130
|
+
onPressOut={handlePressOut}
|
|
131
|
+
onTouchEnd={handlePressOut}
|
|
132
|
+
testID={testID}
|
|
133
|
+
disabled={disabled}
|
|
134
|
+
>
|
|
135
|
+
<Animated.View
|
|
136
|
+
style={[
|
|
137
|
+
IOSelectionListItemStyles.listItem,
|
|
138
|
+
animatedBackgroundStyle,
|
|
139
|
+
{ opacity: disabled ? DISABLED_OPACITY : 1 }
|
|
140
|
+
]}
|
|
141
|
+
// This is required to avoid opacity
|
|
142
|
+
// inheritance on Android
|
|
143
|
+
needsOffscreenAlphaCompositing={true}
|
|
144
|
+
>
|
|
145
|
+
<Animated.View style={animatedScaleStyle}>
|
|
146
|
+
<View style={IOSelectionListItemStyles.listItemInner}>
|
|
147
|
+
<View style={[IOStyles.row, { flexShrink: 1 }]}>
|
|
148
|
+
{icon && (
|
|
149
|
+
<View
|
|
150
|
+
style={{
|
|
151
|
+
marginRight: IOSelectionListItemVisualParams.iconMargin
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
<Icon
|
|
155
|
+
name={icon}
|
|
156
|
+
color="grey-300"
|
|
157
|
+
size={IOSelectionListItemVisualParams.iconSize}
|
|
158
|
+
/>
|
|
159
|
+
</View>
|
|
160
|
+
)}
|
|
161
|
+
|
|
162
|
+
<H6 color={"black"} style={{ flexShrink: 1 }}>
|
|
163
|
+
{value}
|
|
164
|
+
</H6>
|
|
165
|
+
</View>
|
|
166
|
+
<HSpacer size={8} />
|
|
167
|
+
<View pointerEvents="none">
|
|
168
|
+
<AnimatedRadio checked={selected ?? toggleValue} />
|
|
169
|
+
</View>
|
|
170
|
+
</View>
|
|
171
|
+
{description && (
|
|
172
|
+
<View>
|
|
173
|
+
<VSpacer
|
|
174
|
+
size={IOSelectionListItemVisualParams.descriptionMargin}
|
|
175
|
+
/>
|
|
176
|
+
<LabelSmall weight="Regular" color={theme["textBody-tertiary"]}>
|
|
177
|
+
{description}
|
|
178
|
+
</LabelSmall>
|
|
179
|
+
</View>
|
|
180
|
+
)}
|
|
181
|
+
</Animated.View>
|
|
182
|
+
</Animated.View>
|
|
183
|
+
</Pressable>
|
|
184
|
+
);
|
|
185
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { GestureResponderEvent, Switch, View } from "react-native";
|
|
3
|
+
import {
|
|
4
|
+
IOSelectionListItemStyles,
|
|
5
|
+
IOSelectionListItemVisualParams,
|
|
6
|
+
IOStyles,
|
|
7
|
+
useIOTheme
|
|
8
|
+
} from "../../core";
|
|
9
|
+
import { IOIcons, Icon } from "../icons";
|
|
10
|
+
import { HSpacer, VSpacer } from "../spacer";
|
|
11
|
+
import { H6, LabelSmall, Link } from "../typography";
|
|
12
|
+
import { NativeSwitch } from "../switch/NativeSwitch";
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
label: string;
|
|
16
|
+
onSwitchValueChange?: (newValue: boolean) => void;
|
|
17
|
+
description?: string;
|
|
18
|
+
icon?: IOIcons;
|
|
19
|
+
action?: SwitchAction;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type SwitchAction = {
|
|
23
|
+
label: string;
|
|
24
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const DISABLED_OPACITY = 0.5;
|
|
28
|
+
|
|
29
|
+
type OwnProps = Props &
|
|
30
|
+
Pick<React.ComponentProps<typeof Switch>, "value" | "disabled">;
|
|
31
|
+
|
|
32
|
+
export const ListItemSwitch = React.memo(
|
|
33
|
+
({
|
|
34
|
+
label,
|
|
35
|
+
description,
|
|
36
|
+
icon,
|
|
37
|
+
value,
|
|
38
|
+
disabled,
|
|
39
|
+
action,
|
|
40
|
+
onSwitchValueChange
|
|
41
|
+
}: OwnProps) => {
|
|
42
|
+
const theme = useIOTheme();
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<View
|
|
46
|
+
testID="ListItemSwitch"
|
|
47
|
+
style={[
|
|
48
|
+
IOSelectionListItemStyles.listItem,
|
|
49
|
+
{
|
|
50
|
+
opacity: disabled ? DISABLED_OPACITY : 1
|
|
51
|
+
}
|
|
52
|
+
]}
|
|
53
|
+
pointerEvents={disabled ? "none" : "auto"}
|
|
54
|
+
needsOffscreenAlphaCompositing={true}
|
|
55
|
+
>
|
|
56
|
+
<View
|
|
57
|
+
style={[
|
|
58
|
+
IOSelectionListItemStyles.listItemInner,
|
|
59
|
+
{ alignItems: "center" }
|
|
60
|
+
]}
|
|
61
|
+
>
|
|
62
|
+
<View style={{ flexShrink: 1 }}>
|
|
63
|
+
<View style={[IOStyles.row, { flexShrink: 1 }]}>
|
|
64
|
+
{icon && (
|
|
65
|
+
<View
|
|
66
|
+
style={{
|
|
67
|
+
marginRight: IOSelectionListItemVisualParams.iconMargin
|
|
68
|
+
}}
|
|
69
|
+
>
|
|
70
|
+
<Icon
|
|
71
|
+
name={icon}
|
|
72
|
+
color="grey-300"
|
|
73
|
+
size={IOSelectionListItemVisualParams.iconSize}
|
|
74
|
+
/>
|
|
75
|
+
</View>
|
|
76
|
+
)}
|
|
77
|
+
<H6 color={"black"} style={{ flexShrink: 1 }}>
|
|
78
|
+
{label}
|
|
79
|
+
</H6>
|
|
80
|
+
</View>
|
|
81
|
+
{description && (
|
|
82
|
+
<>
|
|
83
|
+
<VSpacer
|
|
84
|
+
size={IOSelectionListItemVisualParams.descriptionMargin}
|
|
85
|
+
/>
|
|
86
|
+
<LabelSmall weight="Regular" color={theme["textBody-tertiary"]}>
|
|
87
|
+
{description}
|
|
88
|
+
</LabelSmall>
|
|
89
|
+
</>
|
|
90
|
+
)}
|
|
91
|
+
{action && (
|
|
92
|
+
<>
|
|
93
|
+
<VSpacer size={IOSelectionListItemVisualParams.actionMargin} />
|
|
94
|
+
<Link fontSize="small" onPress={action.onPress}>
|
|
95
|
+
{action.label}
|
|
96
|
+
</Link>
|
|
97
|
+
</>
|
|
98
|
+
)}
|
|
99
|
+
</View>
|
|
100
|
+
|
|
101
|
+
<HSpacer size={8} />
|
|
102
|
+
<View style={{ flexShrink: 0, alignSelf: "flex-start" }}>
|
|
103
|
+
<NativeSwitch value={value} onValueChange={onSwitchValueChange} />
|
|
104
|
+
</View>
|
|
105
|
+
</View>
|
|
106
|
+
</View>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
);
|