Add Navigation on Popup Editing
This commit is contained in:
parent
dc86d9ddc4
commit
a5977d5dd1
3 changed files with 89 additions and 27 deletions
|
|
@ -633,10 +633,10 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
val isNoteModified = newNot != oldNot
|
val isNoteModified = newNot != oldNot
|
||||||
// println("est-ce? $isNoteModified = $newNot != $oldNot")
|
// println("est-ce? $isNoteModified = $newNot != $oldNot")
|
||||||
|
|
||||||
/*if (!isNoteModified) {
|
if (!isNoteModified) {
|
||||||
println("Voix $linePrefix : Aucune modification détectée (Note: $oldNot ).")
|
// println("Voix $linePrefix : Aucune modification détectée (Note: $oldNot ).")
|
||||||
continue
|
continue
|
||||||
}*/
|
}
|
||||||
|
|
||||||
val newNote = notesByVoice[voiceNum] ?: ""
|
val newNote = notesByVoice[voiceNum] ?: ""
|
||||||
if (newNote.isEmpty()) continue
|
if (newNote.isEmpty()) continue
|
||||||
|
|
@ -936,8 +936,8 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
compactedBlock.append("")
|
compactedBlock.append("")
|
||||||
}
|
}
|
||||||
|
|
||||||
println(String.format("%-4d | %-25s | %-15s | %-25s",
|
// println(String.format("%-4d | %-25s | %-15s | %-25s",
|
||||||
currentLogicalIdx, rawBlockText, actionTaken, compactedBlock.toString()))
|
// currentLogicalIdx, rawBlockText, actionTaken, compactedBlock.toString()))
|
||||||
|
|
||||||
resultBody.append(compactedBlock)
|
resultBody.append(compactedBlock)
|
||||||
if (i < body.length) resultBody.append(body[i])
|
if (i < body.length) resultBody.append(body[i])
|
||||||
|
|
@ -951,9 +951,9 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository
|
||||||
}
|
}
|
||||||
|
|
||||||
val finalResult = "$prefix$resultBody$suffix"
|
val finalResult = "$prefix$resultBody$suffix"
|
||||||
println("-".repeat(100))
|
// println("-".repeat(100))
|
||||||
println("RÉSULTAT FINAL COMPACTÉ : $finalResult")
|
// println("RÉSULTAT FINAL COMPACTÉ : $finalResult")
|
||||||
println("=".repeat(100))
|
// println("=".repeat(100))
|
||||||
|
|
||||||
return finalResult
|
return finalResult
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import androidx.compose.foundation.text.BasicTextField
|
||||||
import androidx.compose.foundation.text.KeyboardOptions
|
import androidx.compose.foundation.text.KeyboardOptions
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.ArrowForward
|
||||||
import androidx.compose.material.icons.filled.Add
|
import androidx.compose.material.icons.filled.Add
|
||||||
import androidx.compose.material.icons.filled.Build
|
import androidx.compose.material.icons.filled.Build
|
||||||
import androidx.compose.material.icons.filled.Clear
|
import androidx.compose.material.icons.filled.Clear
|
||||||
|
|
@ -41,9 +43,11 @@ fun TUODetailDialog(
|
||||||
globalIndex: Int,
|
globalIndex: Int,
|
||||||
isEditable: Boolean,
|
isEditable: Boolean,
|
||||||
canAdd: Boolean,
|
canAdd: Boolean,
|
||||||
|
onIndexChanged: (Int) -> Unit,
|
||||||
onDismiss: () -> Unit,
|
onDismiss: () -> Unit,
|
||||||
onSave: (TUOEditState) -> Unit
|
onSave: (TUOEditState) -> Unit
|
||||||
) {
|
) {
|
||||||
|
var currentIndex by remember(globalIndex) { mutableStateOf(globalIndex) }
|
||||||
val notes = remember {
|
val notes = remember {
|
||||||
mutableStateMapOf<Int, String>().apply {
|
mutableStateMapOf<Int, String>().apply {
|
||||||
putAll(editState.notesByVoice)
|
putAll(editState.notesByVoice)
|
||||||
|
|
@ -107,13 +111,49 @@ fun TUODetailDialog(
|
||||||
color = Color(0xFF2D2D2D).copy(0.75f),
|
color = Color(0xFF2D2D2D).copy(0.75f),
|
||||||
) {
|
) {
|
||||||
Column(modifier = Modifier.padding(horizontal = 10.dp, vertical = 5.dp).fillMaxWidth()) {
|
Column(modifier = Modifier.padding(horizontal = 10.dp, vertical = 5.dp).fillMaxWidth()) {
|
||||||
|
Row (
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
IconButton(
|
||||||
|
onClick = {
|
||||||
|
currentIndex--
|
||||||
|
onIndexChanged(currentIndex)
|
||||||
|
},
|
||||||
|
modifier = Modifier.size(32.dp)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.AutoMirrored.Filled.ArrowBack,
|
||||||
|
contentDescription = "Précédent",
|
||||||
|
tint = Color.White
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Text(
|
Text(
|
||||||
text = "N°$globalIndex",
|
text = "N°$currentIndex",
|
||||||
fontSize = 15.sp,
|
fontSize = 15.sp,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
color = Color.White
|
color = Color.White
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IconButton(
|
||||||
|
onClick = {
|
||||||
|
currentIndex++
|
||||||
|
onIndexChanged(currentIndex)
|
||||||
|
},
|
||||||
|
modifier = Modifier.size(32.dp)
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.AutoMirrored.Filled.ArrowForward,
|
||||||
|
contentDescription = "Suivant",
|
||||||
|
tint = Color.White
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(2.dp))
|
Spacer(modifier = Modifier.height(2.dp))
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
|
|
@ -494,13 +534,13 @@ public fun getGlobalTemplate(editState: TUOEditState): String {
|
||||||
if (combinedChar == ',' && result.isNotEmpty() && result.last() == ' ') {
|
if (combinedChar == ',' && result.isNotEmpty() && result.last() == ' ') {
|
||||||
result.deleteCharAt(result.length - 1)
|
result.deleteCharAt(result.length - 1)
|
||||||
}
|
}
|
||||||
println("Pour $i = ${chars.toString()} on a > ${combinedChar.toString()}")
|
// println("Pour $i = ${chars.toString()} on a > ${combinedChar.toString()}")
|
||||||
|
|
||||||
val lastChar = if (result.isNotEmpty()) result.last() else null
|
val lastChar = if (result.isNotEmpty()) result.last() else null
|
||||||
if (!((combinedChar == '.' && lastChar == '.') || (combinedChar == ',' && lastChar == ','))) {
|
if (!((combinedChar == '.' && lastChar == '.') || (combinedChar == ',' && lastChar == ','))) {
|
||||||
result.append(combinedChar)
|
result.append(combinedChar)
|
||||||
}
|
}
|
||||||
println("all = ${result.toString()}")
|
// println("all = ${result.toString()}")
|
||||||
|
|
||||||
if (openAfter[i]) result.append('(')
|
if (openAfter[i]) result.append('(')
|
||||||
if (closeAfter[i]) result.append(')')
|
if (closeAfter[i]) result.append(')')
|
||||||
|
|
|
||||||
|
|
@ -877,6 +877,19 @@ fun LazyVerticalGridTUO(
|
||||||
sharedScreenModel.openTUOEditor(newState)
|
sharedScreenModel.openTUOEditor(newState)
|
||||||
showAddDialog = false
|
showAddDialog = false
|
||||||
showEditDialog = false
|
showEditDialog = false
|
||||||
|
},
|
||||||
|
onIndexChanged = { newIndex ->
|
||||||
|
selectedIndex = newIndex
|
||||||
|
val globalList = sharedScreenModel.tuoList.value
|
||||||
|
val nextTUO = globalList.getOrNull(newIndex)
|
||||||
|
|
||||||
|
if (nextTUO != null) {
|
||||||
|
selectedTUO = nextTUO
|
||||||
|
}else {
|
||||||
|
showAddDialog = false
|
||||||
|
showDetailDialog = false
|
||||||
|
showEditDialog = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -1267,12 +1280,12 @@ fun autoFixNote(rawNote: String, template: String): String {
|
||||||
val noteRegex = Regex("([drmfsltDRFSTw][ia]?|―)[0-9'¹²³⁴₁₂₃₄,]*")
|
val noteRegex = Regex("([drmfsltDRFSTw][ia]?|―)[0-9'¹²³⁴₁₂₃₄,]*")
|
||||||
val actualNotes = if (rawNote.isEmpty()) emptyList() else noteRegex.findAll(rawNote).map { it.value }.toList()
|
val actualNotes = if (rawNote.isEmpty()) emptyList() else noteRegex.findAll(rawNote).map { it.value }.toList()
|
||||||
|
|
||||||
if (rawNote.contains("•") || rawNote.contains("―") || rawNote.contains(",")) {
|
/*if (rawNote.contains("•") || rawNote.contains("―") || rawNote.contains(",")) {
|
||||||
val templateNotesCount = template.count { c ->
|
val templateNotesCount = template.count { c ->
|
||||||
c in 'A'..'Y' || c in 'a'..'y'
|
c in 'A'..'Y' || c in 'a'..'y'
|
||||||
}
|
}
|
||||||
if (actualNotes.size >= templateNotesCount) return rawNote
|
if (actualNotes.size >= templateNotesCount) return rawNote
|
||||||
}
|
}*/
|
||||||
val requiredNotesCount = template.count { it in 'A'..'Y' || it in 'a'..'y' }
|
val requiredNotesCount = template.count { it in 'A'..'Y' || it in 'a'..'y' }
|
||||||
|
|
||||||
val shouldIncludeParentheses = actualNotes.size >= requiredNotesCount
|
val shouldIncludeParentheses = actualNotes.size >= requiredNotesCount
|
||||||
|
|
@ -1286,25 +1299,33 @@ fun autoFixNote(rawNote: String, template: String): String {
|
||||||
(char in 'A'..'Y' || char in 'a'..'y') -> {
|
(char in 'A'..'Y' || char in 'a'..'y') -> {
|
||||||
if (noteIdx < actualNotes.size) {
|
if (noteIdx < actualNotes.size) {
|
||||||
val noteToAdd = actualNotes[noteIdx]
|
val noteToAdd = actualNotes[noteIdx]
|
||||||
if (noteIdx > 0) {
|
if (noteIdx > 0 && result.isNotEmpty()) {
|
||||||
|
val lastChar = result.last()
|
||||||
|
if (lastChar != '•' && lastChar != ',' && lastChar != '(' && lastChar != ' ') {
|
||||||
result.append(" ")
|
result.append(" ")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
result.append(noteToAdd)
|
result.append(noteToAdd)
|
||||||
noteIdx++
|
noteIdx++
|
||||||
} else {
|
} else {
|
||||||
if (rawNote.isEmpty()) {
|
/*if (rawNote.isEmpty()) {*/
|
||||||
result.append("z")
|
result.append("z")
|
||||||
} else {
|
/*} else {
|
||||||
result.append("―")
|
result.append("―")
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char == '-' -> {
|
char == '-' -> {
|
||||||
|
if (noteIdx < actualNotes.size && actualNotes[noteIdx] == "―") {
|
||||||
|
result.append("―")
|
||||||
|
noteIdx++
|
||||||
|
} else {
|
||||||
val prev = if (i > 0) template[i - 1] else null
|
val prev = if (i > 0) template[i - 1] else null
|
||||||
val next = if (i < template.lastIndex) template[i + 1] else null
|
val next = if (i < template.lastIndex) template[i + 1] else null
|
||||||
if (prev == '.' && next == ',') result.append(" ") else result.append("―")
|
if (prev == '.' && next == ',') result.append(" ") else result.append("―")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
char == 'z' -> result.append(" ")
|
char == 'z' -> result.append(" ")
|
||||||
char == '.' -> {
|
char == '.' -> {
|
||||||
val currentText = result.toString()
|
val currentText = result.toString()
|
||||||
|
|
@ -1322,5 +1343,6 @@ fun autoFixNote(rawNote: String, template: String): String {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// println("on a RES ${result.toString()}")
|
||||||
return result.toString()
|
return result.toString()
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue