Skip to content

Commit

Permalink
ABW-2721 - Warning shown on Non conforming transaction before user ca…
Browse files Browse the repository at this point in the history
…n continue with signing. (#751)

* ABW-2721 - Warning shown on Non conforming transaction before user can continue with signing.

* ABW-2721 - Backin val removed.

* ABW-2721 - detekt fix.
  • Loading branch information
raf-rdx authored Jan 22, 2024
1 parent ffd610f commit e2cff08
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ fun TransactionReviewScreen(
onTipPercentageChanged = viewModel::onTipPercentageChanged,
onViewDefaultModeClick = viewModel::onViewDefaultModeClick,
onViewAdvancedModeClick = viewModel::onViewAdvancedModeClick,
dismissTransactionErrorDialog = viewModel::dismissTerminalErrorDialog
dismissTransactionErrorDialog = viewModel::dismissTerminalErrorDialog,
onAcknowledgeRawTransactionWarning = viewModel::onAcknowledgeRawTransactionWarning
)

state.interactionState?.let {
Expand Down Expand Up @@ -149,6 +150,7 @@ fun TransactionReviewScreen(
}
}

@Suppress("CyclomaticComplexMethod")
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun TransactionPreviewContent(
Expand Down Expand Up @@ -176,7 +178,8 @@ private fun TransactionPreviewContent(
onTipPercentageChanged: (String) -> Unit,
onViewDefaultModeClick: () -> Unit,
onViewAdvancedModeClick: () -> Unit,
dismissTransactionErrorDialog: () -> Unit
dismissTransactionErrorDialog: () -> Unit,
onAcknowledgeRawTransactionWarning: () -> Unit
) {
val modalBottomSheetState = rememberModalBottomSheetState(
skipPartiallyExpanded = true
Expand Down Expand Up @@ -273,6 +276,22 @@ private fun TransactionPreviewContent(
}
}

if (state.showRawTransactionWarning) {
BasicPromptAlertDialog(
finish = { acknowledged ->
if (acknowledged) {
onAcknowledgeRawTransactionWarning()
}
},
titleText = stringResource(id = R.string.transactionReview_nonConformingManifestWarning_title),
messageText = stringResource(id = R.string.transactionReview_nonConformingManifestWarning_message),
confirmText = stringResource(
id = R.string.common_continue
),
dismissText = null
)
}

AnimatedVisibility(
visible = !state.isRawManifestVisible,
enter = fadeIn(),
Expand Down Expand Up @@ -517,7 +536,8 @@ fun TransactionPreviewContentPreview() {
onTipPercentageChanged = {},
onViewDefaultModeClick = {},
onViewAdvancedModeClick = {},
dismissTransactionErrorDialog = {}
dismissTransactionErrorDialog = {},
onAcknowledgeRawTransactionWarning = {}
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ class TransactionReviewViewModel @Inject constructor(
onBackClick()
}

fun onAcknowledgeRawTransactionWarning() {
_state.update { it.copy(showRawTransactionWarning = false) }
}

sealed interface Event : OneOffEvent {
data class OnFungibleClick(
val resource: FungibleResource,
Expand All @@ -265,6 +269,7 @@ class TransactionReviewViewModel @Inject constructor(
val isNetworkFeeLoading: Boolean,
val isSubmitting: Boolean = false,
val isRawManifestVisible: Boolean = false,
val showRawTransactionWarning: Boolean = false,
val previewType: PreviewType,
val transactionFees: TransactionFees = TransactionFees(),
val feePayerSearchResult: FeePayerSearchResult? = null,
Expand All @@ -277,9 +282,6 @@ class TransactionReviewViewModel @Inject constructor(
val isTransactionDismissed: Boolean = false
) : UiState {

val showRawTransactionWarning
get() = previewType == PreviewType.NonConforming

val requestNonNull: MessageFromDataChannel.IncomingRequest.TransactionRequest
get() = requireNotNull(request)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ class TransactionAnalysisDelegate @Inject constructor(
_state.update {
it.copy(
isRawManifestVisible = previewType == PreviewType.NonConforming,
showRawTransactionWarning = previewType == PreviewType.NonConforming,
isLoading = false,
previewType = previewType,
defaultSignersCount = notaryAndSigners.signers.count()
Expand Down

0 comments on commit e2cff08

Please sign in to comment.