better UX for gomuks built-in commands

Fixes #157
This commit is contained in:
Henry Hiles 2026-11-06 10:41:19 -05:00
commit dbc42b0ec2
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs

View file

@ -8,13 +8,16 @@ import "package:nexus/controllers/bot_argument_suggestions.dart";
import "package:nexus/controllers/bot_command_draft.dart";
import "package:nexus/models/bot_argument_suggestion.dart";
import "package:nexus/models/bot_command.dart";
import "package:nexus/models/text_command.dart";
import "package:nexus/widgets/avatar_or_hash.dart";
class const BotCommandPanel(
final ComposerParams composer, {
required final IList<BotCommand> commands,
required final IList<TextCommand> textCommands,
required final TextEditingController controller,
required final void Function(BotCommand command) onPick,
required final void Function(TextCommand command) onPickText,
super.key,
}) extends HookConsumerWidget {
@override
@ -49,13 +52,27 @@ class const BotCommandPanel(
);
final children = switch (ref.watch(draftProvider)) {
null =>
commands
null => [
...textCommands
.where((command) => command.completes(text.value))
.map(
(command) => ListTile(
leading: AvatarOrHash(null, "gomuks", dimension: 32),
title: Text(command.prefix),
subtitle: Text(
"gomuks · ${command.description}",
maxLines: 1,
overflow: .ellipsis,
),
onTap: () => onPickText(command),
),
),
...commands
.where((command) => command.completes(text.value))
.map(
(command) => commandTile(command, onTap: () => onPick(command)),
)
.toList(),
),
],
final draft => [
commandTile(draft.command),
if (draft.focusedParameter case final parameter?)