1+ package com.smarttoolfactory.composecropper.demo
2+
3+ import androidx.compose.foundation.background
4+ import androidx.compose.foundation.layout.Box
5+ import androidx.compose.foundation.layout.Column
6+ import androidx.compose.foundation.layout.fillMaxSize
7+ import androidx.compose.foundation.layout.fillMaxWidth
8+ import androidx.compose.runtime.Composable
9+ import androidx.compose.runtime.getValue
10+ import androidx.compose.runtime.mutableStateOf
11+ import androidx.compose.runtime.remember
12+ import androidx.compose.ui.Alignment
13+ import androidx.compose.ui.Modifier
14+ import androidx.compose.ui.graphics.Color
15+ import androidx.compose.ui.graphics.ImageBitmap
16+ import androidx.compose.ui.platform.LocalContext
17+ import androidx.compose.ui.res.imageResource
18+ import com.smarttoolfactory.composecropper.R
19+ import com.smarttoolfactory.cropper.ImageCropper
20+ import com.smarttoolfactory.cropper.model.OutlineType
21+ import com.smarttoolfactory.cropper.model.RectCropShape
22+ import com.smarttoolfactory.cropper.settings.CropDefaults
23+ import com.smarttoolfactory.cropper.settings.CropOutlineProperty
24+
25+ @Composable
26+ fun ImageCropDemoSimple () {
27+
28+ val cropProperties by remember {
29+ mutableStateOf(
30+ CropDefaults .properties(
31+ cropOutlineProperty = CropOutlineProperty (
32+ OutlineType .Rect ,
33+ RectCropShape (0 , " Rect" )
34+ )
35+ )
36+ )
37+ }
38+ val cropStyle by remember { mutableStateOf(CropDefaults .style()) }
39+
40+ val imageBitmapLarge = ImageBitmap .imageResource(
41+ LocalContext .current.resources,
42+ R .drawable.landscape1
43+ )
44+
45+ val imageBitmap by remember { mutableStateOf(imageBitmapLarge) }
46+ val crop by remember { mutableStateOf(false ) }
47+
48+
49+ Box (
50+ modifier = Modifier
51+ .fillMaxSize()
52+ .background(Color .DarkGray ),
53+ contentAlignment = Alignment .Center
54+ ) {
55+ Column (modifier = Modifier .fillMaxSize()) {
56+
57+ ImageCropper (
58+ modifier = Modifier
59+ .fillMaxWidth()
60+ .weight(1f ),
61+ imageBitmap = imageBitmap,
62+ contentDescription = " Image Cropper" ,
63+ cropStyle = cropStyle,
64+ cropProperties = cropProperties,
65+ crop = crop,
66+ onCropStart = {}
67+ ) {
68+ }
69+ }
70+ }
71+ }
0 commit comments