Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release] 0.0.91 #237

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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