diff options
author | Torsten Grote <t@grobox.de> | 2023-01-03 12:35:33 -0300 |
---|---|---|
committer | Torsten Grote <t@grobox.de> | 2023-01-03 12:35:33 -0300 |
commit | 5764a5c9228cf25662da697668a246fc3a4eedeb (patch) | |
tree | 02a7c0e0e5ddf1ff7f69d578fb09b08e6bcf8ff0 /wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt | |
parent | f94169acb441b5993a82f080c5830d566793a752 (diff) | |
download | taler-android-5764a5c9228cf25662da697668a246fc3a4eedeb.tar.gz taler-android-5764a5c9228cf25662da697668a246fc3a4eedeb.tar.bz2 taler-android-5764a5c9228cf25662da697668a246fc3a4eedeb.zip |
[wallet] Add share button to Peer-Push (and adapt to new API)
#0007471
Diffstat (limited to 'wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt')
-rw-r--r-- | wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt | 63 |
1 files changed, 13 insertions, 50 deletions
diff --git a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt index 6d8b5dc..5afac59 100644 --- a/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt +++ b/wallet/src/main/java/net/taler/wallet/peer/OutgoingPushResultComposable.kt @@ -17,11 +17,8 @@ package net.taler.wallet.peer import android.content.res.Configuration.UI_MODE_NIGHT_YES -import androidx.compose.foundation.Image -import androidx.compose.foundation.horizontalScroll import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.ColumnScope -import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size @@ -29,28 +26,21 @@ import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.material.Button import androidx.compose.material.CircularProgressIndicator -import androidx.compose.material.Icon -import androidx.compose.material.IconButton import androidx.compose.material.MaterialTheme import androidx.compose.material.Surface import androidx.compose.material.Text -import androidx.compose.material.icons.Icons -import androidx.compose.material.icons.filled.ContentCopy import androidx.compose.runtime.Composable -import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment.Companion.CenterHorizontally import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.asImageBitmap -import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.colorResource import androidx.compose.ui.res.stringResource -import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import net.taler.common.QrCodeManager import net.taler.wallet.R import net.taler.wallet.backend.TalerErrorInfo -import net.taler.wallet.compose.copyToClipBoard +import net.taler.wallet.compose.QrCodeUriComposable +import net.taler.wallet.compose.TalerSurface import net.taler.wallet.compose.getQrCodeSize import org.json.JSONObject @@ -95,42 +85,15 @@ private fun ColumnScope.PeerPushCreatingComposable() { @Composable private fun ColumnScope.PeerPushResponseComposable(state: OutgoingResponse) { - val qrCodeSize = getQrCodeSize() - Image( - modifier = Modifier - .size(qrCodeSize) - .align(CenterHorizontally), - bitmap = state.qrCode.asImageBitmap(), - contentDescription = stringResource(id = R.string.button_scan_qr_code), - ) - Text( - modifier = Modifier.padding(horizontal = 16.dp), - style = MaterialTheme.typography.body1, - text = stringResource(id = R.string.receive_peer_invoice_uri), - ) - val scrollState = rememberScrollState() - Text( - modifier = Modifier - .horizontalScroll(scrollState) - .padding(16.dp), - fontFamily = FontFamily.Monospace, - style = MaterialTheme.typography.body1, - text = state.talerUri, - ) - val context = LocalContext.current - IconButton( - modifier = Modifier - .align(CenterHorizontally), - onClick = { copyToClipBoard(context, "Invoice", state.talerUri) }, + QrCodeUriComposable( + talerUri = state.talerUri, + clipBoardLabel = "Invoice", ) { - Row(verticalAlignment = Alignment.CenterVertically) { - Icon(Icons.Default.ContentCopy, stringResource(R.string.copy)) - Text( - modifier = Modifier.padding(start = 8.dp), - text = stringResource(R.string.copy), - style = MaterialTheme.typography.body1, - ) - } + Text( + modifier = Modifier.padding(horizontal = 16.dp), + style = MaterialTheme.typography.body1, + text = stringResource(id = R.string.receive_peer_invoice_uri), + ) } } @@ -154,10 +117,10 @@ fun PeerPushCreatingPreview() { } } -@Preview +@Preview(uiMode = UI_MODE_NIGHT_YES) @Composable fun PeerPushResponsePreview() { - Surface { + TalerSurface { val talerUri = "https://example.org/foo/bar/can/be/very/long/url/so/fit/it/on/screen" val response = OutgoingResponse(talerUri, QrCodeManager.makeQrCode(talerUri)) OutgoingPushResultComposable(response) {} @@ -167,7 +130,7 @@ fun PeerPushResponsePreview() { @Preview(widthDp = 720, uiMode = UI_MODE_NIGHT_YES) @Composable fun PeerPushResponseLandscapePreview() { - Surface { + TalerSurface { val talerUri = "https://example.org/foo/bar/can/be/very/long/url/so/fit/it/on/screen" val response = OutgoingResponse(talerUri, QrCodeManager.makeQrCode(talerUri)) OutgoingPushResultComposable(response) {} |