[#1418] Display all transaction messages
* [#1418] - Display all transaction messages as separate items - Closes #1418 - Fix new line indent - Mention functionality in the changelog - Use plurals for title when displaying transaction history messages --------- Co-authored-by: Serhii Ihnatiev <serhii.ihnatiev@ext.grandcentrix.net>
This commit is contained in:
parent
cc07535f44
commit
34e741e3b3
|
@ -41,6 +41,7 @@ directly impact users rather than highlighting other key architectural updates.*
|
||||||
### Changed
|
### Changed
|
||||||
- The app dialog window has now a bit more rounded corners
|
- The app dialog window has now a bit more rounded corners
|
||||||
- A few more minor UI improvements
|
- A few more minor UI improvements
|
||||||
|
- Display all messages within transaction history record when it is expanded
|
||||||
|
|
||||||
## [1.0 (650)] - 2024-05-07
|
## [1.0 (650)] - 2024-05-07
|
||||||
|
|
||||||
|
@ -221,4 +222,4 @@ this screen, together with buttons for copying the address and sharing the addre
|
||||||
- New Wallet Recovery Seed screen (accessible from onboarding)
|
- New Wallet Recovery Seed screen (accessible from onboarding)
|
||||||
- Seed Recovery screen (accessible from Settings)
|
- Seed Recovery screen (accessible from Settings)
|
||||||
- Restore Seed screen for an existing wallet (accessible from onboarding)
|
- Restore Seed screen for an existing wallet (accessible from onboarding)
|
||||||
- Restore Seed Birthday Height screen for an existing wallet (accessible from onboarding)
|
- Restore Seed Birthday Height screen for an existing wallet (accessible from onboarding)
|
||||||
|
|
|
@ -31,6 +31,7 @@ import androidx.compose.ui.draw.clip
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.graphics.vector.ImageVector
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
import androidx.compose.ui.platform.testTag
|
import androidx.compose.ui.platform.testTag
|
||||||
|
import androidx.compose.ui.res.pluralStringResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.res.vectorResource
|
import androidx.compose.ui.res.vectorResource
|
||||||
import androidx.compose.ui.text.TextStyle
|
import androidx.compose.ui.text.TextStyle
|
||||||
|
@ -65,7 +66,7 @@ import co.electriccoin.zcash.ui.screen.balances.BalancesTag
|
||||||
import co.electriccoin.zcash.ui.screen.balances.model.StatusAction
|
import co.electriccoin.zcash.ui.screen.balances.model.StatusAction
|
||||||
import co.electriccoin.zcash.ui.screen.send.view.DEFAULT_LESS_THAN_FEE
|
import co.electriccoin.zcash.ui.screen.send.view.DEFAULT_LESS_THAN_FEE
|
||||||
import kotlinx.collections.immutable.ImmutableList
|
import kotlinx.collections.immutable.ImmutableList
|
||||||
import kotlinx.collections.immutable.toPersistentList
|
import kotlinx.collections.immutable.persistentListOf
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
@ -239,6 +240,23 @@ private fun ComposableHistoryListItemPreview() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
@Preview("Multiple History List Items")
|
||||||
|
private fun ComposableHistoryListItemsPreview() {
|
||||||
|
ZcashTheme(forceDarkMode = false) {
|
||||||
|
BlankSurface {
|
||||||
|
HistoryItem(
|
||||||
|
onAction = {},
|
||||||
|
transaction =
|
||||||
|
TransactionUiFixture.new(
|
||||||
|
messages = persistentListOf("Message 1", "Message 2", "Message 3"),
|
||||||
|
expandableState = TrxItemState.EXPANDED
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const val ADDRESS_IN_TITLE_WIDTH_RATIO = 0.5f
|
const val ADDRESS_IN_TITLE_WIDTH_RATIO = 0.5f
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@ -468,7 +486,10 @@ private fun HistoryItemCollapsedAddressPart(
|
||||||
color = ZcashTheme.colors.textDescription,
|
color = ZcashTheme.colors.textDescription,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
overflow = TextOverflow.Ellipsis,
|
overflow = TextOverflow.Ellipsis,
|
||||||
modifier = Modifier.fillMaxWidth(ADDRESS_IN_TITLE_WIDTH_RATIO).then(clickModifier)
|
modifier =
|
||||||
|
Modifier
|
||||||
|
.fillMaxWidth(ADDRESS_IN_TITLE_WIDTH_RATIO)
|
||||||
|
.then(clickModifier)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -544,6 +565,7 @@ private fun HistoryItemDatePart(
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
@Suppress("LongMethod")
|
||||||
private fun HistoryItemExpandedPart(
|
private fun HistoryItemExpandedPart(
|
||||||
onAction: (TrxItemAction) -> Unit,
|
onAction: (TrxItemAction) -> Unit,
|
||||||
transaction: TransactionUi,
|
transaction: TransactionUi,
|
||||||
|
@ -551,18 +573,32 @@ private fun HistoryItemExpandedPart(
|
||||||
) {
|
) {
|
||||||
Column(modifier = modifier) {
|
Column(modifier = modifier) {
|
||||||
if (transaction.messages.containsValidMemo()) {
|
if (transaction.messages.containsValidMemo()) {
|
||||||
|
Text(
|
||||||
|
text =
|
||||||
|
pluralStringResource(
|
||||||
|
id = R.plurals.account_history_item_message,
|
||||||
|
count = transaction.messages!!.size
|
||||||
|
),
|
||||||
|
style = ZcashTheme.extendedTypography.transactionItemStyles.contentMedium,
|
||||||
|
color = ZcashTheme.colors.textCommon
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingSmall))
|
||||||
|
|
||||||
// Filter out identical messages on a multi-messages transaction that could be created, e.g., using
|
// Filter out identical messages on a multi-messages transaction that could be created, e.g., using
|
||||||
// YWallet, which tends to balance orchard and sapling pools, including by splitting a payment equally
|
// YWallet, which tends to balance orchard and sapling pools, including by splitting a payment equally
|
||||||
// across both pools.
|
// across both pools.
|
||||||
val uniqueMessages = transaction.messages!!.deduplicateMemos()
|
val uniqueMessages = transaction.messages.deduplicateMemos()
|
||||||
|
|
||||||
HistoryItemMessagePart(
|
uniqueMessages.forEach { message ->
|
||||||
messages = uniqueMessages.toPersistentList(),
|
HistoryItemMessagePart(
|
||||||
state = transaction.overview.getExtendedState(),
|
message = message,
|
||||||
onAction = onAction
|
state = transaction.overview.getExtendedState(),
|
||||||
)
|
onAction = onAction
|
||||||
|
)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault))
|
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingDefault))
|
||||||
|
}
|
||||||
} else if (transaction.recipientAddressType == null ||
|
} else if (transaction.recipientAddressType == null ||
|
||||||
transaction.recipientAddressType == AddressType.Shielded
|
transaction.recipientAddressType == AddressType.Shielded
|
||||||
) {
|
) {
|
||||||
|
@ -611,7 +647,7 @@ private fun HistoryItemExpandedPart(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun List<String>?.containsValidMemo(): Boolean {
|
private fun List<String>?.containsValidMemo(): Boolean {
|
||||||
return !isNullOrEmpty() && find { it.isNotEmpty() } != null
|
return !isNullOrEmpty() && any { it.isNotEmpty() }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun List<String>.deduplicateMemos(): List<String> {
|
private fun List<String>.deduplicateMemos(): List<String> {
|
||||||
|
@ -750,7 +786,7 @@ private fun HistoryItemTransactionFeePart(
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun HistoryItemMessagePart(
|
private fun HistoryItemMessagePart(
|
||||||
messages: ImmutableList<String>,
|
message: String,
|
||||||
state: TransactionExtendedState,
|
state: TransactionExtendedState,
|
||||||
onAction: (TrxItemAction) -> Unit,
|
onAction: (TrxItemAction) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
|
@ -766,25 +802,14 @@ private fun HistoryItemMessagePart(
|
||||||
}
|
}
|
||||||
|
|
||||||
Column(modifier = modifier.then(Modifier.fillMaxWidth())) {
|
Column(modifier = modifier.then(Modifier.fillMaxWidth())) {
|
||||||
Text(
|
|
||||||
text = stringResource(id = R.string.account_history_item_message),
|
|
||||||
style = ZcashTheme.extendedTypography.transactionItemStyles.contentMedium,
|
|
||||||
color = ZcashTheme.colors.textCommon
|
|
||||||
)
|
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(ZcashTheme.dimens.spacingSmall))
|
|
||||||
|
|
||||||
Box(
|
Box(
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.border(width = 1.dp, color = ZcashTheme.colors.textFieldFrame)
|
.border(width = 1.dp, color = ZcashTheme.colors.textFieldFrame)
|
||||||
) {
|
) {
|
||||||
// TODO [#1315]: Proper more messages in transaction displaying
|
|
||||||
// TODO [#1315]: Note we display the first one only for now
|
|
||||||
// TODO [#1315]: https://github.com/Electric-Coin-Company/zashi-android/issues/1315
|
|
||||||
Text(
|
Text(
|
||||||
text = messages[0],
|
text = message,
|
||||||
style = textStyle,
|
style = textStyle,
|
||||||
color = textColor,
|
color = textColor,
|
||||||
modifier = Modifier.padding(all = ZcashTheme.dimens.spacingMid)
|
modifier = Modifier.padding(all = ZcashTheme.dimens.spacingMid)
|
||||||
|
@ -801,7 +826,7 @@ private fun HistoryItemMessagePart(
|
||||||
modifier =
|
modifier =
|
||||||
Modifier
|
Modifier
|
||||||
.clip(RoundedCornerShape(ZcashTheme.dimens.regularRippleEffectCorner))
|
.clip(RoundedCornerShape(ZcashTheme.dimens.regularRippleEffectCorner))
|
||||||
.clickable { onAction(TrxItemAction.MessageClick(messages[0])) }
|
.clickable { onAction(TrxItemAction.MessageClick(message)) }
|
||||||
.padding(all = ZcashTheme.dimens.spacingTiny)
|
.padding(all = ZcashTheme.dimens.spacingTiny)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
<string name="account_history_item_sent_prefix">-</string>
|
<string name="account_history_item_sent_prefix">-</string>
|
||||||
<string name="account_history_item_received_prefix">+</string>
|
<string name="account_history_item_received_prefix">+</string>
|
||||||
<string name="account_history_item_tap_to_copy">Tap to copy</string>
|
<string name="account_history_item_tap_to_copy">Tap to copy</string>
|
||||||
<string name="account_history_item_message">Message</string>
|
n <plurals name="account_history_item_message">
|
||||||
|
<item quantity="one">Message</item>
|
||||||
|
<item quantity="other">Messages</item>
|
||||||
|
</plurals>
|
||||||
<string name="account_history_item_no_message">No message included in transaction</string>
|
<string name="account_history_item_no_message">No message included in transaction</string>
|
||||||
<string name="account_history_item_collapse_transaction">Collapse transaction</string>
|
<string name="account_history_item_collapse_transaction">Collapse transaction</string>
|
||||||
<string name="account_history_item_transaction_id">Transaction ID</string>
|
<string name="account_history_item_transaction_id">Transaction ID</string>
|
||||||
|
|
Loading…
Reference in New Issue