@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
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
label,
|
|
27
|
+
value,
|
|
28
|
+
numberOfLines = 2,
|
|
29
|
+
icon,
|
|
30
|
+
action,
|
|
31
|
+
accessibilityLabel,
|
|
32
|
+
testID
|
|
34
33
|
}: ListItemInfo) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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;
|