Приложение
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package core.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.net.Uri
|
||||
import androidx.compose.ui.graphics.toArgb
|
||||
import com.yalantis.ucrop.UCrop
|
||||
import core.presentation.theme.Indigo500
|
||||
import java.io.File
|
||||
|
||||
object ImageCropper {
|
||||
fun getCropIntent(
|
||||
context: Context,
|
||||
sourceUri: Uri,
|
||||
destinationUri: Uri
|
||||
): UCrop {
|
||||
val options = UCrop.Options().apply {
|
||||
setCompressionQuality(90)
|
||||
setHideBottomControls(false)
|
||||
setFreeStyleCropEnabled(false) // Фиксированный аспект
|
||||
setToolbarColor(Indigo500.toArgb())
|
||||
setStatusBarColor(Indigo500.toArgb())
|
||||
setActiveControlsWidgetColor(Indigo500.toArgb())
|
||||
setToolbarTitle("Crop Avatar")
|
||||
// Настройка под "квадрат" (софт-сквайр эмулируется на стороне UI, кроп всегда 1:1)
|
||||
}
|
||||
|
||||
return UCrop.of(sourceUri, destinationUri)
|
||||
.withAspectRatio(1f, 1f)
|
||||
.withMaxResultSize(1000, 1000)
|
||||
.withOptions(options)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user