Skip to content

Commit

Permalink
Added comments for Tx History + updated app version
Browse files Browse the repository at this point in the history
  • Loading branch information
tohrxyz committed Feb 8, 2023
1 parent 175c9b9 commit 97416e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ android {
applicationId "xyz.tomashrib.zephyruswallet"
minSdk 26
targetSdk 32
versionCode 61
versionName "0.6.1"
versionCode 71
versionName "0.7.1"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ internal fun HomeScreen(
}
}

// tx history container
Row(
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.Center,
Expand All @@ -224,7 +225,8 @@ internal fun HomeScreen(
bottom.linkTo(buttonsBar.top)
}
){
//this should display transaction history

//this displays all transactions from history
allTransactions?.let { TransactionHistoryList(transactions = it) }
}

Expand Down Expand Up @@ -357,16 +359,14 @@ fun isOnline(context: Context): Boolean {

@Composable
fun TransactionHistoryList(transactions: List<TransactionDetails>){
val unconfirmedTransactions = transactions.filter{
it.confirmationTime == null
}
val confirmedTransasctions = transactions.filter{
it.confirmationTime != null
}

val sortedTxList = transactions.sortedWith(compareByDescending(nullsLast(), { it.confirmationTime?.height }))
// sorts transactions by confirmation time, if unconfirmed it goes to the top
val sortedTxList = transactions.sortedWith(compareByDescending(nullsLast()) { it.confirmationTime?.height })

// for scrollable tx history
val scrollState = rememberScrollState()

// container for all txs
Column(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally,
Expand All @@ -376,7 +376,11 @@ fun TransactionHistoryList(transactions: List<TransactionDetails>){
.padding(vertical = 10.dp, horizontal = 10.dp)
.verticalScroll(scrollState)
) {

// for every transaction in list
for(item in sortedTxList){

//if unconfirmed
if (item.confirmationTime == null){
TransactionHistoryTile(
isPayment = (checkIsPayment(item.received.toString(), item.sent.toString())),
Expand All @@ -385,15 +389,17 @@ fun TransactionHistoryList(transactions: List<TransactionDetails>){
sent = item.sent.toString(),
timestamp = "pending",
)
// space between
Spacer(Modifier.padding(vertical = 10.dp))
} else{
} else{ // if confirmed
TransactionHistoryTile(
isPayment = (checkIsPayment(item.received.toString(), item.sent.toString())),
isConfirmed = (checkIsConfirmed(item.confirmationTime.toString())),
received = item.received.toString(),
sent = item.sent.toString(),
timestamp = item.confirmationTime!!.timestamp.timestampToString()
)
// space between
Spacer(Modifier.padding(vertical = 10.dp))
}
}
Expand Down

0 comments on commit 97416e2

Please sign in to comment.