From bf21f7b3506b680a608dafadbae54bf0427100cf Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Thu, 30 Sep 2021 16:32:21 +0530 Subject: [PATCH] chore(repo): finish adding dart_code_metrics.yaml Signed-off-by: xsahil03x --- .github/workflows/dart_code_metrics.yaml | 2 +- .github/workflows/stream_flutter_workflow.yml | 2 +- analysis_options.yaml | 10 +- melos.yaml | 2 +- packages/stream_chat/example/pubspec.yaml | 5 +- .../stream_chat_flutter/example/pubspec.yaml | 17 +- .../lib/src/attachment_actions_modal.dart | 234 +++++++++--------- .../lib/src/full_screen_media.dart | 4 +- .../lib/src/gallery_footer.dart | 43 ++-- .../lib/src/message_input.dart | 69 +++--- .../lib/src/quoted_message_widget.dart | 2 +- .../example/pubspec.yaml | 10 +- .../example/pubspec.yaml | 14 +- .../example/pubspec.yaml | 10 +- 14 files changed, 203 insertions(+), 221 deletions(-) diff --git a/.github/workflows/dart_code_metrics.yaml b/.github/workflows/dart_code_metrics.yaml index 9d36add8..1272babc 100644 --- a/.github/workflows/dart_code_metrics.yaml +++ b/.github/workflows/dart_code_metrics.yaml @@ -33,7 +33,7 @@ jobs: flutter-version: ${{ env.flutter_version }} - name: "Install Tools" - run: flutter pub global activate melos + run: flutter pub global activate melos 1.0.0-dev.3 - name: "Bootstrap Workspace" run: melos bootstrap diff --git a/.github/workflows/stream_flutter_workflow.yml b/.github/workflows/stream_flutter_workflow.yml index 28063c18..1eb5082a 100644 --- a/.github/workflows/stream_flutter_workflow.yml +++ b/.github/workflows/stream_flutter_workflow.yml @@ -31,7 +31,7 @@ jobs: flutter-version: ${{ env.flutter_version }} - name: "Install Tools" run: | - flutter pub global activate melos + flutter pub global activate melos 1.0.0-dev.3 - name: "Bootstrap Workspace" run: melos bootstrap - name: "Dart Analyze" diff --git a/analysis_options.yaml b/analysis_options.yaml index e52012e6..a1fa9388 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -149,12 +149,6 @@ linter: # https://dartcodemetrics.dev/docs/getting-started/introduction dart_code_metrics: - metrics-exclude: - - packages/*/test/** - metrics: - source-lines-of-code: 90 - maximum-nesting-level: 5 - halstead-volume: 150 rules: # Dart Specific - binary-expression-operand-order @@ -162,6 +156,7 @@ dart_code_metrics: - prefer-match-file-name: exclude: - packages/*/test/** + - packages/*/example/** - packages/**/util/** - packages/**/utils.dart - packages/stream_chat/lib/src/client/client.dart @@ -181,5 +176,4 @@ dart_code_metrics: # Flutter specific - always-remove-listener - - avoid-unnecessary-setstate - - avoid-wrapping-in-padding + - avoid-unnecessary-setstate \ No newline at end of file diff --git a/melos.yaml b/melos.yaml index 062f57a3..9c5d4e4f 100644 --- a/melos.yaml +++ b/melos.yaml @@ -4,7 +4,7 @@ versioning: mode: independent packages: - - packages/stream_chat*/* + - packages/** scripts: lint:all: diff --git a/packages/stream_chat/example/pubspec.yaml b/packages/stream_chat/example/pubspec.yaml index 1b092b3e..cf1f3874 100644 --- a/packages/stream_chat/example/pubspec.yaml +++ b/packages/stream_chat/example/pubspec.yaml @@ -1,4 +1,4 @@ -name: example +name: stream_chat_example description: A new Flutter project. publish_to: "none" @@ -11,8 +11,7 @@ dependencies: cupertino_icons: ^1.0.0 flutter: sdk: flutter - stream_chat: - path: ../ + stream_chat: ^2.2.1 dev_dependencies: flutter_test: diff --git a/packages/stream_chat_flutter/example/pubspec.yaml b/packages/stream_chat_flutter/example/pubspec.yaml index 3afa4cc1..9c7ae6ee 100644 --- a/packages/stream_chat_flutter/example/pubspec.yaml +++ b/packages/stream_chat_flutter/example/pubspec.yaml @@ -1,4 +1,4 @@ -name: example +name: stream_chat_flutter_example description: A new Flutter project. # The following line prevents the package from being accidentally published to @@ -27,18 +27,9 @@ dependencies: cupertino_icons: ^1.0.3 flutter: sdk: flutter - -dependency_overrides: - stream_chat: - path: ../../stream_chat - stream_chat_flutter: - path: ../../stream_chat_flutter - stream_chat_flutter_core: - path: ../../stream_chat_flutter_core - stream_chat_localizations: - path: ../../stream_chat_localizations - stream_chat_persistence: - path: ../../stream_chat_persistence + stream_chat_flutter: ^2.2.1 + stream_chat_localizations: ^1.1.0 + stream_chat_persistence: ^2.2.0 dev_dependencies: flutter_test: diff --git a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart index f7f074c6..f49561aa 100644 --- a/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart +++ b/packages/stream_chat_flutter/lib/src/attachment_actions_modal.dart @@ -54,131 +54,135 @@ class AttachmentActionsModal extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.end, children: [ const SizedBox(height: kToolbarHeight), - Container( + Padding( padding: const EdgeInsets.only(right: 8), - width: MediaQuery.of(context).size.width * 0.5, - clipBehavior: Clip.hardEdge, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(16), - ), - child: SizedBox( - child: Column( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: [ - _buildButton( - context, - context.translations.replyLabel, - StreamSvgIcon.iconCurveLineLeftUp( - size: 24, - color: theme.colorTheme.textLowEmphasis, - ), - () { - Navigator.pop(context, ReturnActionType.reply); - }, - ), - _buildButton( - context, - context.translations.showInChatLabel, - StreamSvgIcon.eye( - size: 24, - color: theme.colorTheme.textHighEmphasis, - ), - onShowMessage, - ), - _buildButton( - context, - message.attachments[currentIndex].type == 'video' - ? context.translations.saveVideoLabel - : context.translations.saveImageLabel, - StreamSvgIcon.iconSave( - size: 24, - color: theme.colorTheme.textLowEmphasis, - ), - () { - final attachment = message.attachments[currentIndex]; - final isImage = attachment.type == 'image'; - final Future Function( - Attachment, { - void Function(int, int) progressCallback, - }) saveFile = fileDownloader ?? _downloadAttachment; - final Future Function( - Attachment, { - void Function(int, int) progressCallback, - }) saveImage = imageDownloader ?? _downloadAttachment; - final downloader = isImage ? saveImage : saveFile; - - final progressNotifier = ValueNotifier<_DownloadProgress?>( - _DownloadProgress.initial(), - ); - - downloader( - attachment, - progressCallback: (received, total) { - progressNotifier.value = _DownloadProgress( - total, - received, - ); - }, - ).catchError((e, stk) { - progressNotifier.value = null; - }); - - // Closing attachment actions modal before opening - // attachment download dialog - Navigator.pop(context); - - showDialog( - barrierDismissible: false, - context: context, - barrierColor: theme.colorTheme.overlay, - builder: (context) => _buildDownloadProgressDialog( - context, - progressNotifier, - ), - ); - }, - ), - if (StreamChat.of(context).currentUser?.id == message.user?.id) + child: Container( + width: MediaQuery.of(context).size.width * 0.5, + clipBehavior: Clip.hardEdge, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(16), + ), + child: SizedBox( + child: Column( + crossAxisAlignment: CrossAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ _buildButton( context, - context.translations.deleteLabel.capitalize(), - StreamSvgIcon.delete( + context.translations.replyLabel, + StreamSvgIcon.iconCurveLineLeftUp( size: 24, - color: theme.colorTheme.accentError, + color: theme.colorTheme.textLowEmphasis, ), () { - final channel = StreamChannel.of(context).channel; - if (message.attachments.length > 1 || - message.text?.isNotEmpty == true) { - final remainingAttachments = [...message.attachments] - ..removeAt(currentIndex); - channel.updateMessage(message.copyWith( - attachments: remainingAttachments, - )); - Navigator.of(context) - ..pop() - ..maybePop(); - } else { - channel.deleteMessage(message); - Navigator.of(context) - ..pop() - ..maybePop(); - } + Navigator.pop(context, ReturnActionType.reply); }, - color: theme.colorTheme.accentError, ), - ] - .map((e) => Align( - alignment: Alignment.centerRight, - child: e, - )) - .insertBetween( - Container( - height: 1, - color: theme.colorTheme.borders, + _buildButton( + context, + context.translations.showInChatLabel, + StreamSvgIcon.eye( + size: 24, + color: theme.colorTheme.textHighEmphasis, ), + onShowMessage, ), + _buildButton( + context, + message.attachments[currentIndex].type == 'video' + ? context.translations.saveVideoLabel + : context.translations.saveImageLabel, + StreamSvgIcon.iconSave( + size: 24, + color: theme.colorTheme.textLowEmphasis, + ), + () { + final attachment = message.attachments[currentIndex]; + final isImage = attachment.type == 'image'; + final Future Function( + Attachment, { + void Function(int, int) progressCallback, + }) saveFile = fileDownloader ?? _downloadAttachment; + final Future Function( + Attachment, { + void Function(int, int) progressCallback, + }) saveImage = imageDownloader ?? _downloadAttachment; + final downloader = isImage ? saveImage : saveFile; + + final progressNotifier = + ValueNotifier<_DownloadProgress?>( + _DownloadProgress.initial(), + ); + + downloader( + attachment, + progressCallback: (received, total) { + progressNotifier.value = _DownloadProgress( + total, + received, + ); + }, + ).catchError((e, stk) { + progressNotifier.value = null; + }); + + // Closing attachment actions modal before opening + // attachment download dialog + Navigator.pop(context); + + showDialog( + barrierDismissible: false, + context: context, + barrierColor: theme.colorTheme.overlay, + builder: (context) => _buildDownloadProgressDialog( + context, + progressNotifier, + ), + ); + }, + ), + if (StreamChat.of(context).currentUser?.id == + message.user?.id) + _buildButton( + context, + context.translations.deleteLabel.capitalize(), + StreamSvgIcon.delete( + size: 24, + color: theme.colorTheme.accentError, + ), + () { + final channel = StreamChannel.of(context).channel; + if (message.attachments.length > 1 || + message.text?.isNotEmpty == true) { + final remainingAttachments = [...message.attachments] + ..removeAt(currentIndex); + channel.updateMessage(message.copyWith( + attachments: remainingAttachments, + )); + Navigator.of(context) + ..pop() + ..maybePop(); + } else { + channel.deleteMessage(message); + Navigator.of(context) + ..pop() + ..maybePop(); + } + }, + color: theme.colorTheme.accentError, + ), + ] + .map((e) => Align( + alignment: Alignment.centerRight, + child: e, + )) + .insertBetween( + Container( + height: 1, + color: theme.colorTheme.borders, + ), + ), + ), ), ), ), diff --git a/packages/stream_chat_flutter/lib/src/full_screen_media.dart b/packages/stream_chat_flutter/lib/src/full_screen_media.dart index 57dadfc6..0c47383c 100644 --- a/packages/stream_chat_flutter/lib/src/full_screen_media.dart +++ b/packages/stream_chat_flutter/lib/src/full_screen_media.dart @@ -112,8 +112,8 @@ class _FullScreenMediaState extends State attachment.assetUrl ?? attachment.thumbUrl; return PhotoView( - loadingBuilder: (context, image) => - const Offstage(),imageProvider: (imageUrl == null && + loadingBuilder: (context, image) => const Offstage(), + imageProvider: (imageUrl == null && attachment.localUri != null && attachment.file?.bytes != null) ? Image.memory(attachment.file!.bytes!).image diff --git a/packages/stream_chat_flutter/lib/src/gallery_footer.dart b/packages/stream_chat_flutter/lib/src/gallery_footer.dart index 87ef1759..dcfa0e29 100644 --- a/packages/stream_chat_flutter/lib/src/gallery_footer.dart +++ b/packages/stream_chat_flutter/lib/src/gallery_footer.dart @@ -251,26 +251,29 @@ class _GalleryFooterState extends State { children: [ media, if (widget.message.user != null) - Container( - padding: const EdgeInsets.all(10), - clipBehavior: Clip.antiAlias, - decoration: BoxDecoration( - shape: BoxShape.circle, - color: Colors.white.withOpacity(0.6), - boxShadow: [ - BoxShadow( - blurRadius: 8, - color: chatThemeData - .colorTheme.textHighEmphasis - .withOpacity(0.3), - ), - ], - ), - child: UserAvatar( - user: widget.message.user!, - constraints: - BoxConstraints.tight(const Size(24, 24)), - showOnlineStatus: false, + Padding( + padding: const EdgeInsets.all(8), + child: Container( + padding: const EdgeInsets.all(2), + clipBehavior: Clip.antiAlias, + decoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.white.withOpacity(0.6), + boxShadow: [ + BoxShadow( + blurRadius: 8, + color: chatThemeData + .colorTheme.textHighEmphasis + .withOpacity(0.3), + ), + ], + ), + child: UserAvatar( + user: widget.message.user!, + constraints: + BoxConstraints.tight(const Size(24, 24)), + showOnlineStatus: false, + ), ), ), ], diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index 6f10bb5c..99819f77 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -752,28 +752,31 @@ class MessageInputState extends State { ? Row( mainAxisSize: MainAxisSize.min, children: [ - Container( + Padding( padding: const EdgeInsets.all(8), - constraints: BoxConstraints.tight(const Size(64, 24)), - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12), - color: _streamChatTheme.colorTheme.accentPrimary, - ), - alignment: Alignment.center, - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - StreamSvgIcon.lightning( - color: Colors.white, - size: 16, - ), - Text( - _chosenCommand?.name.toUpperCase() ?? '', - style: _streamChatTheme.textTheme.footnoteBold.copyWith( + child: Container( + constraints: BoxConstraints.tight(const Size(64, 24)), + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12), + color: _streamChatTheme.colorTheme.accentPrimary, + ), + alignment: Alignment.center, + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + StreamSvgIcon.lightning( color: Colors.white, + size: 16, ), - ), - ], + Text( + _chosenCommand?.name.toUpperCase() ?? '', + style: + _streamChatTheme.textTheme.footnoteBold.copyWith( + color: Colors.white, + ), + ), + ], + ), ), ), ], @@ -1024,8 +1027,10 @@ class MessageInputState extends State { _attachments.isNotEmpty) ? null : () { - pickFile(DefaultAttachmentTypes.image, - camera: true); + pickFile( + DefaultAttachmentTypes.image, + camera: true, + ); }, ), IconButton( @@ -1038,8 +1043,10 @@ class MessageInputState extends State { _attachments.isNotEmpty) ? null : () { - pickFile(DefaultAttachmentTypes.video, - camera: true); + pickFile( + DefaultAttachmentTypes.video, + camera: true, + ); }, ), ], @@ -1053,13 +1060,15 @@ class MessageInputState extends State { ), ), child: Center( - child: Container( - width: 40, - height: 4, - padding: const EdgeInsets.all(8), - decoration: BoxDecoration( - color: _streamChatTheme.colorTheme.inputBg, - borderRadius: BorderRadius.circular(4), + child: Padding( + padding: const EdgeInsets.all(8), + child: Container( + width: 40, + height: 4, + decoration: BoxDecoration( + color: _streamChatTheme.colorTheme.inputBg, + borderRadius: BorderRadius.circular(4), + ), ), ), ), diff --git a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart index 500ac039..c69d490d 100644 --- a/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart +++ b/packages/stream_chat_flutter/lib/src/quoted_message_widget.dart @@ -189,7 +189,7 @@ class QuotedMessageWidget extends StatelessWidget { image: DecorationImage( fit: BoxFit.cover, image: CachedNetworkImageProvider( - attachment.imageUrl!, + attachment.thumbUrl!, ), ), ), diff --git a/packages/stream_chat_flutter_core/example/pubspec.yaml b/packages/stream_chat_flutter_core/example/pubspec.yaml index 9af602cc..4b0e27fb 100644 --- a/packages/stream_chat_flutter_core/example/pubspec.yaml +++ b/packages/stream_chat_flutter_core/example/pubspec.yaml @@ -1,4 +1,4 @@ -name: example +name: stream_chat_flutter_core_example description: Example app for testing stream_chat_flutter_core # The following line prevents the package from being accidentally published to @@ -26,13 +26,7 @@ dependencies: cupertino_icons: ^1.0.3 flutter: sdk: flutter - -dependency_overrides: - stream_chat: - path: ../../stream_chat - stream_chat_flutter_core: - path: ../../stream_chat_flutter_core - + stream_chat_flutter_core: ^2.2.1 dev_dependencies: flutter_test: diff --git a/packages/stream_chat_localizations/example/pubspec.yaml b/packages/stream_chat_localizations/example/pubspec.yaml index 5d47ef36..9aaa23c6 100644 --- a/packages/stream_chat_localizations/example/pubspec.yaml +++ b/packages/stream_chat_localizations/example/pubspec.yaml @@ -1,4 +1,4 @@ -name: example +name: stream_chat_localizations_example description: A new Flutter project. publish_to: 'none' @@ -11,16 +11,8 @@ dependencies: cupertino_icons: ^1.0.3 flutter: sdk: flutter - -dependency_overrides: - stream_chat: - path: ../../stream_chat - stream_chat_flutter: - path: ../../stream_chat_flutter - stream_chat_flutter_core: - path: ../../stream_chat_flutter_core - stream_chat_localizations: - path: ../../stream_chat_localizations + stream_chat_flutter: ^2.2.1 + stream_chat_localizations: ^1.1.0 dev_dependencies: flutter_test: diff --git a/packages/stream_chat_persistence/example/pubspec.yaml b/packages/stream_chat_persistence/example/pubspec.yaml index cbf48a8b..6c6e8c6d 100644 --- a/packages/stream_chat_persistence/example/pubspec.yaml +++ b/packages/stream_chat_persistence/example/pubspec.yaml @@ -1,4 +1,4 @@ -name: example +name: stream_chat_persistence_example description: A new Flutter project. publish_to: 'none' @@ -11,12 +11,8 @@ dependencies: cupertino_icons: ^1.0.3 flutter: sdk: flutter - -dependency_overrides: - stream_chat: - path: ../../stream_chat - stream_chat_persistence: - path: ../../stream_chat_persistence + stream_chat: ^2.2.1 + stream_chat_persistence: ^2.2.0 dev_dependencies: flutter_test: