mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-07-26 07:45:21 +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(
|
ChatInputSection(
|
||||||
messageText = messageText,
|
messageText = messageText,
|
||||||
onMessageTextChange = { newText: TextFieldValue ->
|
onMessageTextChange = { newText: TextFieldValue ->
|
||||||
@@ -225,7 +228,8 @@ fun ChatScreen(viewModel: ChatViewModel) {
|
|||||||
selectedPrivatePeer = selectedPrivatePeer,
|
selectedPrivatePeer = selectedPrivatePeer,
|
||||||
currentChannel = currentChannel,
|
currentChannel = currentChannel,
|
||||||
nickname = nickname,
|
nickname = nickname,
|
||||||
colorScheme = colorScheme
|
colorScheme = colorScheme,
|
||||||
|
showMediaButtons = !isGeohashTimeline
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -381,7 +385,8 @@ private fun ChatInputSection(
|
|||||||
selectedPrivatePeer: String?,
|
selectedPrivatePeer: String?,
|
||||||
currentChannel: String?,
|
currentChannel: String?,
|
||||||
nickname: String,
|
nickname: String,
|
||||||
colorScheme: ColorScheme
|
colorScheme: ColorScheme,
|
||||||
|
showMediaButtons: Boolean
|
||||||
) {
|
) {
|
||||||
Surface(
|
Surface(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
@@ -417,7 +422,8 @@ private fun ChatInputSection(
|
|||||||
selectedPrivatePeer = selectedPrivatePeer,
|
selectedPrivatePeer = selectedPrivatePeer,
|
||||||
currentChannel = currentChannel,
|
currentChannel = currentChannel,
|
||||||
nickname = nickname,
|
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.RealtimeScrollingWaveform
|
||||||
import com.bitchat.android.ui.media.ImagePickerButton
|
import com.bitchat.android.ui.media.ImagePickerButton
|
||||||
import com.bitchat.android.ui.media.FilePickerButton
|
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
|
* Input components for ChatScreen
|
||||||
@@ -170,7 +173,8 @@ fun MessageInput(
|
|||||||
selectedPrivatePeer: String?,
|
selectedPrivatePeer: String?,
|
||||||
currentChannel: String?,
|
currentChannel: String?,
|
||||||
nickname: String,
|
nickname: String,
|
||||||
modifier: Modifier = Modifier
|
modifier: Modifier = Modifier,
|
||||||
|
showMediaButtons: Boolean = true
|
||||||
) {
|
) {
|
||||||
val colorScheme = MaterialTheme.colorScheme
|
val colorScheme = MaterialTheme.colorScheme
|
||||||
val isFocused = remember { mutableStateOf(false) }
|
val isFocused = remember { mutableStateOf(false) }
|
||||||
@@ -263,7 +267,7 @@ fun MessageInput(
|
|||||||
val latestOnSendVoiceNote = rememberUpdatedState(onSendVoiceNote)
|
val latestOnSendVoiceNote = rememberUpdatedState(onSendVoiceNote)
|
||||||
|
|
||||||
// Image button (image picker) - hide during recording
|
// 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)
|
// 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) {
|
Row(horizontalArrangement = Arrangement.spacedBy(6.dp), verticalAlignment = Alignment.CenterVertically) {
|
||||||
FilePickerButton(
|
FilePickerButton(
|
||||||
@@ -281,7 +285,7 @@ fun MessageInput(
|
|||||||
|
|
||||||
Spacer(Modifier.width(1.dp))
|
Spacer(Modifier.width(1.dp))
|
||||||
|
|
||||||
VoiceRecordButton(
|
if (showMediaButtons) VoiceRecordButton(
|
||||||
backgroundColor = bg,
|
backgroundColor = bg,
|
||||||
onStart = {
|
onStart = {
|
||||||
isRecording = true
|
isRecording = true
|
||||||
@@ -310,6 +314,17 @@ fun MessageInput(
|
|||||||
path
|
path
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
) else SlashCommandButton(
|
||||||
|
onClick = {
|
||||||
|
val newText = "/"
|
||||||
|
onValueChange(
|
||||||
|
TextFieldValue(
|
||||||
|
text = newText,
|
||||||
|
selection = androidx.compose.ui.text.TextRange(newText.length)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
try { focusRequester.requestFocus() } catch (_: Exception) {}
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
@@ -363,6 +378,29 @@ fun MessageInput(
|
|||||||
// Auto-stop handled inside VoiceRecordButton
|
// 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
|
@Composable
|
||||||
fun CommandSuggestionsBox(
|
fun CommandSuggestionsBox(
|
||||||
suggestions: List<CommandSuggestion>,
|
suggestions: List<CommandSuggestion>,
|
||||||
|
|||||||
Reference in New Issue
Block a user