Updated on 2026-08-14

This commit is contained in:
Tangem 2023-07-31 18:59:35 +08:00
parent 3d887a5574
commit 06b13f2227
15 changed files with 491 additions and 243 deletions

View file

@ -18,7 +18,25 @@ sealed interface TransactionState {
open val address: String,
open val amount: String,
open val timestamp: String,
) : TransactionState
) : TransactionState {
fun copySealed(
address: String = this.address,
amount: String = this.amount,
timestamp: String = this.timestamp,
): Content {
return when (this) {
is Approved -> copy(address, amount, timestamp)
is Receive -> copy(address, amount, timestamp)
is Send -> copy(address, amount, timestamp)
is Swapped -> copy(address, amount, timestamp)
is Approving -> copy(address, amount, timestamp)
is Receiving -> copy(address, amount, timestamp)
is Sending -> copy(address, amount, timestamp)
is Swapping -> copy(address, amount, timestamp)
}
}
}
/**
* Content state for processed transaction

View file

@ -6,10 +6,16 @@ plugins {
dependencies {
/** DI */
// region DI
implementation(deps.hilt.core)
kapt(deps.hilt.kapt)
// endregion
/** Coroutines */
// region Coroutines
implementation(deps.kotlin.coroutines)
// endregion
// region Time dependencies
implementation(deps.jodatime)
// endregion
}

View file

@ -0,0 +1,14 @@
package com.tangem.utils
/**
* Convert address to brief format. Example, 33BddS...ga2B.
* If [this.length] is less than a sum of [startCharsCount] and [endCharsCount], return [this].
*/
fun String.toBriefAddressFormat(startCharsCount: Int = 6, endCharsCount: Int = 4): String {
return if (startCharsCount + endCharsCount < length) {
substring(startIndex = 0, endIndex = startCharsCount) + "..." +
substring(startIndex = length - endCharsCount, endIndex = length)
} else {
this
}
}

View file

@ -0,0 +1,8 @@
package com.tangem.utils.extensions
import org.joda.time.DateTime
import org.joda.time.LocalDate
fun DateTime.isToday(): Boolean = LocalDate.now().equals(LocalDate(this))
fun DateTime.isYesterday(): Boolean = LocalDate.now().minusDays(1).equals(LocalDate(this))