Add CommandSuggestionsBox quick access (#146)

* Add CommandSuggestionsBox quick access

* Remove unnecessary evaluation

* Use a FilledTonalIconButton for the CommandSuggestionsBox quick access button

* fix import

* quick command instead of send

* simplify

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
Héctor de Isidro
2025-08-06 01:25:15 +02:00
committed by GitHub
co-authored by callebtc
parent 1d1a91108e
commit b418aa3899
4 changed files with 90 additions and 71 deletions
@@ -44,27 +44,27 @@ fun ChatScreen(viewModel: ChatViewModel) {
val showMentionSuggestions by viewModel.showMentionSuggestions.observeAsState(false)
val mentionSuggestions by viewModel.mentionSuggestions.observeAsState(emptyList())
val showAppInfo by viewModel.showAppInfo.observeAsState(false)
var messageText by remember { mutableStateOf(TextFieldValue("")) }
var showPasswordPrompt by remember { mutableStateOf(false) }
var showPasswordDialog by remember { mutableStateOf(false) }
var passwordInput by remember { mutableStateOf("") }
// Show password dialog when needed
LaunchedEffect(showPasswordPrompt) {
showPasswordDialog = showPasswordPrompt
}
val isConnected by viewModel.isConnected.observeAsState(false)
val passwordPromptChannel by viewModel.passwordPromptChannel.observeAsState(null)
// Determine what messages to show
val displayMessages = when {
selectedPrivatePeer != null -> privateChats[selectedPrivatePeer] ?: emptyList()
currentChannel != null -> channelMessages[currentChannel] ?: emptyList()
else -> messages
}
// Use WindowInsets to handle keyboard properly
Box(modifier = Modifier.fillMaxSize()) {
val headerHeight = 42.dp
@@ -78,7 +78,7 @@ fun ChatScreen(viewModel: ChatViewModel) {
) {
// Header spacer - creates space for the floating header
Spacer(modifier = Modifier.height(headerHeight))
// Messages area - takes up available space, will compress when keyboard appears
MessagesList(
messages = displayMessages,
@@ -86,7 +86,6 @@ fun ChatScreen(viewModel: ChatViewModel) {
meshService = viewModel.meshService,
modifier = Modifier.weight(1f)
)
// Input area - stays at bottom
ChatInputSection(
messageText = messageText,
@@ -125,7 +124,7 @@ fun ChatScreen(viewModel: ChatViewModel) {
colorScheme = colorScheme
)
}
// Floating header - positioned absolutely at top, ignores keyboard
ChatFloatingHeader(
headerHeight = headerHeight,
@@ -168,7 +167,7 @@ fun ChatScreen(viewModel: ChatViewModel) {
targetOffsetX = { it },
animationSpec = tween(250, easing = EaseInCubic)
) + fadeOut(animationSpec = tween(250)),
modifier = Modifier.zIndex(2f)
modifier = Modifier.zIndex(2f)
) {
SidebarOverlay(
viewModel = viewModel,
@@ -177,7 +176,7 @@ fun ChatScreen(viewModel: ChatViewModel) {
)
}
}
// Dialogs
ChatDialogs(
showPasswordDialog = showPasswordDialog,
@@ -225,7 +224,6 @@ private fun ChatInputSection(
) {
Column {
HorizontalDivider(color = colorScheme.outline.copy(alpha = 0.3f))
// Command suggestions box
if (showCommandSuggestions && commandSuggestions.isNotEmpty()) {
CommandSuggestionsBox(
@@ -247,7 +245,7 @@ private fun ChatInputSection(
HorizontalDivider(color = colorScheme.outline.copy(alpha = 0.2f))
}
MessageInput(
value = messageText,
onValueChange = onMessageTextChange,
@@ -306,7 +304,7 @@ private fun ChatFloatingHeader(
)
)
}
// Divider under header
HorizontalDivider(
modifier = Modifier
@@ -337,7 +335,7 @@ private fun ChatDialogs(
onConfirm = onPasswordConfirm,
onDismiss = onPasswordDismiss
)
// App info dialog
AppInfoDialog(
show = showAppInfo,