From 0402e1cae77508e71496d2cd515caf32b5866bfa Mon Sep 17 00:00:00 2001 From: Andre Rossi Date: Mon, 4 Dec 2023 09:20:29 -0300 Subject: [PATCH 1/3] fix: center the icon when image is broken --- lib/src/widgets/utils/ds_expanded_image.widget.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/widgets/utils/ds_expanded_image.widget.dart b/lib/src/widgets/utils/ds_expanded_image.widget.dart index 36c72167..a1d0f797 100644 --- a/lib/src/widgets/utils/ds_expanded_image.widget.dart +++ b/lib/src/widgets/utils/ds_expanded_image.widget.dart @@ -92,7 +92,7 @@ class DSExpandedImage extends StatelessWidget { _error.value = true; return Column( - mainAxisSize: MainAxisSize.min, + mainAxisAlignment: MainAxisAlignment.center, children: [ Center( child: Padding( From b3144028bf2fbf70200716d91a439a99162b3a74 Mon Sep 17 00:00:00 2001 From: Marcelo Amaro Date: Mon, 4 Dec 2023 09:40:00 -0300 Subject: [PATCH 2/3] fix: Check if options exists before building them at DSSelectMenu widget --- .../widgets/chat/ds_select_menu.widget.dart | 76 +++++++++++-------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/lib/src/widgets/chat/ds_select_menu.widget.dart b/lib/src/widgets/chat/ds_select_menu.widget.dart index c0986ce1..11a102e9 100644 --- a/lib/src/widgets/chat/ds_select_menu.widget.dart +++ b/lib/src/widgets/chat/ds_select_menu.widget.dart @@ -22,51 +22,61 @@ class DSSelectMenu extends StatelessWidget { @override Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.only(top: 18.0), - child: Column( - children: _buildSelectMenu(), + final options = _getOptions(); + + return Visibility( + visible: options.isNotEmpty, + child: Padding( + padding: const EdgeInsets.only(top: 18.0), + child: Column( + children: options, + ), ), ); } - List _buildSelectMenu() { + List _getOptions() { final List children = []; int count = 0; - List options = - content['options'].map((doc) => DSSelectOption.fromJson(doc)).toList(); + final options = (content['options'] as List?) + ?.map( + (doc) => DSSelectOption.fromJson(doc), + ) + .toList(); - for (final option in options) { - count++; + if (options != null) { + for (final option in options) { + count++; - children.add( - DSMenuItem( - text: option.text, - align: align, - showDivider: count != content['options'].length, - onPressed: () { - if (onSelected != null) { - Map payload = {}; + children.add( + DSMenuItem( + text: option.text, + align: align, + showDivider: count != content['options'].length, + onPressed: () { + if (onSelected != null) { + Map payload = {}; - if (option.value != null) { - String type = option.type!; - payload = {"type": type, "content": option.value}; - } else { - payload = { - "type": DSMessageContentType.textPlain, - "content": option.order != null - ? option.order.toString() - : option.text - }; + if (option.value != null) { + String type = option.type!; + payload = {"type": type, "content": option.value}; + } else { + payload = { + "type": DSMessageContentType.textPlain, + "content": option.order != null + ? option.order.toString() + : option.text + }; + } + onSelected!(option.text, payload); } - onSelected!(option.text, payload); - } - }, - style: style, - ), - ); + }, + style: style, + ), + ); + } } return children; From 0bd52eb68778846d18bf233f0b73b14dd1b6e642 Mon Sep 17 00:00:00 2001 From: Marcelo Amaro Date: Mon, 4 Dec 2023 09:45:34 -0300 Subject: [PATCH 3/3] chore: Upgrade lib version to 0.0.91 --- CHANGELOG.md | 5 +++++ pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87e2b25e..419d1840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.0.91 + +- [DSSelectMenu] Added check to see if options exists before building them. +- [DSExpandedImage] Centered icon that appears when the image is broken. + ## 0.0.90 - [DSReplyContainer] Created the widget. diff --git a/pubspec.yaml b/pubspec.yaml index 4f4cb247..ac41ce23 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: blip_ds description: Blip Design System for Flutter. -version: 0.0.90 +version: 0.0.91 homepage: https://github.com/takenet/blip-ds-flutter#readme repository: https://github.com/takenet/blip-ds-flutter