wip mentions

This commit is contained in:
Henry Hiles 2025-12-07 10:53:49 -05:00
commit 541933a939
No known key found for this signature in database
11 changed files with 145 additions and 86 deletions

View file

@ -1,64 +1,101 @@
import "package:flutter/material.dart";
import "package:flutter_chat_core/flutter_chat_core.dart";
import "package:flutter_chat_ui/flutter_chat_ui.dart";
import "package:flutter_hooks/flutter_hooks.dart";
import "package:fluttertagger/fluttertagger.dart";
import "package:matrix/matrix.dart";
import "package:nexus/helpers/extensions/get_headers.dart";
import "package:nexus/widgets/form_text_input.dart";
class ChatBox extends StatelessWidget {
class ChatBox extends HookWidget {
final Message? replyToMessage;
final VoidCallback onDismiss;
final Map<String, String> headers;
final Room room;
const ChatBox({
required this.replyToMessage,
required this.onDismiss,
required this.headers,
required this.room,
super.key,
});
@override
Widget build(BuildContext context) => Composer(
sigmaX: 0,
sigmaY: 0,
sendIconColor: Theme.of(context).colorScheme.primary,
sendOnEnter: true,
topWidget: replyToMessage == null
? null
: ColoredBox(
color: Theme.of(context).colorScheme.surfaceContainer,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 16, vertical: 4),
child: Row(
spacing: 8,
children: [
Avatar(
userId: replyToMessage!.authorId,
headers: headers,
size: 16,
),
Text(
replyToMessage!.metadata?["displayName"] ??
replyToMessage!.authorId,
style: Theme.of(context).textTheme.labelMedium?.copyWith(
fontWeight: FontWeight.bold,
),
),
Expanded(
child: (replyToMessage is TextMessage)
? Text(
(replyToMessage as TextMessage).text,
overflow: TextOverflow.ellipsis,
style: Theme.of(context).textTheme.labelMedium,
maxLines: 1,
)
: SizedBox(),
),
IconButton(
onPressed: onDismiss,
icon: Icon(Icons.close),
iconSize: 20,
),
],
),
),
),
autofocus: true,
);
Widget build(BuildContext context) {
final theme = Theme.of(context);
final controller = useRef(FlutterTaggerController());
final trigger = useState<String?>(null);
final style = TextStyle(
color: theme.colorScheme.primary,
fontWeight: FontWeight.bold,
);
return Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FlutterTagger(
overlay: SizedBox(),
controller: controller.value,
onSearch: (query, triggerCharacter) {
triggerCharacter == "#";
if (controller.value.tags.isEmpty)
controller.value.addTag(id: "id", name: "name");
},
triggerCharacterAndStyles: {"@": style, "#": style},
builder: (context, key) => TextFormField(controller: controller.value, key: key,autofocus: true,onFieldSubmitted: (_) {
},)
// Composer(
// textEditingController: controller.value,
// key: key,
// sigmaY: 0,
// sendIconColor: theme.colorScheme.primary,
// sendOnEnter: true,
// topWidget: replyToMessage == null
// ? null
// : ColoredBox(
// color: theme.colorScheme.surfaceContainer,
// child: Padding(
// padding: EdgeInsets.symmetric(
// horizontal: 16,
// vertical: 4,
// ),
// child: Row(
// spacing: 8,
// children: [
// Avatar(
// userId: replyToMessage!.authorId,
// headers: room.client.headers,
// size: 16,
// ),
// Text(
// replyToMessage!.metadata?["displayName"] ??
// replyToMessage!.authorId,
// style: theme.textTheme.labelMedium?.copyWith(
// fontWeight: FontWeight.bold,
// ),
// ),
// Expanded(
// child: (replyToMessage is TextMessage)
// ? Text(
// (replyToMessage as TextMessage).text,
// overflow: TextOverflow.ellipsis,
// style: theme.textTheme.labelMedium,
// maxLines: 1,
// )
// : SizedBox(),
// ),
// IconButton(
// onPressed: onDismiss,
// icon: Icon(Icons.close),
// iconSize: 20,
// ),
// ],
// ),
// ),
// ),
// autofocus: true,
// ),
),
],
);
}
}