Skip to content

Commit

Permalink
Migrate sealed objects to data objects
Browse files Browse the repository at this point in the history
  • Loading branch information
saket committed Feb 15, 2024
1 parent 2a8fb89 commit f401e6d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ sealed interface FlickToDismissState {
/**
* Content is resting at its default position with no ongoing drag gesture.
*/
object Idle : GestureState
data object Idle : GestureState

@Poko
class Dragging(
Expand All @@ -69,7 +69,7 @@ sealed interface FlickToDismissState {
* Content is settling back to its default position after it was released because the drag
* distance wasn't sufficient to dismiss the content.
*/
object Resetting : GestureState
data object Resetting : GestureState

@Poko
class Dismissing(
Expand Down Expand Up @@ -99,6 +99,6 @@ sealed interface FlickToDismissState {
* Content was dismissed. At this point, [FlickToDismiss] is no longer usable
* and must be removed from composition.
*/
object Dismissed : GestureState
data object Dismissed : GestureState
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,9 @@ interface ZoomableContentLocation {
* A placeholder value for indicating that the zoomable content's location
* isn't calculated yet. The content will stay hidden until this is replaced.
*/
object Unspecified : ZoomableContentLocation {
data object Unspecified : ZoomableContentLocation {
override fun size(layoutSize: Size) = Size.Unspecified
override fun location(layoutSize: Size, direction: LayoutDirection) = throw UnsupportedOperationException()
override fun toString(): String = "ZoomableContentLocation.Unspecified"
}

/**
Expand All @@ -118,10 +117,9 @@ interface ZoomableContentLocation {
* For richer content such as images whose visual size may not always match its layout
* size, you should provide a different value using [ZoomableState.setContentLocation].
*/
object SameAsLayoutBounds : ZoomableContentLocation {
data object SameAsLayoutBounds : ZoomableContentLocation {
override fun size(layoutSize: Size): Size = layoutSize
override fun location(layoutSize: Size, direction: LayoutDirection) = Rect(Offset.Zero, layoutSize)
override fun toString(): String = "ZoomableContentLocation.SameAsLayoutBounds"
}

fun size(layoutSize: Size): Size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ private sealed interface QuickZoomEvent {
val zoomDelta: Float,
) : QuickZoomEvent

object QuickZoomStopped : QuickZoomEvent
data object QuickZoomStopped : QuickZoomEvent
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private suspend fun AwaitPointerEventScope.detectZoom(
}

private sealed class TransformEvent {
object TransformStarted : TransformEvent()
data object TransformStarted : TransformEvent()
class TransformStopped(val velocity: Velocity) : TransformEvent()
class TransformDelta(
val zoomChange: Float,
Expand Down

0 comments on commit f401e6d

Please sign in to comment.