Skip to content

Commit

Permalink
- topx made public
Browse files Browse the repository at this point in the history
  • Loading branch information
oguzhanaslann committed Aug 3, 2023
1 parent 3e1e5cf commit b311f16
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.tooling.preview.Preview
import com.oguzhanaslann.compose.cropview.cropShape.CropShape
import com.oguzhanaslann.compose.cropview.cropShape.grid.rememberGridCrop
import com.oguzhanaslann.compose.cropview.util.toPx

@Composable
fun Crop(
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/java/com/oguzhanaslann/compose/cropview/Util.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import com.oguzhanaslann.compose.cropview.isMiddle
import com.oguzhanaslann.compose.cropview.isRightEdge
import com.oguzhanaslann.compose.cropview.isTopLeftCorner
import com.oguzhanaslann.compose.cropview.isTopRightCorner
import com.oguzhanaslann.compose.cropview.toPx
import com.oguzhanaslann.compose.cropview.util.boundedHeight
import com.oguzhanaslann.compose.cropview.util.boundedNewX
import com.oguzhanaslann.compose.cropview.util.boundedNewY
Expand All @@ -29,6 +28,7 @@ import com.oguzhanaslann.compose.cropview.util.isHeightBiggerThanAllowedHeight
import com.oguzhanaslann.compose.cropview.util.isHeightLessThanMinHeight
import com.oguzhanaslann.compose.cropview.util.isWidthBiggerThanAllowedWidth
import com.oguzhanaslann.compose.cropview.util.isWidthLessThanMinWidth
import com.oguzhanaslann.compose.cropview.util.toPx
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.launch
Expand All @@ -40,7 +40,7 @@ class GridCropState(
val minSize: Size,
) : RectangleCropShapeState {
private val _topLeft = mutableStateOf(topLeft)
override val topLeft by _topLeft
override val topLeft by _topLeft

private val _size = mutableStateOf(size)
override var size: Size by _size
Expand All @@ -59,7 +59,7 @@ class GridCropState(
override fun resize(
change: PointerInputChange,
dragAmount: Offset,
maxSize: Size
maxSize: Size,
): PointerInputScope.() -> Unit = {

val xDp = change.position.x.toDp()
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/java/com/oguzhanaslann/compose/cropview/util/Util.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.oguzhanaslann.compose.cropview.util

import androidx.compose.runtime.Composable
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp


internal fun boundedNewX(
Expand Down Expand Up @@ -114,4 +118,11 @@ internal fun isHeightLessThanMinHeight(
minHeight: Float,
): Boolean {
return targetHeight < minHeight
}


@Composable
fun Dp.toPx(): Float {
val density = Density(LocalContext.current)
return with(density) { toPx() }
}

0 comments on commit b311f16

Please sign in to comment.