mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-25 01:45:22 +00:00
slash button position
This commit is contained in:
@@ -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>,
|
||||
|
||||
Reference in New Issue
Block a user