Skip to content

Commit

Permalink
Merge pull request #237 from takenet/release/0.0.91
Browse files Browse the repository at this point in the history
[Release] 0.0.91
  • Loading branch information
mpamaro authored Dec 4, 2023
2 parents a312baa + 0bd52eb commit 31cc113
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 35 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
76 changes: 43 additions & 33 deletions lib/src/widgets/chat/ds_select_menu.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Widget> _buildSelectMenu() {
List<Widget> _getOptions() {
final List<Widget> 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<String, dynamic> payload = {};
children.add(
DSMenuItem(
text: option.text,
align: align,
showDivider: count != content['options'].length,
onPressed: () {
if (onSelected != null) {
Map<String, dynamic> 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;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/widgets/utils/ds_expanded_image.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class DSExpandedImage extends StatelessWidget {
_error.value = true;

return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Padding(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand Down

0 comments on commit 31cc113

Please sign in to comment.