Skip to content

Commit

Permalink
Fixes after PR
Browse files Browse the repository at this point in the history
  • Loading branch information
demchenkoalex committed Apr 3, 2022
1 parent 084755b commit dba4a6b
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: 097d3313d8e2c7f901932d63e537c1acefb87800
revision: c860cba910319332564e1e9d470a17074c1f2dfd
channel: stable

project_type: package
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 3.3.2

- Add `showStatus` to all messages. Thanks @arsamme for the PR!
- Update to Flutter 2.10.4

## 3.3.1

- Update to Flutter 2.10.2
Expand Down
17 changes: 8 additions & 9 deletions lib/src/message.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:equatable/equatable.dart';
import 'package:meta/meta.dart';

import 'messages/custom_message.dart';
import 'messages/file_message.dart';
import 'messages/image_message.dart';
Expand All @@ -27,11 +26,11 @@ abstract class Message extends Equatable {
this.remoteId,
this.repliedMessage,
this.roomId,
this.showStatus,
this.status,
this.type,
this.updatedAt, {
this.showStatus = true,
});
this.updatedAt,
);

/// Creates a particular message from a map (decoded JSON).
/// Type is determined by the `type` field.
Expand All @@ -57,18 +56,18 @@ abstract class Message extends Equatable {
/// both metadatas will be merged into one Map, where keys from a passed
/// metadata will overwite keys from the previous one.
/// [previewData] will be only set for the text message type.
/// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value.
/// [status] with null value will be overwritten by the previous status.
/// [text] will be only set for the text message type. Null value will be
/// overwritten by the previous text (can't be empty).
/// [remoteId] and [updatedAt] with null values will nullify existing value.
/// [uri] will be only set for file and image message types. Null value
/// will be overwritten by the previous value (uri can't be empty).
Message copyWith({
Map<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
bool? showStatus,
Status? status,
String? text,
int? updatedAt,
String? uri,
Expand Down Expand Up @@ -98,12 +97,12 @@ abstract class Message extends Equatable {
/// ID of the room where this message is sent
final String? roomId;

/// Show status or not
final bool? showStatus;

/// Message [Status]
final Status? status;

/// Show status or not
final bool showStatus;

/// [MessageType]
final MessageType type;

Expand Down
13 changes: 7 additions & 6 deletions lib/src/messages/custom_message.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

import '../message.dart';
import '../preview_data.dart' show PreviewData;
import '../user.dart' show User;
Expand All @@ -22,10 +21,10 @@ class CustomMessage extends Message {
String? remoteId,
Message? repliedMessage,
String? roomId,
bool? showStatus,
Status? status,
MessageType? type,
int? updatedAt,
bool showStatus = true,
}) : super(
author,
createdAt,
Expand All @@ -34,10 +33,10 @@ class CustomMessage extends Message {
remoteId,
repliedMessage,
roomId,
showStatus,
status,
type ?? MessageType.custom,
updatedAt,
showStatus: showStatus,
);

/// Creates a full custom message from a partial one.
Expand All @@ -49,6 +48,7 @@ class CustomMessage extends Message {
String? remoteId,
Message? repliedMessage,
String? roomId,
bool? showStatus,
Status? status,
int? updatedAt,
}) : super(
Expand All @@ -59,6 +59,7 @@ class CustomMessage extends Message {
remoteId,
repliedMessage,
roomId,
showStatus,
status,
MessageType.custom,
updatedAt,
Expand All @@ -78,7 +79,7 @@ class CustomMessage extends Message {
/// both metadatas will be merged into one Map, where keys from a passed
/// metadata will overwite keys from the previous one.
/// [previewData] is ignored for this message type.
/// [remoteId] and [updatedAt] with null values will nullify existing value.
/// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value.
/// [status] with null value will be overwritten by the previous status.
/// [text] is ignored for this message type.
/// [uri] is ignored for this message type.
Expand All @@ -87,8 +88,8 @@ class CustomMessage extends Message {
Map<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
bool? showStatus,
Status? status,
String? text,
int? updatedAt,
String? uri,
Expand All @@ -107,7 +108,7 @@ class CustomMessage extends Message {
repliedMessage: repliedMessage,
roomId: roomId,
status: status ?? this.status,
showStatus: showStatus ?? this.showStatus,
showStatus: showStatus,
updatedAt: updatedAt,
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/src/messages/custom_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions lib/src/messages/file_message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class FileMessage extends Message {
String? remoteId,
Message? repliedMessage,
String? roomId,
bool? showStatus,
required this.size,
Status? status,
MessageType? type,
int? updatedAt,
required this.uri,
bool showStatus = true,
}) : super(
author,
createdAt,
Expand All @@ -36,6 +36,7 @@ class FileMessage extends Message {
remoteId,
repliedMessage,
roomId,
showStatus,
status,
type ?? MessageType.file,
updatedAt,
Expand All @@ -50,9 +51,9 @@ class FileMessage extends Message {
String? remoteId,
Message? repliedMessage,
String? roomId,
bool? showStatus,
Status? status,
int? updatedAt,
bool showStatus = true,
}) : mimeType = partialFile.mimeType,
name = partialFile.name,
size = partialFile.size,
Expand All @@ -65,10 +66,10 @@ class FileMessage extends Message {
remoteId,
repliedMessage,
roomId,
showStatus,
status,
MessageType.file,
updatedAt,
showStatus:showStatus,
);

/// Creates a file message from a map (decoded JSON).
Expand All @@ -84,16 +85,16 @@ class FileMessage extends Message {
/// both metadatas will be merged into one Map, where keys from a passed
/// metadata will overwite keys from the previous one.
/// [previewData] is ignored for this message type.
/// [remoteId] and [updatedAt] with null values will nullify existing value.
/// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value.
/// [status] and [uri] with null values will be overwritten by previous values.
/// [text] is ignored for this message type.
@override
Message copyWith({
Map<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
bool? showStatus,
Status? status,
String? text,
int? updatedAt,
String? uri,
Expand All @@ -113,9 +114,9 @@ class FileMessage extends Message {
remoteId: remoteId,
repliedMessage: repliedMessage,
roomId: roomId,
showStatus: showStatus,
size: size,
status: status ?? this.status,
showStatus: showStatus?? this.showStatus,
updatedAt: updatedAt,
uri: uri ?? this.uri,
);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/messages/file_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions lib/src/messages/image_message.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:json_annotation/json_annotation.dart';
import 'package:meta/meta.dart';

import '../message.dart';
import '../preview_data.dart' show PreviewData;
import '../user.dart' show User;
Expand All @@ -23,13 +22,13 @@ class ImageMessage extends Message {
String? remoteId,
Message? repliedMessage,
String? roomId,
bool? showStatus,
required this.size,
Status? status,
MessageType? type,
int? updatedAt,
required this.uri,
this.width,
bool showStatus = true,
}) : super(
author,
createdAt,
Expand All @@ -38,10 +37,10 @@ class ImageMessage extends Message {
remoteId,
repliedMessage,
roomId,
showStatus,
status,
type ?? MessageType.image,
updatedAt,
showStatus: showStatus,
);

/// Creates a full image message from a partial one.
Expand All @@ -53,6 +52,7 @@ class ImageMessage extends Message {
String? remoteId,
Message? repliedMessage,
String? roomId,
bool? showStatus,
Status? status,
int? updatedAt,
}) : height = partialImage.height,
Expand All @@ -68,6 +68,7 @@ class ImageMessage extends Message {
remoteId,
repliedMessage,
roomId,
showStatus,
status,
MessageType.image,
updatedAt,
Expand All @@ -86,16 +87,16 @@ class ImageMessage extends Message {
/// both metadatas will be merged into one Map, where keys from a passed
/// metadata will overwite keys from the previous one.
/// [previewData] is ignored for this message type.
/// [remoteId] and [updatedAt] with null values will nullify existing value.
/// [remoteId], [showStatus] and [updatedAt] with null values will nullify existing value.
/// [status] and [uri] with null values will be overwritten by previous values.
/// [text] is ignored for this message type.
@override
Message copyWith({
Map<String, dynamic>? metadata,
PreviewData? previewData,
String? remoteId,
Status? status,
bool? showStatus,
Status? status,
String? text,
int? updatedAt,
String? uri,
Expand All @@ -115,9 +116,9 @@ class ImageMessage extends Message {
remoteId: remoteId,
repliedMessage: repliedMessage,
roomId: roomId,
showStatus: showStatus,
size: size,
status: status ?? this.status,
showStatus: showStatus?? this.showStatus,
updatedAt: updatedAt,
uri: uri ?? this.uri,
width: width,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/messages/image_message.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dba4a6b

Please sign in to comment.