Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix audio settings button missing on some devices #3036

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.quran.mobile.feature.audiobar.ui

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.RowScope
import androidx.compose.foundation.layout.width
import androidx.compose.material.icons.filled.FastForward
import androidx.compose.material.icons.filled.FastRewind
import androidx.compose.material.icons.filled.Pause
Expand All @@ -20,6 +22,7 @@ import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import com.quran.labs.androidquran.common.ui.core.QuranIcons
import com.quran.labs.androidquran.common.ui.core.QuranTheme
import com.quran.mobile.feature.audiobar.state.AudioBarState
Expand All @@ -33,7 +36,11 @@ internal fun PlayingAudioBar(
modifier: Modifier = Modifier
) {
AudioBar(state, eventSink, modifier) {
IconButton(onClick = { playbackEventSink(AudioBarUiEvent.PlayingPlaybackEvent.Pause) }) {
IconButton(
modifier = Modifier
.width(40.dp)
.weight(1f),
onClick = { playbackEventSink(AudioBarUiEvent.PlayingPlaybackEvent.Pause) }) {
Icon(QuranIcons.Pause, contentDescription = "")
}
}
Expand All @@ -47,7 +54,11 @@ internal fun PausedAudioBar(
modifier: Modifier = Modifier
) {
AudioBar(state = state, eventSink, modifier = modifier) {
IconButton(onClick = { pausedEventSink(AudioBarUiEvent.PausedPlaybackEvent.Play) }) {
IconButton(
modifier = Modifier
.width(40.dp)
.weight(1f),
onClick = { pausedEventSink(AudioBarUiEvent.PausedPlaybackEvent.Play) }) {
Icon(QuranIcons.PlayArrow, contentDescription = "")
}
}
Expand All @@ -58,26 +69,38 @@ internal fun AudioBar(
state: AudioBarState.ActivePlayback,
sink: (AudioBarUiEvent.CommonPlaybackEvent) -> Unit,
modifier: Modifier = Modifier,
actionButton: @Composable () -> Unit
actionButton: @Composable RowScope.() -> Unit
) {
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
Row(
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically,
modifier = modifier
) {
IconButton(onClick = { sink(AudioBarUiEvent.CommonPlaybackEvent.Stop) }) {
Icon(QuranIcons.Stop, contentDescription = "")
IconButton(
modifier = Modifier
.width(40.dp)
.weight(1f),
onClick = { sink(AudioBarUiEvent.CommonPlaybackEvent.Stop) }) {
Icon(QuranIcons.Stop, contentDescription = "", modifier = Modifier.width(40.dp))
}

IconButton(onClick = { sink(AudioBarUiEvent.CommonPlaybackEvent.Rewind) }) {
Icon(QuranIcons.FastRewind, contentDescription = "")
IconButton(
modifier = Modifier
.width(40.dp)
.weight(1f),
onClick = { sink(AudioBarUiEvent.CommonPlaybackEvent.Rewind) }) {
Icon(QuranIcons.FastRewind, contentDescription = "", modifier = Modifier.width(40.dp))
}

actionButton()

IconButton(onClick = { sink(AudioBarUiEvent.CommonPlaybackEvent.FastForward) }) {
Icon(QuranIcons.FastForward, contentDescription = "")
IconButton(
modifier = Modifier
.width(40.dp)
.weight(1f),
onClick = { sink(AudioBarUiEvent.CommonPlaybackEvent.FastForward) }) {
Icon(QuranIcons.FastForward, contentDescription = "", modifier = Modifier.width(40.dp))
}

val infinity = stringResource(id = com.quran.mobile.common.ui.core.R.string.infinity)
Expand All @@ -87,6 +110,9 @@ internal fun AudioBar(
values = REPEAT_VALUES,
value = state.repeat,
defaultValue = 0,
modifier = Modifier
.width(40.dp)
.weight(1f),
format = {
if (it > -1) {
it.toString()
Expand All @@ -104,12 +130,19 @@ internal fun AudioBar(
values = SPEED_VALUES,
value = state.speed,
defaultValue = 1.0f,
modifier = Modifier
.width(40.dp)
.weight(1f),
format = { it.toString() }
) {
sink(AudioBarUiEvent.CommonPlaybackEvent.SetSpeed(it))
}

IconButton(onClick = { sink(AudioBarUiEvent.CommonPlaybackEvent.ShowSettings) }) {
IconButton(
modifier = Modifier
.width(40.dp)
.weight(1f),
onClick = { sink(AudioBarUiEvent.CommonPlaybackEvent.ShowSettings) }) {
Icon(QuranIcons.Settings, contentDescription = "")
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ fun <T> RepeatableButton(
value: T,
defaultValue: T,
format: (T) -> String,
modifier: Modifier = Modifier,
onValueChanged: (T) -> Unit
) {
Box {
Box(contentAlignment = Alignment.Center, modifier = modifier) {
IconButton(onClick = {
val index = (values.indexOf(value) + 1) % values.size
onValueChanged(values[index])
Expand Down
Loading