From cadb2a6b3fea75c6a3793a1baa23705f457c2155 Mon Sep 17 00:00:00 2001 From: Hasinjato Date: Tue, 12 May 2026 14:54:05 +0300 Subject: [PATCH] Undo botton to revert source code after edit --- .../kotlin/mg/dot/feufaro/ui/DrawerUI.kt | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt index 30ac05c..7672c4f 100644 --- a/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt +++ b/composeApp/src/commonMain/kotlin/mg/dot/feufaro/ui/DrawerUI.kt @@ -106,6 +106,20 @@ fun MainScreenWithDrawer( val currentActiveFilePath = sharedScreenModel.activeFilePath.value val fileName = currentActiveFilePath.substringAfterLast('/') + var sourceTitle = sharedScreenModel.songTitle.value + val originalPath = remember(sourceTitle) { + if (!currentActiveFilePath.contains("_tmp") && !currentActiveFilePath.contains("/tmp/")) { + currentActiveFilePath + } else { + currentActiveFilePath + } + } + + var sourceContent = sharedScreenModel.fileContent.value ?: "" + var codeContent by remember { mutableStateOf(sourceContent?: "") } + LaunchedEffect(sourceContent) { + codeContent = sourceContent + } val saveLauncher = rememberFileSaveLauncher { chosenPath -> if (chosenPath != null) { scope.launch(Dispatchers.IO) { @@ -246,7 +260,13 @@ fun MainScreenWithDrawer( ) { FloatingActionButton( onClick = { - //sharedScreenModel. + scope.launch { + codeContent = sourceContent + + withContext(Dispatchers.Main) { + solfaScreenModel.loadExternalFile(originalPath) + } + } }, modifier = Modifier.alpha(0.45f) ) { Icon(