Skip to content

Commit

Permalink
[f]: fixed second and more sheet expand if u previous select image
Browse files Browse the repository at this point in the history
  • Loading branch information
BadKiko committed Feb 13, 2024
1 parent 6a47a9d commit 05613a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
4 changes: 0 additions & 4 deletions kige/src/main/java/com/kiko/kige/data/state/KigeState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,4 @@ data class KigeState(
this.visibleState.value = false
}
}

fun hide(coroutineScope: CoroutineScope, onHided: () -> Unit) {
rememberGalleryState.hide(coroutineScope, onHided)
}
}
16 changes: 7 additions & 9 deletions kige/src/main/java/com/kiko/kige/ui/components/GallerySheet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ internal fun GallerySheet(
rememberKigeState: KigeState,
onSelect: (painter: Painter, uri: Uri) -> Unit
) {
var selectedPhotoUri by remember { mutableStateOf("") }
val selectedPainter = rememberAsyncImagePainter(model = selectedPhotoUri)

val context = LocalContext.current

val coroutineScope = rememberCoroutineScope()

var selectedPhotoUri by remember { mutableStateOf("") }
val selectedPainter = rememberAsyncImagePainter(
model = selectedPhotoUri,
onSuccess = { rememberKigeState.hide(coroutineScope) })

if (rememberGalleryState.visibleState.value) {
ModalBottomSheet(
sheetState = rememberGalleryState.sheetState,
Expand Down Expand Up @@ -84,10 +84,8 @@ internal fun GallerySheet(
CoilImage(
modifier = rememberGalleryState.galleryUIState.imagesModifier
.clickable {
rememberKigeState.hide(coroutineScope) {
selectedPhotoUri = photoUri
onSelect(selectedPainter, Uri.fromFile(File(photoUri)))
}
selectedPhotoUri = photoUri
onSelect(selectedPainter, Uri.fromFile(File(photoUri)))
},
component = rememberImageComponent {
// shows a shimmering effect when loading an image.
Expand Down

0 comments on commit 05613a0

Please sign in to comment.