Skip to content

Commit

Permalink
CR: update
Browse files Browse the repository at this point in the history
  • Loading branch information
banklesss committed May 29, 2024
1 parent d525844 commit 6fb424c
Show file tree
Hide file tree
Showing 22 changed files with 217 additions and 216 deletions.
4 changes: 2 additions & 2 deletions apps/wallet-mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,7 @@ SPEC CHECKSUMS:
amplitude-react-native: 1ea3d5e1f80ccc357dd178c55c29e51c89f1cd11
boost: 57d2868c099736d80fcd648bf211b4431e51a558
BVLinearGradient: e3aad03778a456d77928f594a649e96995f1c872
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
EXApplication: d8f53a7eee90a870a75656280e8d4b85726ea903
EXBarCodeScanner: 8e23fae8d267dbef9f04817833a494200f1fce35
EXCamera: 0fbfa338a3776af2722d626a3437abe33f708aad
Expand All @@ -838,7 +838,7 @@ SPEC CHECKSUMS:
FBLazyVector: 12ea01e587c9594e7b144e1bfc86ac4d9ac28fde
FBReactNativeSpec: faca7d16c37626ca5780a87adef703817722fe61
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: c5d68082e772fa1c511173d6b30a9de2c05a69a2
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
hermes-engine: d7cc127932c89c53374452d6f93473f1970d8e88
libaom: 144606b1da4b5915a1054383c3a4459ccdb3c661
libavif: 84bbb62fb232c3018d6f1bab79beea87e35de7b7
Expand Down
6 changes: 3 additions & 3 deletions apps/wallet-mobile/src/components/AmountItem/AmountItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type AmountItemProps = {
wallet: YoroiWallet
amount: Balance.Amount
style?: ViewProps['style']
isPrivacyOff?: boolean
isPrivacyActive?: boolean
status?: string
inWallet?: boolean
variant?: 'swap'
Expand All @@ -25,7 +25,7 @@ export type AmountItemProps = {
}

export const AmountItem = ({
isPrivacyOff,
isPrivacyActive,
wallet,
style,
amount,
Expand Down Expand Up @@ -84,7 +84,7 @@ export const AmountItem = ({
{priceImpactRisk === 'high' && <Icon.Warning size={24} color={priceImpactRiskTextColor} />}

<Text style={[styles.quantity, {color: priceImpactRiskTextColor}]}>
{isPrivacyOff ? '**.*******' : formattedQuantity}
{isPrivacyActive ? '**.*******' : formattedQuantity}
</Text>
</View>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type Props = TextProps & {
}

export const HideableText = ({text, ...props}: Props) => {
const {isPrivacyOn} = usePrivacyMode()
const children = isPrivacyOn ? text : text?.replaceAll(/./g, '\u25CF')
const {isPrivacyActive} = usePrivacyMode()
const children = !isPrivacyActive ? text : text?.replaceAll(/./g, '\u25CF')

return <Text {...props}>{children}</Text>
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ export const PairedBalance = React.forwardRef<ResetErrorRef, Props>(({amount, te
const Price = ({amount, textStyle, ignorePrivacy}: Props) => {
const styles = useStyles()
const wallet = useSelectedWallet()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode()
const {currency, config} = useCurrencyContext()
const rate = useExchangeRate({wallet, to: currency})

const price = React.useMemo(() => {
if (rate == null) return `... ${currency}`

return isPrivacyOn || !ignorePrivacy
return !isPrivacyActive || ignorePrivacy === true
? `${amountBreakdown(amount).bn.times(rate).toFormat(config.decimals)} ${currency}`
: `${privacyPlaceholder} ${currency}`
}, [amount, config.decimals, currency, ignorePrivacy, isPrivacyOn, privacyPlaceholder, rate])
}, [amount, config.decimals, currency, ignorePrivacy, isPrivacyActive, privacyPlaceholder, rate])

return (
<Text style={[styles.pairedBalanceText, textStyle]} testID="pairedTotalText">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export const TokenAmountItem = ({
orderType,
}: TokenAmountItemProps) => {
const {styles, colors} = useStyles()
const {privacyPlaceholder, isPrivacyOn} = usePrivacyMode()
const {privacyPlaceholder, isPrivacyActive} = usePrivacyMode()
const priceImpactRiskTheme = usePriceImpactRiskTheme(priceImpactRisk ?? 'none')

const {info} = amount
const isPrimary = isPrimaryToken(info)
const detail = isPrimary ? info.description : info.fingerprint
const name = infoExtractName(info)

const formattedQuantity = isPrivacyOn || !ignorePrivacy ? amountFormatter()(amount) : privacyPlaceholder
const formattedQuantity = !isPrivacyActive && ignorePrivacy == true ? amountFormatter()(amount) : privacyPlaceholder

const showSwapDetails = !isPrimary && variant === 'swap'
const priceImpactRiskTextColor = orderType === 'market' ? priceImpactRiskTheme.text : colors.text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ApplicationSettingsScreen = () => {
const {languageCode, supportedLanguages} = useLanguage()
const language = supportedLanguages.find((lang) => lang.code === languageCode) ?? defaultLanguage

const {isTogglePrivacyModeLoading, isPrivacyOff} = usePrivacyMode()
const {isTogglePrivacyModeLoading, isPrivacyActive} = usePrivacyMode()
const {currency} = useCurrencyContext()
const {enabled: crashReportEnabled} = useCrashReports()

Expand Down Expand Up @@ -119,7 +119,7 @@ export const ApplicationSettingsScreen = () => {
label={strings.privacyMode}
info={strings.privacyModeInfo}
>
<PrivacyModeSwitch isPrivacyOff={isPrivacyOff} />
<PrivacyModeSwitch isPrivacyActive={isPrivacyActive} />
</SettingsItem>

<SettingsItem
Expand Down Expand Up @@ -164,9 +164,9 @@ export const ApplicationSettingsScreen = () => {
}

// to avoid switch jumps
const PrivacyModeSwitch = ({isPrivacyOff}: {isPrivacyOff: boolean}) => {
const PrivacyModeSwitch = ({isPrivacyActive}: {isPrivacyActive: boolean}) => {
const {setPrivacyModeOn, setPrivacyModeOff, isTogglePrivacyModeLoading} = usePrivacyMode()
const [isLocalPrivacyOff, setIsLocalPrivacyOff] = React.useState(isPrivacyOff)
const [isLocalPrivacyActive, setIsLocalPrivacyOff] = React.useState(isPrivacyActive)

const onTogglePrivacyMode = () => {
setIsLocalPrivacyOff((prevState) => {
Expand All @@ -182,7 +182,7 @@ const PrivacyModeSwitch = ({isPrivacyOff}: {isPrivacyOff: boolean}) => {

return (
<SettingsSwitch
value={isLocalPrivacyOff}
value={isLocalPrivacyActive}
onValueChange={onTogglePrivacyMode}
disabled={isTogglePrivacyModeLoading}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ type ActionableAmountProps = {
}
const ActionableAmount = ({amount, onRemove, wallet, collateralId, disabled}: ActionableAmountProps) => {
const {styles} = useStyles()
const {isPrivacyOff} = usePrivacyMode()
const {isPrivacyActive} = usePrivacyMode()

const handleRemove = () => onRemove()

return (
<View style={styles.amountItem} testID="amountItem">
<Left>
<AmountItem amount={amount} wallet={wallet} isPrivacyOff={isPrivacyOff} />
<AmountItem amount={amount} wallet={wallet} isPrivacyActive={isPrivacyActive} />
</Left>

{collateralId !== '' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ export const usePrivacyMode = () => {
const writePrivacyMode = useWritePrivacyMode()

return {
isPrivacyOff: privacyMode === 'HIDDEN',
isPrivacyOn: privacyMode === 'SHOWN',
isPrivacyActive: privacyMode === 'HIDDEN',
privacyMode,
togglePrivacyMode,
isTogglePrivacyModeLoading,
Expand Down
8 changes: 4 additions & 4 deletions apps/wallet-mobile/src/legacy/Dashboard/UserSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const UserSummary = ({totalAdaSum, totalRewards, totalDelegated, onWithdr
const styles = useStyles()
const strings = useStrings()
const wallet = useSelectedWallet()
const {isPrivacyOn} = usePrivacyMode()
const {isPrivacyActive} = usePrivacyMode()

return (
<View style={styles.wrapper}>
Expand All @@ -40,7 +40,7 @@ export const UserSummary = ({totalAdaSum, totalRewards, totalDelegated, onWithdr
<Text style={styles.label}>{strings.availableFunds}:</Text>

<Text bold style={styles.value} testID="userSummaryAvailableFundsText">
{isPrivacyOn
{!isPrivacyActive
? totalAdaSum != null
? formatAdaWithText(asQuantity(totalAdaSum), wallet.primaryToken)
: '-'
Expand All @@ -58,7 +58,7 @@ export const UserSummary = ({totalAdaSum, totalRewards, totalDelegated, onWithdr
<Text style={styles.label}>{strings.rewardsLabel}:</Text>

<Text bold style={styles.value} testID="userSummaryRewardsText">
{isPrivacyOn
{!isPrivacyActive
? totalRewards != null
? formatAdaWithText(asQuantity(totalRewards), wallet.primaryToken)
: '-'
Expand Down Expand Up @@ -88,7 +88,7 @@ export const UserSummary = ({totalAdaSum, totalRewards, totalDelegated, onWithdr
<Text style={styles.label}>{strings.delegatedLabel}:</Text>

<Text bold style={styles.value} testID="userSummaryDelegatedText">
{isPrivacyOn
{!isPrivacyActive
? totalDelegated != null
? formatAdaWithText(asQuantity(totalDelegated), wallet.primaryToken)
: '-'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ type ExplorableAssetItemProps = AmountItemProps & {
}
const ExplorableAssetItem = ({wallet, amount, onPress}: ExplorableAssetItemProps) => {
const styles = useStyles()
const {isPrivacyOff} = usePrivacyMode()
const {isPrivacyActive} = usePrivacyMode()
return (
<TouchableOpacity style={styles.button} onPress={onPress} testID="assetSelectorItem">
<AmountItem isPrivacyOff={isPrivacyOff} wallet={wallet} amount={amount} />
<AmountItem isPrivacyActive={isPrivacyActive} wallet={wallet} amount={amount} />
</TouchableOpacity>
)
}
Expand Down
8 changes: 5 additions & 3 deletions apps/wallet-mobile/src/legacy/TxHistory/BalanceBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ export const BalanceBanner = React.forwardRef<ResetErrorRef>((_, ref) => {

type BalanceProps = {amount: Portfolio.Token.Amount; ignorePrivacy?: boolean}
const Balance = ({amount, ignorePrivacy}: BalanceProps) => {
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode()
const styles = useStyles()

console.log('ignorePrivacy', ignorePrivacy)

const balance = React.useMemo(
() =>
isPrivacyOn || !ignorePrivacy
!isPrivacyActive || ignorePrivacy === true
? amountFormatter({template: '{{value}} {{ticker}}'})(amount)
: amountFormatter({template: `${privacyPlaceholder} {{ticker}}`})(amount),
[amount, ignorePrivacy, isPrivacyOn, privacyPlaceholder],
[amount, ignorePrivacy, isPrivacyActive, privacyPlaceholder],
)

return (
Expand Down
6 changes: 3 additions & 3 deletions apps/wallet-mobile/src/legacy/TxHistory/LockedDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import globalMessages from '../../kernel/i18n/global-messages'

export const LockedDeposit = ({ignorePrivacy = false}: {ignorePrivacy?: boolean}) => {
const wallet = useSelectedWallet()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode()
const {lockedAsStorageCost} = usePortfolioPrimaryBreakdown({wallet})

const amount = React.useMemo(
() =>
isPrivacyOn || !ignorePrivacy
!isPrivacyActive || !ignorePrivacy
? amountFormatter({template: '{{value}} {{ticker}}'})({
quantity: lockedAsStorageCost,
info: wallet.portfolioPrimaryTokenInfo,
Expand All @@ -26,7 +26,7 @@ export const LockedDeposit = ({ignorePrivacy = false}: {ignorePrivacy?: boolean}
quantity: 0n,
info: wallet.portfolioPrimaryTokenInfo,
}),
[ignorePrivacy, isPrivacyOn, lockedAsStorageCost, privacyPlaceholder, wallet.portfolioPrimaryTokenInfo],
[ignorePrivacy, isPrivacyActive, lockedAsStorageCost, privacyPlaceholder, wallet.portfolioPrimaryTokenInfo],
)

return <FormattedAmount amount={amount} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type AssetRowProps = {
const AssetRow = ({styles, entry, backColor, onSelect}: AssetRowProps) => {
const intl = useIntl()
const wallet = useSelectedWallet()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode()
const tokenInfo = useTokenInfo({wallet, tokenId: entry.identifier})
const isPrimary = tokenInfo.id === wallet.primaryTokenInfo.id
const primaryTicker = wallet.primaryTokenInfo.ticker
Expand All @@ -75,7 +75,7 @@ const AssetRow = ({styles, entry, backColor, onSelect}: AssetRowProps) => {

<View style={styles.assetBalanceView}>
<Text style={styles.assetBalance}>
{isPrivacyOn ? privacyPlaceholder : formatTokenAmount(asQuantity(entry.amount), tokenInfo)}
{isPrivacyActive ? privacyPlaceholder : formatTokenAmount(asQuantity(entry.amount), tokenInfo)}
</Text>
</View>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ const Label = ({children}: {children: string}) => {
const AdaAmount = ({amount}: {amount: BigNumber}) => {
const wallet = useSelectedWallet()
const {styles} = useStyles()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode()
const amountStyle = amount.gte(0) ? styles.positiveAmount : styles.negativeAmount

if (isPrivacyOn) {
if (isPrivacyActive) {
return <Text style={amountStyle}>{privacyPlaceholder}</Text>
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const Middle = ({style, ...props}: ViewProps) => (
const Right = ({style, ...props}: ViewProps) => <View style={[style, {padding: 4}]} {...props} />
const Amount = ({wallet, transaction}: {wallet: YoroiWallet; transaction: TransactionInfo}) => {
const {styles} = useStyles()
const {isPrivacyOn, privacyPlaceholder} = usePrivacyMode()
const {isPrivacyActive, privacyPlaceholder} = usePrivacyMode()
const amountAsMT = MultiToken.fromArray(transaction.amount)
const amount: BigNumber = amountAsMT.getDefault()
const fee = transaction.fee ? transaction.fee[0] : null
Expand All @@ -129,10 +129,10 @@ const Amount = ({wallet, transaction}: {wallet: YoroiWallet; transaction: Transa
return (
<View style={styles.amount} testID="transactionAmount">
<Text style={style} secondary={transaction.assurance === 'PENDING'}>
<Text>{isPrivacyOn && formatTokenInteger(asQuantity(amount), wallet.primaryToken)}</Text>
<Text>{!isPrivacyActive && formatTokenInteger(asQuantity(amount), wallet.primaryToken)}</Text>

<Text small>
{isPrivacyOn ? formatTokenFractional(asQuantity(amount), wallet.primaryToken) : privacyPlaceholder}
{!isPrivacyActive ? formatTokenFractional(asQuantity(amount), wallet.primaryToken) : privacyPlaceholder}
</Text>
</Text>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"start": {
"line": 74,
"column": 22,
"index": 2557
"index": 2578
},
"end": {
"line": 77,
"column": 3,
"index": 2689
"index": 2710
}
}
]
Loading

0 comments on commit 6fb424c

Please sign in to comment.