Skip to content

Commit 2e31e8e

Browse files
committed
feat(desktop, match-infos): add ripple effect
1 parent fc1dfac commit 2e31e8e

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

core/shared-ui/src/androidMain/kotlin/com/neoutils/neoregex/core/sharedui/component/MatchResult.android.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ actual fun BoxScope.MatchesInfos(
6161
shape = RoundedCornerShape(dimensions.tiny)
6262
)
6363
.padding(2.dp)
64-
)
64+
)

core/shared-ui/src/commonMain/kotlin/com/neoutils/neoregex/core/sharedui/component/MatchesInfos.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ expect fun BoxScope.MatchesInfos(
2828
duration: Duration,
2929
matches: Int,
3030
modifier: Modifier = Modifier
31-
)
31+
)

core/shared-ui/src/desktopMain/kotlin/com/neoutils/neoregex/core/sharedui/component/MatchResult.desktop.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ import androidx.compose.animation.core.Animatable
2323
import androidx.compose.animation.core.VectorConverter
2424
import androidx.compose.animation.fadeIn
2525
import androidx.compose.animation.fadeOut
26-
import androidx.compose.foundation.ExperimentalFoundationApi
27-
import androidx.compose.foundation.background
28-
import androidx.compose.foundation.border
26+
import androidx.compose.foundation.*
2927
import androidx.compose.foundation.gestures.onDrag
28+
import androidx.compose.foundation.interaction.MutableInteractionSource
3029
import androidx.compose.foundation.layout.*
3130
import androidx.compose.foundation.shape.RoundedCornerShape
3231
import androidx.compose.material3.MaterialTheme.colorScheme
3332
import androidx.compose.material3.MaterialTheme.typography
3433
import androidx.compose.material3.Text
34+
import androidx.compose.material3.ripple
3535
import androidx.compose.runtime.*
3636
import androidx.compose.ui.Alignment
3737
import androidx.compose.ui.Modifier
@@ -40,7 +40,10 @@ import androidx.compose.ui.geometry.Rect
4040
import androidx.compose.ui.layout.boundsInRoot
4141
import androidx.compose.ui.layout.onGloballyPositioned
4242
import androidx.compose.ui.platform.LocalDensity
43-
import androidx.compose.ui.unit.*
43+
import androidx.compose.ui.unit.DpSize
44+
import androidx.compose.ui.unit.dp
45+
import androidx.compose.ui.unit.round
46+
import androidx.compose.ui.unit.toSize
4447
import com.neoutils.neoregex.core.designsystem.theme.NeoTheme.dimensions
4548
import com.neoutils.neoregex.core.designsystem.theme.NeoTheme.fontSizes
4649
import com.neoutils.neoregex.core.resources.Res
@@ -120,6 +123,8 @@ actual fun BoxScope.MatchesInfos(
120123
}
121124
}
122125

126+
val hover = remember { MutableInteractionSource() }
127+
123128
Text(
124129
text = pluralStringResource(
125130
Res.plurals.match_result_infos,
@@ -143,6 +148,11 @@ actual fun BoxScope.MatchesInfos(
143148
targetSize = density.run { it.size.toSize().toDpSize() }
144149
targetRect = it.boundsInRoot()
145150
}
151+
.hoverable(hover)
152+
.indication(
153+
interactionSource = hover,
154+
indication = ripple()
155+
)
146156
.onDrag(
147157
onDragStart = {
148158
isRunning = true
@@ -179,4 +189,4 @@ actual fun BoxScope.MatchesInfos(
179189
)
180190
.padding(dimensions.micro) // internal
181191
)
182-
}
192+
}

core/shared-ui/src/webMain/kotlin/com/neoutils/neoregex/core/sharedui/component/MatchResult.web.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ actual fun BoxScope.MatchesInfos(
3030
modifier: Modifier
3131
) {
3232
// TODO: don't support
33-
}
33+
}

0 commit comments

Comments
 (0)