Skip to content

Commit

Permalink
Merge branch 'develop' into feat/network-swtich-dapp
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljscript authored Aug 2, 2024
2 parents 162ef26 + d2426b6 commit 16bedbf
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Spacer} from '../Spacer'
import {Text} from '../Text'

type Props = {
title: string
title?: string
children: React.ReactNode
primaryButton: {
disabled?: boolean
Expand All @@ -35,9 +35,11 @@ export const TwoActionView = ({title, children, primaryButton, secondaryButton}:
testID="twoActionView"
>
<View style={styles.content}>
<View style={styles.heading}>
<Text style={styles.titleText}>{title}</Text>
</View>
{title !== undefined && (
<View style={styles.heading}>
<Text style={styles.titleText}>{title}</Text>
</View>
)}

{children}
</View>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export const ConfirmTxWithPassword = ({wallet, onSuccess, onCancel, unsignedTx}:
return (
<>
<TwoActionView
title={strings.confirmTx}
primaryButton={{
disabled: isLoading,
label: strings.confirmButton,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {useExplorers} from '@yoroi/explorers'
import {useTheme} from '@yoroi/theme'
import React from 'react'
import {defineMessages, useIntl} from 'react-intl'
import {Linking, StyleSheet, TouchableOpacity, View, ViewProps} from 'react-native'
import {Linking, StyleSheet, Text, TouchableOpacity} from 'react-native'

import {Text} from '../../../../components'
import {Space} from '../../../../components/Space/Space'
import {confirmationMessages, txLabels} from '../../../../kernel/i18n/global-messages'
import {YoroiWallet} from '../../../../yoroi-wallets/cardano/types'
import {YoroiStaking, YoroiUnsignedTx} from '../../../../yoroi-wallets/types'
Expand All @@ -21,29 +21,27 @@ export const TransferSummary = ({wallet, unsignedTx}: {wallet: YoroiWallet; unsi

return (
<>
<Item>
<Text>{strings.balanceLabel}</Text>
<Text style={styles.balanceLabel}>{strings.balanceLabel}</Text>

<Text style={styles.balanceAmount} testID="recoveredBalanceText">
{formatTokenWithText(refundAmount.quantity, wallet.primaryToken)}
</Text>
</Item>
<Text style={styles.balanceAmount} testID="recoveredBalanceText">
{formatTokenWithText(refundAmount.quantity, wallet.primaryToken)}
</Text>

<Item>
<Text>{strings.fees}</Text>
<Space height="lg" />

<Text style={styles.balanceAmount} testID="feeAmountText">
{formatTokenWithText(feeAmount.quantity, wallet.primaryToken)}
</Text>
</Item>
<Text style={styles.balanceLabel}>{strings.fees}</Text>

<Item>
<Text>{strings.finalBalanceLabel}</Text>
<Text style={styles.balanceAmount} testID="feeAmountText">
{formatTokenWithText(feeAmount.quantity, wallet.primaryToken)}
</Text>

<Text style={styles.balanceAmount} testID="totalAmountText">
{formatTokenWithText(totalAmount.quantity, wallet.primaryToken)}
</Text>
</Item>
<Space height="lg" />

<Text style={styles.balanceLabel}>{strings.finalBalanceLabel}</Text>

<Text style={styles.balanceAmount} testID="totalAmountText">
{formatTokenWithText(totalAmount.quantity, wallet.primaryToken)}
</Text>

{withdrawals && <Withdrawals wallet={wallet} withdrawals={withdrawals} />}

Expand Down Expand Up @@ -79,27 +77,32 @@ const Withdrawals = ({
withdrawals: NonNullable<YoroiStaking['withdrawals']>
}) => {
const strings = useStrings()
const styles = useStyles()
const explorers = useExplorers(wallet.networkManager.network)

const addresses = Entries.toAddresses(withdrawals)
if (addresses.length < 1) return null

return (
<Item>
<Text>{strings.withdrawals}</Text>
<>
<Space height="lg" />

<Text style={styles.balanceLabel}>{strings.withdrawals}</Text>

{Object.keys(withdrawals).map((address) => (
<TouchableOpacity
key={address}
activeOpacity={0.5}
onPress={() => Linking.openURL(explorers.cardanoscan.address(address))}
>
<Text numberOfLines={1} ellipsizeMode="middle" secondary>
<Text style={styles.balanceAmount} numberOfLines={1} ellipsizeMode="middle">
{address}
</Text>
</TouchableOpacity>
))}
</Item>

<Space height="lg" />
</>
)
}

Expand All @@ -111,6 +114,7 @@ const Deregistrations = ({
deregistrations: NonNullable<YoroiStaking['deregistrations']>
}) => {
const strings = useStrings()
const styles = useStyles()
const explorers = useExplorers(wallet.networkManager.network)

const refundAmounts = Entries.toAmounts(deregistrations)
Expand All @@ -121,38 +125,35 @@ const Deregistrations = ({

return (
<>
<Item>
<Text>{strings.stakeDeregistration}</Text>

{addresses.map((address) => (
<TouchableOpacity
key={address}
activeOpacity={0.5}
onPress={() => Linking.openURL(explorers.cardanoscan.address(address))}
>
<Text numberOfLines={1} ellipsizeMode="middle" secondary>
{address}
</Text>
</TouchableOpacity>
))}
</Item>

<Item>
<Text>
{strings.unregisterExplanation({
refundAmount: formatTokenWithText(primaryAmount.quantity, wallet.primaryToken),
})}
</Text>
</Item>
<Space height="lg" />

<Text style={styles.balanceLabel}>{strings.stakeDeregistration}</Text>

{addresses.map((address) => (
<TouchableOpacity
key={address}
activeOpacity={0.5}
onPress={() => Linking.openURL(explorers.cardanoscan.address(address))}
>
<Text style={styles.balanceAmount} numberOfLines={1} ellipsizeMode="middle">
{address}
</Text>
</TouchableOpacity>
))}

<Space height="lg" />

<Text style={styles.balanceAmount}>
{strings.unregisterExplanation({
refundAmount: formatTokenWithText(primaryAmount.quantity, wallet.primaryToken),
})}
</Text>

<Space height="lg" />
</>
)
}

const Item = (props: ViewProps) => {
const styles = useStyles()
return <View {...props} style={styles.item} />
}

const useStrings = () => {
const intl = useIntl()

Expand Down Expand Up @@ -195,12 +196,13 @@ const messages = defineMessages({
const useStyles = () => {
const {atoms, color} = useTheme()
const styles = StyleSheet.create({
item: {
...atoms.pb_xs,
},
balanceAmount: {
color: color.secondary_c500,
...atoms.body_1_lg_regular,
color: color.primary_c500,
...atoms.body_1_lg_medium,
},
balanceLabel: {
color: color.text_gray_medium,
...atoms.body_2_md_regular,
},
})
return styles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,59 @@
"defaultMessage": "!!!From",
"file": "src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.tsx",
"start": {
"line": 175,
"line": 176,
"column": 13,
"index": 5571
"index": 5722
},
"end": {
"line": 178,
"line": 179,
"column": 3,
"index": 5684
"index": 5835
}
},
{
"id": "components.walletinit.restorewallet.upgradeconfirmmodal.balanceLabel",
"defaultMessage": "!!!Recovered balance",
"file": "src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.tsx",
"start": {
"line": 179,
"line": 180,
"column": 16,
"index": 5702
"index": 5853
},
"end": {
"line": 182,
"line": 183,
"column": 3,
"index": 5831
"index": 5982
}
},
{
"id": "components.walletinit.restorewallet.upgradeconfirmmodal.finalBalanceLabel",
"defaultMessage": "!!!Final balance",
"file": "src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.tsx",
"start": {
"line": 183,
"line": 184,
"column": 21,
"index": 5854
"index": 6005
},
"end": {
"line": 186,
"line": 187,
"column": 3,
"index": 5984
"index": 6135
}
},
{
"id": "components.transfer.transfersummarymodal.unregisterExplanation",
"defaultMessage": "!!!This transaction will unregister one or more staking keys, giving you back your {refundAmount} from your deposit",
"file": "src/legacy/Dashboard/WithdrawStakingRewards/TransferSummary/TransferSummary.tsx",
"start": {
"line": 187,
"line": 188,
"column": 25,
"index": 6011
"index": 6162
},
"end": {
"line": 192,
"line": 193,
"column": 3,
"index": 6246
"index": 6397
}
}
]

0 comments on commit 16bedbf

Please sign in to comment.