I’m working on a Kotlin Multiplatform project targeting both Android and iOS, and I need to implement functionality to select a photo from the gallery. I’ve been trying to figure out the best approach to handle this in a shared codebase while utilizing platform-specific APIs for Android and iOS.
Here’s the structure of my AddChildScreen composable where I want to include the photo selection feature:
@Composable
fun AddChildScreen(
viewModel: UserViewModel,
onBackClicked: () -> Unit
) {
// ... other UI components
Column(
modifier = Modifier.padding(15.dp),
horizontalAlignment = Alignment.Start
) {
ProfilePhoto(
photoHref = null,
onEditClicked = { PickImageFromGallery() }
)
// ... other UI components
}
}
My goal is to:
Define a common interface for the image picker in the shared module.
Implement the platform-specific code for both Android and iOS.
Could someone guide me through the steps to achieve this?