mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-24 16:57:50 +00:00
Refactor temporary button text
This commit is contained in:
parent
b8b98f436d
commit
7d7d2b89bd
@ -202,25 +202,13 @@ fun RecoveryPasswordCell(seed: String = "", qrBitmap: Bitmap? = null, copySeed:(
|
||||
|
||||
AnimatedVisibility(!showQr.value) {
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(32.dp)) {
|
||||
var copied by remember { mutableStateOf(false) }
|
||||
if (copied) LaunchedEffectAsync {
|
||||
delay(2.seconds)
|
||||
copied = false
|
||||
}
|
||||
OutlineButton(
|
||||
modifier = Modifier.weight(1f),
|
||||
color = MaterialTheme.colors.onPrimary,
|
||||
onClick = {
|
||||
copySeed()
|
||||
copied = true
|
||||
}
|
||||
onClick = copySeed,
|
||||
temporaryContent = { Text(stringResource(R.string.copied)) }
|
||||
) {
|
||||
AnimatedVisibility(!copied) {
|
||||
Text(stringResource(R.string.copy))
|
||||
}
|
||||
AnimatedVisibility(copied) {
|
||||
Text(stringResource(R.string.copied))
|
||||
}
|
||||
Text(stringResource(R.string.copy))
|
||||
}
|
||||
OutlineButton(text = stringResource(R.string.qrView), modifier = Modifier.weight(1f), color = MaterialTheme.colors.onPrimary) { showQr.toggle() }
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package org.thoughtcrime.securesms.ui
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.foundation.BorderStroke
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.ScrollState
|
||||
@ -34,7 +35,11 @@ import androidx.compose.material.Text
|
||||
import androidx.compose.material.TextButton
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.alpha
|
||||
@ -58,6 +63,7 @@ import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.viewinterop.AndroidView
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import network.loki.messenger.R
|
||||
import org.session.libsession.utilities.recipients.Recipient
|
||||
@ -66,6 +72,7 @@ import org.thoughtcrime.securesms.components.ProfilePictureView
|
||||
import org.thoughtcrime.securesms.conversation.disappearingmessages.ui.OptionsCard
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
@Composable
|
||||
fun OutlineButton(
|
||||
@ -110,6 +117,42 @@ fun OutlineButton(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun OutlineButton(
|
||||
temporaryContent: @Composable () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
color: Color = LocalExtraColors.current.prominentButtonColor,
|
||||
onClick: () -> Unit = {},
|
||||
content: @Composable () -> Unit = {}
|
||||
) {
|
||||
var clicked by remember { mutableStateOf(false) }
|
||||
if (clicked) LaunchedEffectAsync {
|
||||
delay(2.seconds)
|
||||
clicked = false
|
||||
}
|
||||
|
||||
OutlinedButton(
|
||||
modifier = modifier,
|
||||
onClick = {
|
||||
onClick()
|
||||
clicked = true
|
||||
},
|
||||
border = BorderStroke(1.dp, color),
|
||||
shape = RoundedCornerShape(percent = 50),
|
||||
colors = ButtonDefaults.outlinedButtonColors(
|
||||
contentColor = color,
|
||||
backgroundColor = Color.Unspecified
|
||||
)
|
||||
) {
|
||||
AnimatedVisibility(clicked) {
|
||||
temporaryContent()
|
||||
}
|
||||
AnimatedVisibility(!clicked) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun FilledButton(
|
||||
text: String,
|
||||
|
@ -133,7 +133,6 @@
|
||||
<string name="AccessibilityId_user_settings">User settings</string>
|
||||
<string name="AccessibilityId_username">Username</string>
|
||||
<string name="AccessibilityId_privacy">Privacy</string>
|
||||
<string name="AccessibilityId_recovery_password_menu_item">Recovery password</string>
|
||||
<string name="AccessibilityId_recovery_password_menu_item">Recovery password menu item</string>
|
||||
<string name="AccessibilityId_edit_user_nickname">Edit user nickname</string>
|
||||
<string name="AccessibilityId_apply">Apply</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user