-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/ramp-deeplink-handler
- Loading branch information
Showing
59 changed files
with
1,661 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...brary/components/Badges/Badge/variants/BadgeNotifications/BadgeNotifications.constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import { NotificationsKindTypes } from '../../../../../../util/notifications'; | ||
import { NotificationTypes } from '../../../../../../util/notifications'; | ||
import { IconName, IconSize } from '../../../../Icons/Icon/Icon.types'; | ||
|
||
// Internal dependencies. | ||
import { BadgeNotificationsProps } from './BadgeNotifications.types'; | ||
|
||
// Test IDs | ||
export const BADGE_NOTIFICATIONS_TEST_ID = 'badge-notifications'; | ||
export const TEST_NOTIFICATIONS_ACTION = NotificationsKindTypes.transaction; | ||
export const TEST_NOTIFICATIONS_ACTION = NotificationTypes.TRANSACTION; | ||
export const TEST_RNOTIFICATIONS_ICON_NAME = IconName.Send2; | ||
|
||
// Defaults | ||
export const DEFAULT_BADGENOTIFICATIONS_NOTIFICATIONSICON_SIZE = IconSize.Md; | ||
|
||
export const SAMPLE_BADGENOTIFICATIONS_PROPS: BadgeNotificationsProps = { | ||
name: TEST_NOTIFICATIONS_ACTION, | ||
iconName: TEST_RNOTIFICATIONS_ICON_NAME, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
app/components/Views/AccountSelector/AccountSelector.constants.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import React, { useState } from 'react'; | ||
import { Image, View, Linking } from 'react-native'; | ||
import { useFocusEffect, useNavigation } from '@react-navigation/native'; | ||
|
||
import Button, { | ||
ButtonVariants, | ||
} from '../../../../component-library/components/Buttons/Button'; | ||
import { strings } from '../../../../../locales/i18n'; | ||
import Text, { | ||
TextColor, | ||
TextVariant, | ||
} from '../../../../component-library/components/Texts/Text'; | ||
import { useTheme } from '../../../../util/theme'; | ||
import EnableNotificationsCardPlaceholder from '../../../../images/enableNotificationsCard.png'; | ||
import { createStyles } from './styles'; | ||
import Routes from '../../../../constants/navigation/Routes'; | ||
import { CONSENSYS_PRIVACY_POLICY } from '../../../../constants/urls'; | ||
import { useSelector } from 'react-redux'; | ||
import { mmStorage } from '../../../../util/notifications'; | ||
import { STORAGE_IDS } from '../../../../util/notifications/settings/storage/constants'; | ||
|
||
const OptIn = () => { | ||
const theme = useTheme(); | ||
const styles = createStyles(theme); | ||
const navigation = useNavigation(); | ||
const isNotificationEnabled = useSelector( | ||
(state: any) => state.notification?.notificationsSettings?.isEnabled, | ||
); | ||
const [promptCount, setPromptCount] = useState(0); | ||
|
||
const navigateToNotificationsSettings = () => { | ||
navigation.navigate(Routes.SETTINGS.NOTIFICATIONS); | ||
}; | ||
|
||
const navigateToMainWallet = () => { | ||
!isNotificationEnabled && | ||
mmStorage.saveLocal( | ||
STORAGE_IDS.PUSH_NOTIFICATIONS_PROMPT_COUNT, | ||
promptCount, | ||
); | ||
navigation.navigate(Routes.WALLET_VIEW); | ||
}; | ||
|
||
const goToLearnMore = () => { | ||
Linking.openURL(CONSENSYS_PRIVACY_POLICY); | ||
}; | ||
|
||
useFocusEffect(() => { | ||
if (isNotificationEnabled) { | ||
navigateToMainWallet(); | ||
} else { | ||
const count = mmStorage.getLocal( | ||
STORAGE_IDS.PUSH_NOTIFICATIONS_PROMPT_COUNT, | ||
); | ||
const times = count + 1 || 1; | ||
|
||
setPromptCount(times); | ||
} | ||
}); | ||
|
||
return ( | ||
<View style={styles.wrapper}> | ||
<Text | ||
variant={TextVariant.HeadingMD} | ||
color={TextColor.Default} | ||
style={styles.textTitle} | ||
> | ||
{strings('notifications.activation_card.title')} | ||
</Text> | ||
<View style={styles.card}> | ||
<Image | ||
source={EnableNotificationsCardPlaceholder} | ||
style={styles.image} | ||
/> | ||
</View> | ||
<Text | ||
variant={TextVariant.BodyMD} | ||
color={TextColor.Alternative} | ||
style={styles.textSpace} | ||
> | ||
{strings('notifications.activation_card.description_1')} | ||
</Text> | ||
|
||
<Text | ||
variant={TextVariant.BodyMD} | ||
color={TextColor.Alternative} | ||
style={styles.textSpace} | ||
> | ||
{strings('notifications.activation_card.description_2')} | ||
<Text | ||
variant={TextVariant.BodyMD} | ||
color={TextColor.Info} | ||
onPress={goToLearnMore} | ||
> | ||
{strings('notifications.activation_card.learn_more')} | ||
</Text> | ||
</Text> | ||
|
||
<Text variant={TextVariant.BodyMD} color={TextColor.Alternative}> | ||
{strings('notifications.activation_card.manage_preferences_1')} | ||
<Text variant={TextVariant.BodyMDBold} color={TextColor.Alternative}> | ||
{strings('notifications.activation_card.manage_preferences_2')} | ||
</Text> | ||
</Text> | ||
|
||
<View style={styles.btnContainer}> | ||
<Button | ||
variant={ButtonVariants.Secondary} | ||
label={strings('notifications.activation_card.cancel')} | ||
onPress={navigateToMainWallet} | ||
style={styles.ctaBtn} | ||
/> | ||
<Button | ||
variant={ButtonVariants.Primary} | ||
label={strings('notifications.activation_card.cta')} | ||
onPress={navigateToNotificationsSettings} | ||
style={styles.ctaBtn} | ||
/> | ||
</View> | ||
</View> | ||
); | ||
}; | ||
|
||
export default OptIn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* eslint-disable import/prefer-default-export */ | ||
import { StyleSheet } from 'react-native'; | ||
import type { Theme } from '@metamask/design-tokens'; | ||
import Device from '../../../../util/device'; | ||
import scaling from '../../../../util/scaling'; | ||
|
||
const HEIGHT = scaling.scale(240); | ||
|
||
export const createStyles = ({ colors }: Theme) => | ||
StyleSheet.create({ | ||
wrapper: { | ||
flex: 1, | ||
alignItems: 'flex-start', | ||
backgroundColor: colors.background.default, | ||
paddingTop: 40, | ||
paddingHorizontal: 16, | ||
}, | ||
card: { | ||
height: HEIGHT, | ||
width: Device.getDeviceWidth() - 32, | ||
alignSelf: 'center', | ||
borderRadius: 12, | ||
overflow: 'hidden', | ||
marginBottom: 16, | ||
}, | ||
image: { | ||
resizeMode: 'cover', | ||
height: HEIGHT, | ||
width: Device.getDeviceWidth() - 32, | ||
}, | ||
btnContainer: { | ||
bottom: 0, | ||
position: 'absolute', | ||
flexDirection: 'row', | ||
justifyContent: 'space-between', | ||
alignSelf: 'center', | ||
marginBottom: 16, | ||
}, | ||
ctaBtn: { | ||
margin: 4, | ||
width: '48%', | ||
alignSelf: 'center', | ||
}, | ||
textSpace: { | ||
marginBottom: 16, | ||
}, | ||
textTitle: { | ||
marginBottom: 16, | ||
alignSelf: 'center', | ||
}, | ||
}); |
Oops, something went wrong.