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:
Joe Tretter
2026-05-02 22:04:37 -05:00
parent 17f19ca0ba
commit dcd5589d74
3 changed files with 17 additions and 19 deletions

View File

@@ -19,8 +19,8 @@ android {
applicationId = "solutions.tretter.githugandroid"
minSdk = 26
targetSdk = 35
versionCode = 97
versionName = "0.1.96"
versionCode = 98
versionName = "0.1.97"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true

View File

@@ -323,8 +323,9 @@ fun GitHugApp() {
applyRecommendedPaneWeights(persist = false)
}
fun saveEditor(targetPath: String) {
fun saveEditor() {
val state = editorState ?: return
val targetPath = state.saveAsPath.trim()
if (targetPath.isBlank()) return
val (newRepo, lines) = runtime.writeEditorFile(currentLevel, repo, targetPath, state.content)
editorState = null
@@ -452,18 +453,11 @@ fun GitHugApp() {
state = state,
onContentChange = { editorState = state.copy(content = it) },
onSaveAsPathChange = { editorState = state.copy(saveAsPath = it) },
onCancel = {
onClose = {
output = output + "Editor closed without saving"
editorState = null
},
onSave = { saveEditor(state.path) },
onSaveAs = {
val targetPath = state.saveAsPath.trim()
if (targetPath.isNotEmpty()) {
editorState = state.copy(path = targetPath, saveAsPath = targetPath)
saveEditor(targetPath)
}
},
onSave = { saveEditor() },
)
}
}

View File

@@ -38,11 +38,10 @@ fun TextEditorDialog(
state: TextEditorState,
onContentChange: (String) -> Unit,
onSaveAsPathChange: (String) -> Unit,
onCancel: () -> Unit,
onClose: () -> Unit,
onSave: () -> Unit,
onSaveAs: () -> Unit,
) {
Dialog(onDismissRequest = onCancel) {
Dialog(onDismissRequest = onClose) {
Surface(
modifier = Modifier
.fillMaxWidth()
@@ -54,13 +53,18 @@ fun TextEditorDialog(
modifier = Modifier.padding(12.dp),
verticalArrangement = Arrangement.spacedBy(10.dp),
) {
Text(
text = "Edit File",
color = TextPrimary,
fontWeight = FontWeight.Bold,
fontSize = 20.sp,
)
Row(
modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.spacedBy(8.dp),
) {
EditorButton(label = "Cancel", onClick = onCancel)
EditorButton(label = "Save", enabled = state.path.isNotBlank(), onClick = onSave)
EditorButton(label = "Save As", enabled = state.saveAsPath.isNotBlank(), onClick = onSaveAs)
EditorButton(label = "Close", onClick = onClose)
EditorButton(label = "Save", enabled = state.saveAsPath.isNotBlank(), onClick = onSave)
}
Text(
text = "${state.editor} ${state.path.ifBlank { "<new file>" }}",
@@ -72,7 +76,7 @@ fun TextEditorDialog(
onValueChange = onSaveAsPathChange,
modifier = Modifier.fillMaxWidth(),
singleLine = true,
label = { Text("Save As") },
label = { Text("File name") },
)
BasicTextField(
value = state.content,