From a359ef23483b25165224aa3f994c8259e0d53649 Mon Sep 17 00:00:00 2001 From: callebtc <93376500+callebtc@users.noreply.github.com> Date: Sun, 28 Sep 2025 15:57:06 +0200 Subject: [PATCH] slash button position --- .../java/com/bitchat/android/ui/ChatScreen.kt | 12 +++-- .../com/bitchat/android/ui/InputComponents.kt | 44 +++++++++++++++++-- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/bitchat/android/ui/ChatScreen.kt b/app/src/main/java/com/bitchat/android/ui/ChatScreen.kt index 72a9e1e4..221a7d9c 100644 --- a/app/src/main/java/com/bitchat/android/ui/ChatScreen.kt +++ b/app/src/main/java/com/bitchat/android/ui/ChatScreen.kt @@ -180,6 +180,9 @@ fun ChatScreen(viewModel: ChatViewModel) { } } + // Determine whether to show media capture/pick buttons + val isGeohashTimeline = selectedLocationChannel is com.bitchat.android.geohash.ChannelID.Location + ChatInputSection( messageText = messageText, onMessageTextChange = { newText: TextFieldValue -> @@ -225,7 +228,8 @@ fun ChatScreen(viewModel: ChatViewModel) { selectedPrivatePeer = selectedPrivatePeer, currentChannel = currentChannel, nickname = nickname, - colorScheme = colorScheme + colorScheme = colorScheme, + showMediaButtons = !isGeohashTimeline ) } @@ -381,7 +385,8 @@ private fun ChatInputSection( selectedPrivatePeer: String?, currentChannel: String?, nickname: String, - colorScheme: ColorScheme + colorScheme: ColorScheme, + showMediaButtons: Boolean ) { Surface( modifier = Modifier.fillMaxWidth(), @@ -417,7 +422,8 @@ private fun ChatInputSection( selectedPrivatePeer = selectedPrivatePeer, currentChannel = currentChannel, nickname = nickname, - modifier = Modifier.fillMaxWidth() + modifier = Modifier.fillMaxWidth(), + showMediaButtons = showMediaButtons ) } } diff --git a/app/src/main/java/com/bitchat/android/ui/InputComponents.kt b/app/src/main/java/com/bitchat/android/ui/InputComponents.kt index c8e36696..f3a3b216 100644 --- a/app/src/main/java/com/bitchat/android/ui/InputComponents.kt +++ b/app/src/main/java/com/bitchat/android/ui/InputComponents.kt @@ -43,6 +43,9 @@ import com.bitchat.android.features.voice.AudioWaveformExtractor import com.bitchat.android.ui.media.RealtimeScrollingWaveform import com.bitchat.android.ui.media.ImagePickerButton import com.bitchat.android.ui.media.FilePickerButton +import androidx.compose.foundation.shape.CircleShape +import androidx.compose.material3.Surface +import androidx.compose.ui.text.style.TextAlign /** * Input components for ChatScreen @@ -170,7 +173,8 @@ fun MessageInput( selectedPrivatePeer: String?, currentChannel: String?, nickname: String, - modifier: Modifier = Modifier + modifier: Modifier = Modifier, + showMediaButtons: Boolean = true ) { val colorScheme = MaterialTheme.colorScheme val isFocused = remember { mutableStateOf(false) } @@ -263,7 +267,7 @@ fun MessageInput( val latestOnSendVoiceNote = rememberUpdatedState(onSendVoiceNote) // Image button (image picker) - hide during recording - if (!isRecording) { + if (!isRecording && showMediaButtons) { // Revert to original separate buttons: round File button (left) and the old Image plus button (right) Row(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically) { FilePickerButton( @@ -281,7 +285,7 @@ fun MessageInput( Spacer(Modifier.width(1.dp)) - VoiceRecordButton( + if (showMediaButtons) VoiceRecordButton( backgroundColor = bg, onStart = { isRecording = true @@ -310,6 +314,17 @@ fun MessageInput( path ) } + ) else SlashCommandButton( + onClick = { + val newText = "/" + onValueChange( + TextFieldValue( + text = newText, + selection = androidx.compose.ui.text.TextRange(newText.length) + ) + ) + try { focusRequester.requestFocus() } catch (_: Exception) {} + } ) } else { @@ -363,6 +378,29 @@ fun MessageInput( // Auto-stop handled inside VoiceRecordButton } +@Composable +private fun SlashCommandButton(onClick: () -> Unit, modifier: Modifier = Modifier) { + val colorScheme = MaterialTheme.colorScheme + Surface( + onClick = onClick, + shape = CircleShape, + color = colorScheme.background, + tonalElevation = 3.dp, + shadowElevation = 6.dp, + border = BorderStroke(1.dp, colorScheme.outline.copy(alpha = 0.4f)), + modifier = modifier.size(32.dp) + ) { + Box(contentAlignment = Alignment.Center) { + Text( + text = "/", + style = MaterialTheme.typography.bodyMedium.copy(fontFamily = FontFamily.Monospace), + color = colorScheme.primary, + textAlign = TextAlign.Center + ) + } + } +} + @Composable fun CommandSuggestionsBox( suggestions: List,