Updated on 2026-08-14
This commit is contained in:
parent
c4fcd17bef
commit
e2b8b4b660
4 changed files with 14 additions and 1 deletions
|
|
@ -25,6 +25,9 @@ sealed interface TokenItemState {
|
|||
/** List of networks */
|
||||
val networks: ImmutableList<NetworkItemState>
|
||||
|
||||
/** Token composed id that unique for tokens in different networks */
|
||||
val composedId: String
|
||||
|
||||
/**
|
||||
* Token item state that is available for read
|
||||
*
|
||||
|
|
@ -32,12 +35,14 @@ sealed interface TokenItemState {
|
|||
* @property fullName token name
|
||||
* @property iconUrl token icon url
|
||||
* @property networks list of networks that is available for read
|
||||
* @property composedId token composed id to use in lists
|
||||
*/
|
||||
data class ReadContent(
|
||||
override val id: String,
|
||||
override val fullName: String,
|
||||
override val iconUrl: String,
|
||||
override val networks: ImmutableList<NetworkItemState.ReadContent>,
|
||||
override val composedId: String,
|
||||
) : TokenItemState
|
||||
|
||||
/**
|
||||
|
|
@ -47,6 +52,7 @@ sealed interface TokenItemState {
|
|||
* @property fullName token name
|
||||
* @property iconUrl token icon url
|
||||
* @property networks list of networks is available for read and edit
|
||||
* @property composedId token composed id to use in lists
|
||||
* @property name token name
|
||||
* @property symbol token brief name
|
||||
*/
|
||||
|
|
@ -55,6 +61,7 @@ sealed interface TokenItemState {
|
|||
override val fullName: String,
|
||||
override val iconUrl: String,
|
||||
override val networks: ImmutableList<NetworkItemState.ManageContent>,
|
||||
override val composedId: String,
|
||||
val name: String,
|
||||
val symbol: String,
|
||||
) : TokenItemState
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ object TokenListPreviewData {
|
|||
fullName = "Tether (USDT)",
|
||||
iconUrl = "https://s3.eu-central-1.amazonaws.com/tangem.api/coins/large/tether.png",
|
||||
networks = createManageNetworksList(),
|
||||
composedId = "11231",
|
||||
id = "",
|
||||
name = "Tether",
|
||||
symbol = "",
|
||||
|
|
@ -30,6 +31,7 @@ object TokenListPreviewData {
|
|||
fullName = "Tether (USDT)",
|
||||
iconUrl = "https://s3.eu-central-1.amazonaws.com/tangem.api/coins/large/tether.png",
|
||||
networks = createReadNetworksList(),
|
||||
composedId = "11231",
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ private fun TokensListContent(
|
|||
item { DifferentAddressesWarning() }
|
||||
}
|
||||
|
||||
items(items = tokens, key = TokenItemState::id) {
|
||||
items(items = tokens, key = TokenItemState::composedId) {
|
||||
it?.let { TokenItem(model = it) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,10 +131,12 @@ internal class TokensListViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun createManageTokenContent(token: Token): TokenItemState.ManageContent {
|
||||
val currentTime = System.nanoTime()
|
||||
return TokenItemState.ManageContent(
|
||||
fullName = getTokenFullName(token),
|
||||
iconUrl = token.iconUrl,
|
||||
networks = token.networks.map(::createManageNetworkContent).toImmutableList(),
|
||||
composedId = token.id + currentTime,
|
||||
id = token.id,
|
||||
name = token.name,
|
||||
symbol = token.symbol,
|
||||
|
|
@ -162,11 +164,13 @@ internal class TokensListViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun createReadTokenContent(token: Token): TokenItemState.ReadContent {
|
||||
val currentTime = System.nanoTime()
|
||||
return TokenItemState.ReadContent(
|
||||
id = token.id,
|
||||
fullName = getTokenFullName(token),
|
||||
iconUrl = token.iconUrl,
|
||||
networks = token.networks.map(::createReadNetworkContent).toImmutableList(),
|
||||
composedId = token.id + currentTime,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue