Skip to content

Commit

Permalink
CR: update
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss authored and stackchain committed Jan 5, 2024
1 parent a313c36 commit 3c558df
Show file tree
Hide file tree
Showing 13 changed files with 339 additions and 325 deletions.
7 changes: 1 addition & 6 deletions apps/wallet-mobile/src/Dashboard/DashboardNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ export const DashboardNavigator = () => {

return (
<GovernanceProvider manager={manager}>
<Stack.Navigator
screenOptions={{
...defaultStackNavigationOptions,
detachPreviousScreen: false /* https://github.com/react-navigation/react-navigation/issues/9883 */,
}}
>
<Stack.Navigator screenOptions={defaultStackNavigationOptions}>
<Stack.Screen
name="staking-dashboard-main"
component={Dashboard}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import {Balance} from '@yoroi/types'
import React, {useEffect, useState} from 'react'
import {defineMessages, useIntl} from 'react-intl'
import {ScrollView, StyleSheet, View, ViewProps} from 'react-native'
import {Platform, ScrollView, StyleSheet, View, ViewProps} from 'react-native'

import {KeyboardAvoidingView, Text, ValidatedTextInput} from '../../components'
import {KeyboardSpacer, Text, ValidatedTextInput} from '../../components'
import {ConfirmTx} from '../../components/ConfirmTx'
import {useStakePoolInfoAndHistory} from '../../Dashboard/StakePoolInfo'
import {debugWalletInfo, features} from '../../features'
Expand Down Expand Up @@ -54,73 +54,69 @@ export const DelegationConfirmation = () => {

return (
<View style={styles.container}>
<KeyboardAvoidingView style={{flex: 1}}>
<ScrollView style={styles.scrollView}>
<View style={styles.itemBlock}>
<Text style={styles.itemTitle}>{strings.stakePoolName}</Text>
<ScrollView style={styles.scrollView}>
<View style={styles.itemBlock}>
<Text style={styles.itemTitle}>{strings.stakePoolName}</Text>

<StakePoolName stakePoolId={poolId} />
</View>
<StakePoolName stakePoolId={poolId} />
</View>

<View style={styles.itemBlock}>
<Text style={styles.itemTitle}>{strings.stakePoolHash}</Text>
<View style={styles.itemBlock}>
<Text style={styles.itemTitle}>{strings.stakePoolHash}</Text>

<Text testID="stakePoolHashText">{poolId}</Text>
</View>
<Text testID="stakePoolHashText">{poolId}</Text>
</View>

<View style={styles.input} testID="stakingAmount">
<Text small style={styles.fees}>
{`+ ${formatTokenAmount(yoroiUnsignedTx.fee[wallet.primaryToken.identifier], wallet.primaryToken)} ${
strings.ofFees
}`}
</Text>

{/* requires a handler so we pass on a dummy function */}

<ValidatedTextInput
onChangeText={() => undefined}
editable={false}
value={formatTokenAmount(stakingAmount.quantity, wallet.primaryToken)}
label={strings.amount}
/>
</View>
<View style={styles.input} testID="stakingAmount">
<Text small style={styles.fees}>
{`+ ${formatTokenAmount(yoroiUnsignedTx.fee[wallet.primaryToken.identifier], wallet.primaryToken)} ${
strings.ofFees
}`}
</Text>

{!wallet.isEasyConfirmationEnabled && !wallet.isHW && (
<View style={styles.input} testID="spendingPassword">
<ValidatedTextInput
secureTextEntry
value={password}
label={strings.password}
onChangeText={setPassword}
/>
</View>
)}

<View style={styles.itemBlock}>
<Text style={styles.itemTitle}>{strings.rewardsExplanation}</Text>

<Text style={styles.rewards}>{formatTokenWithText(reward, wallet.primaryToken)}</Text>
</View>
{/* requires a handler so we pass on a dummy function */}

{wallet.isHW && <HWInstructions useUSB={useUSB} addMargin />}
</ScrollView>

<Actions>
<ConfirmTx
buttonProps={{
shelleyTheme: true,
title: strings.delegateButtonLabel,
}}
isProvidingPassword
providedPassword={password}
onSuccess={onSuccess}
setUseUSB={setUseUSB}
useUSB={useUSB}
yoroiUnsignedTx={yoroiUnsignedTx}
chooseTransportOnConfirmation
<ValidatedTextInput
onChangeText={() => undefined}
editable={false}
value={formatTokenAmount(stakingAmount.quantity, wallet.primaryToken)}
label={strings.amount}
/>
</Actions>
</KeyboardAvoidingView>
</View>

{!wallet.isEasyConfirmationEnabled && !wallet.isHW && (
<View style={styles.input} testID="spendingPassword">
<ValidatedTextInput secureTextEntry value={password} label={strings.password} onChangeText={setPassword} />
</View>
)}

<View style={styles.itemBlock}>
<Text style={styles.itemTitle}>{strings.rewardsExplanation}</Text>

<Text style={styles.rewards}>{formatTokenWithText(reward, wallet.primaryToken)}</Text>
</View>

{wallet.isHW && <HWInstructions useUSB={useUSB} addMargin />}
</ScrollView>

<Actions>
<ConfirmTx
buttonProps={{
shelleyTheme: true,
title: strings.delegateButtonLabel,
}}
isProvidingPassword
providedPassword={password}
onSuccess={onSuccess}
setUseUSB={setUseUSB}
useUSB={useUSB}
yoroiUnsignedTx={yoroiUnsignedTx}
chooseTransportOnConfirmation
/>
</Actions>

{/* hack to fix weird KeyboardAvoidingView bug in THIS SCREEN */}
{Platform.OS === 'ios' && <KeyboardSpacer />}
</View>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {defineMessages, useIntl} from 'react-intl'
import {View} from 'react-native'
import {SafeAreaView} from 'react-native-safe-area-context'

import {Button, KeyboardSpacer, ScrollableView, Spacer, StatusBar, Text} from '../../components'
import {Button, KeyboardAvoidingView, KeyboardSpacer, ScrollableView, Spacer, StatusBar, Text} from '../../components'
import {WalletInitRouteNavigation, WalletInitRoutes} from '../../navigation'
import {isEmptyString} from '../../utils/utils'
import {getWalletConfigById} from '../../yoroi-wallets/cardano/utils'
Expand All @@ -29,26 +29,28 @@ export const RestoreWalletScreen = () => {
<SafeAreaView edges={['left', 'right', 'bottom']} style={{flex: 1, backgroundColor: 'white'}}>
<StatusBar type="dark" />

<ScrollableView bounces={false} style={{paddingHorizontal: 16}} keyboardShouldPersistTaps="always">
<Spacer height={24} />
<KeyboardAvoidingView style={{flex: 1}}>
<ScrollableView bounces={false} style={{paddingHorizontal: 16}} keyboardShouldPersistTaps="always">
<Spacer height={24} />

<Instructions>{strings.instructions({mnemonicLength})}</Instructions>
<Instructions>{strings.instructions({mnemonicLength})}</Instructions>

<Spacer height={16} />
<Spacer height={16} />

<MnemonicInput length={mnemonicLength} onDone={setPhrase} />
<MnemonicInput length={mnemonicLength} onDone={setPhrase} />

<KeyboardSpacer padding={100} />
</ScrollableView>
<KeyboardSpacer padding={100} />
</ScrollableView>

<Actions>
<Button
onPress={navigateToWalletCredentials}
title={strings.restoreButton}
disabled={isEmptyString(phrase)}
testID="restoreButton"
/>
</Actions>
<Actions>
<Button
onPress={navigateToWalletCredentials}
title={strings.restoreButton}
disabled={isEmptyString(phrase)}
testID="restoreButton"
/>
</Actions>
</KeyboardAvoidingView>
</SafeAreaView>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {ScrollView, StyleSheet, TextInput as RNTextInput, View} from 'react-nati
import {SafeAreaView} from 'react-native-safe-area-context'
import {MutationOptions, useMutation} from 'react-query'

import {Button, Checkmark, Spacer, TextInput} from '../../../components'
import {Button, Checkmark, KeyboardAvoidingView, Spacer, TextInput} from '../../../components'
import {errorMessages} from '../../../i18n/global-messages'
import {useSelectedWallet} from '../../../SelectedWallet'
import {COLORS} from '../../../theme'
Expand Down Expand Up @@ -37,67 +37,69 @@ export const ChangePasswordScreen = () => {

return (
<SafeAreaView edges={['left', 'right', 'bottom']} style={styles.safeAreaView}>
<ScrollView bounces={false} keyboardDismissMode="on-drag" contentContainerStyle={styles.contentContainer}>
<CurrentPasswordInput
ref={currentPasswordRef}
enablesReturnKeyAutomatically
autoFocus
secureTextEntry
label={strings.oldPasswordInputLabel}
value={currentPassword}
onChange={reset}
onChangeText={setCurrentPassword}
returnKeyType="next"
onSubmitEditing={() => newPasswordRef.current?.focus()}
errorText={isError ? strings.incorrectPassword : undefined}
autoComplete="off"
/>

<Spacer />

<PasswordInput
ref={newPasswordRef}
enablesReturnKeyAutomatically
secureTextEntry
label={strings.newPasswordInputLabel}
value={newPassword}
onChangeText={setNewPassword}
errorText={newPasswordErrors.passwordIsWeak ? strings.passwordStrengthRequirement : undefined}
helper={strings.passwordStrengthRequirement}
returnKeyType="next"
onSubmitEditing={() => newPasswordConfirmationRef.current?.focus()}
right={!newPasswordErrors.passwordIsWeak ? <Checkmark /> : undefined}
autoComplete="off"
/>

<Spacer />

<PasswordConfirmationInput
ref={newPasswordConfirmationRef}
enablesReturnKeyAutomatically
secureTextEntry
label={strings.repeatPasswordInputLabel}
value={newPasswordConfirmation}
onChangeText={setNewPasswordConfirmation}
errorText={newPasswordErrors.matchesConfirmation ? strings.repeatPasswordInputNotMatchError : undefined}
returnKeyType="done"
right={
!newPasswordErrors.matchesConfirmation && !newPasswordErrors.passwordConfirmationReq ? (
<Checkmark />
) : undefined
}
autoComplete="off"
/>
</ScrollView>

<Actions>
<Button
onPress={() => changePassword({currentPassword, newPassword})}
disabled={hasErrors}
title={strings.continueButton}
shelleyTheme
/>
</Actions>
<KeyboardAvoidingView style={{flex: 1}}>
<ScrollView bounces={false} keyboardDismissMode="on-drag" contentContainerStyle={styles.contentContainer}>
<CurrentPasswordInput
ref={currentPasswordRef}
enablesReturnKeyAutomatically
autoFocus
secureTextEntry
label={strings.oldPasswordInputLabel}
value={currentPassword}
onChange={reset}
onChangeText={setCurrentPassword}
returnKeyType="next"
onSubmitEditing={() => newPasswordRef.current?.focus()}
errorText={isError ? strings.incorrectPassword : undefined}
autoComplete="off"
/>

<Spacer />

<PasswordInput
ref={newPasswordRef}
enablesReturnKeyAutomatically
secureTextEntry
label={strings.newPasswordInputLabel}
value={newPassword}
onChangeText={setNewPassword}
errorText={newPasswordErrors.passwordIsWeak ? strings.passwordStrengthRequirement : undefined}
helper={strings.passwordStrengthRequirement}
returnKeyType="next"
onSubmitEditing={() => newPasswordConfirmationRef.current?.focus()}
right={!newPasswordErrors.passwordIsWeak ? <Checkmark /> : undefined}
autoComplete="off"
/>

<Spacer />

<PasswordConfirmationInput
ref={newPasswordConfirmationRef}
enablesReturnKeyAutomatically
secureTextEntry
label={strings.repeatPasswordInputLabel}
value={newPasswordConfirmation}
onChangeText={setNewPasswordConfirmation}
errorText={newPasswordErrors.matchesConfirmation ? strings.repeatPasswordInputNotMatchError : undefined}
returnKeyType="done"
right={
!newPasswordErrors.matchesConfirmation && !newPasswordErrors.passwordConfirmationReq ? (
<Checkmark />
) : undefined
}
autoComplete="off"
/>
</ScrollView>

<Actions>
<Button
onPress={() => changePassword({currentPassword, newPassword})}
disabled={hasErrors}
title={strings.continueButton}
shelleyTheme
/>
</Actions>
</KeyboardAvoidingView>
</SafeAreaView>
)
}
Expand Down
Loading

0 comments on commit 3c558df

Please sign in to comment.