Skip to content

Commit

Permalink
Convert OverzoomEffect to a class to prevent custom implementations
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Jan 11, 2025
1 parent a11265e commit 22fd7f7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion zoomable/api/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ package me.saket.telephoto.zoomable {
property public final me.saket.telephoto.zoomable.HardwareShortcutsSpec Disabled;
}

@androidx.compose.runtime.Immutable public interface OverzoomEffect {
@androidx.compose.runtime.Immutable public final class OverzoomEffect {
field public static final me.saket.telephoto.zoomable.OverzoomEffect.Companion Companion;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,27 @@ class ZoomLimit(
val overzoomEffect: OverzoomEffect = OverzoomEffect.RubberBanding,
)

/**
* Represents a visual effect that displays when the zoom limits of a zoomable container
* have been reached.
*
* TODO: Make OverzoomEffect extensible by consumers when ready.
*/
@Immutable
interface OverzoomEffect {
class OverzoomEffect internal constructor(
@Suppress("unused") private val value: Int
) {
companion object {
/**
* Applies a rubber banding effect to zoom gestures when content is zoomed beyond
* its limit as a form of visual feedback that the content can't be zoomed any further.
*/
val RubberBanding: OverzoomEffect = RubberBandingOverzoomEffect
val RubberBanding: OverzoomEffect = OverzoomEffect(1)

/**
* Does not limit over/under zooms in any manner. Content will zoom in a free-form
* manner even when it goes beyond its limit (until the gesture is released).
*/
val NoLimits: OverzoomEffect = NoLimitsOverzoomEffect
val NoLimits: OverzoomEffect = OverzoomEffect(2)
}
}

internal data object RubberBandingOverzoomEffect : OverzoomEffect
internal data object NoLimitsOverzoomEffect : OverzoomEffect

0 comments on commit 22fd7f7

Please sign in to comment.