Undo botton to revert source code after edit
This commit is contained in:
parent
38b6e17008
commit
cadb2a6b3f
1 changed files with 21 additions and 1 deletions
|
|
@ -106,6 +106,20 @@ fun MainScreenWithDrawer(
|
||||||
val currentActiveFilePath = sharedScreenModel.activeFilePath.value
|
val currentActiveFilePath = sharedScreenModel.activeFilePath.value
|
||||||
val fileName = currentActiveFilePath.substringAfterLast('/')
|
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 ->
|
val saveLauncher = rememberFileSaveLauncher { chosenPath ->
|
||||||
if (chosenPath != null) {
|
if (chosenPath != null) {
|
||||||
scope.launch(Dispatchers.IO) {
|
scope.launch(Dispatchers.IO) {
|
||||||
|
|
@ -246,7 +260,13 @@ fun MainScreenWithDrawer(
|
||||||
) {
|
) {
|
||||||
FloatingActionButton(
|
FloatingActionButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
//sharedScreenModel.
|
scope.launch {
|
||||||
|
codeContent = sourceContent
|
||||||
|
|
||||||
|
withContext(Dispatchers.Main) {
|
||||||
|
solfaScreenModel.loadExternalFile(originalPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
}, modifier = Modifier.alpha(0.45f)
|
}, modifier = Modifier.alpha(0.45f)
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue