mirror of
https://github.com/Myzel394/Alibi.git
synced 2025-06-18 23:05:26 +02:00
fix(ui): Make RealtimeAudioVisualizer store more amplitudes than current width would allow to allow user to rotate its device
Signed-off-by: Myzel394 <50424412+Myzel394@users.noreply.github.com>
This commit is contained in:
parent
af19eec613
commit
e5d594a273
@ -61,11 +61,18 @@ fun RealtimeAudioVisualizer(
|
||||
}
|
||||
|
||||
val configuration = LocalConfiguration.current
|
||||
val screenWidth = with(LocalDensity.current) { configuration.screenWidthDp.dp.toPx() }
|
||||
// Use greater value of width and height to make sure the amplitudes are shown
|
||||
// when the user rotates the device
|
||||
val availableSpace = with(LocalDensity.current) {
|
||||
Math.max(
|
||||
configuration.screenWidthDp.dp.toPx(),
|
||||
configuration.screenHeightDp.dp.toPx()
|
||||
)
|
||||
}
|
||||
|
||||
LaunchedEffect(screenWidth) {
|
||||
LaunchedEffect(availableSpace) {
|
||||
// Add 1 to allow the visualizer to overflow the screen
|
||||
audioRecorder.setMaxAmplitudesAmount(ceil(screenWidth.toInt() / BOX_DIFF).toInt() + 1)
|
||||
audioRecorder.setMaxAmplitudesAmount(ceil(availableSpace.toInt() / BOX_DIFF).toInt() + 1)
|
||||
}
|
||||
|
||||
Canvas(modifier = modifier) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user