Auto-commit after successful build: update app gameplay/UI, improve build setup

Changed files:\n.vscode/settings.json
app/build.gradle.kts
app/src/main/java/com/kawomi/githugandroid/PaneLayoutLogic.kt
app/src/main/java/com/kawomi/githugandroid/Panes.kt
This commit is contained in:
Joe Tretter
2026-04-23 21:21:04 -05:00
parent 362c2286ba
commit 9ccfeffe5c
4 changed files with 60 additions and 28 deletions

8
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,8 @@
{
"chat.tools.terminal.autoApprove": {
"/^bash \\./SetupBuildEnvironment\\.sh --build$/": {
"approve": true,
"matchCommandLine": true
}
}
}

View File

@@ -11,8 +11,8 @@ android {
applicationId = "com.kawomi.githugandroid" applicationId = "com.kawomi.githugandroid"
minSdk = 26 minSdk = 26
targetSdk = 34 targetSdk = 34
versionCode = 40 versionCode = 42
versionName = "0.1.39" versionName = "0.1.41"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true vectorDrawables.useSupportLibrary = true

View File

@@ -18,15 +18,19 @@ fun movePane(layout: PaneLayout, paneId: PaneId, delta: Int): PaneLayout {
fun resizePanes( fun resizePanes(
layout: PaneLayout, layout: PaneLayout,
upper: PaneId, upper: PaneId,
lower: PaneId, lower: PaneId?,
dragFraction: Float, dragFraction: Float,
): PaneLayout { ): PaneLayout {
if (upper in layout.collapsed || lower in layout.collapsed) return layout if (upper in layout.collapsed) return layout
if (lower != null && lower in layout.collapsed) return layout
val minWeight = 0.6f val minWeight = 0.6f
val scaledDelta = dragFraction.coerceIn(-0.75f, 0.75f)
if (lower != null) {
// Resize between two panes
val upperWeight = layout.weights[upper] ?: 1f val upperWeight = layout.weights[upper] ?: 1f
val lowerWeight = layout.weights[lower] ?: 1f val lowerWeight = layout.weights[lower] ?: 1f
val scaledDelta = dragFraction.coerceIn(-0.75f, 0.75f)
val newUpper = (upperWeight + scaledDelta).coerceAtLeast(minWeight) val newUpper = (upperWeight + scaledDelta).coerceAtLeast(minWeight)
val newLower = (lowerWeight - scaledDelta).coerceAtLeast(minWeight) val newLower = (lowerWeight - scaledDelta).coerceAtLeast(minWeight)
@@ -37,6 +41,28 @@ fun resizePanes(
lower to newLower, lower to newLower,
) )
) )
} else {
// Resize the upper pane against the bottom (spacer)
val upperWeight = layout.weights[upper] ?: 1f
val newUpper = (upperWeight + scaledDelta).coerceAtLeast(minWeight)
// To keep the total weight sum the same, scale other weights proportionally
val otherPanes = layout.order.filter { it != upper && it !in layout.collapsed }
if (otherPanes.isEmpty()) return layout
val currentTotalOther = otherPanes.sumOf { (layout.weights[it] ?: 1f).toDouble() }.toFloat()
val delta = newUpper - upperWeight
val scale = if (currentTotalOther > 0) (currentTotalOther - delta) / currentTotalOther else 1f
val newWeights = layout.weights.toMutableMap()
newWeights[upper] = newUpper
otherPanes.forEach { pane ->
val current = layout.weights[pane] ?: 1f
newWeights[pane] = (current * scale).coerceAtLeast(minWeight)
}
return layout.copy(weights = newWeights)
}
} }
fun recommendedPaneHeights( fun recommendedPaneHeights(
@@ -76,7 +102,7 @@ fun recommendedWorkspaceHeight(
paneLayout: PaneLayout, paneLayout: PaneLayout,
recommendedHeights: Map<PaneId, Int>, recommendedHeights: Map<PaneId, Int>,
): Dp { ): Dp {
val dividerHeight = 18 * (paneLayout.order.size - 1) val dividerHeight = 18 * paneLayout.order.size
val collapsedPaneHeight = 44 * paneLayout.collapsed.size val collapsedPaneHeight = 44 * paneLayout.collapsed.size
val expandedHeight = paneLayout.order val expandedHeight = paneLayout.order
.filterNot { it in paneLayout.collapsed } .filterNot { it in paneLayout.collapsed }

View File

@@ -33,7 +33,7 @@ fun PaneWorkspace(
paneLayout: PaneLayout, paneLayout: PaneLayout,
onMovePane: (PaneId, Int) -> Unit, onMovePane: (PaneId, Int) -> Unit,
onTogglePane: (PaneId) -> Unit, onTogglePane: (PaneId) -> Unit,
onResize: (PaneId, PaneId, Float) -> Unit, onResize: (PaneId, PaneId?, Float) -> Unit,
onResizeFinished: () -> Unit, onResizeFinished: () -> Unit,
levelsContent: @Composable () -> Unit, levelsContent: @Composable () -> Unit,
visualContent: @Composable () -> Unit, visualContent: @Composable () -> Unit,
@@ -79,11 +79,10 @@ fun PaneWorkspace(
} }
} }
if (index <= paneLayout.order.lastIndex) {
val upper = paneId val upper = paneId
val lower = paneLayout.order[index + 1] val lower = paneLayout.order.getOrNull(index + 1)
PaneDivider( PaneDivider(
enabled = upper !in paneLayout.collapsed && lower !in paneLayout.collapsed, enabled = upper !in paneLayout.collapsed && (lower == null || lower !in paneLayout.collapsed),
onDrag = { deltaPx -> onDrag = { deltaPx ->
val fraction = deltaPx / heightBasis val fraction = deltaPx / heightBasis
onResize(upper, lower, fraction) onResize(upper, lower, fraction)
@@ -93,7 +92,6 @@ fun PaneWorkspace(
} }
} }
} }
}
} }
@Composable @Composable
@@ -244,7 +242,7 @@ private fun PaneDivider(
text = "", text = "",
color = if (enabled) Accent else TextMuted, color = if (enabled) Accent else TextMuted,
modifier = Modifier.padding(horizontal = 8.dp, vertical = 1.dp), modifier = Modifier.padding(horizontal = 8.dp, vertical = 1.dp),
fontSize = 13.sp, fontSize = 20.sp,
fontWeight = FontWeight.ExtraBold, fontWeight = FontWeight.ExtraBold,
) )
} }