Skip to content

Commit

Permalink
Merge pull request #267 from takenet/develop
Browse files Browse the repository at this point in the history
[Release] 0.1.4
  • Loading branch information
mpamaro authored Jul 22, 2024
2 parents 6b5c0ac + c1c86ae commit 1c7dfc4
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.1.4

- [DSInteractiveVoiceCallMessageBubble] Added new bubble to render the request call message.

## 0.1.3

- [DSIcons] Added new icons.
Expand Down
4 changes: 4 additions & 0 deletions lib/blip_ds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export 'src/models/interactive_message/ds_interactive_message_image.model.dart'
show DSInteractiveMessageImage;
export 'src/models/interactive_message/ds_interactive_message_media.model.dart'
show DSInteractiveMessageMedia;
export 'src/models/interactive_message/ds_interactive_message_parameters.model.dart'
show DSInteractiveMessageParameters;
export 'src/models/interactive_message/ds_interactive_message_row.model.dart'
show DSInteractiveMessageRow;
export 'src/models/interactive_message/ds_interactive_message_section.model.dart'
Expand Down Expand Up @@ -138,6 +140,8 @@ export 'src/widgets/chat/ds_interactive_button_message_bubble.widget.dart'
show DSInteractiveButtonMessageBubble;
export 'src/widgets/chat/ds_interactive_list_message_bubble.widget.dart'
show DSInteractiveListMessageBubble;
export 'src/widgets/chat/ds_interactive_voice_call_message_bubble.widget.dart'
show DSInteractiveVoiceCallMessageBubble;
export 'src/widgets/chat/ds_location_message_bubble.widget.dart'
show DSLocationMessageBubble;
export 'src/widgets/chat/ds_message_bubble.widget.dart' show DSMessageBubble;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
import 'ds_interactive_message_button.model.dart';
import 'ds_interactive_message_parameters.model.dart';
import 'ds_interactive_message_section.model.dart';

class DSInteractiveMessageAction {
final String? button;
final List<DSInteractiveMessageButton>? buttons;
final List<DSInteractiveMessageSection>? sections;
final String? name;
final DSInteractiveMessageParameters? parameters;

DSInteractiveMessageAction({
this.button,
this.buttons,
this.sections,
this.name,
this.parameters,
});

DSInteractiveMessageAction.fromJson(Map<String, dynamic> json)
Expand All @@ -27,6 +32,12 @@ class DSInteractiveMessageAction {
(e) => DSInteractiveMessageSection.fromJson(e),
)
.toList()
: null,
name = json['name'],
parameters = json['parameters'] != null
? DSInteractiveMessageParameters.fromJson(
json['parameters'],
)
: null;

Map<String, dynamic> toJson() => {
Expand All @@ -41,5 +52,7 @@ class DSInteractiveMessageAction {
(e) => e.toJson(),
)
.toList(),
'name': name,
'parameters': parameters?.toJson(),
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class DSInteractiveMessageParameters {
final String? displayText;

DSInteractiveMessageParameters({
this.displayText,
});

DSInteractiveMessageParameters.fromJson(Map<String, dynamic> json)
: displayText = json['display_text'];

Map<String, dynamic> toJson() => {
'display_text': displayText,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import '../../themes/colors/ds_colors.theme.dart';
import '../../themes/icons/ds_icons.dart';
import 'ds_interactive_button_message_bubble.widget.dart';
import 'ds_interactive_list_message_bubble.widget.dart';
import 'ds_interactive_voice_call_message_bubble.widget.dart';
import 'ds_unsupported_content_message_bubble.widget.dart';

class DSApplicationJsonMessageBubble extends StatelessWidget {
Expand Down Expand Up @@ -77,6 +78,12 @@ class DSApplicationJsonMessageBubble extends StatelessWidget {
style: style,
avatarConfig: avatarConfig,
),
'voice_call' => DSInteractiveVoiceCallMessageBubble(
content: content,
align: align,
borderRadius: borderRadius,
style: style,
),
_ => _buildUnsupportedContent(),
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import 'package:flutter/material.dart';

import '../../enums/ds_align.enum.dart';
import '../../enums/ds_border_radius.enum.dart';
import '../../models/ds_message_bubble_style.model.dart';
import '../../models/interactive_message/ds_interactive_message.model.dart';
import '../../themes/colors/ds_colors.theme.dart';
import '../../themes/icons/ds_icons.dart';
import '../texts/ds_body_text.widget.dart';
import '../utils/ds_divider.widget.dart';
import 'ds_message_bubble.widget.dart';

class DSInteractiveVoiceCallMessageBubble extends StatelessWidget {
final DSInteractiveMessage content;
final DSAlign align;
final List<DSBorderRadius> borderRadius;
final DSMessageBubbleStyle style;

late final bool _isLightBubbleBackground;
late final Color _foregroundColor;

DSInteractiveVoiceCallMessageBubble({
super.key,
required this.content,
required this.align,
this.borderRadius = const [DSBorderRadius.all],
DSMessageBubbleStyle? style,
}) : style = style ?? DSMessageBubbleStyle() {
_initProperties();
}

void _initProperties() {
_isLightBubbleBackground = style.isLightBubbleBackground(align);

_foregroundColor = _isLightBubbleBackground
? DSColors.neutralDarkCity
: DSColors.neutralLightSnow;
}

@override
Widget build(BuildContext context) {
return DSMessageBubble(
align: align,
style: style,
borderRadius: borderRadius,
child: Column(
children: [
DSBodyText(
content.body?.text,
overflow: TextOverflow.visible,
color: _foregroundColor,
),
content.action?.name == 'voice_call'
? Column(
children: [
const Padding(
padding: EdgeInsets.symmetric(
vertical: 8.0,
),
child: DSDivider(),
),
Padding(
padding: const EdgeInsets.symmetric(
vertical: 8.0,
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
DSIcons.voip_outline,
color: _foregroundColor,
),
content.action?.parameters?.displayText != null
? Padding(
padding: const EdgeInsets.only(
left: 8.0,
),
child: DSBodyText(
content.action?.parameters?.displayText,
overflow: TextOverflow.visible,
color: _foregroundColor,
),
)
: const SizedBox.shrink()
],
),
),
],
)
: const SizedBox.shrink(),
],
),
);
}
}
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.1.3
version: 0.1.4
homepage: https://github.com/takenet/blip-ds-flutter#readme
repository: https://github.com/takenet/blip-ds-flutter

Expand Down
2 changes: 1 addition & 1 deletion sample/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.2"
version: "0.1.4"
boolean_selector:
dependency: transitive
description:
Expand Down

0 comments on commit 1c7dfc4

Please sign in to comment.