IndicationNodeFactory
-
Cmn
interface IndicationNodeFactory : Indication
IndicationNodeFactory is an Indication that creates Modifier.Node instances to render visual effects that occur when certain interactions happens. For example: showing a ripple effect when a component is pressed, or a highlight when a component is focused.
An instance of IndicationNodeFactory is responsible for creating individual nodes on demand for each component that needs to render indication. IndicationNodeFactory instances should be very simple - they just hold the relevant configuration properties needed to create the node instances that are responsible for drawing visual effects.
IndicationNodeFactory is conceptually similar to ModifierNodeElement - it is designed to be able to be created outside of composition, and re-used in multiple places.
Indication is typically provided throughout the hierarchy through LocalIndication - you can provide a custom Indication to LocalIndication to change the default Indication used for components such as clickable.
Summary
Public functions |
||
|---|---|---|
DelegatableNode |
create(interactionSource: InteractionSource)Creates a node that will be applied to a specific component and render indication for the provided |
Cmn
|
operator Boolean |
Require equals() to be implemented. |
Cmn
|
Int |
hashCode()Require hashCode() to be implemented. |
Cmn
|
Inherited functions |
|||
|---|---|---|---|
|
Public functions
create
fun create(interactionSource: InteractionSource): DelegatableNode
Creates a node that will be applied to a specific component and render indication for the provided interactionSource. This method will be re-invoked for a given layout node if a new interactionSource is provided or if hashCode or equals change for this IndicationNodeFactory over time, allowing a new node to be created using the new properties in this IndicationNodeFactory. If you instead want to gracefully update the existing node over time, consider replacing those properties with androidx.compose.runtime.State properties, so when the value of the State changes, equals and hashCode remain the same, and the same node instance can just query the updated state value.
The returned DelegatableNode should implement DrawModifierNode, or delegate to a node that implements DrawModifierNode, so that it can draw visual effects. Inside DrawModifierNode.draw, make sure to call ContentDrawScope.drawContent to render the component in addition to any visual effects.
| Parameters | |
|---|---|
interactionSource: InteractionSource |
the |
| Returns | |
|---|---|
DelegatableNode |
a |
equals
operator fun equals(other: Any?): Boolean
Require equals() to be implemented. Using a data class is sufficient. Singletons may implement this function with referential equality (this === other). Instances with no properties may implement this function by checking the type of the other object.