Auto-commit after successful build: update app gameplay/UI, improve build setup
Changed files:\napp/build.gradle.kts app/src/main/java/solutions/tretter/githugandroid/GitHugApp.kt app/src/main/java/solutions/tretter/githugandroid/TextEditorDialog.kt
This commit is contained in:
@@ -19,8 +19,8 @@ android {
|
|||||||
applicationId = "solutions.tretter.githugandroid"
|
applicationId = "solutions.tretter.githugandroid"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 97
|
versionCode = 98
|
||||||
versionName = "0.1.96"
|
versionName = "0.1.97"
|
||||||
|
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
vectorDrawables.useSupportLibrary = true
|
vectorDrawables.useSupportLibrary = true
|
||||||
|
|||||||
@@ -323,8 +323,9 @@ fun GitHugApp() {
|
|||||||
applyRecommendedPaneWeights(persist = false)
|
applyRecommendedPaneWeights(persist = false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun saveEditor(targetPath: String) {
|
fun saveEditor() {
|
||||||
val state = editorState ?: return
|
val state = editorState ?: return
|
||||||
|
val targetPath = state.saveAsPath.trim()
|
||||||
if (targetPath.isBlank()) return
|
if (targetPath.isBlank()) return
|
||||||
val (newRepo, lines) = runtime.writeEditorFile(currentLevel, repo, targetPath, state.content)
|
val (newRepo, lines) = runtime.writeEditorFile(currentLevel, repo, targetPath, state.content)
|
||||||
editorState = null
|
editorState = null
|
||||||
@@ -452,18 +453,11 @@ fun GitHugApp() {
|
|||||||
state = state,
|
state = state,
|
||||||
onContentChange = { editorState = state.copy(content = it) },
|
onContentChange = { editorState = state.copy(content = it) },
|
||||||
onSaveAsPathChange = { editorState = state.copy(saveAsPath = it) },
|
onSaveAsPathChange = { editorState = state.copy(saveAsPath = it) },
|
||||||
onCancel = {
|
onClose = {
|
||||||
output = output + "Editor closed without saving"
|
output = output + "Editor closed without saving"
|
||||||
editorState = null
|
editorState = null
|
||||||
},
|
},
|
||||||
onSave = { saveEditor(state.path) },
|
onSave = { saveEditor() },
|
||||||
onSaveAs = {
|
|
||||||
val targetPath = state.saveAsPath.trim()
|
|
||||||
if (targetPath.isNotEmpty()) {
|
|
||||||
editorState = state.copy(path = targetPath, saveAsPath = targetPath)
|
|
||||||
saveEditor(targetPath)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,11 +38,10 @@ fun TextEditorDialog(
|
|||||||
state: TextEditorState,
|
state: TextEditorState,
|
||||||
onContentChange: (String) -> Unit,
|
onContentChange: (String) -> Unit,
|
||||||
onSaveAsPathChange: (String) -> Unit,
|
onSaveAsPathChange: (String) -> Unit,
|
||||||
onCancel: () -> Unit,
|
onClose: () -> Unit,
|
||||||
onSave: () -> Unit,
|
onSave: () -> Unit,
|
||||||
onSaveAs: () -> Unit,
|
|
||||||
) {
|
) {
|
||||||
Dialog(onDismissRequest = onCancel) {
|
Dialog(onDismissRequest = onClose) {
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
@@ -54,13 +53,18 @@ fun TextEditorDialog(
|
|||||||
modifier = Modifier.padding(12.dp),
|
modifier = Modifier.padding(12.dp),
|
||||||
verticalArrangement = Arrangement.spacedBy(10.dp),
|
verticalArrangement = Arrangement.spacedBy(10.dp),
|
||||||
) {
|
) {
|
||||||
|
Text(
|
||||||
|
text = "Edit File",
|
||||||
|
color = TextPrimary,
|
||||||
|
fontWeight = FontWeight.Bold,
|
||||||
|
fontSize = 20.sp,
|
||||||
|
)
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
horizontalArrangement = Arrangement.spacedBy(8.dp),
|
||||||
) {
|
) {
|
||||||
EditorButton(label = "Cancel", onClick = onCancel)
|
EditorButton(label = "Close", onClick = onClose)
|
||||||
EditorButton(label = "Save", enabled = state.path.isNotBlank(), onClick = onSave)
|
EditorButton(label = "Save", enabled = state.saveAsPath.isNotBlank(), onClick = onSave)
|
||||||
EditorButton(label = "Save As", enabled = state.saveAsPath.isNotBlank(), onClick = onSaveAs)
|
|
||||||
}
|
}
|
||||||
Text(
|
Text(
|
||||||
text = "${state.editor} ${state.path.ifBlank { "<new file>" }}",
|
text = "${state.editor} ${state.path.ifBlank { "<new file>" }}",
|
||||||
@@ -72,7 +76,7 @@ fun TextEditorDialog(
|
|||||||
onValueChange = onSaveAsPathChange,
|
onValueChange = onSaveAsPathChange,
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
label = { Text("Save As") },
|
label = { Text("File name") },
|
||||||
)
|
)
|
||||||
BasicTextField(
|
BasicTextField(
|
||||||
value = state.content,
|
value = state.content,
|
||||||
|
|||||||
Reference in New Issue
Block a user