@@ -5,10 +5,9 @@ import androidx.compose.foundation.Canvas
5
5
import androidx.compose.foundation.Image
6
6
import androidx.compose.foundation.background
7
7
import androidx.compose.foundation.layout.*
8
- import androidx.compose.material3.AlertDialog
9
- import androidx.compose.material3.Button
10
- import androidx.compose.material3.MaterialTheme
11
- import androidx.compose.material3.Text
8
+ import androidx.compose.material.icons.Icons
9
+ import androidx.compose.material.icons.filled.Crop
10
+ import androidx.compose.material3.*
12
11
import androidx.compose.runtime.*
13
12
import androidx.compose.ui.Alignment
14
13
import androidx.compose.ui.Modifier
@@ -46,7 +45,7 @@ fun EnhancedZoomCropDemo() {
46
45
47
46
val imageBitmap = ImageBitmap .imageResource(
48
47
LocalContext .current.resources,
49
- R .drawable.landscape1
48
+ R .drawable.landscape5
50
49
)
51
50
52
51
var contentScale by remember { mutableStateOf(ContentScale .FillBounds ) }
@@ -179,25 +178,6 @@ private fun CallbackAndCropSample(imageBitmap: ImageBitmap, contentScale: Conten
179
178
)
180
179
}
181
180
182
- Button (
183
- modifier = Modifier
184
- .padding(8 .dp)
185
- .fillMaxWidth(),
186
- enabled = ! zoomState.isAnimationRunning,
187
- onClick = { showDialog = true }
188
- ) {
189
- Text (" Crop" )
190
- }
191
-
192
- ImageDialog (
193
- showDialog = showDialog,
194
- imageBitmap = imageBitmap,
195
- croppedImage = croppedImage
196
- ) {
197
- showDialog = false
198
- }
199
-
200
-
201
181
Spacer (modifier = Modifier .height(20 .dp))
202
182
203
183
if (rectCrop.size != IntSize .Zero ) {
@@ -223,6 +203,30 @@ private fun CallbackAndCropSample(imageBitmap: ImageBitmap, contentScale: Conten
223
203
)
224
204
}
225
205
}
206
+
207
+ Spacer (modifier = Modifier .weight(1f ))
208
+
209
+ Row (
210
+ modifier = Modifier
211
+ .fillMaxWidth()
212
+ .padding(16 .dp),
213
+ horizontalArrangement = Arrangement .End
214
+ ) {
215
+ FloatingActionButton (
216
+ onClick = { showDialog = true }
217
+ ) {
218
+ Icon (imageVector = Icons .Default .Crop , contentDescription = null )
219
+ }
220
+
221
+ }
222
+
223
+ ImageDialog (
224
+ showDialog = showDialog,
225
+ imageBitmap = imageBitmap,
226
+ croppedImage = croppedImage
227
+ ) {
228
+ showDialog = false
229
+ }
226
230
}
227
231
}
228
232
}
0 commit comments