@pagopa/io-app-design-system 1.2.0 → 1.3.1
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/lib/commonjs/components/accordion/RawAccordion.js.map +1 -1
- package/lib/commonjs/components/alert/Alert.js.map +1 -1
- package/lib/commonjs/components/avatar/__test__/avatar.test.js.map +1 -1
- package/lib/commonjs/components/badge/Badge.js.map +1 -1
- package/lib/commonjs/components/banner/Banner.js +1 -1
- package/lib/commonjs/components/banner/Banner.js.map +1 -1
- package/lib/commonjs/components/banner/__test__/banner.test.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonExtendedOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonOutline.js +3 -3
- package/lib/commonjs/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/commonjs/components/buttons/ButtonSolid.js +3 -3
- package/lib/commonjs/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/commonjs/components/contentWrapper/ContentWrapper.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemAction.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemIDP.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/commonjs/components/listitems/PressableListItemsBase.js.map +1 -1
- package/lib/commonjs/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/commonjs/components/listitems/hooks/useListItemSpringAnimation.js.map +1 -1
- package/lib/commonjs/components/pictograms/Pictogram.js +7 -3
- package/lib/commonjs/components/pictograms/Pictogram.js.map +1 -1
- package/lib/commonjs/components/pictograms/svg/PictogramFocusOn.js +56 -0
- package/lib/commonjs/components/pictograms/svg/PictogramFocusOn.js.map +1 -0
- package/lib/commonjs/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/lib/commonjs/components/spacer/Spacer.js.map +1 -1
- package/lib/commonjs/components/typography/Body.js.map +1 -1
- package/lib/commonjs/components/typography/Factory.js.map +1 -1
- package/lib/commonjs/components/typography/H1.js.map +1 -1
- package/lib/commonjs/components/typography/H2.js.map +1 -1
- package/lib/commonjs/components/typography/H4.js.map +1 -1
- package/lib/commonjs/components/typography/H5.js.map +1 -1
- package/lib/commonjs/components/typography/H6.js.map +1 -1
- package/lib/commonjs/components/typography/Label.js.map +1 -1
- package/lib/commonjs/components/typography/LabelSmall.js.map +1 -1
- package/lib/commonjs/components/typography/Monospace.js.map +1 -1
- package/lib/commonjs/components/typography/common.js +2 -2
- package/lib/commonjs/components/typography/common.js.map +1 -1
- package/lib/commonjs/utils/image.js.map +1 -1
- package/lib/module/components/accordion/RawAccordion.js.map +1 -1
- package/lib/module/components/alert/Alert.js.map +1 -1
- package/lib/module/components/avatar/__test__/avatar.test.js.map +1 -1
- package/lib/module/components/badge/Badge.js.map +1 -1
- package/lib/module/components/banner/Banner.js +1 -1
- package/lib/module/components/banner/Banner.js.map +1 -1
- package/lib/module/components/banner/__test__/banner.test.js.map +1 -1
- package/lib/module/components/buttons/ButtonExtendedOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonOutline.js +3 -3
- package/lib/module/components/buttons/ButtonOutline.js.map +1 -1
- package/lib/module/components/buttons/ButtonSolid.js +3 -3
- package/lib/module/components/buttons/ButtonSolid.js.map +1 -1
- package/lib/module/components/buttons/IconButtonContained.js.map +1 -1
- package/lib/module/components/buttons/IconButtonSolid.js.map +1 -1
- package/lib/module/components/contentWrapper/ContentWrapper.js.map +1 -1
- package/lib/module/components/listitems/ListItemAction.js.map +1 -1
- package/lib/module/components/listitems/ListItemIDP.js.map +1 -1
- package/lib/module/components/listitems/ListItemNavAlert.js.map +1 -1
- package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
- package/lib/module/components/listitems/PressableListItemsBase.js.map +1 -1
- package/lib/module/components/listitems/__test__/listitem.test.js.map +1 -1
- package/lib/module/components/listitems/hooks/useListItemSpringAnimation.js.map +1 -1
- package/lib/module/components/pictograms/Pictogram.js +7 -3
- package/lib/module/components/pictograms/Pictogram.js.map +1 -1
- package/lib/module/components/pictograms/svg/PictogramFocusOn.js +48 -0
- package/lib/module/components/pictograms/svg/PictogramFocusOn.js.map +1 -0
- package/lib/module/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/lib/module/components/spacer/Spacer.js.map +1 -1
- package/lib/module/components/typography/Body.js.map +1 -1
- package/lib/module/components/typography/Factory.js.map +1 -1
- package/lib/module/components/typography/H1.js.map +1 -1
- package/lib/module/components/typography/H2.js.map +1 -1
- package/lib/module/components/typography/H4.js.map +1 -1
- package/lib/module/components/typography/H5.js.map +1 -1
- package/lib/module/components/typography/H6.js.map +1 -1
- package/lib/module/components/typography/Label.js.map +1 -1
- package/lib/module/components/typography/LabelSmall.js.map +1 -1
- package/lib/module/components/typography/Monospace.js.map +1 -1
- package/lib/module/components/typography/common.js +2 -2
- package/lib/module/components/typography/common.js.map +1 -1
- package/lib/module/utils/image.js.map +1 -1
- package/lib/typescript/components/alert/Alert.d.ts.map +1 -1
- package/lib/typescript/components/badge/Badge.d.ts.map +1 -1
- package/lib/typescript/components/banner/Banner.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonExtendedOutline.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonOutline.d.ts.map +1 -1
- package/lib/typescript/components/buttons/ButtonSolid.d.ts.map +1 -1
- package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -1
- package/lib/typescript/components/contentWrapper/ContentWrapper.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemAction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemIDP.d.ts +1 -1
- package/lib/typescript/components/listitems/ListItemIDP.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemNavAlert.d.ts.map +1 -1
- package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
- package/lib/typescript/components/listitems/PressableListItemsBase.d.ts.map +1 -1
- package/lib/typescript/components/listitems/hooks/useListItemSpringAnimation.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/Pictogram.d.ts +2 -0
- package/lib/typescript/components/pictograms/Pictogram.d.ts.map +1 -1
- package/lib/typescript/components/pictograms/svg/PictogramFocusOn.d.ts +5 -0
- package/lib/typescript/components/pictograms/svg/PictogramFocusOn.d.ts.map +1 -0
- package/lib/typescript/components/spacer/Spacer.d.ts.map +1 -1
- package/lib/typescript/components/typography/Body.d.ts.map +1 -1
- package/lib/typescript/components/typography/Factory.d.ts.map +1 -1
- package/lib/typescript/components/typography/H1.d.ts.map +1 -1
- package/lib/typescript/components/typography/H2.d.ts.map +1 -1
- package/lib/typescript/components/typography/H4.d.ts.map +1 -1
- package/lib/typescript/components/typography/H5.d.ts.map +1 -1
- package/lib/typescript/components/typography/H6.d.ts.map +1 -1
- package/lib/typescript/components/typography/Label.d.ts.map +1 -1
- package/lib/typescript/components/typography/LabelSmall.d.ts.map +1 -1
- package/lib/typescript/components/typography/Monospace.d.ts.map +1 -1
- package/lib/typescript/components/typography/common.d.ts +2 -2
- package/lib/typescript/components/typography/common.d.ts.map +1 -1
- package/lib/typescript/utils/image.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/components/Advice/index.tsx +1 -1
- package/src/components/accordion/RawAccordion.tsx +3 -3
- package/src/components/alert/Alert.tsx +4 -1
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/avatar/__test__/avatar.test.tsx +7 -4
- package/src/components/avatar/index.tsx +1 -1
- package/src/components/badge/Badge.tsx +16 -11
- package/src/components/banner/Banner.tsx +206 -195
- package/src/components/banner/__test__/banner.test.tsx +11 -9
- package/src/components/banner/index.tsx +1 -1
- package/src/components/buttons/ButtonExtendedOutline.tsx +80 -80
- package/src/components/buttons/ButtonOutline.tsx +278 -280
- package/src/components/buttons/ButtonSolid.tsx +142 -141
- package/src/components/buttons/IconButtonContained.tsx +17 -17
- package/src/components/buttons/IconButtonSolid.tsx +11 -11
- package/src/components/contentWrapper/ContentWrapper.tsx +12 -12
- package/src/components/contentWrapper/index.tsx +1 -1
- package/src/components/divider/index.tsx +1 -1
- package/src/components/icons/index.tsx +1 -1
- package/src/components/listitems/ListItemAction.tsx +120 -119
- package/src/components/listitems/ListItemIDP.tsx +115 -115
- package/src/components/listitems/ListItemNavAlert.tsx +114 -110
- package/src/components/listitems/ListItemTransaction.tsx +2 -6
- package/src/components/listitems/PressableListItemsBase.tsx +29 -29
- package/src/components/listitems/__test__/listitem.test.tsx +53 -15
- package/src/components/listitems/hooks/useListItemSpringAnimation.ts +54 -52
- package/src/components/pictograms/Pictogram.tsx +6 -3
- package/src/components/pictograms/svg/PictogramFocusOn.tsx +39 -0
- package/src/components/pictograms/svg/originals/PictogramFocusOn.svg +19 -0
- package/src/components/spacer/Spacer.tsx +21 -18
- package/src/components/spacer/index.tsx +1 -1
- package/src/components/typography/Body.tsx +10 -10
- package/src/components/typography/Factory.tsx +38 -38
- package/src/components/typography/H1.tsx +19 -19
- package/src/components/typography/H2.tsx +19 -19
- package/src/components/typography/H4.tsx +12 -12
- package/src/components/typography/H5.tsx +24 -24
- package/src/components/typography/H6.tsx +10 -10
- package/src/components/typography/Label.tsx +16 -16
- package/src/components/typography/LabelSmall.tsx +27 -28
- package/src/components/typography/Monospace.tsx +14 -14
- package/src/components/typography/common.tsx +20 -20
- package/src/components/typography/index.tsx +0 -1
- package/src/index.tsx +0 -1
- package/src/json-import.d.ts +3 -4
- package/src/utils/dates.ts +1 -1
- package/src/utils/image.ts +22 -22
|
@@ -1,154 +1,155 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
GestureResponderEvent,
|
|
4
|
+
Pressable,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
Text,
|
|
7
|
+
View
|
|
8
8
|
} from "react-native";
|
|
9
9
|
import Animated, {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
Extrapolate,
|
|
11
|
+
interpolate,
|
|
12
|
+
interpolateColor,
|
|
13
|
+
useAnimatedStyle,
|
|
14
|
+
useDerivedValue,
|
|
15
|
+
useSharedValue,
|
|
16
|
+
withSpring
|
|
17
17
|
} from "react-native-reanimated";
|
|
18
18
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
IOColors,
|
|
20
|
+
IOListItemStyles,
|
|
21
|
+
IOListItemVisualParams,
|
|
22
|
+
IOScaleValues,
|
|
23
|
+
IOSpringValues,
|
|
24
|
+
IOStyles,
|
|
25
|
+
hexToRgba,
|
|
26
|
+
useIOTheme
|
|
26
27
|
} from "../../core";
|
|
27
28
|
import { makeFontStyleObject } from "../../utils/fonts";
|
|
28
29
|
import { WithTestID } from "../../utils/types";
|
|
29
30
|
import { AnimatedIcon, IOIcons } from "../icons";
|
|
30
31
|
|
|
31
32
|
export type ListItemAction = WithTestID<{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
label: string;
|
|
34
|
+
variant: "primary" | "danger";
|
|
35
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
36
|
+
icon?: IOIcons;
|
|
37
|
+
// Accessibility
|
|
38
|
+
accessibilityLabel: string;
|
|
38
39
|
}>;
|
|
39
40
|
|
|
40
41
|
const styles = StyleSheet.create({
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
label: {
|
|
43
|
+
fontSize: 16,
|
|
44
|
+
lineHeight: 20,
|
|
45
|
+
...makeFontStyleObject("Regular", false, "ReadexPro")
|
|
46
|
+
}
|
|
46
47
|
});
|
|
47
48
|
|
|
48
49
|
export const ListItemAction = ({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
variant,
|
|
51
|
+
label,
|
|
52
|
+
onPress,
|
|
53
|
+
icon,
|
|
54
|
+
accessibilityLabel,
|
|
55
|
+
testID
|
|
55
56
|
}: ListItemAction) => {
|
|
56
|
-
|
|
57
|
+
const isPressed = useSharedValue(0);
|
|
57
58
|
|
|
58
|
-
|
|
59
|
+
const theme = useIOTheme();
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
const mapBackgroundStates: Record<string, string> = {
|
|
62
|
+
default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
|
|
63
|
+
pressed: IOColors[theme["listItem-pressed"]]
|
|
64
|
+
};
|
|
64
65
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
const mapForegroundColor: Record<
|
|
67
|
+
NonNullable<ListItemAction["variant"]>,
|
|
68
|
+
string
|
|
69
|
+
> = {
|
|
70
|
+
primary: IOColors[theme["interactiveElem-default"]],
|
|
71
|
+
danger: IOColors[theme.errorText]
|
|
72
|
+
};
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
// Scaling transformation applied when the button is pressed
|
|
75
|
+
const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
|
|
75
76
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
const progressPressed = useDerivedValue(() =>
|
|
78
|
+
withSpring(isPressed.value, IOSpringValues.button)
|
|
79
|
+
);
|
|
79
80
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
// Interpolate animation values from `isPressed` values
|
|
82
|
+
const animatedScaleStyle = useAnimatedStyle(() => {
|
|
83
|
+
const scale = interpolate(
|
|
84
|
+
progressPressed.value,
|
|
85
|
+
[0, 1],
|
|
86
|
+
[1, animationScaleValue],
|
|
87
|
+
Extrapolate.CLAMP
|
|
88
|
+
);
|
|
88
89
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
return {
|
|
91
|
+
transform: [{ scale }]
|
|
92
|
+
};
|
|
93
|
+
});
|
|
93
94
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
const animatedBackgroundStyle = useAnimatedStyle(() => {
|
|
96
|
+
const backgroundColor = interpolateColor(
|
|
97
|
+
progressPressed.value,
|
|
98
|
+
[0, 1],
|
|
99
|
+
[mapBackgroundStates.default, mapBackgroundStates.pressed]
|
|
100
|
+
);
|
|
100
101
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
return {
|
|
103
|
+
backgroundColor
|
|
104
|
+
};
|
|
105
|
+
});
|
|
105
106
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
107
|
+
const handlePressIn = useCallback(() => {
|
|
108
|
+
// eslint-disable-next-line functional/immutable-data
|
|
109
|
+
isPressed.value = 1;
|
|
110
|
+
}, [isPressed]);
|
|
111
|
+
const handlePressOut = useCallback(() => {
|
|
112
|
+
// eslint-disable-next-line functional/immutable-data
|
|
113
|
+
isPressed.value = 0;
|
|
114
|
+
}, [isPressed]);
|
|
114
115
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
return (
|
|
117
|
+
<Pressable
|
|
118
|
+
onPress={onPress}
|
|
119
|
+
onPressIn={handlePressIn}
|
|
120
|
+
onPressOut={handlePressOut}
|
|
121
|
+
onTouchEnd={handlePressOut}
|
|
122
|
+
accessible={true}
|
|
123
|
+
accessibilityLabel={accessibilityLabel}
|
|
124
|
+
accessibilityRole="button"
|
|
125
|
+
testID={testID}
|
|
126
|
+
>
|
|
127
|
+
<Animated.View
|
|
128
|
+
style={[IOListItemStyles.listItem, animatedBackgroundStyle]}
|
|
129
|
+
>
|
|
130
|
+
<Animated.View
|
|
131
|
+
style={[IOListItemStyles.listItemInner, animatedScaleStyle]}
|
|
125
132
|
>
|
|
126
|
-
|
|
127
|
-
|
|
133
|
+
{icon && (
|
|
134
|
+
<View style={{ marginRight: IOListItemVisualParams.iconMargin }}>
|
|
135
|
+
<AnimatedIcon
|
|
136
|
+
name={icon}
|
|
137
|
+
color={mapForegroundColor[variant] as IOColors}
|
|
138
|
+
size={IOListItemVisualParams.iconSize}
|
|
139
|
+
/>
|
|
140
|
+
</View>
|
|
141
|
+
)}
|
|
142
|
+
<View style={IOStyles.flex}>
|
|
143
|
+
<Text
|
|
144
|
+
style={[styles.label, { color: mapForegroundColor[variant] }]}
|
|
128
145
|
>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
color={mapForegroundColor[variant] as IOColors}
|
|
137
|
-
size={IOListItemVisualParams.iconSize}
|
|
138
|
-
/>
|
|
139
|
-
</View>
|
|
140
|
-
)}
|
|
141
|
-
<View style={IOStyles.flex}>
|
|
142
|
-
<Text
|
|
143
|
-
style={[styles.label, { color: mapForegroundColor[variant] }]}
|
|
144
|
-
>
|
|
145
|
-
{label}
|
|
146
|
-
</Text>
|
|
147
|
-
</View>
|
|
148
|
-
</Animated.View>
|
|
149
|
-
</Animated.View>
|
|
150
|
-
</Pressable>
|
|
151
|
-
);
|
|
146
|
+
{label}
|
|
147
|
+
</Text>
|
|
148
|
+
</View>
|
|
149
|
+
</Animated.View>
|
|
150
|
+
</Animated.View>
|
|
151
|
+
</Pressable>
|
|
152
|
+
);
|
|
152
153
|
};
|
|
153
154
|
|
|
154
155
|
export default ListItemAction;
|
|
@@ -1,149 +1,149 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { useCallback } from "react";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
GestureResponderEvent,
|
|
5
|
+
Image,
|
|
6
|
+
ImageSourcePropType,
|
|
7
|
+
Platform,
|
|
8
|
+
Pressable,
|
|
9
|
+
StyleSheet,
|
|
10
|
+
Text
|
|
11
11
|
} from "react-native";
|
|
12
12
|
import Animated, {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
Extrapolate,
|
|
14
|
+
interpolate,
|
|
15
|
+
useAnimatedStyle,
|
|
16
|
+
useDerivedValue,
|
|
17
|
+
useSharedValue,
|
|
18
|
+
withSpring
|
|
19
19
|
} from "react-native-reanimated";
|
|
20
20
|
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
IOColors,
|
|
22
|
+
IOListItemIDPHSpacing,
|
|
23
|
+
IOListItemIDPRadius,
|
|
24
|
+
IOListItemIDPSavedVSpacing,
|
|
25
|
+
IOListItemIDPVSpacing,
|
|
26
|
+
IOListItemLogoMargin,
|
|
27
|
+
IOScaleValues,
|
|
28
|
+
IOSpringValues
|
|
29
29
|
} from "../../core";
|
|
30
30
|
import { toAndroidCacheTimestamp } from "../../utils/dates";
|
|
31
31
|
import { makeFontStyleObject } from "../../utils/fonts";
|
|
32
32
|
import { WithTestID } from "../../utils/types";
|
|
33
33
|
|
|
34
34
|
type ListItemIDP = WithTestID<{
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
name: string;
|
|
36
|
+
localLogo: ImageSourcePropType;
|
|
37
|
+
logo: ImageSourcePropType;
|
|
38
|
+
saved?: boolean;
|
|
39
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
40
|
+
urlLogoIDP: string;
|
|
41
41
|
}>;
|
|
42
42
|
|
|
43
43
|
const styles = StyleSheet.create({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
44
|
+
button: {
|
|
45
|
+
borderWidth: 1,
|
|
46
|
+
borderColor: IOColors["grey-100"],
|
|
47
|
+
borderRadius: IOListItemIDPRadius,
|
|
48
|
+
backgroundColor: IOColors.white,
|
|
49
|
+
flexDirection: "row",
|
|
50
|
+
justifyContent: "space-between",
|
|
51
|
+
alignItems: "center",
|
|
52
|
+
paddingVertical: IOListItemIDPVSpacing,
|
|
53
|
+
paddingHorizontal: IOListItemIDPHSpacing
|
|
54
|
+
},
|
|
55
|
+
idpName: {
|
|
56
|
+
color: IOColors["grey-700"],
|
|
57
|
+
fontSize: 12,
|
|
58
|
+
lineHeight: 16,
|
|
59
|
+
alignSelf: "center",
|
|
60
|
+
textTransform: "uppercase",
|
|
61
|
+
flexShrink: 1,
|
|
62
|
+
...makeFontStyleObject("Regular", false, "ReadexPro")
|
|
63
|
+
},
|
|
64
|
+
idpLogo: {
|
|
65
|
+
marginStart: IOListItemLogoMargin,
|
|
66
|
+
width: 120,
|
|
67
|
+
height: 30,
|
|
68
|
+
resizeMode: "contain"
|
|
69
|
+
}
|
|
70
70
|
});
|
|
71
71
|
|
|
72
72
|
// https://github.com/facebook/react-native/issues/12606
|
|
73
73
|
// Image cache forced refresh for Android by appending
|
|
74
74
|
// the `ts` query parameter as DDMMYYYY to simulate a 24h TTL.
|
|
75
75
|
const androidIdpLogoForcedRefreshed = () =>
|
|
76
|
-
|
|
76
|
+
Platform.OS === "android" ? `?ts=${toAndroidCacheTimestamp()}` : "";
|
|
77
77
|
|
|
78
78
|
export const ListItemIDP = ({
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
79
|
+
name,
|
|
80
|
+
localLogo,
|
|
81
|
+
logo,
|
|
82
|
+
saved,
|
|
83
|
+
onPress,
|
|
84
|
+
testID
|
|
85
85
|
}: ListItemIDP) => {
|
|
86
|
-
|
|
86
|
+
const isPressed = useSharedValue(0);
|
|
87
87
|
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
// Scaling transformation applied when the button is pressed
|
|
89
|
+
const animationScaleValue = IOScaleValues?.magnifiedButton?.pressedState;
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
const scaleTraversed = useDerivedValue(() =>
|
|
92
|
+
withSpring(isPressed.value, IOSpringValues.button)
|
|
93
|
+
);
|
|
94
94
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
// Interpolate animation values from `isPressed` values
|
|
96
|
+
const animatedStyle = useAnimatedStyle(() => {
|
|
97
|
+
const scale = interpolate(
|
|
98
|
+
scaleTraversed.value,
|
|
99
|
+
[0, 1],
|
|
100
|
+
[1, animationScaleValue],
|
|
101
|
+
Extrapolate.CLAMP
|
|
102
|
+
);
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
return {
|
|
105
|
+
transform: [{ scale }]
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
const handlePressIn = useCallback(() => {
|
|
110
|
+
// eslint-disable-next-line functional/immutable-data
|
|
111
|
+
isPressed.value = 1;
|
|
112
|
+
}, [isPressed]);
|
|
113
|
+
const handlePressOut = useCallback(() => {
|
|
114
|
+
// eslint-disable-next-line functional/immutable-data
|
|
115
|
+
isPressed.value = 0;
|
|
116
|
+
}, [isPressed]);
|
|
117
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
|
-
|
|
118
|
+
// eslint-disable-next-line no-console
|
|
119
|
+
const urlLogoIDP = localLogo
|
|
120
|
+
? localLogo
|
|
121
|
+
: {
|
|
122
|
+
uri: `${logo}${androidIdpLogoForcedRefreshed()}`
|
|
123
|
+
};
|
|
124
|
+
return (
|
|
125
|
+
<Pressable
|
|
126
|
+
onPress={onPress}
|
|
127
|
+
onPressIn={handlePressIn}
|
|
128
|
+
onPressOut={handlePressOut}
|
|
129
|
+
onTouchEnd={handlePressOut}
|
|
130
|
+
accessible={true}
|
|
131
|
+
accessibilityRole={"button"}
|
|
132
|
+
accessibilityLabel={name}
|
|
133
|
+
testID={testID}
|
|
134
|
+
>
|
|
135
|
+
<Animated.View
|
|
136
|
+
style={[
|
|
137
|
+
styles.button,
|
|
138
|
+
saved && { paddingVertical: IOListItemIDPSavedVSpacing },
|
|
139
|
+
animatedStyle
|
|
140
|
+
]}
|
|
141
|
+
>
|
|
142
|
+
<Text style={styles.idpName}>{name}</Text>
|
|
143
|
+
<Image source={urlLogoIDP} style={styles.idpLogo} />
|
|
144
|
+
</Animated.View>
|
|
145
|
+
</Pressable>
|
|
146
|
+
);
|
|
147
147
|
};
|
|
148
148
|
|
|
149
149
|
export default ListItemIDP;
|