11package com.d4rk.netprobe.utils
22
3- import android.annotation.SuppressLint
4- import androidx.compose.animation.core.animateFloatAsState
53import androidx.compose.foundation.clickable
6- import androidx.compose.foundation.gestures.awaitFirstDown
7- import androidx.compose.foundation.gestures.waitForUpOrCancellation
8- import androidx.compose.foundation.interaction.MutableInteractionSource
94import androidx.compose.foundation.layout.Arrangement
105import androidx.compose.foundation.layout.Column
116import androidx.compose.foundation.layout.Row
@@ -28,17 +23,10 @@ import androidx.compose.material3.Text
2823import androidx.compose.material3.VerticalDivider
2924import androidx.compose.runtime.Composable
3025import androidx.compose.runtime.State
31- import androidx.compose.runtime.getValue
32- import androidx.compose.runtime.mutableStateOf
33- import androidx.compose.runtime.remember
34- import androidx.compose.runtime.setValue
3526import androidx.compose.ui.Alignment
3627import androidx.compose.ui.Modifier
37- import androidx.compose.ui.composed
3828import androidx.compose.ui.draw.clip
39- import androidx.compose.ui.graphics.graphicsLayer
4029import androidx.compose.ui.graphics.vector.ImageVector
41- import androidx.compose.ui.input.pointer.pointerInput
4230import androidx.compose.ui.text.font.FontWeight
4331import androidx.compose.ui.unit.dp
4432
@@ -267,35 +255,4 @@ fun SwitchPreferenceItemWithDivider(
267255 } , modifier = Modifier .padding(16 .dp))
268256
269257 }
270- }
271-
272- enum class ButtonState { Pressed , Idle }
273-
274- @SuppressLint(" ReturnFromAwaitPointerEventScope" )
275- @Composable
276- fun Modifier.bounceClick () = composed {
277- var buttonState by remember { mutableStateOf(ButtonState .Idle ) }
278- val scale by animateFloatAsState(
279- if (buttonState == ButtonState .Pressed ) 0.95f else 1f , label = " "
280- )
281- this
282- .graphicsLayer {
283- scaleX = scale
284- scaleY = scale
285- }
286- .clickable(interactionSource = remember { MutableInteractionSource () } ,
287- indication = null ,
288- onClick = { })
289- .pointerInput(buttonState) {
290- awaitPointerEventScope {
291- buttonState = if (buttonState == ButtonState .Pressed ) {
292- waitForUpOrCancellation()
293- ButtonState .Idle
294- }
295- else {
296- awaitFirstDown(false )
297- ButtonState .Pressed
298- }
299- }
300- }
301258}
0 commit comments