Capture and convert camera buttons are in a wrong position
Closed this issue · 4 comments
In 0.5.0 version i think something got broken with showing overlay button "the previous way" via PeekabooCamera fun to which you pass captureIcon and convertIcon composables. They are shown in TopStart for me instead of the alignment I pass in the modifier (bottomCenter and bottomEnd).
I feel that it's because of of this function:
@Composable
private fun CompatOverlay(
state: PeekabooCameraState,
captureIcon: @Composable (onClick: () -> Unit) -> Unit,
convertIcon: @Composable (onClick: () -> Unit) -> Unit,
progressIndicator: @Composable () -> Unit,
) {
Box {
captureIcon(state::capture)
convertIcon(state::toggleCamera)
if (state.isCapturing) {
progressIndicator()
}
}
}
Which has a default Box containing them. So it seems like it's not filling maximum size of parent so the modifier of captureIcon and convertIcons are not having effect on alignment.
Adding fillMaxSize seems to fix it. And that's what's done for the overlay in a "new" PeekabooCameraView with state:
@Composable
internal fun PeekabooCameraView(
modifier: Modifier = Modifier,
onCapture: (ByteArray?) -> Unit,
onBack: () -> Unit,
) {
val state = rememberPeekabooCameraState(onCapture = onCapture)
Box(modifier = modifier) {
PeekabooCamera(
state = state,
modifier = Modifier.fillMaxSize(),
permissionDeniedContent = {
PermissionDenied(
modifier = Modifier.fillMaxSize(),
)
},
)
CameraOverlay(
isCapturing = state.isCapturing,
onBack = onBack,
onCapture = { state.capture() },
onConvert = { state.toggleCamera() },
modifier = Modifier.fillMaxSize(),
)
}
}
It looks like the issue was not entirely fixed. It's fixed on Android, but iOS part has the same problem still. Android implementation has .fillMaxSize()
modifier that propagates to Box
underneath, but for iOS the Box
remains without modifier
passed from the above.
Android:
iOS: