Skip to content

Commit

Permalink
feat: add opt-in hidden dev mode trigger to pin enter scrn
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce McMath <[email protected]>
  • Loading branch information
bryce-mcmath authored and jleach committed Jan 7, 2025
1 parent 16208b6 commit c141895
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
30 changes: 26 additions & 4 deletions packages/legacy/core/App/screens/PINEnter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useNavigation, CommonActions } from '@react-navigation/native'
import React, { useCallback, useEffect, useState } from 'react'
import React, { useCallback, useEffect, useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Keyboard, StyleSheet, Text, View, DeviceEventEmitter, InteractionManager } from 'react-native'
import { Keyboard, StyleSheet, Text, View, DeviceEventEmitter, InteractionManager, Pressable } from 'react-native'

import Button, { ButtonType } from '../components/buttons/Button'
import PINInput from '../components/inputs/PINInput'
Expand Down Expand Up @@ -50,7 +50,9 @@ const PINEnter: React.FC<PINEnterProps> = ({ setAuthenticated, usage = PINEntryU
const [biometricsEnrollmentChange, setBiometricsEnrollmentChange] = useState<boolean>(false)
const { ColorPallet, TextTheme, Assets, PINEnterTheme } = useTheme()
const { ButtonLoading } = useAnimatedComponents()
const [logger] = useServices([TOKENS.UTIL_LOGGER])
const [logger, { enableHiddenDevModeTrigger }] = useServices([TOKENS.UTIL_LOGGER, TOKENS.CONFIG])
const developerOptionCount = useRef(0)
const touchCountToEnableBiometrics = 9
const [inlineMessageField, setInlineMessageField] = useState<InlineMessageProps>()
const [inlineMessages] = useServices([TOKENS.INLINE_ERRORS])
const [alertModalMessage, setAlertModalMessage] = useState('')
Expand Down Expand Up @@ -104,6 +106,20 @@ const PINEnter: React.FC<PINEnterProps> = ({ setAuthenticated, usage = PINEntryU
},
})

const incrementDeveloperMenuCounter = useCallback(() => {
if (developerOptionCount.current >= touchCountToEnableBiometrics) {
developerOptionCount.current = 0
dispatch({
type: DispatchAction.ENABLE_DEVELOPER_MODE,
payload: [true],
})
navigation.navigate(Screens.Developer as never)
return
}

developerOptionCount.current = developerOptionCount.current + 1
}, [dispatch, navigation])

const gotoPostAuthScreens = useCallback(() => {
if (store.onboarding.postAuthScreens.length) {
const screen = store.onboarding.postAuthScreens[0]
Expand Down Expand Up @@ -461,7 +477,13 @@ const PINEnter: React.FC<PINEnterProps> = ({ setAuthenticated, usage = PINEntryU
<KeyboardView>
<View style={style.screenContainer}>
<View style={style.contentContainer}>
{displayHelpText()}
{usage === PINEntryUsage.WalletUnlock && enableHiddenDevModeTrigger ? (
<Pressable onPress={incrementDeveloperMenuCounter} testID={testIdWithKey('DeveloperCounter')}>
{displayHelpText()}
</Pressable>
) : (
displayHelpText()
)}
<Text style={style.subText}>{t('PINEnter.EnterPIN')}</Text>
<PINInput
onPINChanged={(p: string) => {
Expand Down
1 change: 1 addition & 0 deletions packages/legacy/core/App/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface Config {
enableTours?: boolean
enableImplicitInvitations?: boolean
enableReuseConnections?: boolean
enableHiddenDevModeTrigger?: boolean
showPreface?: boolean
showPINExplainer?: boolean
disableOnboardingSkip?: boolean
Expand Down

0 comments on commit c141895

Please sign in to comment.