Skip to content

Commit 43cf4ad

Browse files
limichangehuhuanmingoriginalix
authored andcommitted
feat(referral): add visibility toggle for receiving address(OK-49840) (#10012)
- Add eye icon button to toggle address visibility on referral page - Show asterisks when address is hidden - Add event logging for address visibility toggle Co-authored-by: huhuanming <huanming@onekey.so> Co-authored-by: Leon <lixiao.dev@gmail.com>
1 parent 8d068f5 commit 43cf4ad

File tree

2 files changed

+26
-5
lines changed
  • packages
    • kit/src/views/ReferFriends/pages/InviteReward/components/CumulativeRewards
    • shared/src/logger/scopes/referral/scenes

2 files changed

+26
-5
lines changed

packages/kit/src/views/ReferFriends/pages/InviteReward/components/CumulativeRewards/index.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCallback } from 'react';
1+
import { useCallback, useState } from 'react';
22

33
import BigNumber from 'bignumber.js';
44
import { useIntl } from 'react-intl';
@@ -64,6 +64,7 @@ export function CumulativeRewards({
6464
const { activeAccount } = useActiveAccount({ num: 0 });
6565

6666
const isNewEditWithdrawAddress = withdrawAddresses.length === 0;
67+
const [isAddressVisible, setIsAddressVisible] = useState(true);
6768

6869
const toEditAddressPage = useCallback(() => {
6970
navigateToEditAddress({
@@ -166,7 +167,7 @@ export function CumulativeRewards({
166167
</SizableText>
167168

168169
{withdrawAddresses.length ? (
169-
<XStack gap="$1" ai="center">
170+
<XStack gap="$1.5" ai="center">
170171
<NetworkAvatar
171172
networkId={withdrawAddresses[0].networkId}
172173
size="$4"
@@ -177,10 +178,24 @@ export function CumulativeRewards({
177178
flexShrink={1}
178179
numberOfLines={10}
179180
>
180-
{accountUtils.shortenAddress({
181-
address: withdrawAddresses[0].address,
182-
})}
181+
{isAddressVisible
182+
? accountUtils.shortenAddress({
183+
address: withdrawAddresses[0].address,
184+
})
185+
: '**********'}
183186
</SizableText>
187+
<IconButton
188+
icon={isAddressVisible ? 'EyeOffOutline' : 'EyeOutline'}
189+
variant="tertiary"
190+
size="small"
191+
onPress={() => {
192+
const newVisibility = !isAddressVisible;
193+
setIsAddressVisible(newVisibility);
194+
defaultLogger.referral.page.toggleReceivingAddressVisibility(
195+
newVisibility,
196+
);
197+
}}
198+
/>
184199
</XStack>
185200
) : (
186201
<SizableText

packages/shared/src/logger/scopes/referral/scenes/page.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,10 @@ export class PageScene extends BaseScene {
7676
}) {
7777
return params;
7878
}
79+
80+
@LogToServer()
81+
@LogToLocal({ level: 'info' })
82+
public toggleReceivingAddressVisibility(isVisible: boolean) {
83+
return { isVisible };
84+
}
7985
}

0 commit comments

Comments
 (0)