-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathLearnMoreBottomSheet.tsx
More file actions
126 lines (115 loc) · 3.96 KB
/
LearnMoreBottomSheet.tsx
File metadata and controls
126 lines (115 loc) · 3.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import React, { useState, useCallback, useRef } from 'react';
import { View } from 'react-native';
import {
Text,
ButtonIcon,
Checkbox,
TextVariant,
IconName,
TextColor,
Button,
ButtonVariant,
ButtonBaseSize,
BottomSheet,
type BottomSheetRef,
} from '@metamask/design-system-react-native';
import { useNavigation, useTheme } from '@react-navigation/native';
import { strings } from '../../../../../locales/i18n';
import { useStyles } from '../../../../component-library/hooks';
import styleSheet from './LearnMoreBottomSheet.styles';
import Routes from '../../../../constants/navigation/Routes';
import { RootState } from '../../../../reducers';
import { useDispatch, useSelector } from 'react-redux';
import { setMultichainAccountsIntroModalSeen } from '../../../../actions/user';
import { LEARN_MORE_BOTTOM_SHEET_TEST_IDS } from './LearnMoreBottomSheet.testIds';
interface LearnMoreBottomSheetProps {
onClose?: () => void;
}
const LearnMoreBottomSheet: React.FC<LearnMoreBottomSheetProps> = ({
onClose,
}) => {
const { styles } = useStyles(styleSheet, { theme: useTheme() });
const [isCheckboxChecked, setIsCheckboxChecked] = useState(false);
const sheetRef = useRef<BottomSheetRef>(null);
const navigation = useNavigation();
const dispatch = useDispatch();
const isBasicFunctionalityEnabled = useSelector(
(state: RootState) => state?.settings?.basicFunctionalityEnabled,
);
const handleBack = useCallback(() => {
sheetRef.current?.onCloseBottomSheet();
}, []);
const handleClose = useCallback(() => {
sheetRef.current?.onCloseBottomSheet();
}, []);
const handleConfirm = useCallback(() => {
if (isCheckboxChecked) {
navigation.goBack(); // close bottom sheet
navigation.goBack(); // close modal
if (isBasicFunctionalityEnabled) {
dispatch(setMultichainAccountsIntroModalSeen(true));
navigation.navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
screen: Routes.SHEET.BASIC_FUNCTIONALITY,
});
}
}
}, [isCheckboxChecked, navigation, isBasicFunctionalityEnabled, dispatch]);
return (
<BottomSheet
ref={sheetRef}
onClose={onClose}
testID={LEARN_MORE_BOTTOM_SHEET_TEST_IDS.BOTTOM_SHEET}
>
<View style={styles.container}>
<View style={styles.header}>
<ButtonIcon
onPress={handleBack}
iconName={IconName.ArrowLeft}
testID={LEARN_MORE_BOTTOM_SHEET_TEST_IDS.BACK_BUTTON}
/>
<Text
variant={TextVariant.HeadingMd}
style={styles.title}
testID={LEARN_MORE_BOTTOM_SHEET_TEST_IDS.TITLE}
>
{strings('multichain_accounts.learn_more.title')}
</Text>
<ButtonIcon
onPress={handleClose}
iconName={IconName.Close}
testID={LEARN_MORE_BOTTOM_SHEET_TEST_IDS.CLOSE_BUTTON}
/>
</View>
<View style={styles.content}>
<Text
variant={TextVariant.BodyMd}
color={TextColor.TextDefault}
style={styles.description}
testID={LEARN_MORE_BOTTOM_SHEET_TEST_IDS.DESCRIPTION}
>
{strings('multichain_accounts.learn_more.description')}
</Text>
<Checkbox
isSelected={isCheckboxChecked}
onChange={setIsCheckboxChecked}
label={strings('multichain_accounts.learn_more.checkbox_label')}
testID={LEARN_MORE_BOTTOM_SHEET_TEST_IDS.CHECKBOX}
/>
</View>
<View style={styles.footer}>
<Button
variant={ButtonVariant.Primary}
size={ButtonBaseSize.Lg}
isFullWidth
onPress={handleConfirm}
isDisabled={!isCheckboxChecked}
testID={LEARN_MORE_BOTTOM_SHEET_TEST_IDS.CONFIRM_BUTTON}
>
{strings('multichain_accounts.learn_more.confirm_button')}
</Button>
</View>
</View>
</BottomSheet>
);
};
export default LearnMoreBottomSheet;