@@ -28,27 +28,16 @@ import androidx.compose.foundation.text.input.delete
2828import androidx.compose.foundation.text.input.forEachChangeReversed
2929import androidx.compose.foundation.text.input.insert
3030import androidx.compose.foundation.text.input.rememberTextFieldState
31- import androidx.compose.material3.ExperimentalMaterial3Api
32- import androidx.compose.material3.LocalRippleConfiguration
33- import androidx.compose.material3.RichTooltip
34- import androidx.compose.material3.Text
35- import androidx.compose.material3.TextButton
36- import androidx.compose.material3.TooltipAnchorPosition
37- import androidx.compose.material3.TooltipBox
38- import androidx.compose.material3.TooltipDefaults
39- import androidx.compose.material3.rememberTooltipState
31+
4032import androidx.compose.runtime.Composable
41- import androidx.compose.runtime.CompositionLocalProvider
4233import androidx.compose.runtime.LaunchedEffect
4334import androidx.compose.runtime.getValue
4435import androidx.compose.runtime.remember
45- import androidx.compose.runtime.rememberCoroutineScope
4636import androidx.compose.runtime.snapshotFlow
4737import androidx.compose.ui.Alignment
4838import androidx.compose.ui.Modifier
4939import androidx.compose.ui.focus.FocusRequester
5040import androidx.compose.ui.focus.focusRequester
51- import androidx.compose.ui.platform.LocalClipboard
5241import androidx.compose.ui.platform.LocalSoftwareKeyboardController
5342import androidx.compose.ui.text.TextRange
5443import androidx.compose.ui.text.input.KeyboardType
@@ -71,10 +60,6 @@ import com.orange.ouds.core.utilities.mapSettings
7160import com.orange.ouds.foundation.utilities.BasicPreviewParameterProvider
7261import com.orange.ouds.theme.OudsThemeContract
7362import com.orange.ouds.theme.OudsThemeSettings
74- import kotlinx.coroutines.launch
75- import org.jetbrains.compose.resources.stringResource
76- import ouds_android.core.generated.resources.Res
77- import ouds_android.core.generated.resources.core_pinCodeInput_paste_label
7863
7964/* *
8065 * PIN code input is a UI element that allows to capture short, fixed-length numeric codes, typically for authentication or confirmation purposes, such as a
@@ -272,48 +257,12 @@ private fun OudsPinCodeInput(
272257 }
273258}
274259
275- @OptIn(ExperimentalMaterial3Api ::class , ExperimentalFoundationApi ::class )
276260@Composable
277- private fun OudsPinCodeInputTooltipBox (textFieldState : TextFieldState , length : OudsPinCodeInputLength , content : @Composable () -> Unit ) {
278- val tooltipState = rememberTooltipState(isPersistent = true )
279- // TODO: Replace with OUDS tooltip when available
280- TooltipBox (
281- positionProvider = TooltipDefaults .rememberTooltipPositionProvider(
282- positioning = TooltipAnchorPosition .Above ,
283- spacingBetweenTooltipAndAnchor = OudsTheme .spaces.fixed.extraSmall
284- ),
285- tooltip = {
286- val clipboard = LocalClipboard .current
287- val scope = rememberCoroutineScope()
288- RichTooltip {
289- CompositionLocalProvider (LocalRippleConfiguration provides null ) {
290- TextButton (
291- onClick = {
292- scope.launch {
293- // clipboard.getClipEntry()?.clipData?.let { clipData ->
294- // if (clipData.itemCount > 0) {
295- // val text = clipData.getItemAt(0).text.toString()
296- // textFieldState.edit {
297- // insert(selection.min, text)
298- // with(inputTransformation(length)) {
299- // transformInput()
300- // }
301- // }
302- // }
303- // }
304- tooltipState.dismiss()
305- }
306- }
307- ) {
308- Text (text = stringResource(Res .string.core_pinCodeInput_paste_label))
309- }
310- }
311- }
312- },
313- state = tooltipState,
314- content = content
315- )
316- }
261+ internal expect fun OudsPinCodeInputTooltipBox (
262+ textFieldState : TextFieldState ,
263+ length : OudsPinCodeInputLength ,
264+ content : @Composable () -> Unit
265+ )
317266
318267@Composable
319268private fun OudsPinCodeInputDecorator (
@@ -392,7 +341,7 @@ private fun smallDeviceSpecificRules(length: OudsPinCodeInputLength): Boolean {
392341}
393342
394343@OptIn(ExperimentalFoundationApi ::class )
395- private fun inputTransformation (length : OudsPinCodeInputLength ): InputTransformation {
344+ internal fun inputTransformation (length : OudsPinCodeInputLength ): InputTransformation {
396345 return InputTransformation {
397346 changes.forEachChangeReversed { range, originalRange ->
398347 // Text is inserted with either keyboard inputs or pasting from the clipboard
0 commit comments