🐛 Fix messages opacity and couldn't reply
This commit is contained in:
parent
19e243e277
commit
6090367ed6
@ -1,4 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:solian/exts.dart';
|
import 'package:solian/exts.dart';
|
||||||
import 'package:solian/models/account.dart';
|
import 'package:solian/models/account.dart';
|
||||||
@ -40,6 +41,9 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
|
|
||||||
List<int> _attachments = List.empty(growable: true);
|
List<int> _attachments = List.empty(growable: true);
|
||||||
|
|
||||||
|
Message? _editTo;
|
||||||
|
Message? _replyTo;
|
||||||
|
|
||||||
void showAttachments() {
|
void showAttachments() {
|
||||||
showModalBottomSheet(
|
showModalBottomSheet(
|
||||||
context: context,
|
context: context,
|
||||||
@ -96,17 +100,18 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
content: payload['content'] as Map<String, dynamic>,
|
content: payload['content'] as Map<String, dynamic>,
|
||||||
type: payload['type'] as String,
|
type: payload['type'] as String,
|
||||||
sender: sender,
|
sender: sender,
|
||||||
replyId: widget.reply?.id,
|
replyId: _replyTo?.id,
|
||||||
replyTo: widget.reply,
|
replyTo: _replyTo,
|
||||||
channelId: widget.channel.id,
|
channelId: widget.channel.id,
|
||||||
senderId: sender.id,
|
senderId: sender.id,
|
||||||
);
|
);
|
||||||
|
message.isSending = true;
|
||||||
|
|
||||||
if (widget.edit == null) widget.onSent(message);
|
if (widget.edit == null) widget.onSent(message);
|
||||||
resetInput();
|
resetInput();
|
||||||
|
|
||||||
Response resp;
|
Response resp;
|
||||||
if (widget.edit != null) {
|
if (_editTo != null) {
|
||||||
resp = await client.put(
|
resp = await client.put(
|
||||||
'/api/channels/${widget.realm}/${widget.channel.alias}/messages/${widget.edit!.id}',
|
'/api/channels/${widget.realm}/${widget.channel.alias}/messages/${widget.edit!.id}',
|
||||||
payload,
|
payload,
|
||||||
@ -125,13 +130,22 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
|
|
||||||
void resetInput() {
|
void resetInput() {
|
||||||
if (widget.onReset != null) widget.onReset!();
|
if (widget.onReset != null) widget.onReset!();
|
||||||
|
_editTo = null;
|
||||||
|
_replyTo = null;
|
||||||
_textController.clear();
|
_textController.clear();
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void syncWidget() {
|
void syncWidget() {
|
||||||
if (widget.edit != null) {
|
if (widget.edit != null) {
|
||||||
|
_editTo = widget.edit!;
|
||||||
_textController.text = widget.edit!.content['value'];
|
_textController.text = widget.edit!.content['value'];
|
||||||
}
|
}
|
||||||
|
if (widget.reply != null) {
|
||||||
|
_replyTo = widget.reply!;
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -159,12 +173,22 @@ class _ChatMessageInputState extends State<ChatMessageInput> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
if (widget.edit != null)
|
if (_replyTo != null)
|
||||||
|
MaterialBanner(
|
||||||
|
leading: const FaIcon(FontAwesomeIcons.reply, size: 18),
|
||||||
|
dividerColor: Colors.transparent,
|
||||||
|
content: ChatMessage(
|
||||||
|
item: _replyTo!,
|
||||||
|
isContentPreviewing: true,
|
||||||
|
),
|
||||||
|
actions: notifyBannerActions,
|
||||||
|
),
|
||||||
|
if (_editTo != null)
|
||||||
MaterialBanner(
|
MaterialBanner(
|
||||||
leading: const Icon(Icons.edit),
|
leading: const Icon(Icons.edit),
|
||||||
dividerColor: Colors.transparent,
|
dividerColor: Colors.transparent,
|
||||||
content: ChatMessage(
|
content: ChatMessage(
|
||||||
item: widget.edit!,
|
item: _editTo!,
|
||||||
isContentPreviewing: true,
|
isContentPreviewing: true,
|
||||||
),
|
),
|
||||||
actions: notifyBannerActions,
|
actions: notifyBannerActions,
|
||||||
|
Loading…
Reference in New Issue
Block a user