✨ Optimized chat
This commit is contained in:
parent
ca1a8a04cb
commit
df7dd85a0c
@ -339,7 +339,6 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: PagedListView<int, Message>(
|
child: PagedListView<int, Message>(
|
||||||
reverse: true,
|
reverse: true,
|
||||||
clipBehavior: Clip.none,
|
|
||||||
pagingController: _pagingController,
|
pagingController: _pagingController,
|
||||||
builderDelegate: PagedChildBuilderDelegate<Message>(
|
builderDelegate: PagedChildBuilderDelegate<Message>(
|
||||||
itemBuilder: buildHistory,
|
itemBuilder: buildHistory,
|
||||||
@ -351,8 +350,8 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
|||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: math.max(MediaQuery.of(context).padding.bottom, 16),
|
bottom: math.max(MediaQuery.of(context).padding.bottom, 16),
|
||||||
left: 16,
|
left: 0,
|
||||||
right: 16,
|
right: 0,
|
||||||
child: ChatMessageInput(
|
child: ChatMessageInput(
|
||||||
edit: _messageToEditing,
|
edit: _messageToEditing,
|
||||||
reply: _messageToReplying,
|
reply: _messageToReplying,
|
||||||
|
@ -116,8 +116,6 @@ class ChatMessage extends StatelessWidget {
|
|||||||
item.sender.account.nick,
|
item.sender.account.nick,
|
||||||
style: const TextStyle(fontWeight: FontWeight.bold),
|
style: const TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 4),
|
|
||||||
Text(format(item.createdAt, locale: 'en_short')),
|
|
||||||
Expanded(child: buildContent()),
|
Expanded(child: buildContent()),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
@ -157,8 +157,6 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
const borderRadius = BorderRadius.all(Radius.circular(20));
|
|
||||||
|
|
||||||
final notifyBannerActions = [
|
final notifyBannerActions = [
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: resetInput,
|
onPressed: resetInput,
|
||||||
@ -167,71 +165,68 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return Material(
|
return Material(
|
||||||
borderRadius: borderRadius,
|
color: Theme.of(context).colorScheme.surface,
|
||||||
elevation: 2,
|
child: Column(
|
||||||
child: ClipRRect(
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
borderRadius: borderRadius,
|
children: [
|
||||||
child: Column(
|
const Divider(thickness: 0.3, height: 0.3),
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
if (_replyTo != null)
|
||||||
children: [
|
MaterialBanner(
|
||||||
if (_replyTo != null)
|
leading: const FaIcon(FontAwesomeIcons.reply, size: 18),
|
||||||
MaterialBanner(
|
dividerColor: Colors.transparent,
|
||||||
leading: const FaIcon(FontAwesomeIcons.reply, size: 18),
|
content: ChatMessage(
|
||||||
dividerColor: Colors.transparent,
|
item: _replyTo!,
|
||||||
content: ChatMessage(
|
isContentPreviewing: true,
|
||||||
item: _replyTo!,
|
|
||||||
isContentPreviewing: true,
|
|
||||||
),
|
|
||||||
actions: notifyBannerActions,
|
|
||||||
),
|
),
|
||||||
if (_editTo != null)
|
actions: notifyBannerActions,
|
||||||
MaterialBanner(
|
|
||||||
leading: const Icon(Icons.edit),
|
|
||||||
dividerColor: Colors.transparent,
|
|
||||||
content: ChatMessage(
|
|
||||||
item: _editTo!,
|
|
||||||
isContentPreviewing: true,
|
|
||||||
),
|
|
||||||
actions: notifyBannerActions,
|
|
||||||
),
|
|
||||||
SizedBox(
|
|
||||||
height: 56,
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: TextField(
|
|
||||||
controller: _textController,
|
|
||||||
focusNode: _focusNode,
|
|
||||||
maxLines: null,
|
|
||||||
autocorrect: true,
|
|
||||||
keyboardType: TextInputType.text,
|
|
||||||
decoration: InputDecoration.collapsed(
|
|
||||||
hintText: widget.placeholder ??
|
|
||||||
'messageInputPlaceholder'.trParams(
|
|
||||||
{'channel': '#${widget.channel.alias}'},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onSubmitted: (_) => sendMessage(),
|
|
||||||
onTapOutside: (_) =>
|
|
||||||
FocusManager.instance.primaryFocus?.unfocus(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.attach_file),
|
|
||||||
color: Colors.teal,
|
|
||||||
onPressed: () => showAttachments(),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Icons.send),
|
|
||||||
color: Theme.of(context).colorScheme.primary,
|
|
||||||
onPressed: () => sendMessage(),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
).paddingOnly(left: 16, right: 4),
|
|
||||||
),
|
),
|
||||||
],
|
if (_editTo != null)
|
||||||
),
|
MaterialBanner(
|
||||||
|
leading: const Icon(Icons.edit),
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
content: ChatMessage(
|
||||||
|
item: _editTo!,
|
||||||
|
isContentPreviewing: true,
|
||||||
|
),
|
||||||
|
actions: notifyBannerActions,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
height: 56,
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
controller: _textController,
|
||||||
|
focusNode: _focusNode,
|
||||||
|
maxLines: null,
|
||||||
|
autocorrect: true,
|
||||||
|
keyboardType: TextInputType.text,
|
||||||
|
decoration: InputDecoration.collapsed(
|
||||||
|
hintText: widget.placeholder ??
|
||||||
|
'messageInputPlaceholder'.trParams(
|
||||||
|
{'channel': '#${widget.channel.alias}'},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onSubmitted: (_) => sendMessage(),
|
||||||
|
onTapOutside: (_) =>
|
||||||
|
FocusManager.instance.primaryFocus?.unfocus(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.attach_file),
|
||||||
|
color: Colors.teal,
|
||||||
|
onPressed: () => showAttachments(),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Icons.send),
|
||||||
|
color: Theme.of(context).colorScheme.primary,
|
||||||
|
onPressed: () => sendMessage(),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
).paddingOnly(left: 20, right: 16),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user