-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add basic address history popup with sdk known addresses (#7682)
* feat: Add Address history popup to Account actions menu * feat: Implement a list of known addresses in AddressHistoryPopup * feat: Use KeyValueBox in a VirtualList to list addresses with index * enhancemenet: improve address history popup --------- Co-authored-by: Begoña Álvarez de la Cruz <[email protected]>
- Loading branch information
1 parent
3547104
commit f5827ec
Showing
5 changed files
with
99 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
packages/desktop/components/popups/AddressHistoryPopup.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<script lang="ts"> | ||
import { getSelectedAccount } from '@core/account' | ||
import { localize } from '@core/i18n' | ||
import { truncateString } from '@core/utils' | ||
import { AccountAddress } from '@iota/sdk/out/types' | ||
import VirtualList from '@sveltejs/svelte-virtual-list' | ||
import { FontWeight, KeyValueBox, Spinner, Text, TextType } from 'shared/components' | ||
import { onMount } from 'svelte' | ||
let addressList: AccountAddress[] | undefined = undefined | ||
onMount(() => { | ||
getSelectedAccount() | ||
?.addresses() | ||
.then((_addressList) => { | ||
addressList = _addressList?.sort((a, b) => a.keyIndex - b.keyIndex) ?? [] | ||
}) | ||
.catch((err) => { | ||
console.error(err) | ||
addressList = [] | ||
}) | ||
}) | ||
</script> | ||
|
||
<div class="flex flex-col space-y-6"> | ||
<Text type={TextType.h3} fontWeight={FontWeight.semibold} lineHeight="6"> | ||
{localize('popups.addressHistory.title')} | ||
</Text> | ||
<Text fontSize="15" color="gray-700" classes="text-left">{localize('popups.addressHistory.disclaimer')}</Text> | ||
{#if addressList} | ||
{#if addressList.length > 0} | ||
<div class="w-full flex-col space-y-2 virtual-list-wrapper"> | ||
<VirtualList items={addressList} let:item> | ||
<div class="mb-1"> | ||
<KeyValueBox | ||
isCopyable | ||
classes="flex items-center w-full py-4" | ||
keyText={truncateString(item?.address, 15, 15)} | ||
valueText={localize('popups.addressHistory.indexAndType', { | ||
values: { | ||
index: item.keyIndex, | ||
internal: item.internal, | ||
}, | ||
})} | ||
copyValue={item.address} | ||
backgroundColor="gray-50" | ||
darkBackgroundColor="gray-900" | ||
/> | ||
</div> | ||
</VirtualList> | ||
</div> | ||
{:else} | ||
<Text secondary classes="text-center">-</Text> | ||
{/if} | ||
{:else} | ||
<div class="flex items-center justify-center"> | ||
<Spinner /> | ||
</div> | ||
{/if} | ||
</div> | ||
|
||
<style lang="scss"> | ||
.virtual-list-wrapper :global(svelte-virtual-list-viewport) { | ||
margin-right: -1rem !important; | ||
flex: auto; | ||
overflow-y: scroll; | ||
padding-right: 1.5rem !important; | ||
min-height: 52px; | ||
max-height: 300px; | ||
} | ||
.virtual-list-wrapper :global(svelte-virtual-list-contents) { | ||
margin-right: -1rem !important; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters