@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,20 +1,22 @@
|
|
|
1
1
|
import React, { useCallback } from "react";
|
|
2
|
-
import {
|
|
3
|
-
GestureResponderEvent,
|
|
4
|
-
Pressable,
|
|
5
|
-
StyleSheet
|
|
6
|
-
} from "react-native";
|
|
2
|
+
import { GestureResponderEvent, Pressable, StyleSheet } from "react-native";
|
|
7
3
|
import Animated, {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
4
|
+
Extrapolate,
|
|
5
|
+
interpolate,
|
|
6
|
+
interpolateColor,
|
|
7
|
+
useAnimatedProps,
|
|
8
|
+
useAnimatedStyle,
|
|
9
|
+
useDerivedValue,
|
|
10
|
+
useSharedValue,
|
|
11
|
+
withSpring
|
|
16
12
|
} from "react-native-reanimated";
|
|
17
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
IOButtonStyles,
|
|
15
|
+
IOColors,
|
|
16
|
+
IOScaleValues,
|
|
17
|
+
IOSpringValues,
|
|
18
|
+
hexToRgba
|
|
19
|
+
} from "../../core/";
|
|
18
20
|
import { makeFontStyleObject } from "../../utils/fonts";
|
|
19
21
|
import { WithTestID } from "../../utils/types";
|
|
20
22
|
import { AnimatedIcon, IOIcons, IconClassComponent } from "../icons";
|
|
@@ -22,308 +24,304 @@ import { HSpacer } from "../spacer/Spacer";
|
|
|
22
24
|
|
|
23
25
|
type ColorButtonOutline = "primary" | "neutral" | "contrast" | "danger";
|
|
24
26
|
export type ButtonOutline = WithTestID<{
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
27
|
+
color?: ColorButtonOutline;
|
|
28
|
+
label: string;
|
|
29
|
+
small?: boolean;
|
|
30
|
+
fullWidth?: boolean;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
// Icons
|
|
33
|
+
icon?: IOIcons;
|
|
34
|
+
iconPosition?: "start" | "end";
|
|
35
|
+
// Accessibility
|
|
36
|
+
accessibilityLabel: string;
|
|
37
|
+
accessibilityHint?: string;
|
|
38
|
+
onPress: (event: GestureResponderEvent) => void;
|
|
37
39
|
}>;
|
|
38
40
|
|
|
39
41
|
type ColorStates = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
border: {
|
|
43
|
+
default: string;
|
|
44
|
+
pressed: string;
|
|
45
|
+
disabled: string;
|
|
46
|
+
};
|
|
47
|
+
background: {
|
|
48
|
+
default: string;
|
|
49
|
+
pressed: string;
|
|
50
|
+
disabled: string;
|
|
51
|
+
};
|
|
52
|
+
label: {
|
|
53
|
+
default: string;
|
|
54
|
+
pressed: string;
|
|
55
|
+
disabled: string;
|
|
56
|
+
};
|
|
55
57
|
};
|
|
56
58
|
|
|
57
59
|
const mapColorStates: Record<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
NonNullable<ButtonOutline["color"]>,
|
|
61
|
+
ColorStates
|
|
60
62
|
> = {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
63
|
+
// Primary button
|
|
64
|
+
primary: {
|
|
65
|
+
border: {
|
|
66
|
+
default: IOColors["blueIO-500"],
|
|
67
|
+
pressed: IOColors["blueIO-600"],
|
|
68
|
+
disabled: IOColors["grey-200"]
|
|
69
|
+
},
|
|
70
|
+
background: {
|
|
71
|
+
default: hexToRgba(IOColors["blueIO-50"], 0),
|
|
72
|
+
pressed: hexToRgba(IOColors["blueIO-50"], 1),
|
|
73
|
+
disabled: "transparent"
|
|
74
|
+
},
|
|
75
|
+
label: {
|
|
76
|
+
default: IOColors["blueIO-500"],
|
|
77
|
+
pressed: IOColors["blueIO-600"],
|
|
78
|
+
disabled: IOColors["grey-700"]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
// Neutral button
|
|
82
|
+
neutral: {
|
|
83
|
+
border: {
|
|
84
|
+
default: IOColors.grey,
|
|
85
|
+
pressed: IOColors.bluegrey,
|
|
86
|
+
disabled: IOColors.bluegreyLight
|
|
87
|
+
},
|
|
88
|
+
background: {
|
|
89
|
+
default: IOColors.white,
|
|
90
|
+
pressed: IOColors.greyUltraLight,
|
|
91
|
+
disabled: "transparent"
|
|
92
|
+
},
|
|
93
|
+
label: {
|
|
94
|
+
default: IOColors.bluegrey,
|
|
95
|
+
pressed: IOColors.bluegreyDark,
|
|
96
|
+
disabled: IOColors.grey
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
// Contrast button
|
|
100
|
+
contrast: {
|
|
101
|
+
border: {
|
|
102
|
+
default: IOColors.white,
|
|
103
|
+
pressed: IOColors.white,
|
|
104
|
+
disabled: IOColors["blueIO-200"]
|
|
78
105
|
},
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
106
|
+
background: {
|
|
107
|
+
default: hexToRgba(IOColors["blueIO-600"], 0),
|
|
108
|
+
pressed: IOColors["blueIO-600"],
|
|
109
|
+
disabled: "transparent"
|
|
110
|
+
},
|
|
111
|
+
label: {
|
|
112
|
+
default: IOColors.white,
|
|
113
|
+
pressed: IOColors.white,
|
|
114
|
+
disabled: IOColors["blueIO-200"]
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
// Danger button
|
|
118
|
+
danger: {
|
|
119
|
+
border: {
|
|
120
|
+
default: IOColors.red,
|
|
121
|
+
pressed: IOColors.red,
|
|
122
|
+
disabled: IOColors.bluegreyLight
|
|
96
123
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
pressed: IOColors.white,
|
|
102
|
-
disabled: IOColors["blueIO-200"]
|
|
103
|
-
},
|
|
104
|
-
background: {
|
|
105
|
-
default: hexToRgba(IOColors["blueIO-600"], 0),
|
|
106
|
-
pressed: IOColors["blueIO-600"],
|
|
107
|
-
disabled: "transparent"
|
|
108
|
-
},
|
|
109
|
-
label: {
|
|
110
|
-
default: IOColors.white,
|
|
111
|
-
pressed: IOColors.white,
|
|
112
|
-
disabled: IOColors["blueIO-200"]
|
|
113
|
-
}
|
|
124
|
+
background: {
|
|
125
|
+
default: hexToRgba(IOColors.red, 0),
|
|
126
|
+
pressed: hexToRgba(IOColors.red, 0.15),
|
|
127
|
+
disabled: "transparent"
|
|
114
128
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
pressed: IOColors.red,
|
|
120
|
-
disabled: IOColors.bluegreyLight
|
|
121
|
-
},
|
|
122
|
-
background: {
|
|
123
|
-
default: hexToRgba(IOColors.red, 0),
|
|
124
|
-
pressed: hexToRgba(IOColors.red, 0.15),
|
|
125
|
-
disabled: "transparent"
|
|
126
|
-
},
|
|
127
|
-
label: {
|
|
128
|
-
default: IOColors.red,
|
|
129
|
-
pressed: IOColors.red,
|
|
130
|
-
disabled: IOColors.grey
|
|
131
|
-
}
|
|
129
|
+
label: {
|
|
130
|
+
default: IOColors.red,
|
|
131
|
+
pressed: IOColors.red,
|
|
132
|
+
disabled: IOColors.grey
|
|
132
133
|
}
|
|
134
|
+
}
|
|
133
135
|
};
|
|
134
136
|
|
|
135
137
|
const DISABLED_OPACITY = 0.5;
|
|
136
138
|
|
|
137
139
|
const IOButtonStylesLocal = StyleSheet.create({
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
140
|
+
label: {
|
|
141
|
+
...makeFontStyleObject("Regular", false, "ReadexPro")
|
|
142
|
+
},
|
|
143
|
+
buttonWithBorder: {
|
|
144
|
+
borderWidth: 2
|
|
145
|
+
}
|
|
144
146
|
});
|
|
145
147
|
|
|
146
148
|
export const ButtonOutline = ({
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}:
|
|
159
|
-
|
|
160
|
-
const isPressed: Animated.SharedValue<number> = useSharedValue(0);
|
|
149
|
+
color = "primary",
|
|
150
|
+
label,
|
|
151
|
+
small = false,
|
|
152
|
+
fullWidth = false,
|
|
153
|
+
disabled = false,
|
|
154
|
+
icon,
|
|
155
|
+
iconPosition = "start",
|
|
156
|
+
onPress,
|
|
157
|
+
accessibilityLabel,
|
|
158
|
+
accessibilityHint,
|
|
159
|
+
testID
|
|
160
|
+
}: ButtonOutline) => {
|
|
161
|
+
const isPressed: Animated.SharedValue<number> = useSharedValue(0);
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
// Scaling transformation applied when the button is pressed
|
|
164
|
+
const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
|
|
164
165
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
// Using a spring-based animation for our interpolations
|
|
167
|
+
const progressPressed = useDerivedValue(() =>
|
|
168
|
+
withSpring(isPressed.value, IOSpringValues.button)
|
|
169
|
+
);
|
|
169
170
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
171
|
+
// Interpolate animation values from `isPressed` values
|
|
172
|
+
const pressedAnimationStyle = useAnimatedStyle(() => {
|
|
173
|
+
// Link color states to the pressed states
|
|
174
|
+
const backgroundColor = interpolateColor(
|
|
175
|
+
progressPressed.value,
|
|
176
|
+
[0, 1],
|
|
177
|
+
[
|
|
178
|
+
mapColorStates[color].background.default,
|
|
179
|
+
mapColorStates[color].background.pressed
|
|
180
|
+
]
|
|
181
|
+
);
|
|
181
182
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
183
|
+
const borderColor = interpolateColor(
|
|
184
|
+
progressPressed.value,
|
|
185
|
+
[0, 1],
|
|
186
|
+
[
|
|
187
|
+
mapColorStates[color].border.default,
|
|
188
|
+
mapColorStates[color].border.pressed
|
|
189
|
+
]
|
|
190
|
+
);
|
|
190
191
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
192
|
+
// Scale down button slightly when pressed
|
|
193
|
+
const scale = interpolate(
|
|
194
|
+
progressPressed.value,
|
|
195
|
+
[0, 1],
|
|
196
|
+
[1, animationScaleValue],
|
|
197
|
+
Extrapolate.CLAMP
|
|
198
|
+
);
|
|
198
199
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
200
|
+
return {
|
|
201
|
+
borderColor,
|
|
202
|
+
backgroundColor,
|
|
203
|
+
transform: [{ scale }]
|
|
204
|
+
};
|
|
205
|
+
});
|
|
205
206
|
|
|
206
|
-
|
|
207
|
-
|
|
207
|
+
const pressedColorLabelAnimationStyle = useAnimatedStyle(() => {
|
|
208
|
+
// Link color states to the pressed states
|
|
208
209
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
210
|
+
const labelColor = interpolateColor(
|
|
211
|
+
progressPressed.value,
|
|
212
|
+
[0, 1],
|
|
213
|
+
[
|
|
214
|
+
mapColorStates[color].border.default,
|
|
215
|
+
mapColorStates[color].border.pressed
|
|
216
|
+
]
|
|
217
|
+
);
|
|
217
218
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
219
|
+
return {
|
|
220
|
+
color: labelColor
|
|
221
|
+
};
|
|
222
|
+
});
|
|
222
223
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
);
|
|
233
|
-
return { color: iconColor };
|
|
234
|
-
});
|
|
224
|
+
// Animate the <Icon> color prop
|
|
225
|
+
const pressedColorIconAnimationStyle = useAnimatedProps(() => {
|
|
226
|
+
const iconColor = interpolateColor(
|
|
227
|
+
progressPressed.value,
|
|
228
|
+
[0, 1],
|
|
229
|
+
[mapColorStates[color].label.default, mapColorStates[color].label.pressed]
|
|
230
|
+
);
|
|
231
|
+
return { color: iconColor };
|
|
232
|
+
});
|
|
235
233
|
|
|
236
|
-
|
|
237
|
-
|
|
234
|
+
const AnimatedIconClassComponent =
|
|
235
|
+
Animated.createAnimatedComponent(IconClassComponent);
|
|
238
236
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
237
|
+
const onPressIn = useCallback(() => {
|
|
238
|
+
// eslint-disable-next-line functional/immutable-data
|
|
239
|
+
isPressed.value = 1;
|
|
240
|
+
}, [isPressed]);
|
|
241
|
+
const onPressOut = useCallback(() => {
|
|
242
|
+
// eslint-disable-next-line functional/immutable-data
|
|
243
|
+
isPressed.value = 0;
|
|
244
|
+
}, [isPressed]);
|
|
247
245
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
246
|
+
const Button = () => (
|
|
247
|
+
<Pressable
|
|
248
|
+
accessibilityLabel={accessibilityLabel}
|
|
249
|
+
accessibilityHint={accessibilityHint}
|
|
250
|
+
accessibilityRole={"button"}
|
|
251
|
+
testID={testID}
|
|
252
|
+
onPress={onPress}
|
|
253
|
+
onPressIn={onPressIn}
|
|
254
|
+
onPressOut={onPressOut}
|
|
255
|
+
accessible={true}
|
|
256
|
+
disabled={disabled}
|
|
257
|
+
style={!fullWidth ? IOButtonStyles.dimensionsDefault : {}}
|
|
258
|
+
>
|
|
259
|
+
<Animated.View
|
|
260
|
+
style={[
|
|
261
|
+
IOButtonStyles.button,
|
|
262
|
+
IOButtonStylesLocal.buttonWithBorder,
|
|
263
|
+
iconPosition === "end" && { flexDirection: "row-reverse" },
|
|
264
|
+
small
|
|
265
|
+
? IOButtonStyles.buttonSizeSmall
|
|
266
|
+
: IOButtonStyles.buttonSizeDefault,
|
|
267
|
+
disabled
|
|
268
|
+
? {
|
|
269
|
+
backgroundColor: mapColorStates[color]?.background?.disabled,
|
|
270
|
+
borderColor: mapColorStates[color]?.border?.disabled,
|
|
271
|
+
opacity: DISABLED_OPACITY
|
|
272
|
+
}
|
|
273
|
+
: {
|
|
274
|
+
backgroundColor: mapColorStates[color]?.background?.default,
|
|
275
|
+
borderColor: mapColorStates[color]?.border.default
|
|
276
|
+
},
|
|
277
|
+
/* Prevent Reanimated from overriding background colors
|
|
280
278
|
if button is disabled */
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
279
|
+
!disabled && pressedAnimationStyle
|
|
280
|
+
]}
|
|
281
|
+
>
|
|
282
|
+
{icon && (
|
|
283
|
+
<>
|
|
284
|
+
{!disabled ? (
|
|
285
|
+
<AnimatedIconClassComponent
|
|
286
|
+
name={icon}
|
|
287
|
+
animatedProps={pressedColorIconAnimationStyle}
|
|
288
|
+
color={mapColorStates[color]?.label?.default}
|
|
289
|
+
/>
|
|
290
|
+
) : (
|
|
291
|
+
<AnimatedIcon
|
|
292
|
+
name={icon}
|
|
293
|
+
color={mapColorStates[color]?.label?.disabled}
|
|
294
|
+
/>
|
|
295
|
+
)}
|
|
296
|
+
<HSpacer size={8} />
|
|
297
|
+
</>
|
|
298
|
+
)}
|
|
299
|
+
<Animated.Text
|
|
300
|
+
style={[
|
|
301
|
+
IOButtonStylesLocal.label,
|
|
302
|
+
IOButtonStyles.label,
|
|
303
|
+
small
|
|
304
|
+
? IOButtonStyles.labelSizeSmall
|
|
305
|
+
: IOButtonStyles.labelSizeDefault,
|
|
306
|
+
disabled
|
|
307
|
+
? { color: mapColorStates[color]?.label?.disabled }
|
|
308
|
+
: { color: mapColorStates[color]?.label?.default },
|
|
309
|
+
!disabled && pressedColorLabelAnimationStyle
|
|
310
|
+
]}
|
|
311
|
+
numberOfLines={1}
|
|
312
|
+
ellipsizeMode="tail"
|
|
313
|
+
/* A11y-related props:
|
|
316
314
|
DON'T UNCOMMENT THEM */
|
|
317
|
-
|
|
315
|
+
/* allowFontScaling
|
|
318
316
|
maxFontSizeMultiplier={1.3} */
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
317
|
+
>
|
|
318
|
+
{label}
|
|
319
|
+
</Animated.Text>
|
|
320
|
+
</Animated.View>
|
|
321
|
+
</Pressable>
|
|
322
|
+
);
|
|
325
323
|
|
|
326
|
-
|
|
324
|
+
return <Button />;
|
|
327
325
|
};
|
|
328
326
|
|
|
329
327
|
export default ButtonOutline;
|