slash button position

This commit is contained in:
callebtc
2025-09-28 15:57:06 +02:00
parent fc885acc77
commit a359ef2348
2 changed files with 50 additions and 6 deletions
@@ -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
)
}
}
@@ -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<CommandSuggestion>,