Skip to content

Commit

Permalink
UI: Move ScalingIndication to dedicated file (#563)
Browse files Browse the repository at this point in the history
### TL;DR
Moved scaling indication logic into its own file and cleaned up unused imports

### What changed?
- Relocated `ScalingIndication` object from `Klickable.kt` to a dedicated `ScalingIndication.kt` file
- Removed unused imports from `Klickable.kt`
- Renamed `Indication.kt` to `ScalingIndication.kt` to better reflect its contents
  • Loading branch information
ksharma-xyz authored Jan 24, 2025
1 parent 077b892 commit 96554db
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package xyz.ksharma.krail.taj.modifier

import androidx.compose.foundation.IndicationNodeFactory
import androidx.compose.foundation.clickable
import androidx.compose.foundation.interaction.InteractionSource
import androidx.compose.foundation.interaction.MutableInteractionSource
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.node.DelegatableNode
import androidx.compose.ui.semantics.Role
import xyz.ksharma.krail.taj.theme.krailRipple
import xyz.ksharma.krail.taj.themeColor
Expand Down Expand Up @@ -53,13 +50,3 @@ fun Modifier.scalingKlickable(
onClick = onClick,
)
}

object ScalingIndication : IndicationNodeFactory {
override fun create(interactionSource: InteractionSource): DelegatableNode {
return ScaleIndicationNode(interactionSource)
}

override fun equals(other: Any?): Boolean = other === this

override fun hashCode(): Int = -1
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,28 @@ package xyz.ksharma.krail.taj.modifier

import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.spring
import androidx.compose.foundation.IndicationNodeFactory
import androidx.compose.foundation.interaction.InteractionSource
import androidx.compose.foundation.interaction.PressInteraction
import androidx.compose.ui.Modifier
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.graphics.drawscope.ContentDrawScope
import androidx.compose.ui.graphics.drawscope.scale
import androidx.compose.ui.node.DelegatableNode
import androidx.compose.ui.node.DrawModifierNode
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch

object ScalingIndication : IndicationNodeFactory {
override fun create(interactionSource: InteractionSource): DelegatableNode {
return ScaleIndicationNode(interactionSource)
}

override fun equals(other: Any?): Boolean = other === this

override fun hashCode(): Int = -1
}

/**
* https://developer.android.com/develop/ui/compose/touch-input/user-interactions/migrate-indication-ripple
*/
Expand Down

0 comments on commit 96554db

Please sign in to comment.