minor updates

This commit is contained in:
Salvatore Giordano
2021-12-10 10:00:30 +01:00
parent 830ffcd4a7
commit ff2c8801d5
4 changed files with 70 additions and 64 deletions
@@ -118,6 +118,7 @@ class RetryQueue {
} catch (e) { } catch (e) {
if (e is! StreamChatNetworkError || !e.isRetriable) { if (e is! StreamChatNetworkError || !e.isRetriable) {
_messageQueue.removeMessage(message); _messageQueue.removeMessage(message);
_sendFailedEvent(message);
return true; return true;
} }
// retry logic // retry logic
@@ -7,6 +7,7 @@ export 'package:dio/src/options.dart';
export 'package:dio/src/options.dart' show ProgressCallback; export 'package:dio/src/options.dart' show ProgressCallback;
export 'package:logging/logging.dart' show Logger, Level; export 'package:logging/logging.dart' show Logger, Level;
export 'package:rate_limiter/rate_limiter.dart'; export 'package:rate_limiter/rate_limiter.dart';
export 'package:uuid/uuid.dart';
export './src/core/api/attachment_file_uploader.dart' export './src/core/api/attachment_file_uploader.dart'
show AttachmentFileUploader; show AttachmentFileUploader;
@@ -421,72 +421,69 @@ class MessageInputState extends State<MessageInput> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
Widget child = ValueListenableBuilder<Message>( Widget child = ValueListenableBuilder<Message>(
valueListenable: messageInputController, valueListenable: messageInputController,
builder: (context, value, wid) { builder: (context, value, wid) => DecoratedBox(
print('VALUE ${value.text}'); decoration: BoxDecoration(
return DecoratedBox( color: _messageInputTheme.inputBackgroundColor,
decoration: BoxDecoration( ),
color: _messageInputTheme.inputBackgroundColor, child: SafeArea(
), child: GestureDetector(
child: SafeArea( onPanUpdate: (details) {
child: GestureDetector( if (details.delta.dy > 0) {
onPanUpdate: (details) { _focusNode.unfocus();
if (details.delta.dy > 0) { if (_openFilePickerSection) {
_focusNode.unfocus(); setState(() {
if (_openFilePickerSection) { _openFilePickerSection = false;
setState(() { });
_openFilePickerSection = false;
});
}
} }
}, }
child: Column( },
mainAxisSize: MainAxisSize.min, child: Column(
children: [ mainAxisSize: MainAxisSize.min,
if (_hasQuotedMessage) children: [
Padding( if (_hasQuotedMessage)
padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.all(8),
child: StreamSvgIcon.reply(
color: _streamChatTheme.colorTheme.disabled,
),
),
Text(
context.translations.replyToMessageLabel,
style: const TextStyle(fontWeight: FontWeight.bold),
),
IconButton(
visualDensity: VisualDensity.compact,
icon: StreamSvgIcon.closeSmall(),
onPressed: widget.onQuotedMessageCleared,
),
],
),
),
Padding( Padding(
padding: const EdgeInsets.symmetric(vertical: 8), padding: const EdgeInsets.fromLTRB(8, 8, 8, 0),
child: _buildTextField(context), child: Row(
), mainAxisAlignment: MainAxisAlignment.spaceBetween,
if (messageInputController.value.parentId != null && children: [
!widget.hideSendAsDm) Padding(
Padding( padding: const EdgeInsets.all(8),
padding: const EdgeInsets.only( child: StreamSvgIcon.reply(
right: 12, color: _streamChatTheme.colorTheme.disabled,
left: 12, ),
bottom: 12, ),
), Text(
child: _buildDmCheckbox(), context.translations.replyToMessageLabel,
style: const TextStyle(fontWeight: FontWeight.bold),
),
IconButton(
visualDensity: VisualDensity.compact,
icon: StreamSvgIcon.closeSmall(),
onPressed: widget.onQuotedMessageCleared,
),
],
), ),
_buildFilePickerSection(), ),
], Padding(
), padding: const EdgeInsets.symmetric(vertical: 8),
child: _buildTextField(context),
),
if (messageInputController.value.parentId != null &&
!widget.hideSendAsDm)
Padding(
padding: const EdgeInsets.only(
right: 12,
left: 12,
bottom: 12,
),
child: _buildDmCheckbox(),
),
_buildFilePickerSection(),
],
), ),
), ),
); ),
}, ),
); );
if (_isEditing) { if (_isEditing) {
child = Material( child = Material(
@@ -88,7 +88,7 @@ class MessageInputController extends ValueNotifier<Message> {
/// ///
String get text => _textEditingController.text; String get text => _textEditingController.text;
final Message _initialMessage; Message _initialMessage;
/// ///
set message(Message message) { set message(Message message) {
@@ -206,13 +206,20 @@ class MessageInputController extends ValueNotifier<Message> {
} }
/// Set the [value] to the initial [Message] value. /// Set the [value] to the initial [Message] value.
void reset() => value = _initialMessage; void reset({bool resetId = true}) {
if (resetId) {
_initialMessage = _initialMessage.copyWith(
id: const Uuid().v4(),
);
}
value = _initialMessage;
}
@override @override
void dispose() { void dispose() {
super.dispose();
removeListener(_textEditingSyncer); removeListener(_textEditingSyncer);
_textEditingController.dispose(); _textEditingController.dispose();
super.dispose();
} }
} }