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"
|
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
|
||||||
|
|||||||
@@ -18,25 +18,51 @@ 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 upperWeight = layout.weights[upper] ?: 1f
|
|
||||||
val lowerWeight = layout.weights[lower] ?: 1f
|
|
||||||
val scaledDelta = dragFraction.coerceIn(-0.75f, 0.75f)
|
val scaledDelta = dragFraction.coerceIn(-0.75f, 0.75f)
|
||||||
|
|
||||||
val newUpper = (upperWeight + scaledDelta).coerceAtLeast(minWeight)
|
if (lower != null) {
|
||||||
val newLower = (lowerWeight - scaledDelta).coerceAtLeast(minWeight)
|
// Resize between two panes
|
||||||
|
val upperWeight = layout.weights[upper] ?: 1f
|
||||||
|
val lowerWeight = layout.weights[lower] ?: 1f
|
||||||
|
|
||||||
return layout.copy(
|
val newUpper = (upperWeight + scaledDelta).coerceAtLeast(minWeight)
|
||||||
weights = layout.weights + mapOf(
|
val newLower = (lowerWeight - scaledDelta).coerceAtLeast(minWeight)
|
||||||
upper to newUpper,
|
|
||||||
lower to newLower,
|
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(
|
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 }
|
||||||
|
|||||||
@@ -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,18 +79,16 @@ fun PaneWorkspace(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index <= paneLayout.order.lastIndex) {
|
val upper = paneId
|
||||||
val upper = paneId
|
val lower = paneLayout.order.getOrNull(index + 1)
|
||||||
val lower = paneLayout.order[index + 1]
|
PaneDivider(
|
||||||
PaneDivider(
|
enabled = upper !in paneLayout.collapsed && (lower == null || lower !in paneLayout.collapsed),
|
||||||
enabled = upper !in paneLayout.collapsed && lower !in paneLayout.collapsed,
|
onDrag = { deltaPx ->
|
||||||
onDrag = { deltaPx ->
|
val fraction = deltaPx / heightBasis
|
||||||
val fraction = deltaPx / heightBasis
|
onResize(upper, lower, fraction)
|
||||||
onResize(upper, lower, fraction)
|
},
|
||||||
},
|
onDragFinished = onResizeFinished,
|
||||||
onDragFinished = onResizeFinished,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user