diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/MidiControlPanel.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/MidiControlPanel.kt index 2a4b8ac..f2bdcea 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/MidiControlPanel.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/MidiControlPanel.kt @@ -1,4 +1,4 @@ -package mg.dot.feufaro.ui + package mg.dot.feufaro.ui import androidx.compose.animation.AnimatedVisibility import androidx.compose.animation.fadeIn @@ -14,6 +14,8 @@ import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.IntrinsicSize +import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxWidth @@ -69,6 +71,9 @@ import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.RectangleShape +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.input.ImeAction import androidx.compose.ui.text.input.KeyboardType import androidx.compose.ui.unit.DpSize @@ -301,37 +306,49 @@ fun MidiControlPanel( verticalAlignment = Alignment.CenterVertically ){ Column(horizontalAlignment = Alignment.CenterHorizontally) { + val isAtStart = loopState.first == -1L + val isWaitingForB = loopState.first != -1L && !loopState.third + val isLooping = loopState.third + Button( onClick = { - if (loopState.first == -1L) { - mediaPlayer.setPointA() - } else if(!loopState.third) { - mediaPlayer.setPointB() + when { + isAtStart -> mediaPlayer.setPointA() + isWaitingForB -> mediaPlayer.setPointB() + isLooping -> { + mediaPlayer.clearLoop() + } } }, colors = ButtonDefaults.buttonColors( - containerColor = if (loopState.third) Color.Green else MaterialTheme.colorScheme.secondary - ) - ) { - when { - loopState.first == -1L -> Text("A?") - !loopState.third -> Text("B?") - else -> Icon( - imageVector = Icons.Default.Loop, - contentDescription = "boucle" - ) - } - } - } - Column(horizontalAlignment = Alignment.CenterHorizontally) { - if(loopState.first != -1L) { - IconButton( - onClick = { - mediaPlayer.clearLoop() + containerColor = when { + (isWaitingForB || isLooping) -> Color.Red + else -> Color.LightGray } - ) { - Icon(Icons.Default.Clear, contentDescription = "Actualiser", ) - } + ), + shape = RoundedCornerShape(5.dp) , + modifier = Modifier.padding(2.dp) + ) { + Text( + text = "A", + color = if (isWaitingForB || isLooping) Color.White else Color.Black, + fontWeight = FontWeight.Bold, + fontSize = 18.sp + ) + + Icon( + imageVector = Icons.Default.Loop, + contentDescription = null, + tint = if (isLooping) Color.White else Color.Black, + modifier = Modifier.size(18.dp) + ) + + Text( + text = "B", + color = if (isLooping) Color.White else Color.Black, + fontWeight = FontWeight.Bold, + fontSize = 18.sp + ) } }