Auto-commit after successful build: update app gameplay/UI, improve build setup
Changed files:\napp/build.gradle.kts app/src/main/java/com/kawomi/githugandroid/GitHugApp.kt app/src/main/java/com/kawomi/githugandroid/PaneLayoutLogic.kt app/src/main/java/com/kawomi/githugandroid/Panes.kt app/src/main/java/com/kawomi/githugandroid/Terminal.kt
This commit is contained in:
@@ -11,8 +11,8 @@ android {
|
||||
applicationId = "com.kawomi.githugandroid"
|
||||
minSdk = 26
|
||||
targetSdk = 34
|
||||
versionCode = 49
|
||||
versionName = "0.1.48"
|
||||
versionCode = 50
|
||||
versionName = "0.1.49"
|
||||
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
|
||||
@@ -282,12 +282,6 @@ fun GitHugApp() {
|
||||
layout.copy(collapsed = collapsed)
|
||||
})
|
||||
},
|
||||
onResize = { upper, lower, dragFraction ->
|
||||
updatePaneLayout(transform = { layout -> resizePanes(layout, upper, lower, dragFraction) }, persist = false)
|
||||
},
|
||||
onResizeFinished = {
|
||||
scope.launch { paneLayoutStore.save(paneLayout) }
|
||||
},
|
||||
levelsContent = {
|
||||
LevelsPane(levels, currentLevelIndex, completedLevels) { index -> loadLevel(index) }
|
||||
},
|
||||
|
||||
@@ -15,56 +15,6 @@ fun movePane(layout: PaneLayout, paneId: PaneId, delta: Int): PaneLayout {
|
||||
return layout.copy(order = updatedOrder)
|
||||
}
|
||||
|
||||
fun resizePanes(
|
||||
layout: PaneLayout,
|
||||
upper: PaneId,
|
||||
lower: PaneId?,
|
||||
dragFraction: Float,
|
||||
): PaneLayout {
|
||||
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 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(
|
||||
level: Level,
|
||||
levelCount: Int,
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
package com.kawomi.githugandroid
|
||||
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.gestures.Orientation
|
||||
import androidx.compose.foundation.gestures.draggable
|
||||
import androidx.compose.foundation.gestures.rememberDraggableState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.BoxWithConstraints
|
||||
@@ -35,8 +32,6 @@ fun PaneWorkspace(
|
||||
paneLayout: PaneLayout,
|
||||
onMovePane: (PaneId, Int) -> Unit,
|
||||
onTogglePane: (PaneId) -> Unit,
|
||||
onResize: (PaneId, PaneId?, Float) -> Unit,
|
||||
onResizeFinished: () -> Unit,
|
||||
levelsContent: @Composable () -> Unit,
|
||||
visualContent: @Composable () -> Unit,
|
||||
exerciseContent: @Composable () -> Unit,
|
||||
@@ -80,17 +75,6 @@ fun PaneWorkspace(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val upper = paneId
|
||||
val lower = paneLayout.order.getOrNull(index + 1)
|
||||
PaneDivider(
|
||||
enabled = false,
|
||||
onDrag = { deltaPx ->
|
||||
val fraction = deltaPx / heightBasis
|
||||
onResize(upper, lower, fraction)
|
||||
},
|
||||
onDragFinished = onResizeFinished,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,48 +189,3 @@ private fun HeaderActionButton(
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun PaneDivider(
|
||||
enabled: Boolean,
|
||||
onDrag: (Float) -> Unit,
|
||||
onDragFinished: () -> Unit,
|
||||
) {
|
||||
val dragState = rememberDraggableState { delta ->
|
||||
if (enabled) onDrag(delta)
|
||||
}
|
||||
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(18.dp)
|
||||
.draggable(
|
||||
state = dragState,
|
||||
orientation = Orientation.Vertical,
|
||||
enabled = enabled,
|
||||
onDragStopped = { onDragFinished() },
|
||||
),
|
||||
contentAlignment = Alignment.CenterStart,
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(1.dp)
|
||||
.background(if (enabled) Accent.copy(alpha = 0.45f) else PanelTertiary),
|
||||
)
|
||||
Card(
|
||||
colors = CardDefaults.cardColors(
|
||||
containerColor = if (enabled) PanelPrimary else PanelTertiary,
|
||||
),
|
||||
shape = RoundedCornerShape(999.dp),
|
||||
modifier = Modifier.padding(start = 28.dp),
|
||||
) {
|
||||
Text(
|
||||
text = "↕",
|
||||
color = if (enabled) Accent else TextMuted,
|
||||
modifier = Modifier.padding(horizontal = 8.dp, vertical = 1.dp),
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.ExtraBold,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ fun TerminalPane(
|
||||
}
|
||||
|
||||
LaunchedEffect(output.size) {
|
||||
outputVerticalScroll.animateScrollTo(outputVerticalScroll.maxValue)
|
||||
//outputVerticalScroll.animateScrollTo(outputVerticalScroll.maxValue)
|
||||
}
|
||||
|
||||
LaunchedEffect(output.size, commandInput.text) {
|
||||
|
||||
Reference in New Issue
Block a user