Skip to content
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
kotlinVersion = '2.1.20'
kspVersion = '2.1.20-1.0.32'
dokkaVersion = '1.9.20'
androidxNavigationVersion = '2.9.3'
androidxNavigationVersion = '2.9.6'
secretsVaultPluginVersion = '0.1.3'
nexusPublishPluginVersion = '2.0.0'
}
Expand Down Expand Up @@ -62,13 +62,13 @@ ext {
androidxConstraintLayoutVersion = '2.2.1'
androidxActivityVersion = '1.10.1'
androidxFragmentVersion = '1.8.9'
androidxLifecycleVersion = '2.9.0'
androidxLifecycleVersion = '2.9.4'
androidxRecyclerViewVersion = '1.4.0'
androidxSwipeRefreshLayoutVersion = '1.1.0'
androidxBrowserVersion = '1.8.0'
androidxCameraVersion = '1.4.2'

androidxComposeBOMVersion = '2025.04.00'
androidxComposeBOMVersion = '2025.11.01'
composeGooglePayButtonVersion = '1.1.0'

materialVersion = '1.12.0'
Expand All @@ -81,9 +81,9 @@ ext {
okhttpVersion = '4.12.0'
okioVersion = '3.10.2'
coilVersion = '2.7.0'
commonMarkVersion = '0.25.1'
libphonenumberVersion = '9.0.12'
zxingVersion = '3.5.3'
commonMarkVersion = '0.27.0'
libphonenumberVersion = '9.0.19'
zxingVersion = '3.5.4'
jjwtVersion = '0.13.0'
bouncyCastleVersion = '1.79'
slf4jVersion = '1.7.36'
Expand All @@ -92,15 +92,15 @@ ext {
checkout3dsSdkVersion = '3.2.7'

junitVersion = '4.13.2'
mockitoVersion = '5.19.0'
mockitoVersion = '5.20.0'
mockitoInlineVersion = '5.2.0'
mockitoKotlinVersion = '6.0.0'
robolectricVersion = '4.15.1'
mockitoKotlinVersion = '6.1.0'
robolectricVersion = '4.16'
androidxTestCoreVersion = '1.7.0'

// Legacy
volleyVersion = '1.2.1'
gsonVersion = '2.13.1'
gsonVersion = '2.13.2'
}

apply from: "${rootDir}/scripts/publish-root.gradle"
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

package com.processout.sdk.ui.core.component

import android.content.ClipData
import androidx.compose.animation.*
import androidx.compose.animation.core.tween
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalClipboardManager
import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.platform.ClipEntry
import androidx.compose.ui.platform.LocalClipboard
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.Dp
import com.processout.sdk.ui.core.R
Expand Down Expand Up @@ -36,7 +37,7 @@ fun POCopyButton(
copiedIcon: PODrawableImage? = POCopyButton.CopiedIcon,
iconSize: Dp = dimensions.iconSizeSmall
) {
val clipboardManager = LocalClipboardManager.current
val clipboard = LocalClipboard.current
var isCopied by remember { mutableStateOf(false) }
var timerJob by remember { mutableStateOf<Job?>(null) }
val coroutineScope = rememberCoroutineScope()
Expand All @@ -55,12 +56,14 @@ fun POCopyButton(
POButton(
text = if (isCopiedAnimated) copiedText else copyText,
onClick = {
clipboardManager.setText(AnnotatedString(textToCopy))
isCopied = true
timerJob?.cancel()
timerJob = coroutineScope.launch {
delay(timeMillis = 2500)
isCopied = false
coroutineScope.launch {
clipboard.setClipEntry(ClipEntry(ClipData.newPlainText(textToCopy, textToCopy)))
isCopied = true
timerJob?.cancel()
timerJob = launch {
delay(timeMillis = 2500)
isCopied = false
}
}
},
modifier = modifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import androidx.compose.foundation.focusGroup
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.contextmenu.builder.item
import androidx.compose.foundation.text.contextmenu.modifier.appendTextContextMenuComponents
import androidx.compose.foundation.text.contextmenu.modifier.filterTextContextMenuComponents
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand All @@ -30,15 +33,16 @@ import com.processout.sdk.ui.core.component.PORequestFocus
import com.processout.sdk.ui.core.component.POText
import com.processout.sdk.ui.core.component.field.POField
import com.processout.sdk.ui.core.component.field.POField.stateStyle
import com.processout.sdk.ui.core.component.field.code.POCodeField.ContextMenuPasteKey
import com.processout.sdk.ui.core.component.field.code.POCodeField.align
import com.processout.sdk.ui.core.component.field.code.POCodeField.rememberTextFieldWidth
import com.processout.sdk.ui.core.component.field.code.POCodeField.validLength
import com.processout.sdk.ui.core.component.field.text.POTextField
import com.processout.sdk.ui.core.component.texttoolbar.ProcessOutTextToolbar
import com.processout.sdk.ui.core.state.POInputFilter
import com.processout.sdk.ui.core.theme.ProcessOutTheme.colors
import com.processout.sdk.ui.core.theme.ProcessOutTheme.spacing
import com.processout.sdk.ui.core.theme.ProcessOutTheme.typography
import kotlinx.coroutines.launch

/** @suppress */
@ProcessOutInternalApi
Expand Down Expand Up @@ -111,31 +115,7 @@ private fun Code(
keyboardActions: KeyboardActions,
modifier: Modifier = Modifier
) {
val validLength = remember(length) { validLength(length) }
var values by remember(validLength) { mutableStateOf(values(value.text, validLength, inputFilter)) }
var focusedIndex by remember(validLength) { mutableIntStateOf(values.focusedIndex()) }
val clipboardManager = LocalClipboardManager.current
CompositionLocalProvider(
LocalLayoutDirection provides LayoutDirection.Ltr,
LocalTextToolbar provides ProcessOutTextToolbar(
view = LocalView.current,
onPasteRequested = {
if (clipboardManager.hasText()) {
val pastedValues = values(
text = clipboardManager.getText()?.text ?: String(),
length = validLength,
inputFilter = inputFilter
)
if (!pastedValues.all { it.text.isEmpty() }) {
values = pastedValues
focusedIndex = values.focusedIndex()
onValueChange(values.codeValue())
}
}
},
hideUnspecifiedActions = true
)
) {
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
var rowWidthPx by remember { mutableIntStateOf(0) }
val horizontalSpace = spacing.space8
Row(
Expand All @@ -146,7 +126,15 @@ private fun Code(
horizontalArrangement = Arrangement.spacedBy(horizontalSpace),
verticalAlignment = Alignment.CenterVertically
) {
val context = LocalContext.current
val clipboard = LocalClipboard.current
val focusManager = LocalFocusManager.current
val coroutineScope = rememberCoroutineScope()

val validLength = remember(length) { validLength(length) }
var values by remember(validLength) { mutableStateOf(values(value.text, validLength, inputFilter)) }
var focusedIndex by remember(validLength) { mutableIntStateOf(values.focusedIndex()) }

for (textFieldIndex in values.indices) {
val focusRequester = remember { FocusRequester() }
POTextField(
Expand Down Expand Up @@ -225,6 +213,31 @@ private fun Code(
}
false
}
.appendTextContextMenuComponents {
item(
key = ContextMenuPasteKey,
label = context.getString(android.R.string.paste)
) {
coroutineScope.launch {
val pastedText = clipboard.getClipEntry()?.clipData
?.getItemAt(0)?.text?.toString() ?: String()
val pastedValues = values(
text = pastedText,
length = validLength,
inputFilter = inputFilter
)
if (!pastedValues.all { it.text.isEmpty() }) {
values = pastedValues
focusedIndex = values.focusedIndex()
onValueChange(values.codeValue())
}
close()
}
}
}
.filterTextContextMenuComponents {
it.key == ContextMenuPasteKey
}
.focusRequester(focusRequester)
.onFocusChanged {
if (it.isFocused) {
Expand Down Expand Up @@ -289,6 +302,8 @@ private fun List<TextFieldValue>.codeValue() = TextFieldValue(
@ProcessOutInternalApi
object POCodeField {

data object ContextMenuPasteKey

val default: POField.Style
@Composable get() = POField.default.let {
val text = POText.Style(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fun PODropdownField(
onValueChange = {},
modifier = Modifier.fillMaxWidth(),
textFieldModifier = textFieldModifier
.menuAnchor(MenuAnchorType.PrimaryNotEditable)
.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable)
.onFocusChanged {
isFocused = it.isFocused
},
Expand Down Expand Up @@ -140,7 +140,7 @@ fun PODropdownField(
expanded = expanded,
onDismissRequest = { expanded = false },
modifier = Modifier
.exposedDropdownSize(matchTextFieldWidth = menuMatchesTextFieldWidth)
.exposedDropdownSize(matchAnchorWidth = menuMatchesTextFieldWidth)
.heightIn(max = maxMenuHeight)
.border(
width = menuStyle.border.width,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading