@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.
Files changed (265) hide show
  1. package/README.md +39 -4
  2. package/lib/commonjs/components/Advice/Advice.js +5 -7
  3. package/lib/commonjs/components/Advice/Advice.js.map +1 -1
  4. package/lib/commonjs/components/Advice/__test__/advice.test.js +2 -2
  5. package/lib/commonjs/components/Advice/__test__/advice.test.js.map +1 -1
  6. package/lib/commonjs/components/accordion/RawAccordion.js.map +1 -1
  7. package/lib/commonjs/components/badge/__test__/badge.test.js.map +1 -1
  8. package/lib/commonjs/components/buttons/ButtonLink.js +4 -5
  9. package/lib/commonjs/components/buttons/ButtonLink.js.map +1 -1
  10. package/lib/commonjs/components/buttons/IconButton.js +0 -2
  11. package/lib/commonjs/components/buttons/IconButton.js.map +1 -1
  12. package/lib/commonjs/components/buttons/IconButtonContained.js +131 -0
  13. package/lib/commonjs/components/buttons/IconButtonContained.js.map +1 -0
  14. package/lib/commonjs/components/buttons/IconButtonSolid.js +109 -0
  15. package/lib/commonjs/components/buttons/IconButtonSolid.js.map +1 -0
  16. package/lib/commonjs/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
  17. package/lib/commonjs/components/buttons/__test__/button.test.js +27 -0
  18. package/lib/commonjs/components/buttons/__test__/button.test.js.map +1 -1
  19. package/lib/commonjs/components/buttons/index.js +30 -8
  20. package/lib/commonjs/components/buttons/index.js.map +1 -1
  21. package/lib/commonjs/components/checkbox/AnimatedCheckbox.js +1 -1
  22. package/lib/commonjs/components/checkbox/AnimatedCheckbox.js.map +1 -1
  23. package/lib/commonjs/components/icons/index.js +0 -18
  24. package/lib/commonjs/components/icons/index.js.map +1 -1
  25. package/lib/commonjs/components/index.js +72 -72
  26. package/lib/commonjs/components/index.js.map +1 -1
  27. package/lib/commonjs/components/layout/GradientBottomActions.js +90 -0
  28. package/lib/commonjs/components/layout/GradientBottomActions.js.map +1 -0
  29. package/lib/commonjs/components/layout/GradientScrollView.js +111 -0
  30. package/lib/commonjs/components/layout/GradientScrollView.js.map +1 -0
  31. package/lib/commonjs/components/layout/HeaderFirstLevel.js +62 -0
  32. package/lib/commonjs/components/layout/HeaderFirstLevel.js.map +1 -0
  33. package/lib/commonjs/components/layout/index.js +17 -0
  34. package/lib/commonjs/components/layout/index.js.map +1 -0
  35. package/lib/commonjs/components/listitems/ListItemCheckbox.js +135 -0
  36. package/lib/commonjs/components/listitems/ListItemCheckbox.js.map +1 -0
  37. package/lib/commonjs/components/listitems/ListItemInfo.js +3 -6
  38. package/lib/commonjs/components/listitems/ListItemInfo.js.map +1 -1
  39. package/lib/commonjs/components/listitems/ListItemInfoCopy.js +1 -4
  40. package/lib/commonjs/components/listitems/ListItemInfoCopy.js.map +1 -1
  41. package/lib/commonjs/components/listitems/ListItemRadio.js +136 -0
  42. package/lib/commonjs/components/listitems/ListItemRadio.js.map +1 -0
  43. package/lib/commonjs/components/listitems/ListItemSwitch.js +82 -0
  44. package/lib/commonjs/components/listitems/ListItemSwitch.js.map +1 -0
  45. package/lib/commonjs/components/listitems/ListItemTransaction.js.map +1 -1
  46. package/lib/commonjs/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
  47. package/lib/commonjs/components/listitems/index.js +33 -0
  48. package/lib/commonjs/components/listitems/index.js.map +1 -1
  49. package/lib/commonjs/components/logos/svg/LogoPaymentExtMaestro.js +3 -19
  50. package/lib/commonjs/components/logos/svg/LogoPaymentExtMaestro.js.map +1 -1
  51. package/lib/commonjs/components/logos/svg/LogoPaymentExtMastercard.js +5 -21
  52. package/lib/commonjs/components/logos/svg/LogoPaymentExtMastercard.js.map +1 -1
  53. package/lib/commonjs/components/logos/svg/LogoPaymentExtPayPal.js +9 -28
  54. package/lib/commonjs/components/logos/svg/LogoPaymentExtPayPal.js.map +1 -1
  55. package/lib/commonjs/components/logos/svg/LogoPaymentMaestro.js +8 -18
  56. package/lib/commonjs/components/logos/svg/LogoPaymentMaestro.js.map +1 -1
  57. package/lib/commonjs/components/logos/svg/LogoPaymentMastercard.js +7 -17
  58. package/lib/commonjs/components/logos/svg/LogoPaymentMastercard.js.map +1 -1
  59. package/lib/commonjs/components/logos/svg/LogoPaymentPayPal.js +5 -5
  60. package/lib/commonjs/components/logos/svg/LogoPaymentPayPal.js.map +1 -1
  61. package/lib/commonjs/components/radio/AnimatedRadio.js +1 -1
  62. package/lib/commonjs/components/radio/AnimatedRadio.js.map +1 -1
  63. package/lib/commonjs/components/radio/RadioGroup.js +36 -0
  64. package/lib/commonjs/components/radio/RadioGroup.js.map +1 -0
  65. package/lib/commonjs/components/radio/index.js +11 -0
  66. package/lib/commonjs/components/radio/index.js.map +1 -1
  67. package/lib/commonjs/components/typography/H3.js +20 -49
  68. package/lib/commonjs/components/typography/H3.js.map +1 -1
  69. package/lib/commonjs/components/typography/Link.js +17 -23
  70. package/lib/commonjs/components/typography/Link.js.map +1 -1
  71. package/lib/commonjs/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
  72. package/lib/commonjs/core/IOColors.js +1 -1
  73. package/lib/commonjs/core/IOColors.js.map +1 -1
  74. package/lib/commonjs/core/IOSpacing.js +1 -1
  75. package/lib/commonjs/core/IOSpacing.js.map +1 -1
  76. package/lib/commonjs/core/IOStyles.js +7 -1
  77. package/lib/commonjs/core/IOStyles.js.map +1 -1
  78. package/lib/commonjs/index.js +11 -0
  79. package/lib/commonjs/index.js.map +1 -1
  80. package/lib/commonjs/json-import.d.js +2 -0
  81. package/lib/commonjs/json-import.d.js.map +1 -0
  82. package/lib/module/components/Advice/Advice.js +4 -6
  83. package/lib/module/components/Advice/Advice.js.map +1 -1
  84. package/lib/module/components/Advice/__test__/advice.test.js +1 -1
  85. package/lib/module/components/Advice/__test__/advice.test.js.map +1 -1
  86. package/lib/module/components/accordion/RawAccordion.js +1 -1
  87. package/lib/module/components/accordion/RawAccordion.js.map +1 -1
  88. package/lib/module/components/badge/__test__/badge.test.js.map +1 -1
  89. package/lib/module/components/buttons/ButtonLink.js +4 -5
  90. package/lib/module/components/buttons/ButtonLink.js.map +1 -1
  91. package/lib/module/components/buttons/IconButton.js +0 -2
  92. package/lib/module/components/buttons/IconButton.js.map +1 -1
  93. package/lib/module/components/buttons/IconButtonContained.js +122 -0
  94. package/lib/module/components/buttons/IconButtonContained.js.map +1 -0
  95. package/lib/module/components/buttons/IconButtonSolid.js +100 -0
  96. package/lib/module/components/buttons/IconButtonSolid.js.map +1 -0
  97. package/lib/module/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
  98. package/lib/module/components/buttons/__test__/button.test.js +27 -0
  99. package/lib/module/components/buttons/__test__/button.test.js.map +1 -1
  100. package/lib/module/components/buttons/index.js +4 -2
  101. package/lib/module/components/buttons/index.js.map +1 -1
  102. package/lib/module/components/checkbox/AnimatedCheckbox.js +3 -3
  103. package/lib/module/components/checkbox/AnimatedCheckbox.js.map +1 -1
  104. package/lib/module/components/icons/index.js +0 -1
  105. package/lib/module/components/icons/index.js.map +1 -1
  106. package/lib/module/components/index.js +13 -13
  107. package/lib/module/components/index.js.map +1 -1
  108. package/lib/module/components/layout/GradientBottomActions.js +79 -0
  109. package/lib/module/components/layout/GradientBottomActions.js.map +1 -0
  110. package/lib/module/components/layout/GradientScrollView.js +100 -0
  111. package/lib/module/components/layout/GradientScrollView.js.map +1 -0
  112. package/lib/module/components/layout/HeaderFirstLevel.js +52 -0
  113. package/lib/module/components/layout/HeaderFirstLevel.js.map +1 -0
  114. package/lib/module/components/layout/index.js +2 -0
  115. package/lib/module/components/layout/index.js.map +1 -0
  116. package/lib/module/components/listitems/ListItemCheckbox.js +126 -0
  117. package/lib/module/components/listitems/ListItemCheckbox.js.map +1 -0
  118. package/lib/module/components/listitems/ListItemInfo.js +3 -6
  119. package/lib/module/components/listitems/ListItemInfo.js.map +1 -1
  120. package/lib/module/components/listitems/ListItemInfoCopy.js +1 -4
  121. package/lib/module/components/listitems/ListItemInfoCopy.js.map +1 -1
  122. package/lib/module/components/listitems/ListItemRadio.js +127 -0
  123. package/lib/module/components/listitems/ListItemRadio.js.map +1 -0
  124. package/lib/module/components/listitems/ListItemSwitch.js +74 -0
  125. package/lib/module/components/listitems/ListItemSwitch.js.map +1 -0
  126. package/lib/module/components/listitems/ListItemTransaction.js.map +1 -1
  127. package/lib/module/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
  128. package/lib/module/components/listitems/index.js +3 -0
  129. package/lib/module/components/listitems/index.js.map +1 -1
  130. package/lib/module/components/logos/svg/LogoPaymentExtMaestro.js +3 -19
  131. package/lib/module/components/logos/svg/LogoPaymentExtMaestro.js.map +1 -1
  132. package/lib/module/components/logos/svg/LogoPaymentExtMastercard.js +5 -21
  133. package/lib/module/components/logos/svg/LogoPaymentExtMastercard.js.map +1 -1
  134. package/lib/module/components/logos/svg/LogoPaymentExtPayPal.js +10 -29
  135. package/lib/module/components/logos/svg/LogoPaymentExtPayPal.js.map +1 -1
  136. package/lib/module/components/logos/svg/LogoPaymentMaestro.js +9 -19
  137. package/lib/module/components/logos/svg/LogoPaymentMaestro.js.map +1 -1
  138. package/lib/module/components/logos/svg/LogoPaymentMastercard.js +8 -18
  139. package/lib/module/components/logos/svg/LogoPaymentMastercard.js.map +1 -1
  140. package/lib/module/components/logos/svg/LogoPaymentPayPal.js +5 -5
  141. package/lib/module/components/logos/svg/LogoPaymentPayPal.js.map +1 -1
  142. package/lib/module/components/radio/AnimatedRadio.js +3 -3
  143. package/lib/module/components/radio/AnimatedRadio.js.map +1 -1
  144. package/lib/module/components/radio/RadioGroup.js +28 -0
  145. package/lib/module/components/radio/RadioGroup.js.map +1 -0
  146. package/lib/module/components/radio/index.js +1 -0
  147. package/lib/module/components/radio/index.js.map +1 -1
  148. package/lib/module/components/typography/H3.js +19 -47
  149. package/lib/module/components/typography/H3.js.map +1 -1
  150. package/lib/module/components/typography/Link.js +17 -23
  151. package/lib/module/components/typography/Link.js.map +1 -1
  152. package/lib/module/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
  153. package/lib/module/core/IOColors.js +1 -1
  154. package/lib/module/core/IOColors.js.map +1 -1
  155. package/lib/module/core/IOSpacing.js +1 -1
  156. package/lib/module/core/IOSpacing.js.map +1 -1
  157. package/lib/module/core/IOStyles.js +5 -0
  158. package/lib/module/core/IOStyles.js.map +1 -1
  159. package/lib/module/index.js +1 -0
  160. package/lib/module/index.js.map +1 -1
  161. package/lib/module/json-import.d.js +2 -0
  162. package/lib/module/json-import.d.js.map +1 -0
  163. package/lib/typescript/components/Advice/Advice.d.ts +7 -3
  164. package/lib/typescript/components/Advice/Advice.d.ts.map +1 -1
  165. package/lib/typescript/components/accordion/RawAccordion.d.ts +2 -2
  166. package/lib/typescript/components/accordion/RawAccordion.d.ts.map +1 -1
  167. package/lib/typescript/components/buttons/ButtonLink.d.ts.map +1 -1
  168. package/lib/typescript/components/buttons/IconButton.d.ts.map +1 -1
  169. package/lib/typescript/components/buttons/IconButtonContained.d.ts +15 -0
  170. package/lib/typescript/components/buttons/IconButtonContained.d.ts.map +1 -0
  171. package/lib/typescript/components/buttons/IconButtonSolid.d.ts +15 -0
  172. package/lib/typescript/components/buttons/IconButtonSolid.d.ts.map +1 -0
  173. package/lib/typescript/components/buttons/index.d.ts +4 -2
  174. package/lib/typescript/components/buttons/index.d.ts.map +1 -1
  175. package/lib/typescript/components/checkbox/AnimatedCheckbox.d.ts.map +1 -1
  176. package/lib/typescript/components/icons/index.d.ts +0 -1
  177. package/lib/typescript/components/icons/index.d.ts.map +1 -1
  178. package/lib/typescript/components/index.d.ts +13 -13
  179. package/lib/typescript/components/index.d.ts.map +1 -1
  180. package/lib/typescript/components/layout/GradientBottomActions.d.ts +22 -0
  181. package/lib/typescript/components/layout/GradientBottomActions.d.ts.map +1 -0
  182. package/lib/typescript/components/layout/GradientScrollView.d.ts +14 -0
  183. package/lib/typescript/components/layout/GradientScrollView.d.ts.map +1 -0
  184. package/lib/typescript/components/layout/HeaderFirstLevel.d.ts +11 -0
  185. package/lib/typescript/components/layout/HeaderFirstLevel.d.ts.map +1 -0
  186. package/lib/typescript/components/layout/index.d.ts +2 -0
  187. package/lib/typescript/components/layout/index.d.ts.map +1 -0
  188. package/lib/typescript/components/listitems/ListItemCheckbox.d.ts +21 -0
  189. package/lib/typescript/components/listitems/ListItemCheckbox.d.ts.map +1 -0
  190. package/lib/typescript/components/listitems/ListItemInfo.d.ts.map +1 -1
  191. package/lib/typescript/components/listitems/ListItemInfoCopy.d.ts.map +1 -1
  192. package/lib/typescript/components/listitems/ListItemRadio.d.ts +22 -0
  193. package/lib/typescript/components/listitems/ListItemRadio.d.ts.map +1 -0
  194. package/lib/typescript/components/listitems/ListItemSwitch.d.ts +18 -0
  195. package/lib/typescript/components/listitems/ListItemSwitch.d.ts.map +1 -0
  196. package/lib/typescript/components/listitems/ListItemTransaction.d.ts.map +1 -1
  197. package/lib/typescript/components/listitems/index.d.ts +3 -0
  198. package/lib/typescript/components/listitems/index.d.ts.map +1 -1
  199. package/lib/typescript/components/logos/svg/LogoPaymentExtMaestro.d.ts.map +1 -1
  200. package/lib/typescript/components/logos/svg/LogoPaymentExtMastercard.d.ts +2 -2
  201. package/lib/typescript/components/logos/svg/LogoPaymentExtMastercard.d.ts.map +1 -1
  202. package/lib/typescript/components/logos/svg/LogoPaymentExtPayPal.d.ts.map +1 -1
  203. package/lib/typescript/components/logos/svg/LogoPaymentMaestro.d.ts.map +1 -1
  204. package/lib/typescript/components/logos/svg/LogoPaymentMastercard.d.ts.map +1 -1
  205. package/lib/typescript/components/radio/AnimatedRadio.d.ts.map +1 -1
  206. package/lib/typescript/components/radio/RadioGroup.d.ts +22 -0
  207. package/lib/typescript/components/radio/RadioGroup.d.ts.map +1 -0
  208. package/lib/typescript/components/radio/index.d.ts +1 -0
  209. package/lib/typescript/components/radio/index.d.ts.map +1 -1
  210. package/lib/typescript/components/typography/H3.d.ts +11 -30
  211. package/lib/typescript/components/typography/H3.d.ts.map +1 -1
  212. package/lib/typescript/components/typography/Link.d.ts +4 -4
  213. package/lib/typescript/components/typography/Link.d.ts.map +1 -1
  214. package/lib/typescript/core/IOColors.d.ts +2 -1
  215. package/lib/typescript/core/IOColors.d.ts.map +1 -1
  216. package/lib/typescript/core/IOSpacing.d.ts +1 -1
  217. package/lib/typescript/core/IOSpacing.d.ts.map +1 -1
  218. package/lib/typescript/core/IOStyles.d.ts +6 -2
  219. package/lib/typescript/core/IOStyles.d.ts.map +1 -1
  220. package/lib/typescript/index.d.ts +1 -0
  221. package/lib/typescript/index.d.ts.map +1 -1
  222. package/package.json +9 -5
  223. package/src/components/Advice/Advice.tsx +19 -23
  224. package/src/components/Advice/__test__/advice.test.tsx +4 -2
  225. package/src/components/accordion/RawAccordion.tsx +6 -6
  226. package/src/components/badge/__test__/badge.test.tsx +4 -2
  227. package/src/components/buttons/ButtonLink.tsx +177 -177
  228. package/src/components/buttons/IconButton.tsx +9 -6
  229. package/src/components/buttons/IconButtonContained.tsx +201 -0
  230. package/src/components/buttons/IconButtonSolid.tsx +168 -0
  231. package/src/components/buttons/__test__/__snapshots__/button.test.tsx.snap +370 -0
  232. package/src/components/buttons/__test__/button.test.tsx +59 -4
  233. package/src/components/buttons/index.tsx +5 -3
  234. package/src/components/checkbox/AnimatedCheckbox.tsx +6 -8
  235. package/src/components/icons/index.tsx +1 -2
  236. package/src/components/index.tsx +13 -13
  237. package/src/components/layout/GradientBottomActions.tsx +119 -0
  238. package/src/components/layout/GradientScrollView.tsx +167 -0
  239. package/src/components/layout/HeaderFirstLevel.tsx +76 -0
  240. package/src/components/layout/index.tsx +1 -0
  241. package/src/components/listitems/ListItemCheckbox.tsx +182 -0
  242. package/src/components/listitems/ListItemInfo.tsx +53 -58
  243. package/src/components/listitems/ListItemInfoCopy.tsx +122 -127
  244. package/src/components/listitems/ListItemRadio.tsx +185 -0
  245. package/src/components/listitems/ListItemSwitch.tsx +109 -0
  246. package/src/components/listitems/ListItemTransaction.tsx +154 -150
  247. package/src/components/listitems/__test__/__snapshots__/listitem.test.tsx.snap +0 -14
  248. package/src/components/listitems/index.tsx +3 -0
  249. package/src/components/logos/svg/LogoPaymentExtMaestro.tsx +3 -20
  250. package/src/components/logos/svg/LogoPaymentExtMastercard.tsx +5 -22
  251. package/src/components/logos/svg/LogoPaymentExtPayPal.tsx +9 -31
  252. package/src/components/logos/svg/LogoPaymentMaestro.tsx +8 -6
  253. package/src/components/logos/svg/LogoPaymentMastercard.tsx +8 -6
  254. package/src/components/logos/svg/LogoPaymentPayPal.tsx +5 -5
  255. package/src/components/radio/AnimatedRadio.tsx +6 -8
  256. package/src/components/radio/RadioGroup.tsx +43 -0
  257. package/src/components/radio/index.tsx +1 -0
  258. package/src/components/typography/H3.tsx +25 -91
  259. package/src/components/typography/Link.tsx +23 -30
  260. package/src/components/typography/__test__/__snapshots__/typography.test.tsx.snap +50 -45
  261. package/src/core/IOColors.ts +2 -2
  262. package/src/core/IOSpacing.ts +2 -2
  263. package/src/core/IOStyles.ts +9 -0
  264. package/src/index.tsx +1 -0
  265. package/src/json-import.d.ts +13 -0
@@ -0,0 +1,167 @@
1
+ import * as React from "react";
2
+ import { useMemo } from "react";
3
+ import Animated, {
4
+ Easing,
5
+ useAnimatedScrollHandler,
6
+ useAnimatedStyle,
7
+ useSharedValue,
8
+ withTiming
9
+ } from "react-native-reanimated";
10
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
11
+ import { WithTestID } from "../../utils/types";
12
+ import {
13
+ IOVisualCostants,
14
+ buttonSolidHeight,
15
+ IOSpacer,
16
+ IOSpacingScale
17
+ } from "../../core";
18
+ import GradientBottomActions from "./GradientBottomActions";
19
+
20
+ export type GradientScrollView = WithTestID<{
21
+ children: React.ReactNode;
22
+ excludeSafeAreaMargins?: boolean;
23
+ debugMode?: boolean;
24
+ // Accepted components: ButtonSolid, ButtonLink
25
+ // Don't use any components other than this, please.
26
+ primaryAction: React.ReactNode;
27
+ secondaryAction?: React.ReactNode;
28
+ }>;
29
+
30
+ // Extended gradient area above the actions
31
+ export const gradientSafeArea: IOSpacingScale = 80;
32
+ // End content margin before the actions
33
+ const contentEndMargin: IOSpacingScale = 32;
34
+ // Margin between primary action and secondary one
35
+ const spaceBetweenActions: IOSpacer = 24;
36
+ // Estimated height of the secondary action
37
+ const secondaryActionEstHeight: number = 20;
38
+ // Extra bottom margin for iPhone bottom handle
39
+ const extraSafeAreaMargin: IOSpacingScale = 8;
40
+
41
+ export const GradientScrollView = ({
42
+ children,
43
+ primaryAction,
44
+ secondaryAction,
45
+ // Don't include safe area insets
46
+ excludeSafeAreaMargins = false,
47
+ debugMode = false,
48
+ testID
49
+ }: GradientScrollView) => {
50
+ const gradientOpacity = useSharedValue(1);
51
+ const insets = useSafeAreaInsets();
52
+
53
+ /* Check if the iPhone bottom handle is present.
54
+ If not, or if you don't need safe area insets,
55
+ add a default margin to prevent the button
56
+ from sticking to the bottom. */
57
+ const bottomMargin: number = useMemo(
58
+ () =>
59
+ insets.bottom === 0 || excludeSafeAreaMargins
60
+ ? IOVisualCostants.appMarginDefault
61
+ : insets.bottom,
62
+ [insets, excludeSafeAreaMargins]
63
+ );
64
+
65
+ /* When the secondary action is visible, add extra margin
66
+ to avoid little space from iPhone bottom handle */
67
+ const extraBottomMargin: number = useMemo(
68
+ () => (secondaryAction && insets.bottom !== 0 ? extraSafeAreaMargin : 0),
69
+ [insets.bottom, secondaryAction]
70
+ );
71
+
72
+ /* Total height of actions */
73
+ const actionsArea: number = useMemo(
74
+ () =>
75
+ primaryAction && secondaryAction
76
+ ? buttonSolidHeight +
77
+ spaceBetweenActions +
78
+ secondaryActionEstHeight +
79
+ extraBottomMargin
80
+ : buttonSolidHeight,
81
+ [extraBottomMargin, primaryAction, secondaryAction]
82
+ );
83
+
84
+ /* Total height of "Actions + Gradient" area */
85
+ const gradientAreaHeight: number = useMemo(
86
+ () => bottomMargin + actionsArea + gradientSafeArea,
87
+ [actionsArea, bottomMargin]
88
+ );
89
+
90
+ /* Height of the safe bottom area, applied to the ScrollView:
91
+ Actions + Content end margin */
92
+ const safeBottomAreaHeight: number = useMemo(
93
+ () => bottomMargin + actionsArea + contentEndMargin,
94
+ [actionsArea, bottomMargin]
95
+ );
96
+
97
+ {
98
+ /* Safe background block. It's added because when
99
+ you swipe up quickly, the content below is visible
100
+ for about 100ms. Without this block, the content
101
+ appears glitchy. */
102
+ }
103
+
104
+ const safeBackgroundHeight = useMemo(
105
+ () =>
106
+ secondaryAction
107
+ ? spaceBetweenActions +
108
+ secondaryActionEstHeight +
109
+ extraBottomMargin +
110
+ bottomMargin
111
+ : bottomMargin,
112
+ [bottomMargin, extraBottomMargin, secondaryAction]
113
+ );
114
+
115
+ const handleScroll = useAnimatedScrollHandler(
116
+ ({ contentOffset, layoutMeasurement, contentSize }) => {
117
+ /* We use Math.floor because decimals used on Android
118
+ devices never change the `isEndReached` boolean value.
119
+ We have more consistent behavior across platforms
120
+ if we round these calculations ¯\_(ツ)_/¯ */
121
+ const isEndReached =
122
+ Math.floor(layoutMeasurement.height + contentOffset.y) >=
123
+ Math.floor(contentSize.height);
124
+
125
+ // eslint-disable-next-line functional/immutable-data
126
+ gradientOpacity.value = isEndReached ? 0 : 1;
127
+ }
128
+ );
129
+
130
+ const opacityTransition = useAnimatedStyle(() => ({
131
+ opacity: withTiming(gradientOpacity.value, {
132
+ duration: 200,
133
+ easing: Easing.ease
134
+ })
135
+ }));
136
+
137
+ return (
138
+ <>
139
+ <Animated.ScrollView
140
+ testID={testID}
141
+ onScroll={handleScroll}
142
+ scrollEventThrottle={16}
143
+ contentContainerStyle={{
144
+ paddingHorizontal: IOVisualCostants.appMarginDefault,
145
+ paddingBottom: safeBottomAreaHeight
146
+ }}
147
+ >
148
+ {children}
149
+ </Animated.ScrollView>
150
+ <GradientBottomActions
151
+ debugMode={debugMode}
152
+ primaryAction={primaryAction}
153
+ secondaryAction={secondaryAction}
154
+ transitionAnimStyle={opacityTransition}
155
+ dimensions={{
156
+ bottomMargin,
157
+ extraBottomMargin,
158
+ gradientAreaHeight,
159
+ spaceBetweenActions,
160
+ safeBackgroundHeight
161
+ }}
162
+ />
163
+ </>
164
+ );
165
+ };
166
+
167
+ export default GradientScrollView;
@@ -0,0 +1,76 @@
1
+ import * as React from "react";
2
+ import { View, StyleSheet } from "react-native";
3
+ import { useSafeAreaInsets } from "react-native-safe-area-context";
4
+ import { WithTestID } from "../../utils/types";
5
+ import { IOStyles, IOVisualCostants, IOColors } from "../../core";
6
+ import { H3 } from "../typography";
7
+ import { HSpacer } from "../spacer";
8
+
9
+ export type HeaderFirstLevel = WithTestID<{
10
+ title: string;
11
+ // Accepted components: IconButton
12
+ // Don't use any components other than this, please.
13
+ firstAction?: React.ReactNode;
14
+ secondAction?: React.ReactNode;
15
+ thirdAction?: React.ReactNode;
16
+ }>;
17
+
18
+ const HEADER_BG_COLOR: IOColors = "white";
19
+
20
+ const styles = StyleSheet.create({
21
+ headerInner: {
22
+ paddingHorizontal: IOVisualCostants.appMarginDefault,
23
+ height: IOVisualCostants.headerHeight,
24
+ width: "100%",
25
+ flexDirection: "row",
26
+ alignItems: "center",
27
+ justifyContent: "space-between"
28
+ }
29
+ });
30
+
31
+ export const HeaderFirstLevel = ({
32
+ title,
33
+ firstAction,
34
+ secondAction,
35
+ thirdAction,
36
+ testID
37
+ }: HeaderFirstLevel) => {
38
+ const insets = useSafeAreaInsets();
39
+
40
+ return (
41
+ <View
42
+ style={{
43
+ paddingTop: insets.top,
44
+ backgroundColor: IOColors[HEADER_BG_COLOR]
45
+ }}
46
+ accessibilityRole="header"
47
+ testID={testID}
48
+ >
49
+ <View style={styles.headerInner}>
50
+ <H3 style={{ flexShrink: 1 }} numberOfLines={1}>
51
+ {title}
52
+ </H3>
53
+ <View style={[IOStyles.row, { flexShrink: 0 }]}>
54
+ {firstAction}
55
+ {secondAction && (
56
+ <>
57
+ {/* Ideally, with the "gap" flex property,
58
+ we can get rid of these ugly constructs */}
59
+ <HSpacer size={16} />
60
+ {secondAction}
61
+ </>
62
+ )}
63
+ {thirdAction && (
64
+ <>
65
+ {/* Same as above */}
66
+ <HSpacer size={16} />
67
+ {thirdAction}
68
+ </>
69
+ )}
70
+ </View>
71
+ </View>
72
+ </View>
73
+ );
74
+ };
75
+
76
+ export default HeaderFirstLevel;
@@ -0,0 +1 @@
1
+ export * from "./GradientBottomActions";
@@ -0,0 +1,182 @@
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 { IOIcons, Icon } from "../icons";
25
+ import { HSpacer, VSpacer } from "../spacer";
26
+ import { H6, LabelSmall } from "../typography";
27
+ import { AnimatedCheckbox } from "../checkbox/AnimatedCheckbox";
28
+
29
+ type Props = {
30
+ value: string;
31
+ description?: string;
32
+ icon?: IOIcons;
33
+ selected?: boolean;
34
+ onValueChange?: (newValue: boolean) => void;
35
+ };
36
+
37
+ const DISABLED_OPACITY = 0.5;
38
+
39
+ // disabled: the component is no longer touchable
40
+ // onPress:
41
+ type OwnProps = Props &
42
+ Pick<
43
+ React.ComponentProps<typeof Pressable>,
44
+ "onPress" | "accessibilityLabel" | "disabled"
45
+ >;
46
+
47
+ /**
48
+ * with the automatic state management that uses a {@link AnimatedCheckBox}
49
+ * The toggleValue change when a `onPress` event is received and dispatch the `onValueChange`.
50
+ *
51
+ * @param props
52
+ * @constructor
53
+ */
54
+ export const ListItemCheckbox = ({
55
+ value,
56
+ description,
57
+ icon,
58
+ selected,
59
+ disabled,
60
+ onValueChange
61
+ }: OwnProps) => {
62
+ const [toggleValue, setToggleValue] = useState(selected ?? false);
63
+ // Animations
64
+ const isPressed: Animated.SharedValue<number> = useSharedValue(0);
65
+
66
+ // Scaling transformation applied when the button is pressed
67
+ const animationScaleValue = IOScaleValues?.basicButton?.pressedState;
68
+
69
+ const progressPressed = useDerivedValue(() =>
70
+ withSpring(isPressed.value, IOSpringValues.button)
71
+ );
72
+
73
+ // Theme
74
+ const theme = useIOTheme();
75
+
76
+ const mapBackgroundStates: Record<string, string> = {
77
+ default: hexToRgba(IOColors[theme["listItem-pressed"]], 0),
78
+ pressed: IOColors[theme["listItem-pressed"]]
79
+ };
80
+
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
+ );
89
+
90
+ return {
91
+ transform: [{ scale }]
92
+ };
93
+ });
94
+
95
+ const handlePressIn = useCallback(() => {
96
+ // eslint-disable-next-line functional/immutable-data
97
+ isPressed.value = 1;
98
+ }, [isPressed]);
99
+ const handlePressOut = useCallback(() => {
100
+ // eslint-disable-next-line functional/immutable-data
101
+ isPressed.value = 0;
102
+ }, [isPressed]);
103
+
104
+ const animatedBackgroundStyle = useAnimatedStyle(() => {
105
+ const backgroundColor = interpolateColor(
106
+ progressPressed.value,
107
+ [0, 1],
108
+ [mapBackgroundStates.default, mapBackgroundStates.pressed]
109
+ );
110
+
111
+ return {
112
+ backgroundColor
113
+ };
114
+ });
115
+
116
+ const toggleCheckbox = () => {
117
+ ReactNativeHapticFeedback.trigger("impactLight");
118
+ setToggleValue(!toggleValue);
119
+ if (onValueChange !== undefined) {
120
+ onValueChange(!toggleValue);
121
+ }
122
+ };
123
+
124
+ return (
125
+ <Pressable
126
+ onPress={toggleCheckbox}
127
+ onPressIn={handlePressIn}
128
+ onPressOut={handlePressOut}
129
+ onTouchEnd={handlePressOut}
130
+ testID="ListItemCheckbox"
131
+ disabled={disabled}
132
+ >
133
+ <Animated.View
134
+ style={[
135
+ IOSelectionListItemStyles.listItem,
136
+ animatedBackgroundStyle,
137
+ { opacity: disabled ? DISABLED_OPACITY : 1 }
138
+ ]}
139
+ // This is required to avoid opacity
140
+ // inheritance on Android
141
+ needsOffscreenAlphaCompositing={true}
142
+ >
143
+ <Animated.View style={animatedScaleStyle}>
144
+ <View style={IOSelectionListItemStyles.listItemInner}>
145
+ <View style={[IOStyles.row, { flexShrink: 1 }]}>
146
+ {icon && (
147
+ <View
148
+ style={{
149
+ marginRight: IOSelectionListItemVisualParams.iconMargin
150
+ }}
151
+ >
152
+ <Icon
153
+ name={icon}
154
+ color="grey-300"
155
+ size={IOSelectionListItemVisualParams.iconSize}
156
+ />
157
+ </View>
158
+ )}
159
+ <H6 color={"black"} style={{ flexShrink: 1 }}>
160
+ {value}
161
+ </H6>
162
+ </View>
163
+ <HSpacer size={8} />
164
+ <View pointerEvents="none">
165
+ <AnimatedCheckbox checked={selected ?? toggleValue} />
166
+ </View>
167
+ </View>
168
+ {description && (
169
+ <View>
170
+ <VSpacer
171
+ size={IOSelectionListItemVisualParams.descriptionMargin}
172
+ />
173
+ <LabelSmall weight="Regular" color={theme["textBody-tertiary"]}>
174
+ {description}
175
+ </LabelSmall>
176
+ </View>
177
+ )}
178
+ </Animated.View>
179
+ </Animated.View>
180
+ </Pressable>
181
+ );
182
+ };
@@ -1,75 +1,70 @@
1
1
  import React from "react";
2
2
  import { View } from "react-native";
3
3
  import {
4
- IOListItemStyles,
5
- IOListItemVisualParams,
6
- IOStyles,
7
- useIOTheme
4
+ IOListItemStyles,
5
+ IOListItemVisualParams,
6
+ IOStyles,
7
+ useIOTheme
8
8
  } from "../../core";
9
9
  import { WithTestID } from "../../utils/types";
10
10
  import { Icon, IOIcons } from "../icons";
11
- import { VSpacer } from "../spacer/Spacer";
12
11
  import { H6, LabelSmall } from "../typography";
13
12
 
14
13
  export type ListItemInfo = WithTestID<{
15
- label: string;
16
- value: string | React.ReactNode;
17
- numberOfLines?: number;
18
- icon?: IOIcons;
19
- // Accepted components: ButtonLink, IconButton
20
- // Don't use any components other than these
21
- action?: React.ReactNode;
22
- // Accessibility
23
- accessibilityLabel: string;
14
+ label: string;
15
+ value: string | React.ReactNode;
16
+ numberOfLines?: number;
17
+ icon?: IOIcons;
18
+ // Accepted components: ButtonLink, IconButton
19
+ // Don't use any components other than these
20
+ action?: React.ReactNode;
21
+ // Accessibility
22
+ accessibilityLabel: string;
24
23
  }>;
25
24
 
26
25
  export const ListItemInfo = ({
27
- label,
28
- value,
29
- numberOfLines = 2,
30
- icon,
31
- action,
32
- accessibilityLabel,
33
- testID
26
+ label,
27
+ value,
28
+ numberOfLines = 2,
29
+ icon,
30
+ action,
31
+ accessibilityLabel,
32
+ testID
34
33
  }: ListItemInfo) => {
35
- const theme = useIOTheme();
36
- return (
37
- <View
38
- style={IOListItemStyles.listItem}
39
- testID={testID}
40
- accessible={true}
41
- accessibilityLabel={accessibilityLabel}
42
- >
43
- <View style={IOListItemStyles.listItemInner}>
44
- {icon && (
45
- <View style={{ marginRight: IOListItemVisualParams.iconMargin }}>
46
- <Icon
47
- name={icon}
48
- color="grey-450"
49
- size={IOListItemVisualParams.iconSize}
50
- />
51
- </View>
52
- )}
53
- <View style={IOStyles.flex}>
54
- <LabelSmall weight="Regular" color={theme["textBody-tertiary"]}>
55
- {label}
56
- </LabelSmall>
57
- <VSpacer size={4} />
58
- <H6
59
- color={theme["textBody-default"]}
60
- numberOfLines={numberOfLines}
61
- >
62
- {value}
63
- </H6>
64
- </View>
65
- {action && (
66
- <View style={{ marginLeft: IOListItemVisualParams.iconMargin }}>
67
- {action}
68
- </View>
69
- )}
70
- </View>
34
+ const theme = useIOTheme();
35
+ return (
36
+ <View
37
+ style={IOListItemStyles.listItem}
38
+ testID={testID}
39
+ accessible={true}
40
+ accessibilityLabel={accessibilityLabel}
41
+ >
42
+ <View style={IOListItemStyles.listItemInner}>
43
+ {icon && (
44
+ <View style={{ marginRight: IOListItemVisualParams.actionMargin }}>
45
+ <Icon
46
+ name={icon}
47
+ color="grey-450"
48
+ size={IOListItemVisualParams.iconSize}
49
+ />
50
+ </View>
51
+ )}
52
+ <View style={IOStyles.flex}>
53
+ <LabelSmall weight="Regular" color={theme["textBody-tertiary"]}>
54
+ {label}
55
+ </LabelSmall>
56
+ <H6 color={theme["textBody-default"]} numberOfLines={numberOfLines}>
57
+ {value}
58
+ </H6>
71
59
  </View>
72
- );
60
+ {action && (
61
+ <View style={{ marginLeft: IOListItemVisualParams.actionMargin }}>
62
+ {action}
63
+ </View>
64
+ )}
65
+ </View>
66
+ </View>
67
+ );
73
68
  };
74
69
 
75
70
  export default ListItemInfo;