Skip to content

Commit

Permalink
Merge pull request #236 from takenet/release/0.0.90
Browse files Browse the repository at this point in the history
Release/0.0.90
  • Loading branch information
mpamaro authored Nov 30, 2023
2 parents f20eadf + 1d927f8 commit a312baa
Show file tree
Hide file tree
Showing 35 changed files with 892 additions and 348 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.90

- [DSReplyContainer] Created the widget.
- [DSUploading] Created the widget.

## 0.0.89

- [DSInteractiveButtonMessageBubble] Fixed border radius behavior.
Expand Down
9 changes: 8 additions & 1 deletion lib/blip_ds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ export 'src/models/ds_message_bubble_avatar_config.model.dart'
export 'src/models/ds_message_bubble_style.model.dart'
show DSMessageBubbleStyle;
export 'src/models/ds_message_item.model.dart' show DSMessageItem;
export 'src/models/ds_reply_content.model.dart' show DSReplyContent;
export 'src/models/ds_reply_content_in_reply_to.model.dart'
show DSReplyContentInReplyTo;
export 'src/models/ds_reply_content_replied.model.dart'
show DSReplyContentReplied;
export 'src/models/ds_toast_props.model.dart' show DSToastProps;
export 'src/models/interactive_message/ds_interactive_message.model.dart'
show DSInteractiveMessage;
Expand Down Expand Up @@ -135,6 +140,7 @@ export 'src/widgets/chat/ds_location_message_bubble.widget.dart'
export 'src/widgets/chat/ds_message_bubble.widget.dart' show DSMessageBubble;
export 'src/widgets/chat/ds_message_bubble_detail.widget.dart'
show DSMessageBubbleDetail;
export 'src/widgets/chat/ds_reply_container.widget.dart' show DSReplyContainer;
export 'src/widgets/chat/ds_request_location_bubble.widget.dart'
show DSRequestLocationBubble;
export 'src/widgets/chat/ds_survey_message_bubble.widget.dart'
Expand All @@ -144,7 +150,8 @@ export 'src/widgets/chat/ds_text_message_bubble.widget.dart'
export 'src/widgets/chat/ds_unsupported_content_message_bubble.widget.dart'
show DSUnsupportedContentMessageBubble;
export 'src/widgets/chat/ds_url_preview.widget.dart' show DSUrlPreview;
export 'src/widgets/chat/ds_weblink.widget.dart' show DSWeblink;
export 'src/widgets/chat/ds_weblink_message_bubble.widget.dart'
show DSWeblinkMessageBubble;
export 'src/widgets/chat/typing/ds_typing_dot_animation.widget.dart'
show DSTypingDotAnimation;
export 'src/widgets/chat/typing/ds_typing_message_bubble.widget.dart'
Expand Down
1 change: 1 addition & 0 deletions lib/src/controllers/chat/ds_audio_player.controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class DSAudioPlayerController extends GetxController {
final audioSpeed = RxDouble(1.0);
final player = AudioPlayer();
final isInitialized = RxBool(false);
final isLoadingAudio = RxBool(false);

/// Collects the data useful for displaying in a SeekBar widget.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class DSImageMessageBubbleController extends GetxController {
final maximumProgress = RxInt(0);
final downloadProgress = RxInt(0);
final localPath = RxnString();

final String url;
final String? mediaType;
final bool shouldAuthenticate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class DSVideoMessageBubbleController {
hasError.value = !isSuccess;
}

_generateThumbnail(outputFile.path);
await _generateThumbnail(outputFile.path);
} catch (_) {
hasError.value = true;

Expand Down
11 changes: 11 additions & 0 deletions lib/src/extensions/future.extension.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'package:get/get.dart';

extension FutureExtension on Future {
Future<dynamic> trueWhile<T>(Rx<bool> rxValue) {
rxValue.value = true;

return whenComplete(
() => rxValue.value = false,
);
}
}
7 changes: 6 additions & 1 deletion lib/src/models/ds_message_item.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class DSMessageItem {
/// 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 [DSMessageItem] model
/// if the media message is uploading
bool isUploading;

/// Creates a new Design System's [DSMessageItemModel] model
DSMessageItem({
this.id,
required this.date,
Expand All @@ -41,6 +44,7 @@ class DSMessageItem {
this.content,
this.customer,
this.hideMessageDetail,
this.isUploading = false,
});

factory DSMessageItem.fromJson(Map<String, dynamic> json) {
Expand All @@ -53,6 +57,7 @@ class DSMessageItem {
content: json['content'],
status: DSDeliveryReportStatus.unknown.getValue(json['status']),
hideMessageDetail: json['hideMessageDetail'],
isUploading: json['isUploading'] ?? false,
);

if (json.containsKey('customer')) {
Expand Down
20 changes: 20 additions & 0 deletions lib/src/models/ds_reply_content.model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'ds_reply_content_in_reply_to.model.dart';
import 'ds_reply_content_replied.model.dart';

class DSReplyContent {
DSReplyContentReplied replied;
DSReplyContentInReplyTo inReplyTo;

DSReplyContent({
required this.replied,
required this.inReplyTo,
});

DSReplyContent.fromJson(Map<String, dynamic> json)
: replied = DSReplyContentReplied.fromJson(
json['replied'],
),
inReplyTo = DSReplyContentInReplyTo.fromJson(
json['inReplyTo'],
);
}
19 changes: 19 additions & 0 deletions lib/src/models/ds_reply_content_in_reply_to.model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class DSReplyContentInReplyTo {
String id;
String type;
dynamic value;
String direction;

DSReplyContentInReplyTo({
required this.id,
required this.type,
required this.value,
required this.direction,
});

DSReplyContentInReplyTo.fromJson(Map<String, dynamic> json)
: id = json['id'],
type = json['type'],
value = json['value'],
direction = json['direction'];
}
13 changes: 13 additions & 0 deletions lib/src/models/ds_reply_content_replied.model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class DSReplyContentReplied {
String type;
dynamic value;

DSReplyContentReplied({
required this.type,
required this.value,
});

DSReplyContentReplied.fromJson(Map<String, dynamic> json)
: type = json['type'],
value = json['value'];
}
7 changes: 5 additions & 2 deletions lib/src/services/ds_file.service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ abstract class DSFileService {
return null;
}

static String getFileExtensionFromMime(String? mimeType) =>
extensionFromMime(mimeType ?? '');
static String getFileExtensionFromMime(String? mimeType) {
return mimeType == 'application/vnd.ms-powerpoint'
? 'ppt'
: extensionFromMime(mimeType ?? '');
}
}
1 change: 1 addition & 0 deletions lib/src/themes/colors/ds_colors.theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ abstract class DSColors {
static const Color surface1 = Color(0xFFF6F6F6);
static const Color surface3 = Color(0xFFC7C7C7);
static const Color contentDefault = Color(0xFF454545);
static const Color contentGhost = Color(0xFF949494);

static const Color disabledText = Color(0xFF637798);
static const Color disabledBg = Color(0xFFE8F2FF);
Expand Down
1 change: 1 addition & 0 deletions lib/src/utils/ds_utils.util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ abstract class DSUtils {
static const bubbleMinSize = 240.0;
static const bubbleMaxSize = 480.0;
static const defaultAnimationDuration = Duration(milliseconds: 300);
static bool shouldShowReplyContainer = false;

static String generateUniqueID() =>
md5.convert(utf8.encode(DateTime.now().toIso8601String())).toString();
Expand Down
53 changes: 53 additions & 0 deletions lib/src/widgets/animations/ds_uploading.widget.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import 'dart:async';

import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../../themes/colors/ds_colors.theme.dart';
import '../../themes/icons/ds_icons.dart';

class DSUploading extends StatefulWidget {
final double size;
final Color color;

const DSUploading({
super.key,
this.size = 24.0,
this.color = DSColors.neutralLightSnow,
});

@override
State<DSUploading> createState() => _DSUploadingState();
}

class _DSUploadingState extends State<DSUploading> {
final _visible = RxBool(false);

@override
void initState() {
super.initState();
Timer.periodic(
const Duration(seconds: 1),
(timer) {
_visible.value = !_visible.value;
},
);
}

@override
Widget build(BuildContext context) {
return Center(
child: Obx(
() => AnimatedOpacity(
opacity: _visible.value ? 1.0 : 0.0,
duration: const Duration(seconds: 1),
child: Icon(
DSIcons.upload_outline,
color: widget.color,
size: widget.size,
),
),
),
);
}
}
76 changes: 39 additions & 37 deletions lib/src/widgets/chat/audio/ds_audio_message_bubble.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ 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/ds_reply_content.model.dart';
import '../../../themes/colors/ds_colors.theme.dart';
import '../ds_message_bubble.widget.dart';
import 'ds_audio_player.widget.dart';
Expand All @@ -14,12 +15,14 @@ class DSAudioMessageBubble extends StatelessWidget {
final DSMessageBubbleStyle style;
final String? uniqueId;
final bool shouldAuthenticate;
final DSReplyContent? replyContent;

DSAudioMessageBubble({
super.key,
required this.uri,
required this.align,
this.uniqueId,
this.replyContent,
this.borderRadius = const [DSBorderRadius.all],
this.shouldAuthenticate = false,
final DSMessageBubbleStyle? style,
Expand All @@ -33,44 +36,43 @@ class DSAudioMessageBubble extends StatelessWidget {
return DSMessageBubble(
borderRadius: borderRadius,
align: align,
replyContent: replyContent,
style: style,
padding: const EdgeInsets.only(
left: 4.0,
right: 8.0,
top: 8.0,
bottom: 8.0,
),
child: DSAudioPlayer(
uri: uri,
shouldAuthenticate: shouldAuthenticate,
controlForegroundColor: isLightBubbleBackground
? DSColors.neutralDarkRooftop
: DSColors.neutralLightSnow,
labelColor: isLightBubbleBackground
? DSColors.neutralDarkCity
: DSColors.neutralLightSnow,
bufferActiveTrackColor: isLightBubbleBackground
? DSColors.neutralMediumWave
: DSColors.neutralMediumElephant,
bufferInactiveTrackColor: isLightBubbleBackground
? DSColors.neutralDarkRooftop
: DSColors.neutralLightBox,
sliderActiveTrackColor: isLightBubbleBackground
? DSColors.primaryNight
: DSColors.primaryLight,
sliderThumbColor: isLightBubbleBackground
? DSColors.neutralDarkRooftop
: DSColors.neutralLightSnow,
speedForegroundColor: isLightBubbleBackground
? DSColors.neutralDarkCity
: DSColors.neutralLightSnow,
speedBorderColor: isLightBubbleBackground
? isDefaultBubbleColors
? DSColors.neutralMediumSilver
: DSColors.neutralDarkCity
: isDefaultBubbleColors
? DSColors.disabledText
: DSColors.neutralLightSnow,
padding: EdgeInsets.zero,
child: Padding(
padding: const EdgeInsets.fromLTRB(4.0, 8.0, 8.0, 8.0),
child: DSAudioPlayer(
uri: uri,
shouldAuthenticate: shouldAuthenticate,
controlForegroundColor: isLightBubbleBackground
? DSColors.neutralDarkRooftop
: DSColors.neutralLightSnow,
labelColor: isLightBubbleBackground
? DSColors.neutralDarkCity
: DSColors.neutralLightSnow,
bufferActiveTrackColor: isLightBubbleBackground
? DSColors.neutralMediumWave
: DSColors.neutralMediumElephant,
bufferInactiveTrackColor: isLightBubbleBackground
? DSColors.neutralDarkRooftop
: DSColors.neutralLightBox,
sliderActiveTrackColor: isLightBubbleBackground
? DSColors.primaryNight
: DSColors.primaryLight,
sliderThumbColor: isLightBubbleBackground
? DSColors.neutralDarkRooftop
: DSColors.neutralLightSnow,
speedForegroundColor: isLightBubbleBackground
? DSColors.neutralDarkCity
: DSColors.neutralLightSnow,
speedBorderColor: isLightBubbleBackground
? isDefaultBubbleColors
? DSColors.neutralMediumSilver
: DSColors.neutralDarkCity
: isDefaultBubbleColors
? DSColors.disabledText
: DSColors.neutralLightSnow,
),
),
);
}
Expand Down
8 changes: 6 additions & 2 deletions lib/src/widgets/chat/audio/ds_audio_player.widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:get/get.dart';
import 'package:just_audio/just_audio.dart';

import '../../../controllers/chat/ds_audio_player.controller.dart';
import '../../../extensions/future.extension.dart';
import '../../../services/ds_auth.service.dart';
import '../../../services/ds_file.service.dart';
import '../../../services/ds_media_format.service.dart';
Expand Down Expand Up @@ -112,7 +113,9 @@ class _DSAudioPlayerState extends State<DSAudioPlayer>
);

try {
await _loadAudio();
await _loadAudio().trueWhile(
_controller.isLoadingAudio,
);

_controller.isInitialized.value = true;
} catch (_) {
Expand Down Expand Up @@ -214,7 +217,8 @@ class _DSAudioPlayerState extends State<DSAudioPlayer>
? _controller.player.play
: () => {},
isLoading: [ProcessingState.loading, ProcessingState.buffering]
.contains(processingState),
.contains(processingState) ||
_controller.isLoadingAudio.value,
color: _controller.isInitialized.value
? widget.controlForegroundColor
: DSColors.contentDisable,
Expand Down
Loading

0 comments on commit a312baa

Please sign in to comment.