@@ -65,7 +65,24 @@ fun MediaPickerDialog(
6565 state : MutableState <MediaPickerDialogState >,
6666 authority : String
6767) {
68- val data = state.value as ? MediaPickerDialogState .Visible ? : return
68+ val data = state.value as ? MediaPickerDialogState .Visible
69+ val imageCropper = rememberImageCropper()
70+
71+ imageCropper.cropState?.let {
72+
73+ ImageCropperDialog (
74+ state = it,
75+ style = CropperStyle (
76+ autoZoom = false ,
77+ guidelines = null
78+ ),
79+ showAspectRatioSelectionButton = (data?.cropParams as ? MediaPickerCropParams .Enabled )?.showAspectRatioSelectionButton ? : true ,
80+ showShapeCropButton = (data?.cropParams as ? MediaPickerCropParams .Enabled )?.showAspectRatioSelectionButton ? : true ,
81+ lockAspectRatio = (data?.cropParams as ? MediaPickerCropParams .Enabled )?.lockAspectRatio
82+ )
83+ }
84+
85+ if (data == null ) return
6986
7087 LaunchedEffect (key1 = Unit ) {
7188 if (data.cropParams is MediaPickerCropParams .Enabled ) {
@@ -82,8 +99,6 @@ fun MediaPickerDialog(
8299 ) == PackageManager .PERMISSION_GRANTED
83100 }
84101
85- val imageCropper = rememberImageCropper()
86-
87102 AlertDialog (
88103 modifier = Modifier
89104 .padding(28 .dp)
@@ -128,20 +143,6 @@ fun MediaPickerDialog(
128143 }
129144 }
130145 )
131-
132- imageCropper.cropState?.let {
133-
134- ImageCropperDialog (
135- state = it,
136- style = CropperStyle (
137- autoZoom = false ,
138- guidelines = null
139- ),
140- showAspectRatioSelectionButton = (data.cropParams as ? MediaPickerCropParams .Enabled )?.showAspectRatioSelectionButton ? : true ,
141- showShapeCropButton = (data.cropParams as ? MediaPickerCropParams .Enabled )?.showAspectRatioSelectionButton ? : true ,
142- lockAspectRatio = (data.cropParams as ? MediaPickerCropParams .Enabled )?.lockAspectRatio
143- )
144- }
145146}
146147
147148@Composable
0 commit comments