Skip to content

Commit

Permalink
Rename DoubleClickListener -> DoubleClickToZoomListener
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Jun 28, 2024
1 parent 0c9d5b8 commit 9c63acd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package me.saket.telephoto.zoomable

import androidx.compose.runtime.Immutable
import androidx.compose.ui.geometry.Offset
import me.saket.telephoto.zoomable.DoubleClickListener.ToggleBetweenMinAndMax
import me.saket.telephoto.zoomable.DoubleClickToZoomListener.ToggleBetweenMinAndMax
import me.saket.telephoto.zoomable.internal.maxScale

/**
* Implement this interface for reacting to double clicks on `Modifier.zoomable`'s content.
* By default, [ToggleBetweenMinAndMax] is used.
*/
@Immutable
fun interface DoubleClickListener {
fun interface DoubleClickToZoomListener {
suspend fun onDoubleClick(
state: ZoomableState,
centroid: Offset,
Expand All @@ -19,7 +19,7 @@ fun interface DoubleClickListener {
/**
* Toggles between [ZoomSpec.maxZoomFactor] and the minimum zoom factor on double clicks.
*/
data object ToggleBetweenMinAndMax : DoubleClickListener {
data object ToggleBetweenMinAndMax : DoubleClickToZoomListener {
override suspend fun onDoubleClick(state: ZoomableState, centroid: Offset) {
val zoomFraction = state.zoomFraction ?: return // Content isn't ready yet.
state.zoomTo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fun Modifier.zoomable(
onClick: ((Offset) -> Unit)? = null,
onLongClick: ((Offset) -> Unit)? = null,
clipToBounds: Boolean = true,
onDoubleClick: DoubleClickListener = DoubleClickListener.ToggleBetweenMinAndMax,
onDoubleClick: DoubleClickToZoomListener = DoubleClickToZoomListener.ToggleBetweenMinAndMax,
): Modifier {
check(state is RealZoomableState)
return this
Expand Down Expand Up @@ -81,7 +81,7 @@ private data class ZoomableElement(
private val enabled: Boolean,
private val onClick: ((Offset) -> Unit)?,
private val onLongClick: ((Offset) -> Unit)?,
private val onDoubleClick: DoubleClickListener,
private val onDoubleClick: DoubleClickToZoomListener,
) : ModifierNodeElement<ZoomableNode>() {

override fun create(): ZoomableNode = ZoomableNode(
Expand Down Expand Up @@ -114,7 +114,7 @@ private data class ZoomableElement(
@OptIn(ExperimentalFoundationApi::class)
private class ZoomableNode(
private var state: RealZoomableState,
private var suspendableOnDoubleClick: DoubleClickListener,
private var suspendableOnDoubleClick: DoubleClickToZoomListener,
enabled: Boolean,
onClick: ((Offset) -> Unit)?,
onLongClick: ((Offset) -> Unit)?,
Expand Down Expand Up @@ -180,7 +180,7 @@ private class ZoomableNode(
enabled: Boolean,
onClick: ((Offset) -> Unit)?,
onLongClick: ((Offset) -> Unit)?,
onDoubleClick: DoubleClickListener,
onDoubleClick: DoubleClickToZoomListener,
) {
if (this.state != state) {
// Note to self: when the state is updated, the delegated
Expand Down

0 comments on commit 9c63acd

Please sign in to comment.