update loop icon
This commit is contained in:
parent
21502c3681
commit
8112e30161
1 changed files with 43 additions and 26 deletions
|
|
@ -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
|
||||
)
|
||||
containerColor = when {
|
||||
(isWaitingForB || isLooping) -> Color.Red
|
||||
else -> Color.LightGray
|
||||
}
|
||||
),
|
||||
shape = RoundedCornerShape(5.dp) ,
|
||||
modifier = Modifier.padding(2.dp)
|
||||
) {
|
||||
when {
|
||||
loopState.first == -1L -> Text("A?")
|
||||
!loopState.third -> Text("B?")
|
||||
else -> Icon(
|
||||
Text(
|
||||
text = "A",
|
||||
color = if (isWaitingForB || isLooping) Color.White else Color.Black,
|
||||
fontWeight = FontWeight.Bold,
|
||||
fontSize = 18.sp
|
||||
)
|
||||
|
||||
Icon(
|
||||
imageVector = Icons.Default.Loop,
|
||||
contentDescription = "boucle"
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
if(loopState.first != -1L) {
|
||||
IconButton(
|
||||
onClick = {
|
||||
mediaPlayer.clearLoop()
|
||||
}
|
||||
) {
|
||||
Icon(Icons.Default.Clear, contentDescription = "Actualiser", )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue