Skip to content

Commit

Permalink
fix: passing reply content to ds card
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulRodrigo06 committed Oct 26, 2023
1 parent 5b28905 commit cdaac63
Show file tree
Hide file tree
Showing 17 changed files with 75 additions and 89 deletions.
15 changes: 0 additions & 15 deletions lib/src/controllers/chat/ds_reply.controller.dart

This file was deleted.

5 changes: 5 additions & 0 deletions lib/src/models/ds_message_item.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class DSMessageItemModel {
/// Customer data
Map<String, dynamic>? customer;

/// The message content
dynamic replyContent;

/// Used to define if a message detail (typicament a messages date and time) should be displayed or not
bool? hideMessageDetail;

Expand All @@ -40,6 +43,7 @@ class DSMessageItemModel {
this.content,
this.customer,
this.hideMessageDetail,
this.replyContent,
});

factory DSMessageItemModel.fromJson(Map<String, dynamic> json) {
Expand All @@ -52,6 +56,7 @@ class DSMessageItemModel {
content: json['content'],
status: DSDeliveryReportStatus.unknown.getValue(json['status']),
hideMessageDetail: json['hideMessageDetail'],
replyContent: json['replyContent'],
);

if (json.containsKey('customer')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class DSAudioMessageBubble extends StatelessWidget {
final String? uniqueId;
final String audioType;
final bool shouldAuthenticate;
final String? replyId;
final dynamic replyContent;

DSAudioMessageBubble({
super.key,
required this.uri,
required this.align,
required this.audioType,
this.uniqueId,
this.replyId,
this.replyContent,
this.borderRadius = const [DSBorderRadius.all],
this.shouldAuthenticate = false,
final DSMessageBubbleStyle? style,
Expand All @@ -37,7 +37,7 @@ class DSAudioMessageBubble extends StatelessWidget {
return DSMessageBubble(
borderRadius: borderRadius,
align: align,
replyId: replyId,
replyContent: replyContent,
style: style,
padding: const EdgeInsets.only(
left: 4.0,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/widgets/chat/ds_application_json_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ class DSApplicationJsonMessageBubble extends StatelessWidget {
required this.borderRadius,
required this.content,
this.status,
this.replyId,
this.replyContent,
DSMessageBubbleStyle? style,
}) : style = style ?? DSMessageBubbleStyle();

final DSAlign align;
final List<DSBorderRadius> borderRadius;
final Map<String, dynamic> content;
final String? replyId;
final dynamic replyContent;
final DSDeliveryReportStatus? status;
final DSMessageBubbleStyle style;

Expand All @@ -33,7 +33,7 @@ class DSApplicationJsonMessageBubble extends StatelessWidget {
opacity: status == DSDeliveryReportStatus.failed ? .3 : 1,
child: DSUnsupportedContentMessageBubble(
align: align,
replyId: replyId,
replyContent: replyContent,
borderRadius: borderRadius,
style: style,
overflow: TextOverflow.visible,
Expand All @@ -53,7 +53,7 @@ class DSApplicationJsonMessageBubble extends StatelessWidget {
align: align,
borderRadius: borderRadius,
style: style,
replyId: replyId,
replyContent: replyContent,
);
}
}
7 changes: 4 additions & 3 deletions lib/src/widgets/chat/ds_contact_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DSContactMessageBubble extends StatelessWidget {
final String? phone;
final String? email;
final String? address;
final String? replyId;
final dynamic replyContent;
final DSAlign align;
final List<DSBorderRadius> borderRadius;
final DSMessageBubbleStyle style;
Expand All @@ -18,7 +18,7 @@ class DSContactMessageBubble extends StatelessWidget {
required this.address,
required this.email,
required this.align,
this.replyId,
this.replyContent,
this.borderRadius = const [DSBorderRadius.all],
DSMessageBubbleStyle? style,
}) : style = style ?? DSMessageBubbleStyle();
Expand All @@ -31,7 +31,7 @@ class DSContactMessageBubble extends StatelessWidget {
padding: const EdgeInsets.all(16.0),
shouldUseDefaultSize: true,
style: style,
replyId: replyId,
replyContent: replyContent,
child: _buildContactCard(),
);
}
Expand All @@ -53,6 +53,7 @@ class DSContactMessageBubble extends StatelessWidget {
),
),
const SizedBox(height: 16.0),

/// TODO(format): Format phone number
if (phone != null)
Padding(
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widgets/chat/ds_file_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DSFileMessageBubble extends StatelessWidget {
final List<DSBorderRadius> borderRadius;
final DSMessageBubbleStyle style;
final bool shouldAuthenticate;
final String? replyId;
final dynamic replyContent;

/// Creates a Design System's [DSMessageBubble] used on files other than image, audio, or video
DSFileMessageBubble({
Expand All @@ -31,7 +31,7 @@ class DSFileMessageBubble extends StatelessWidget {
required this.url,
required this.size,
required this.filename,
this.replyId,
this.replyContent,
this.borderRadius = const [DSBorderRadius.all],
this.shouldAuthenticate = false,
DSMessageBubbleStyle? style,
Expand All @@ -48,7 +48,7 @@ class DSFileMessageBubble extends StatelessWidget {
),
child: DSMessageBubble(
borderRadius: borderRadius,
replyId: replyId,
replyContent: replyContent,
padding: EdgeInsets.zero,
align: align,
style: style,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widgets/chat/ds_image_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DSImageMessageBubble extends StatefulWidget {
this.showSelect = false,
this.onSelected,
this.onOpenLink,
this.replyId,
this.replyContent,
this.shouldAuthenticate = false,
this.mediaType,
this.imageMaxHeight,
Expand All @@ -44,7 +44,7 @@ class DSImageMessageBubble extends StatefulWidget {
final String? text;
final String appBarText;
final Uri? appBarPhotoUri;
final String? replyId;
final dynamic replyContent;
final DSMessageBubbleStyle style;
final List<DSDocumentSelectOption> selectOptions;
final bool showSelect;
Expand Down Expand Up @@ -86,7 +86,7 @@ class _DSImageMessageBubbleState extends State<DSImageMessageBubble>
defaultMaxSize: 360.0,
shouldUseDefaultSize: true,
align: widget.align,
replyId:widget.replyId,
replyContent: widget.replyContent,
borderRadius: widget.borderRadius,
padding: EdgeInsets.zero,
hasSpacer: widget.hasSpacer,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widgets/chat/ds_location_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DSLocationMessageBubble extends StatelessWidget {
final DSAlign align;
final DSMessageBubbleStyle style;
final String? title;
final String? replyId;
final dynamic replyContent;
final String latitude;
final String longitude;
final List<DSBorderRadius> borderRadius;
Expand All @@ -26,7 +26,7 @@ class DSLocationMessageBubble extends StatelessWidget {
required this.align,
required this.latitude,
required this.longitude,
this.replyId,
this.replyContent,
this.borderRadius = const [DSBorderRadius.all],
DSMessageBubbleStyle? style,
this.title,
Expand Down Expand Up @@ -58,7 +58,7 @@ class DSLocationMessageBubble extends StatelessWidget {
defaultMaxSize: 240.0,
defaultMinSize: 240.0,
borderRadius: borderRadius,
replyId: replyId,
replyContent: replyContent,
padding: EdgeInsets.zero,
align: align,
style: style,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/widgets/chat/ds_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import '../animations/ds_animated_size.widget.dart';
class DSMessageBubble extends StatelessWidget {
final DSAlign align;
final Widget child;
final String? replyId;
final dynamic replyContent;
final List<DSBorderRadius> borderRadius;
final EdgeInsets padding;
final bool shouldUseDefaultSize;
Expand All @@ -24,7 +24,7 @@ class DSMessageBubble extends StatelessWidget {
Key? key,
required this.align,
required this.child,
this.replyId,
this.replyContent,
this.borderRadius = const [DSBorderRadius.all],
this.padding = const EdgeInsets.symmetric(
vertical: 8.0,
Expand Down Expand Up @@ -67,9 +67,9 @@ class DSMessageBubble extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (replyId != null)
if (replyContent != null)
DSReplyContainer(
replyId: replyId!,
replyContent: replyContent!,
style: style,
align: align,
),
Expand Down
21 changes: 10 additions & 11 deletions lib/src/widgets/chat/ds_reply_container.widget.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../controllers/chat/ds_reply.controller.dart';
import '../../enums/ds_align.enum.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
Expand All @@ -13,13 +11,13 @@ import '../texts/ds_caption_text.widget.dart';
class DSReplyContainer extends StatelessWidget {
const DSReplyContainer({
super.key,
required this.replyId,
required this.replyContent,
required this.style,
required this.align,
});

final DSAlign align;
final String replyId;
final dynamic replyContent;
final DSMessageBubbleStyle style;

@override
Expand Down Expand Up @@ -84,7 +82,7 @@ class DSReplyContainer extends StatelessWidget {
left: 8.0,
bottom: 8.0,
),
child: _replyWidget(replyId, style, align),
child: _replyWidget(replyContent, style, align),
),
),
],
Expand All @@ -98,17 +96,18 @@ class DSReplyContainer extends StatelessWidget {
}

Widget _replyWidget(
String id,
dynamic replyContent,
DSMessageBubbleStyle style,
DSAlign align,
) {
final replyController = Get.find<DSReplyController>();
final message = replyController.getMessageById(id);

switch (message?.type) {
final replyType =
replyContent != '' ? replyContent['content']['replied']['type'] : '';
switch (replyType) {
case DSMessageContentType.textPlain:
return DSBodyText(
message?.content is String ? message?.content : '**********',
replyContent['content']['replied']['value'] is String
? replyContent['content']['replied']['value']
: '**********',
color: _color(align, style),
overflow: TextOverflow.visible,
);
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widgets/chat/ds_request_location_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class DSRequestLocationBubble extends StatelessWidget {
required this.label,
required this.value,
required this.align,
this.replyId,
this.replyContent,
this.type = DSMessageContentType.textPlain,
this.borderRadius = const [DSBorderRadius.all],
this.showRequestLocationButton = false,
Expand All @@ -24,7 +24,7 @@ class DSRequestLocationBubble extends StatelessWidget {
final String? label;
final String type;
final String? value;
final String? replyId;
final dynamic replyContent;
final DSAlign align;
final List<DSBorderRadius> borderRadius;
final bool showRequestLocationButton;
Expand All @@ -47,7 +47,7 @@ class DSRequestLocationBubble extends StatelessWidget {
),
child: DSTextMessageBubble(
text: value!,
replyId: replyId,
replyContent: replyContent,
align: align,
borderRadius: borderRadius,
style: style,
Expand Down
6 changes: 3 additions & 3 deletions lib/src/widgets/chat/ds_text_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class DSTextMessageBubble extends StatefulWidget {
final bool hasSpacer;
final List<DSBorderRadius> borderRadius;
final dynamic selectContent;
final String? replyId;
final dynamic replyContent;
final bool showSelect;
final void Function(String, Map<String, dynamic>)? onSelected;
final DSMessageBubbleStyle style;
Expand All @@ -25,7 +25,7 @@ class DSTextMessageBubble extends StatefulWidget {
Key? key,
required this.text,
required this.align,
this.replyId,
this.replyContent,
this.borderRadius = const [DSBorderRadius.all],
this.selectContent,
this.hasSpacer = true,
Expand Down Expand Up @@ -63,7 +63,7 @@ class _DSTextMessageBubbleState extends State<DSTextMessageBubble> {
padding: EdgeInsets.zero,
style: widget.style,
hasSpacer: widget.hasSpacer,
replyId: widget.replyId,
replyContent: widget.replyContent,
child: _buildText(),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'ds_message_bubble.widget.dart';
class DSUnsupportedContentMessageBubble extends StatelessWidget {
final DSAlign align;
final Widget? leftWidget;
final String? replyId;
final dynamic replyContent;
final String? text;
final TextOverflow overflow;
final List<DSBorderRadius> borderRadius;
Expand All @@ -22,7 +22,7 @@ class DSUnsupportedContentMessageBubble extends StatelessWidget {
required this.align,
this.leftWidget,
this.text,
this.replyId,
this.replyContent,
this.overflow = TextOverflow.ellipsis,
this.borderRadius = const [DSBorderRadius.all],
DSMessageBubbleStyle? style,
Expand All @@ -39,7 +39,7 @@ class DSUnsupportedContentMessageBubble extends StatelessWidget {
borderRadius: borderRadius,
align: align,
style: style,
replyId: replyId,
replyContent: replyContent,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down
Loading

0 comments on commit cdaac63

Please sign in to comment.