Update ui: arrange Floatting Action Button horizontally
This commit is contained in:
parent
1a4854743d
commit
cc71d4c340
1 changed files with 159 additions and 113 deletions
|
|
@ -706,16 +706,16 @@ fun MainScreenWithDrawer(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
if (!solfaKeyboardState.isVisible) {
|
if (!solfaKeyboardState.isVisible) {
|
||||||
Column(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth().padding(5.dp),
|
modifier = Modifier.fillMaxWidth().padding(5.dp),
|
||||||
horizontalAlignment = Alignment.End,
|
horizontalArrangement = Arrangement.spacedBy(7.dp, Alignment.End),
|
||||||
verticalArrangement = Arrangement.spacedBy(7.dp)
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
if (isEditMode) {
|
if (isEditMode) {
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = true,
|
visible = true,
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + scaleIn() + slideInHorizontally { it / 2 },
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
exit = fadeOut() + scaleOut() + slideOutHorizontally { it / 2 }
|
||||||
) {
|
) {
|
||||||
MyFAB(
|
MyFAB(
|
||||||
onClick = {
|
onClick = {
|
||||||
|
|
@ -733,15 +733,14 @@ fun MainScreenWithDrawer(
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = true,
|
visible = true,
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + scaleIn() + slideInHorizontally { it / 2 },
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
exit = fadeOut() + scaleOut() + slideOutHorizontally { it / 2 }
|
||||||
) {
|
) {
|
||||||
MyFAB(
|
MyFAB(
|
||||||
onClick = {
|
onClick = {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
try {
|
try {
|
||||||
val initialDir =
|
val initialDir = solfaScreenModel.fileRepository.getAppPublicFolder().absolutePath
|
||||||
solfaScreenModel.fileRepository.getAppPublicFolder().absolutePath
|
|
||||||
saveLauncher.launch(fileName, initialDir)
|
saveLauncher.launch(fileName, initialDir)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
|
@ -754,8 +753,8 @@ fun MainScreenWithDrawer(
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = true,
|
visible = true,
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + scaleIn() + slideInHorizontally { it / 2 },
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
exit = fadeOut() + scaleOut() + slideOutHorizontally { it / 2 }
|
||||||
) {
|
) {
|
||||||
MyFAB(
|
MyFAB(
|
||||||
onClick = {
|
onClick = {
|
||||||
|
|
@ -765,119 +764,146 @@ fun MainScreenWithDrawer(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (!isQrVisible) {
|
} else if (!isQrVisible) {
|
||||||
AnimatedVisibility(
|
if (!showMidiCtrl) {
|
||||||
visible = isExpanded and !showMidiCtrl,
|
AnimatedVisibility(
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
visible = isExpanded,
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
enter = fadeIn() + scaleIn() + slideInHorizontally { it / 2 },
|
||||||
) {
|
exit = fadeOut() + scaleOut() + slideOutHorizontally { it / 2 }
|
||||||
Row {
|
) {
|
||||||
Column {
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(4.dp)
|
||||||
|
) {
|
||||||
MyFAB(
|
MyFAB(
|
||||||
onClick = {
|
onClick = { sharedScreenModel.descGridCount(1) },
|
||||||
sharedScreenModel.descGridCount(1)
|
|
||||||
},
|
|
||||||
size = 30.dp,
|
size = 30.dp,
|
||||||
icon = Icons.Default.Remove
|
icon = Icons.Default.Remove
|
||||||
)
|
)
|
||||||
}
|
|
||||||
Column {
|
|
||||||
MyFAB(
|
MyFAB(
|
||||||
onClick = {
|
onClick = { sharedScreenModel.addGridCount(1) },
|
||||||
sharedScreenModel.addGridCount(1)
|
|
||||||
},
|
|
||||||
size = 30.dp,
|
size = 30.dp,
|
||||||
icon = Icons.Default.Add
|
icon = Icons.Default.Add
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = isExpanded and !showMidiCtrl,
|
visible = isExpanded,
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + scaleIn() + slideInHorizontally { it / 2 },
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
exit = fadeOut() + scaleOut() + slideOutHorizontally { it / 2 }
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp)
|
|
||||||
) {
|
) {
|
||||||
AnimatedVisibility(
|
|
||||||
visible = isShareExpanded,
|
|
||||||
enter = fadeIn() + expandHorizontally(),
|
|
||||||
exit = fadeOut() + shrinkHorizontally()
|
|
||||||
) {
|
|
||||||
Row(
|
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
|
||||||
verticalAlignment = Alignment.CenterVertically
|
|
||||||
) {
|
|
||||||
MyFAB(
|
|
||||||
onClick = {
|
|
||||||
sharedScreenModel.toggleQRCodeVisibility()
|
|
||||||
sharedScreenModel.setExpandedFAB(false)
|
|
||||||
isShareExpanded = false
|
|
||||||
},
|
|
||||||
icon = Icons.Filled.QrCode2
|
|
||||||
)
|
|
||||||
|
|
||||||
MyFAB(
|
|
||||||
onClick = {
|
|
||||||
showPrintSettings = !showPrintSettings
|
|
||||||
isShareExpanded = false
|
|
||||||
},
|
|
||||||
icon = Icons.Filled.Print
|
|
||||||
)
|
|
||||||
|
|
||||||
MyFAB(
|
|
||||||
onClick = {
|
|
||||||
isShareExpanded = false
|
|
||||||
scope.launch {
|
|
||||||
withContext(Dispatchers.IO) {
|
|
||||||
try {
|
|
||||||
val cleanS = songTitle.replace(' ','_')
|
|
||||||
val exportName = "${cleanS.ifEmpty { "partition" }}.mid"
|
|
||||||
|
|
||||||
val savedPath = solfaScreenModel.fileRepository.pickSavePath(
|
|
||||||
defaultName = exportName,
|
|
||||||
title = "Enregistrer le fichier MIDI"
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!savedPath.isNullOrEmpty()) {
|
|
||||||
val transpositionInterval = sharedScreenModel.transpositionInterval.value
|
|
||||||
val bpm = sharedScreenModel.getBpmFlow().value ?: 120f
|
|
||||||
|
|
||||||
solfaScreenModel.generateMidiFile(bpm, savedPath, transpositionInterval)
|
|
||||||
println("Fichier MIDI enregistré avec succès sous : $savedPath")
|
|
||||||
}
|
|
||||||
} catch (e: Exception) {
|
|
||||||
e.printStackTrace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
icon = Icons.Filled.AudioFile
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MyFAB(
|
MyFAB(
|
||||||
onClick = { isShareExpanded = !isShareExpanded },
|
onClick = {
|
||||||
icon = Icons.Filled.Share
|
sharedScreenModel.showSearchMenu(true)
|
||||||
|
scope.launch {
|
||||||
|
delay(100)
|
||||||
|
focusRequester.requestFocus()
|
||||||
|
}
|
||||||
|
sharedScreenModel.setExpandedFAB(!isExpanded)
|
||||||
|
},
|
||||||
|
icon = if (isSearchActive) Icons.Default.Close else Icons.Default.Search
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
AnimatedVisibility(
|
AnimatedVisibility(
|
||||||
visible = isExpanded,
|
visible = isExpanded,
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
enter = fadeIn() + scaleIn() + slideInHorizontally { it / 2 },
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
exit = fadeOut() + scaleOut() + slideOutHorizontally { it / 2 }
|
||||||
) {
|
) {
|
||||||
MyFAB(
|
Box(
|
||||||
onClick = {
|
modifier = Modifier.size(55.dp),
|
||||||
sharedScreenModel.setMidiCtrl(!showMidiCtrl)
|
contentAlignment = Alignment.BottomEnd
|
||||||
},
|
) {
|
||||||
icon = if (showMidiCtrl) Icons.Filled.StopCircle else Icons.Filled.PlayCircle
|
androidx.compose.animation.AnimatedVisibility(
|
||||||
)
|
visible = isShareExpanded,
|
||||||
|
enter = fadeIn() + slideInVertically { it / 2 } + scaleIn(),
|
||||||
|
exit = fadeOut() + slideOutVertically { it / 2 } + scaleOut(),
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.BottomEnd)
|
||||||
|
.offset(y = (-65).dp)
|
||||||
|
.wrapContentWidth(unbounded = true)
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
MyFAB(
|
||||||
|
onClick = {
|
||||||
|
sharedScreenModel.toggleQRCodeVisibility()
|
||||||
|
sharedScreenModel.setExpandedFAB(false)
|
||||||
|
isShareExpanded = false
|
||||||
|
},
|
||||||
|
icon = Icons.Filled.QrCode2
|
||||||
|
)
|
||||||
|
|
||||||
|
MyFAB(
|
||||||
|
onClick = {
|
||||||
|
showPrintSettings = !showPrintSettings
|
||||||
|
isShareExpanded = false
|
||||||
|
},
|
||||||
|
icon = Icons.Filled.Print
|
||||||
|
)
|
||||||
|
|
||||||
|
MyFAB(
|
||||||
|
onClick = {
|
||||||
|
isShareExpanded = false
|
||||||
|
scope.launch {
|
||||||
|
withContext(Dispatchers.IO) {
|
||||||
|
try {
|
||||||
|
val cleanS =
|
||||||
|
songTitle.replace(' ', '_')
|
||||||
|
val exportName =
|
||||||
|
"${cleanS.ifEmpty { "partition" }}.mid"
|
||||||
|
val savedPath =
|
||||||
|
solfaScreenModel.fileRepository.pickSavePath(
|
||||||
|
defaultName = exportName,
|
||||||
|
title = "Enregistrer le fichier MIDI"
|
||||||
|
)
|
||||||
|
|
||||||
|
if (!savedPath.isNullOrEmpty()) {
|
||||||
|
val transpositionInterval =
|
||||||
|
sharedScreenModel.transpositionInterval.value
|
||||||
|
val bpm =
|
||||||
|
sharedScreenModel.getBpmFlow().value
|
||||||
|
?: 120f
|
||||||
|
solfaScreenModel.generateMidiFile(
|
||||||
|
bpm,
|
||||||
|
savedPath,
|
||||||
|
transpositionInterval
|
||||||
|
)
|
||||||
|
println("Fichier MIDI enregistré avec succès sous : $savedPath")
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
icon = Icons.Filled.AudioFile
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MyFAB(
|
||||||
|
onClick = { isShareExpanded = !isShareExpanded },
|
||||||
|
icon = Icons.Filled.Share
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!showMidiCtrl && !isSearchActive) {
|
if (!showMidiCtrl && !isSearchActive) {
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = isExpanded,
|
||||||
|
enter = fadeIn() + scaleIn() + slideInHorizontally { it / 2 },
|
||||||
|
exit = fadeOut() + scaleOut() + slideOutHorizontally { it / 2 }
|
||||||
|
) {
|
||||||
|
MyFAB(
|
||||||
|
onClick = {
|
||||||
|
sharedScreenModel.setMidiCtrl(!showMidiCtrl)
|
||||||
|
},
|
||||||
|
icon = Icons.Filled.PlayCircle
|
||||||
|
)
|
||||||
|
}
|
||||||
MyFAB(
|
MyFAB(
|
||||||
onClick = {
|
onClick = {
|
||||||
sharedScreenModel.setExpandedFAB(!isExpanded)
|
sharedScreenModel.setExpandedFAB(!isExpanded)
|
||||||
|
|
@ -887,13 +913,20 @@ fun MainScreenWithDrawer(
|
||||||
icon = if (isExpanded) Icons.Filled.Close else Icons.Filled.Menu
|
icon = if (isExpanded) Icons.Filled.Close else Icons.Filled.Menu
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
AnimatedVisibility(
|
}
|
||||||
visible = showMidiCtrl,
|
AnimatedVisibility(
|
||||||
enter = fadeIn() + scaleIn() + slideInVertically { it / 2 },
|
visible = showMidiCtrl,
|
||||||
exit = fadeOut() + scaleOut() + slideOutVertically { it / 2 }
|
enter = fadeIn() + scaleIn() + slideInHorizontally { it / 2 },
|
||||||
|
exit = fadeOut() + scaleOut() + slideOutHorizontally { it / 2 }
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.Start,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
) {
|
) {
|
||||||
Box(
|
Box(
|
||||||
modifier = Modifier.fillMaxWidth(0.9f)
|
modifier = Modifier.fillMaxWidth()
|
||||||
|
.padding(top = 15.dp)
|
||||||
) {
|
) {
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
MidiControlPanel(
|
MidiControlPanel(
|
||||||
|
|
@ -927,13 +960,26 @@ fun MainScreenWithDrawer(
|
||||||
} else {
|
} else {
|
||||||
Text("Sélectionner un morceau")
|
Text("Sélectionner un morceau")
|
||||||
}
|
}
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.align(Alignment.TopEnd)
|
||||||
|
.offset(y = (-30).dp, x = (-10).dp)
|
||||||
|
) {
|
||||||
|
MyFAB(
|
||||||
|
onClick = {
|
||||||
|
sharedScreenModel.setMidiCtrl(false)
|
||||||
|
},
|
||||||
|
icon = Icons.Filled.StopCircle
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}) { paddingValues ->
|
}
|
||||||
|
) { paddingValues ->
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue