Skip to content

Commit

Permalink
Merge branch 'develop' into feature/368855-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcelo Amaro committed Oct 11, 2022
2 parents 10854fb + 7480080 commit 002f2f0
Show file tree
Hide file tree
Showing 88 changed files with 3,223 additions and 750 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
}
EOF
- name: Publish package
uses: subosito/flutter-action@v2.4.0
uses: subosito/flutter-action@v2.7.0
with:
flutter-version: '3.0.4'
flutter-version: '3.3.0'
- run: flutter pub publish -f
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: subosito/flutter-action@v2.4.0
- uses: subosito/flutter-action@v2.7.0
with:
flutter-version: '3.0.4'
flutter-version: '3.3.0'
- run: flutter pub get
- run: flutter test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ build/
.flutter-plugins-dependencies
.fvm/
coverage/html
test/**/failures
test/**/failures
.vscode/settings.json
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 0.0.14

* Added suport for Quick Reply and Select
* Added suport for Video messages
* Image message bubble size fixe

## 0.0.13

* Added delivery report & timestamp message widget
* Added DSHeader
* Added DSGroupCard
* Added DSRadio and DSRadioTile
* Added link preview to messages bubbles

## 0.0.12

* Add button styles
Expand Down
Binary file added assets/fonts/DSIcons.ttf
Binary file not shown.
3 changes: 0 additions & 3 deletions assets/images/arrow_back.svg

This file was deleted.

Binary file removed assets/images/block_neutral_dark_city.png
Binary file not shown.
Binary file removed assets/images/block_neutral_light_snow.png
Binary file not shown.
Binary file added assets/images/clip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/emoji.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/file_image_broken.png
Binary file not shown.
Binary file modified assets/images/play_neutral_dark_rooftop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/play_neutral_light_snow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/send_button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions lib/blip_ds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export 'src/widgets/chat/ds_url_preview.widget.dart' show DSUrlPreview;
export 'src/widgets/chat/audio/ds_audio_message_bubble.widget.dart'
show DSAudioMessageBubble;

/// Widgets / Chat / Form Fields
export 'src/widgets/fields/ds_text_form_field.widget.dart'
show DSTextFormField;

/// Widgets / Animations
export 'src/widgets/animations/ds_animated_size.widget.dart'
show DSAnimatedSize;
Expand All @@ -28,11 +32,18 @@ export 'src/widgets/animations/ds_fading_circle_loading.widget.dart'
export 'src/widgets/animations/ds_ring_loading.widget.dart' show DSRingLoading;

/// Widgets / Buttons
export 'src/widgets/buttons/ds_button.widget.dart' show DSButton;
export 'src/widgets/buttons/ds_primary_button.widget.dart' show DSPrimaryButton;
export 'src/widgets/buttons/ds_secondary_button.widget.dart'
show DSSecondaryButton;
export 'src/widgets/buttons/ds_tertiary_button.widget.dart'
show DSTertiaryButton;
export 'src/widgets/buttons/ds_send_button.widget.dart'
show DSSendButton;
export 'src/widgets/buttons/ds_icon_button.widget.dart'
show DSIconButton;
export 'src/widgets/buttons/ds_attachment_button.widget.dart'
show DSAttachmentButton;

/// Widgets / Texts
export 'src/widgets/texts/ds_body_text.widget.dart' show DSBodyText;
Expand Down Expand Up @@ -93,6 +104,8 @@ export 'src/services/ds_dialog.service.dart' show DSDialogService;

/// Models
export 'src/models/ds_message_item.model.dart' show DSMessageItemModel;
export 'src/models/ds_message_bubble_style.model.dart' show DSMessageBubbleStyle;
export 'src/models/ds_message_bubble_avatar_config.model.dart' show DSMessageBubbleAvatarConfig;

/// Widgets / Typing
export 'src/widgets/chat/typing/ds_typing_message_bubble.widget.dart'
Expand All @@ -107,3 +120,9 @@ export 'src/widgets/switch/ds_switch.widget.dart' show DSSwitch;
/// Widgets / Radio
export 'src/widgets/radio/ds_radio.widget.dart' show DSRadio;
export 'src/widgets/radio/ds_radio_tile.widget.dart' show DSRadioTile;

/// Widgets / Video
export 'src/widgets/chat/ds_video_message_bubble.widget.dart'
show DSVideoMessageBubble;
export 'src/widgets/chat/video/ds_video_player.widget.dart' show DSVideoPlayer;
export 'src/themes/icons/ds_icons.dart' show DSIcons;
63 changes: 9 additions & 54 deletions lib/src/controllers/chat/ds_file_message_bubble.controller.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import 'dart:io' as io;
import 'package:blip_ds/blip_ds.dart';
import 'package:dio/dio.dart';
import 'package:get/get.dart';
import 'package:filesize/filesize.dart';
import 'package:open_filex/open_filex.dart';
import 'package:path_provider/path_provider.dart';
import 'package:url_launcher/url_launcher_string.dart';
import 'package:get/get.dart';
import 'package:path/path.dart' as path_utils;

import 'package:blip_ds/src/services/ds_file.service.dart';

class DSFileMessageBubbleController extends GetxController {
final isDownloading = RxBool(false);

Expand All @@ -28,51 +24,10 @@ class DSFileMessageBubbleController extends GetxController {
Future<void> openFile(
final String filename,
final String url,
) async {
final String directory = (await getTemporaryDirectory()).path;
final String savedFilePath = path_utils.join(directory, filename);

if (!await io.File(savedFilePath).exists()) {
final response = await _downloadFile(url, savedFilePath);
if (response == null) {
return;
}
}

final result = await OpenFilex.open(savedFilePath);

switch (result.type) {
case ResultType.done:
break;
case ResultType.noAppToOpen:
launchUrlString(url, mode: LaunchMode.externalApplication);
break;
default:
_showAlert('Erro', 'Visualização indisponível');
}
}

Future<dynamic> _downloadFile(
final String url,
final String savedFilePath,
) async {
isDownloading.value = true;
try {
return await Dio().download(url, savedFilePath);
} catch (e) {
_showAlert('Erro', 'Download indisponível');
} finally {
isDownloading.value = false;
}
}

//TODO: Use the DS's widget when avalible and question the PD about it
void _showAlert(
final String title,
final String message,
) {
Get.snackbar(title, message,
snackPosition: SnackPosition.BOTTOM,
backgroundColor: DSColors.neutralLightSnow);
}
) =>
DSFileService.open(
filename,
url,
onDownloadStateChange: (loading) => isDownloading.value = loading,
);
}
23 changes: 23 additions & 0 deletions lib/src/controllers/chat/ds_image_message_bubble.controller.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'dart:async';

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

class DSImageMessageBubbleController extends GetxController {
Expand All @@ -13,4 +16,24 @@ class DSImageMessageBubbleController extends GetxController {
? appBarVisible.value = false
: appBarVisible.value = true;
}

Future<ImageInfo> getImageInfo(final String url) async {
final Image img = Image.network(url);

final completer = Completer<ImageInfo>();

final ImageStream imageStream =
img.image.resolve(const ImageConfiguration());

imageStream.addListener(
ImageStreamListener(
(ImageInfo i, bool _) {
completer.complete(i);
},
onError: (exception, stackTrace) => completer.completeError(exception),
),
);

return completer.future;
}
}

This file was deleted.

140 changes: 140 additions & 0 deletions lib/src/controllers/ds_video_player.controller.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';

import 'package:chewie/chewie.dart';
import 'package:get/get.dart';
import 'package:video_player/video_player.dart';

import 'package:blip_ds/src/services/ds_dialog.service.dart';
import 'package:blip_ds/src/services/ds_file.service.dart';
import 'package:blip_ds/src/themes/colors/ds_colors.theme.dart';
import 'package:blip_ds/src/widgets/buttons/ds_primary_button.widget.dart';
import 'package:blip_ds/src/widgets/buttons/ds_secondary_button.widget.dart';

class DSVideoPlayerController extends GetxController {
/// Video controller. responsible for managing the state of the video widget, and all
/// the management of video controls.
DSVideoPlayerController({
required this.url,
});

// External URL containing the video to be played
final String url;

VideoPlayerController? _videoPlayerController;
ChewieController? chewieController;
int? bufferDelay;

@override
bool isClosed = false;

RxBool appBarVisible = true.obs;
RxBool isLoading = true.obs;

@override
void onInit() async {
await initializePlayer();

super.onInit();
}

@override
void onClose() {
_videoPlayerController?.dispose();
chewieController?.dispose();
_videoPlayerController?.removeListener(_showAppBar);
isClosed = true;
super.onClose();
}

Future<void> initializePlayer() async {
try {
final fileName = url.substring(url.lastIndexOf('/')).substring(1);
final result = await DSFileService.download(url, fileName);
if (result?.isNotEmpty ?? false) {
_videoPlayerController = VideoPlayerController.file(File(result!));

final completer = Completer<void>();

await Future<void>(() async {
_videoPlayerController!
.initialize()
.then((_) => completer.complete())
.catchError((e) {
_screenError(fileName);
});

return completer.future;
});

if (!completer.isCompleted) {
_screenError(fileName);
} else {
if (!isClosed) _createChewieController();
}

_videoPlayerController?.addListener(_showAppBar);

isLoading.value = false;
}
} on Exception {
isLoading.value = false;
Get.back();
}
}

void _screenError(final fileName) {
Get.back();
Get.delete<DSVideoPlayerController>();
final dialog = _dialogErrorFile(fileName);
dialog.error();
}

DSDialogService _dialogErrorFile(final String fileName) {
return DSDialogService(
title: 'Erro ao reproduzir o vídeo',
text:
'Encontramos um erro ao reproduzir o vídeo. Você deseja tentar abrir o vídeo externamente?',
firstButton: DSPrimaryButton(
onPressed: () {
Get.back();
DSFileService.open(fileName, url);
},
label: 'Sim',
),
secondButton: DSSecondaryButton(
onPressed: (() => Navigator.of(Get.context!).pop()),
label: 'Não, obrigado',
),
context: Get.context!,
);
}

void _createChewieController() {
chewieController = ChewieController(
videoPlayerController: _videoPlayerController!,
autoPlay: true,
looping: true,
allowPlaybackSpeedChanging: true,
allowMuting: false,
allowFullScreen: false,
playbackSpeeds: const [0.5, 1.0, 1.5, 2.0],
fullScreenByDefault: false,
progressIndicatorDelay:
bufferDelay != null ? Duration(milliseconds: bufferDelay!) : null,
materialProgressColors: ChewieProgressColors(
playedColor: DSColors.neutralDarkCity,
handleColor: DSColors.neutralLightSnow,
backgroundColor: DSColors.neutralDarkCity,
bufferedColor: DSColors.neutralMediumSilver,
),
autoInitialize: true,
);
}

Future<void> _showAppBar() async {
appBarVisible.value = !(chewieController!.isPlaying);
}
}
4 changes: 4 additions & 0 deletions lib/src/enums/ds_button_shape.enum.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
enum DSButtonShape {
rounded,
rectangular,
}
Loading

0 comments on commit 002f2f0

Please sign in to comment.