Skip to content

Commit

Permalink
feat: Add content models to DSInteractiveListMessageBubble
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelo Amaro committed Nov 20, 2023
1 parent dad66c3 commit 11e2d13
Show file tree
Hide file tree
Showing 16 changed files with 273 additions and 108 deletions.
2 changes: 1 addition & 1 deletion lib/blip_ds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export 'src/models/ds_message_bubble_avatar_config.model.dart'
show DSMessageBubbleAvatarConfig;
export 'src/models/ds_message_bubble_style.model.dart'
show DSMessageBubbleStyle;
export 'src/models/ds_message_item.model.dart' show DSMessageItemModel;
export 'src/models/ds_message_item.model.dart' show DSMessageItem;
export 'src/models/ds_toast_props.model.dart' show DSToastProps;
export 'src/services/ds_auth.service.dart' show DSAuthService;
export 'src/services/ds_bottom_sheet.service.dart' show DSBottomSheetService;
Expand Down
10 changes: 5 additions & 5 deletions lib/src/models/ds_message_item.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import '../enums/ds_align.enum.dart';
import '../enums/ds_delivery_report_status.enum.dart';

/// A Design System message model used with [DSGroupCard] to display grouped bubble
class DSMessageItemModel {
class DSMessageItem {
/// Identifier of message
String? id;

Expand Down Expand Up @@ -30,8 +30,8 @@ class DSMessageItemModel {
/// Used to define if a message detail (typicament a messages date and time) should be displayed or not
bool? hideMessageDetail;

/// Creates a new Design System's [DSMessageItemModel] model
DSMessageItemModel({
/// Creates a new Design System's [DSMessageItem] model
DSMessageItem({
this.id,
required this.date,
required this.displayDate,
Expand All @@ -43,8 +43,8 @@ class DSMessageItemModel {
this.hideMessageDetail,
});

factory DSMessageItemModel.fromJson(Map<String, dynamic> json) {
final messageItem = DSMessageItemModel(
factory DSMessageItem.fromJson(Map<String, dynamic> json) {
final messageItem = DSMessageItem(
id: json['id'],
date: json['date'],
displayDate: json['displayDate'],
Expand Down
8 changes: 4 additions & 4 deletions lib/src/models/ds_select_option.model.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/// A Design System select options model used with [DSSelectMenu], [DSQuickReply] to display a options menu
class DSSelectOptionModel {
class DSSelectOption {
String text;
int? order;
String? type;
dynamic value;

DSSelectOptionModel({
DSSelectOption({
required this.text,
this.order,
this.type,
this.value,
});

factory DSSelectOptionModel.fromJson(Map<String, dynamic> json) {
final option = DSSelectOptionModel(
factory DSSelectOption.fromJson(Map<String, dynamic> json) {
final option = DSSelectOption(
text: json['text'],
);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'ds_interactive_list_message_action.model.dart';
import 'ds_interactive_list_message_body.model.dart';
import 'ds_interactive_list_message_footer.model.dart';

class DSInteractiveListMessage {
final DSInteractiveListMessageBody? body;
final DSInteractiveListMessageAction? action;
final DSInteractiveListMessageFooter? footer;

DSInteractiveListMessage({
this.body,
this.action,
this.footer,
});

DSInteractiveListMessage.fromJson(Map<String, dynamic> json)
: body = json['body'] != null
? DSInteractiveListMessageBody.fromJson(json['body'])
: null,
action = json['action'] != null
? DSInteractiveListMessageAction.fromJson(json['action'])
: null,
footer = json['footer'] != null
? DSInteractiveListMessageFooter.fromJson(json['footer'])
: null;

Map<String, dynamic> toJson() => {
'body': body?.toJson(),
'action': action?.toJson(),
'footer': footer?.toJson(),
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import 'ds_interactive_list_message_section.model.dart';

class DSInteractiveListMessageAction {
final String? button;
final List<DSInteractiveListMessageSection>? sections;

DSInteractiveListMessageAction({
this.button,
this.sections,
});

DSInteractiveListMessageAction.fromJson(Map<String, dynamic> json)
: button = json['button'],
sections = json['sections'] != null
? List.from(json['sections'])
.map(
(e) => DSInteractiveListMessageSection.fromJson(e),
)
.toList()
: null;

Map<String, dynamic> toJson() => {
'button': button,
'sections': sections
?.map(
(e) => e.toJson(),
)
.toList(),
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class DSInteractiveListMessageBody {
final String? text;

DSInteractiveListMessageBody({
this.text,
});

DSInteractiveListMessageBody.fromJson(Map<String, dynamic> json)
: text = json['text'];

Map<String, dynamic> toJson() => {
'text': text,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class DSInteractiveListMessageFooter {
final String? text;

DSInteractiveListMessageFooter({
this.text,
});

DSInteractiveListMessageFooter.fromJson(Map<String, dynamic> json)
: text = json['text'];

Map<String, dynamic> toJson() => {
'text': text,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class DSInteractiveListMessageRow {
final String? title;

DSInteractiveListMessageRow({
this.title,
});

DSInteractiveListMessageRow.fromJson(Map<String, dynamic> json)
: title = json['title'];

Map<String, dynamic> toJson() => {
'title': title,
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'ds_interactive_list_message_row.model.dart';

class DSInteractiveListMessageSection {
final List<DSInteractiveListMessageRow>? rows;

DSInteractiveListMessageSection({
this.rows,
});

DSInteractiveListMessageSection.fromJson(Map<String, dynamic> json)
: rows = List.from(json['rows'])
.map(
(e) => DSInteractiveListMessageRow.fromJson(e),
)
.toList();

Map<String, dynamic> toJson() => {
'rows': rows
?.map(
(e) => e.toJson(),
)
.toList(),
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import '../../enums/ds_align.enum.dart';
import '../../enums/ds_border_radius.enum.dart';
import '../../enums/ds_delivery_report_status.enum.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../models/interactive_list_message/ds_interactive_list_message.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
import '../../themes/icons/ds_icons.dart';
import 'ds_interactive_list_message_bubble.widget.dart';
Expand Down Expand Up @@ -62,7 +63,7 @@ class DSApplicationJsonMessageBubble extends StatelessWidget {
};

Widget _buildInteractiveList() => DSInteractiveListMessageBubble(
content: interactive,
content: DSInteractiveListMessage.fromJson(interactive),
align: align,
borderRadius: borderRadius,
style: style,
Expand Down
Loading

0 comments on commit 11e2d13

Please sign in to comment.