centered play btn for android

This commit is contained in:
hasinarak3@gmail.com 2026-02-06 09:52:47 +03:00
parent d25753aee4
commit 6dd58b8bb3

View file

@ -61,6 +61,7 @@ fun MidiControlPanel(
var showSATBTools by remember { mutableStateOf(false) } var showSATBTools by remember { mutableStateOf(false) }
var expandedCtl by remember { mutableStateOf(false) } var expandedCtl by remember { mutableStateOf(false) }
val platform = getPlatform().name
LaunchedEffect(tempo) { LaunchedEffect(tempo) {
currentBpm = mediaPlayer.getCurrentBPM() currentBpm = mediaPlayer.getCurrentBPM()
} }
@ -91,7 +92,7 @@ fun MidiControlPanel(
) { ) {
Column( Column(
modifier = modifier modifier = modifier
.fillMaxWidth(if (getPlatform().name.startsWith("Android")) 0.9f else 0.6f) .fillMaxWidth(if (platform.startsWith("Android")) 1f else 0.6f)
.padding(16.dp) .padding(16.dp)
.background(color = Color.Gray.copy(alpha = 0.5f), shape = RoundedCornerShape(size = 5.dp)), .background(color = Color.Gray.copy(alpha = 0.5f), shape = RoundedCornerShape(size = 5.dp)),
horizontalAlignment = Alignment.CenterHorizontally horizontalAlignment = Alignment.CenterHorizontally
@ -214,7 +215,7 @@ fun MidiControlPanel(
slideInHorizontally { -it } + fadeIn() togetherWith slideOutHorizontally { it } + fadeOut() slideInHorizontally { -it } + fadeIn() togetherWith slideOutHorizontally { it } + fadeOut()
} }
}, },
modifier = Modifier.padding(horizontal = 4.dp) modifier = Modifier.padding(horizontal = 2.dp)
) { displayedBpm -> ) { displayedBpm ->
val isCenter = displayedBpm == currentBpmInt val isCenter = displayedBpm == currentBpmInt
Text( Text(
@ -225,7 +226,7 @@ fun MidiControlPanel(
modifier = Modifier modifier = Modifier
.clip(CircleShape) .clip(CircleShape)
.clickable(enabled = !isCenter) { updateTempoToBpm(displayedBpm) } .clickable(enabled = !isCenter) { updateTempoToBpm(displayedBpm) }
.padding(horizontal = 4.dp) .padding(horizontal = 2.dp)
) )
} }
} }
@ -333,7 +334,26 @@ fun MidiControlPanel(
} }
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
Column { if(platform.startsWith("Android")) {
Column(
modifier = Modifier.wrapContentWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
IconButton(
onClick = onPlayPauseClick,
modifier = Modifier.size(48.dp).background(MaterialTheme.colorScheme.primary, CircleShape)
) {
Icon(
imageVector = if (isPause) Icons.Filled.PlayArrow else Icons.Filled.Pause,
contentDescription = "Pla",
tint = Color.White
)
}
}
Spacer(modifier = Modifier.weight(1f))
Column {
IconButton( IconButton(
onClick = { onClick = {
isPianoSelected = !isPianoSelected isPianoSelected = !isPianoSelected
@ -361,29 +381,58 @@ fun MidiControlPanel(
} }
} }
} }
} else {
Column {
IconButton(
onClick = {
isPianoSelected = !isPianoSelected
if (isPianoSelected) {
mediaPlayer?.changeInstru(1)
} else {
mediaPlayer?.changeInstru(20)
}
Spacer(modifier = Modifier.weight(1f)) }
) {
Column( if (isPianoSelected) {
modifier = Modifier.wrapContentWidth(), Icon(
horizontalAlignment = Alignment.CenterHorizontally Icons.Default.Piano,
) { contentDescription = "Piano",
IconButton( tint = Color.Black
onClick = onPlayPauseClick, )
modifier = Modifier.size(48.dp).background(MaterialTheme.colorScheme.primary, CircleShape) } else {
) { Icon(
Icon( painter = painterResource(Res.drawable.ic_organ),
imageVector = if (isPause) Icons.Filled.PlayArrow else Icons.Filled.Pause, contentDescription = "Orgue",
contentDescription = "Pla", tint = Color.Black,
tint = Color.White modifier = Modifier.size(25.dp)
) )
}
}
} }
}
Spacer(modifier = Modifier.weight(1f))
Column(
modifier = Modifier.wrapContentWidth(),
horizontalAlignment = Alignment.CenterHorizontally
) {
IconButton(
onClick = onPlayPauseClick,
modifier = Modifier.size(48.dp).background(MaterialTheme.colorScheme.primary, CircleShape)
) {
Icon(
imageVector = if (isPause) Icons.Filled.PlayArrow else Icons.Filled.Pause,
contentDescription = "Pla",
tint = Color.White
)
}
}
}
Spacer(modifier = Modifier.weight(1f)) Spacer(modifier = Modifier.weight(1f))
val platform = getPlatform() if (platform.startsWith("Java")) {
if (platform.name.startsWith("Java")) {
ModernVolumeSlider( ModernVolumeSlider(
volume, onVolumeChange = onVolumeChange volume, onVolumeChange = onVolumeChange
) )