diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 46c1203..d75f2d4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -11,8 +11,8 @@ android { applicationId = "com.kawomi.githugandroid" minSdk = 26 targetSdk = 34 - versionCode = 24 - versionName = "0.1.23" + versionCode = 25 + versionName = "0.1.24" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables.useSupportLibrary = true diff --git a/app/src/main/java/com/kawomi/githugandroid/GitHugApp.kt b/app/src/main/java/com/kawomi/githugandroid/GitHugApp.kt index 26a8dfb..67e9d3a 100644 --- a/app/src/main/java/com/kawomi/githugandroid/GitHugApp.kt +++ b/app/src/main/java/com/kawomi/githugandroid/GitHugApp.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.RowScope import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize @@ -122,13 +123,13 @@ private data class PaneLayout( ) private fun defaultPaneLayout(): PaneLayout = PaneLayout( - order = listOf(PaneId.LEVELS, PaneId.VISUAL, PaneId.EXERCISE, PaneId.TERMINAL), + order = listOf(PaneId.EXERCISE, PaneId.TERMINAL, PaneId.VISUAL, PaneId.LEVELS), collapsed = emptySet(), weights = mapOf( - PaneId.LEVELS to 0.9f, + PaneId.EXERCISE to 0.95f, + PaneId.TERMINAL to 1.45f, PaneId.VISUAL to 1.0f, - PaneId.EXERCISE to 0.9f, - PaneId.TERMINAL to 1.4f, + PaneId.LEVELS to 0.8f, ), ) @@ -657,14 +658,14 @@ private fun PaneDivider( Box( modifier = Modifier .fillMaxWidth() - .height(6.dp) + .height(18.dp) .draggable( state = dragState, orientation = Orientation.Vertical, enabled = enabled, onDragStopped = { onDragFinished() }, ), - contentAlignment = Alignment.Center, + contentAlignment = Alignment.CenterStart, ) { Box( modifier = Modifier @@ -672,12 +673,87 @@ private fun PaneDivider( .height(1.dp) .background(if (enabled) Accent.copy(alpha = 0.45f) else PanelTertiary), ) - Text( - text = "↕", - color = if (enabled) Accent else TextMuted, - modifier = Modifier.align(Alignment.CenterStart).padding(start = 28.dp), - fontSize = 12.sp, - fontWeight = FontWeight.Bold, + 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 = 13.sp, + fontWeight = FontWeight.ExtraBold, + ) + } + } +} + +@OptIn(ExperimentalFoundationApi::class) +@Composable +private fun RowScope.TerminalInputField( + inputFieldVersion: Int, + commandInput: TextFieldValue, + onValueChange: (TextFieldValue) -> Unit, + focusRequester: FocusRequester, + bringIntoViewRequester: BringIntoViewRequester, + keyboardController: androidx.compose.ui.platform.SoftwareKeyboardController?, + onSubmit: () -> Unit, +) { + val scope = rememberCoroutineScope() + + key(inputFieldVersion) { + BasicTextField( + value = commandInput, + onValueChange = onValueChange, + modifier = Modifier + .weight(1f) + .focusRequester(focusRequester) + .bringIntoViewRequester(bringIntoViewRequester) + .onFocusChanged { state -> + if (state.isFocused) { + keyboardController?.show() + scope.launch { + delay(150) + bringIntoViewRequester.bringIntoView() + } + } + }, + singleLine = true, + textStyle = TextStyle( + color = TextPrimary, + fontFamily = FontFamily.Monospace, + fontSize = 17.sp, + fontWeight = FontWeight.Medium, + ), + cursorBrush = SolidColor(Accent), + keyboardOptions = KeyboardOptions( + autoCorrect = false, + keyboardType = KeyboardType.Ascii, + imeAction = ImeAction.Done, + ), + keyboardActions = KeyboardActions(onDone = { onSubmit() }), + decorationBox = { innerTextField -> + Box( + modifier = Modifier + .fillMaxWidth() + .background(Color.Transparent) + .padding(vertical = 10.dp), + contentAlignment = Alignment.CenterStart, + ) { + if (commandInput.text.isEmpty()) { + Text( + text = "Enter git command", + color = TextMuted.copy(alpha = 0.7f), + fontFamily = FontFamily.Monospace, + fontSize = 17.sp, + ) + } + innerTextField() + } + }, ) } } @@ -869,11 +945,8 @@ private fun TerminalPane( val horizontalScroll = rememberScrollState() val outputVerticalScroll = rememberScrollState() val terminalMinWidth = 640.dp - val scope = rememberCoroutineScope() LaunchedEffect(inputFieldVersion) { - if (inputFieldVersion == 0) return@LaunchedEffect - delay(75) focusRequester.requestFocus() keyboardController?.show() } @@ -941,45 +1014,17 @@ private fun TerminalPane( color = Accent, fontFamily = FontFamily.Monospace, fontWeight = FontWeight.Bold, + fontSize = 17.sp, + ) + TerminalInputField( + inputFieldVersion = inputFieldVersion, + commandInput = commandInput, + onValueChange = onValueChange, + focusRequester = focusRequester, + bringIntoViewRequester = bringIntoViewRequester, + keyboardController = keyboardController, + onSubmit = { submitCommand() }, ) - key(inputFieldVersion) { - BasicTextField( - value = commandInput, - onValueChange = onValueChange, - modifier = Modifier - .weight(1f) - .focusRequester(focusRequester) - .bringIntoViewRequester(bringIntoViewRequester) - .onFocusChanged { state -> - if (state.isFocused) { - keyboardController?.show() - scope.launch { - delay(150) - bringIntoViewRequester.bringIntoView() - } - } - }, - singleLine = true, - textStyle = TextStyle(color = TextPrimary, fontFamily = FontFamily.Monospace), - cursorBrush = SolidColor(Accent), - keyboardOptions = KeyboardOptions( - autoCorrect = false, - keyboardType = KeyboardType.Ascii, - imeAction = ImeAction.Done, - ), - keyboardActions = KeyboardActions(onDone = { submitCommand() }), - decorationBox = { innerTextField -> - Box( - modifier = Modifier - .fillMaxWidth() - .padding(vertical = 8.dp), - contentAlignment = Alignment.CenterStart, - ) { - innerTextField() - } - }, - ) - } } } }