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

View File

@@ -18,25 +18,51 @@ fun movePane(layout: PaneLayout, paneId: PaneId, delta: Int): PaneLayout {
fun resizePanes(
layout: PaneLayout,
upper: PaneId,
lower: PaneId,
lower: PaneId?,
dragFraction: Float,
): 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 upperWeight = layout.weights[upper] ?: 1f
val lowerWeight = layout.weights[lower] ?: 1f
val scaledDelta = dragFraction.coerceIn(-0.75f, 0.75f)
val newUpper = (upperWeight + scaledDelta).coerceAtLeast(minWeight)
val newLower = (lowerWeight - scaledDelta).coerceAtLeast(minWeight)
if (lower != null) {
// Resize between two panes
val upperWeight = layout.weights[upper] ?: 1f
val lowerWeight = layout.weights[lower] ?: 1f
return layout.copy(
weights = layout.weights + mapOf(
upper to newUpper,
lower to newLower,
val newUpper = (upperWeight + scaledDelta).coerceAtLeast(minWeight)
val newLower = (lowerWeight - scaledDelta).coerceAtLeast(minWeight)
return layout.copy(
weights = layout.weights + mapOf(
upper to newUpper,
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(
@@ -76,7 +102,7 @@ fun recommendedWorkspaceHeight(
paneLayout: PaneLayout,
recommendedHeights: Map<PaneId, Int>,
): Dp {
val dividerHeight = 18 * (paneLayout.order.size - 1)
val dividerHeight = 18 * paneLayout.order.size
val collapsedPaneHeight = 44 * paneLayout.collapsed.size
val expandedHeight = paneLayout.order
.filterNot { it in paneLayout.collapsed }

View File

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