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:
8
.vscode/settings.json
vendored
Normal file
8
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"chat.tools.terminal.autoApprove": {
|
||||
"/^bash \\./SetupBuildEnvironment\\.sh --build$/": {
|
||||
"approve": true,
|
||||
"matchCommandLine": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,8 +11,8 @@ android {
|
||||
applicationId = "com.kawomi.githugandroid"
|
||||
minSdk = 26
|
||||
targetSdk = 34
|
||||
versionCode = 40
|
||||
versionName = "0.1.39"
|
||||
versionCode = 42
|
||||
versionName = "0.1.41"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
@@ -18,15 +18,19 @@ 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 scaledDelta = dragFraction.coerceIn(-0.75f, 0.75f)
|
||||
|
||||
if (lower != null) {
|
||||
// Resize between two panes
|
||||
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)
|
||||
@@ -37,6 +41,28 @@ fun resizePanes(
|
||||
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 }
|
||||
|
||||
@@ -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,11 +79,10 @@ fun PaneWorkspace(
|
||||
}
|
||||
}
|
||||
|
||||
if (index <= paneLayout.order.lastIndex) {
|
||||
val upper = paneId
|
||||
val lower = paneLayout.order[index + 1]
|
||||
val lower = paneLayout.order.getOrNull(index + 1)
|
||||
PaneDivider(
|
||||
enabled = upper !in paneLayout.collapsed && lower !in paneLayout.collapsed,
|
||||
enabled = upper !in paneLayout.collapsed && (lower == null || lower !in paneLayout.collapsed),
|
||||
onDrag = { deltaPx ->
|
||||
val fraction = deltaPx / heightBasis
|
||||
onResize(upper, lower, fraction)
|
||||
@@ -93,7 +92,6 @@ fun PaneWorkspace(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@@ -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,
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user