From a5977d5dd105174cb2dfea24103358f833f1bfe0 Mon Sep 17 00:00:00 2001 From: Hasinjato Date: Tue, 26 May 2026 16:30:10 +0300 Subject: [PATCH] Add Navigation on Popup Editing --- .../kotlin/mg/dot/feufaro/solfa/Solfa.kt | 16 +++--- .../mg/dot/feufaro/solfa/TUODetailDialog.kt | 56 ++++++++++++++++--- .../mg/dot/feufaro/solfa/TimeUnitObject.kt | 44 +++++++++++---- 3 files changed, 89 insertions(+), 27 deletions(-) diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt index 2093db7..2c9ee53 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/Solfa.kt @@ -633,10 +633,10 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository val isNoteModified = newNot != oldNot // println("est-ce? $isNoteModified = $newNot != $oldNot") - /*if (!isNoteModified) { - println("Voix $linePrefix : Aucune modification détectée (Note: $oldNot ).") + if (!isNoteModified) { +// println("Voix $linePrefix : Aucune modification détectée (Note: $oldNot ).") continue - }*/ + } val newNote = notesByVoice[voiceNum] ?: "" if (newNote.isEmpty()) continue @@ -936,8 +936,8 @@ class Solfa(val sharedScreenModel: SharedScreenModel, private val fileRepository compactedBlock.append("") } - println(String.format("%-4d | %-25s | %-15s | %-25s", - currentLogicalIdx, rawBlockText, actionTaken, compactedBlock.toString())) +// println(String.format("%-4d | %-25s | %-15s | %-25s", +// currentLogicalIdx, rawBlockText, actionTaken, compactedBlock.toString())) resultBody.append(compactedBlock) 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" - println("-".repeat(100)) - println("RÉSULTAT FINAL COMPACTÉ : $finalResult") - println("=".repeat(100)) +// println("-".repeat(100)) +// println("RÉSULTAT FINAL COMPACTÉ : $finalResult") +// println("=".repeat(100)) return finalResult } diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TUODetailDialog.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TUODetailDialog.kt index dec9a10..9bdf194 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TUODetailDialog.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TUODetailDialog.kt @@ -9,6 +9,8 @@ import androidx.compose.foundation.text.BasicTextField import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.verticalScroll 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.Build import androidx.compose.material.icons.filled.Clear @@ -41,9 +43,11 @@ fun TUODetailDialog( globalIndex: Int, isEditable: Boolean, canAdd: Boolean, + onIndexChanged: (Int) -> Unit, onDismiss: () -> Unit, onSave: (TUOEditState) -> Unit ) { + var currentIndex by remember(globalIndex) { mutableStateOf(globalIndex) } val notes = remember { mutableStateMapOf().apply { putAll(editState.notesByVoice) @@ -107,12 +111,48 @@ fun TUODetailDialog( color = Color(0xFF2D2D2D).copy(0.75f), ) { Column(modifier = Modifier.padding(horizontal = 10.dp, vertical = 5.dp).fillMaxWidth()) { - Text( - text = "N°$globalIndex", - fontSize = 15.sp, - fontWeight = FontWeight.Bold, - color = Color.White - ) + 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 = "N°$currentIndex", + fontSize = 15.sp, + fontWeight = FontWeight.Bold, + 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)) @@ -494,13 +534,13 @@ public fun getGlobalTemplate(editState: TUOEditState): String { if (combinedChar == ',' && result.isNotEmpty() && result.last() == ' ') { 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 if (!((combinedChar == '.' && lastChar == '.') || (combinedChar == ',' && lastChar == ','))) { result.append(combinedChar) } - println("all = ${result.toString()}") +// println("all = ${result.toString()}") if (openAfter[i]) result.append('(') if (closeAfter[i]) result.append(')') diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TimeUnitObject.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TimeUnitObject.kt index 5e93572..617376e 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TimeUnitObject.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/solfa/TimeUnitObject.kt @@ -877,6 +877,19 @@ fun LazyVerticalGridTUO( sharedScreenModel.openTUOEditor(newState) showAddDialog = 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 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 -> c in 'A'..'Y' || c in 'a'..'y' } if (actualNotes.size >= templateNotesCount) return rawNote - } + }*/ val requiredNotesCount = template.count { it in 'A'..'Y' || it in 'a'..'y' } val shouldIncludeParentheses = actualNotes.size >= requiredNotesCount @@ -1286,24 +1299,32 @@ fun autoFixNote(rawNote: String, template: String): String { (char in 'A'..'Y' || char in 'a'..'y') -> { if (noteIdx < actualNotes.size) { val noteToAdd = actualNotes[noteIdx] - if (noteIdx > 0) { - result.append(" ") + if (noteIdx > 0 && result.isNotEmpty()) { + val lastChar = result.last() + if (lastChar != '•' && lastChar != ',' && lastChar != '(' && lastChar != ' ') { + result.append(" ") + } } result.append(noteToAdd) noteIdx++ } else { - if (rawNote.isEmpty()) { - result.append("z") - } else { + /*if (rawNote.isEmpty()) {*/ + result.append("z") + /*} else { result.append("―") - } + }*/ } } char == '-' -> { - val prev = if (i > 0) 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 (noteIdx < actualNotes.size && actualNotes[noteIdx] == "―") { + result.append("―") + noteIdx++ + } else { + val prev = if (i > 0) template[i - 1] else null + val next = if (i < template.lastIndex) template[i + 1] else null + if (prev == '.' && next == ',') result.append(" ") else result.append("―") + } } char == 'z' -> result.append(" ") char == '.' -> { @@ -1322,5 +1343,6 @@ fun autoFixNote(rawNote: String, template: String): String { } } } +// println("on a RES ${result.toString()}") return result.toString() } \ No newline at end of file