-
Notifications
You must be signed in to change notification settings - Fork 477
Expand file tree
/
Copy pathpostWelcomeSelection.tsx
More file actions
119 lines (110 loc) · 4.19 KB
/
Copy pathpostWelcomeSelection.tsx
File metadata and controls
119 lines (110 loc) · 4.19 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
import { Button, Icons } from "@ledgerhq/native-ui";
import { useFocusEffect, useNavigation, useRoute } from "@react-navigation/native";
import React, { useCallback } from "react";
import { Linking } from "react-native";
import { useTranslation } from "~/context/Locale";
import { useDispatch } from "~/context/hooks";
import { useTheme } from "styled-components/native";
import { setOnboardingHasDevice } from "~/actions/settings";
import { track, updateIdentify } from "~/analytics";
import { OnboardingNavigatorParamList } from "~/components/RootNavigator/types/OnboardingNavigator";
import { StackNavigatorProps } from "~/components/RootNavigator/types/helpers";
import { NavigatorName, ScreenName } from "~/const";
import { SelectionCards } from "./Cards/SelectionCard";
import OnboardingView from "./OnboardingView";
import { useWalletFeaturesConfig } from "@features/platform-feature-flags";
import { urls } from "~/utils/urls";
import { useLocalizedUrl } from "LLM/hooks/useLocalizedUrls";
import { DETOX_ENABLED } from "~/utils/constants";
type NavigationProps = StackNavigatorProps<
OnboardingNavigatorParamList,
ScreenName.OnboardingPostWelcomeSelection
>;
function PostWelcomeSelection() {
const dispatch = useDispatch();
const { colors } = useTheme();
const { t } = useTranslation();
const navigation = useNavigation<NavigationProps["navigation"]>();
const route = useRoute<NavigationProps["route"]>();
const userHasDevice = route.params?.userHasDevice ?? false;
const currentNavigation = navigation.getParent()?.getParent()?.getState().routes[0].name;
const isInOnboarding = currentNavigation === NavigatorName.BaseOnboarding;
const localizedRebornUrl = useLocalizedUrl(urls.reborn);
const { isEnabled: isWallet40Enabled } = useWalletFeaturesConfig("mobile");
const identifyUser = useCallback(
(hasDevice: boolean | null) => {
if (isInOnboarding) dispatch(setOnboardingHasDevice(hasDevice));
updateIdentify();
},
[dispatch, isInOnboarding],
);
const openNoLedgerYet = useCallback(() => {
identifyUser(null);
track("button_clicked", {
button: "I don’t have a Ledger yet",
});
// Detox: keep the discover-live read-only e2e path; production opens the Reborn URL
if (DETOX_ENABLED) {
navigation.navigate(ScreenName.OnboardingModalDiscoverLive);
return;
}
Linking.openURL(localizedRebornUrl);
}, [identifyUser, localizedRebornUrl, navigation]);
useFocusEffect(() => {
identifyUser(null);
});
const setupLedger = () => {
identifyUser(null);
navigation.navigate(ScreenName.OnboardingDeviceSelection);
};
const accessExistingWallet = () => {
identifyUser(null);
navigation.navigate(ScreenName.OnboardingWelcomeBack);
};
return (
<OnboardingView
title={t("onboarding.postWelcomeStep.title")}
analytics={{
tracking: {
category: "Onboarding",
name: "Get Started",
},
}}
footer={
isWallet40Enabled && userHasDevice ? undefined : (
<Button type="default" mb={10} onPress={openNoLedgerYet} testID="onboarding-noLedgerYet">
{t("onboarding.postWelcomeStep.noLedgerYet")}
</Button>
)
}
>
<SelectionCards
cards={[
{
title: t("onboarding.postWelcomeStep.setupLedger.title"),
text: t("onboarding.postWelcomeStep.setupLedger.subtitle"),
event: "button_clicked",
eventProperties: {
button: "Setup your Ledger",
},
testID: `onboarding-setupLedger`,
onPress: setupLedger,
icon: <Icons.PlusCircle color={colors.primary.c80} size="M" />,
},
{
title: t("onboarding.postWelcomeStep.accessWallet.title"),
text: t("onboarding.postWelcomeStep.accessWallet.subtitle"),
event: "button_clicked",
eventProperties: {
button: "Access an existing wallet",
},
testID: `onboarding-accessWallet`,
onPress: accessExistingWallet,
icon: <Icons.WalletInput color={colors.primary.c80} />,
},
]}
/>
</OnboardingView>
);
}
export default PostWelcomeSelection;