From c9c790e120604cfa3ba65846e1aa016b24bee12d Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 29 Oct 2020 12:24:40 +0100 Subject: [PATCH 01/13] fix ios staus bar icon colors --- analysis_options.yaml | 126 +++++++++++++-------------- example/ios/Podfile.lock | 8 +- example/ios/Runner/AppDelegate.swift | 4 + example/ios/Runner/Info.plist | 4 + example/pubspec.yaml | 2 +- example/test/widget_test.dart | 30 ------- lib/src/channel_header.dart | 1 + lib/src/message_actions_modal.dart | 2 +- lib/src/message_reactions_modal.dart | 2 +- 9 files changed, 79 insertions(+), 100 deletions(-) delete mode 100644 example/test/widget_test.dart diff --git a/analysis_options.yaml b/analysis_options.yaml index 8d6f9064..ef7efa9f 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,63 +1,63 @@ -include: package:pedantic/analysis_options.yaml - -analyzer: - enable-experiment: - - extension-methods - exclude: - - lib/**/*.g.dart - - example/** - -linter: - rules: - # these rules are documented on and in the same order as - # the Dart Lint rules page to make maintenance easier - # https://github.com/dart-lang/linter/blob/master/example/all.yaml - # - always_declare_return_types - # - always_specify_types - # - annotate_overrides - # - avoid_as - - avoid_empty_else - - avoid_init_to_null - - avoid_return_types_on_setters - - avoid_web_libraries_in_flutter - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - # - comment_references # we do not presume as to what people want to reference in their dartdocs - # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 - - control_flow_in_finally - - empty_constructor_bodies - - empty_statements - - hash_and_equals - - implementation_imports - # - invariant_booleans - # - iterable_contains_unrelated_type - - library_names - # - library_prefixes - # - list_remove_unrelated_type - # - literal_only_boolean_expressions - - non_constant_identifier_names - # - one_member_abstracts - # - only_throw_errors - # - overridden_fields -# - package_api_docs - - package_names - - package_prefixed_library_names - - prefer_is_not_empty - # - prefer_mixin # https://github.com/dart-lang/language/issues/32 - - public_member_api_docs - - slash_for_doc_comments - # - sort_constructors_first - # - sort_unnamed_constructors_first - # - super_goes_last # no longer needed w/ Dart 2 - - test_types_in_equals - - throw_in_finally - # - type_annotate_public_apis # subset of always_specify_types - - type_init_formals - # - unawaited_futures - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_statements - - unrelated_type_equality_checks - - valid_regexps +#include: package:pedantic/analysis_options.yaml +# +#analyzer: +# enable-experiment: +# - extension-methods +# exclude: +# - lib/**/*.g.dart +# - example/** +# +#linter: +# rules: +# # these rules are documented on and in the same order as +# # the Dart Lint rules page to make maintenance easier +# # https://github.com/dart-lang/linter/blob/master/example/all.yaml +# # - always_declare_return_types +# # - always_specify_types +# # - annotate_overrides +# # - avoid_as +# - avoid_empty_else +# - avoid_init_to_null +# - avoid_return_types_on_setters +# - avoid_web_libraries_in_flutter +# - await_only_futures +# - camel_case_types +# - cancel_subscriptions +# - close_sinks +# # - comment_references # we do not presume as to what people want to reference in their dartdocs +# # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 +# - control_flow_in_finally +# - empty_constructor_bodies +# - empty_statements +# - hash_and_equals +# - implementation_imports +# # - invariant_booleans +# # - iterable_contains_unrelated_type +# - library_names +# # - library_prefixes +# # - list_remove_unrelated_type +# # - literal_only_boolean_expressions +# - non_constant_identifier_names +# # - one_member_abstracts +# # - only_throw_errors +# # - overridden_fields +## - package_api_docs +# - package_names +# - package_prefixed_library_names +# - prefer_is_not_empty +# # - prefer_mixin # https://github.com/dart-lang/language/issues/32 +# - public_member_api_docs +# - slash_for_doc_comments +# # - sort_constructors_first +# # - sort_unnamed_constructors_first +# # - super_goes_last # no longer needed w/ Dart 2 +# - test_types_in_equals +# - throw_in_finally +# # - type_annotate_public_apis # subset of always_specify_types +# - type_init_formals +# # - unawaited_futures +# - unnecessary_brace_in_string_interps +# - unnecessary_getters_setters +# - unnecessary_statements +# - unrelated_type_equality_checks +# - valid_regexps diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 1e268608..0068f96c 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -124,9 +124,9 @@ PODS: - SDWebImage/Core (5.9.3) - shared_preferences (0.0.1): - Flutter - - sqflite (0.0.1): + - sqflite (0.0.2): - Flutter - - FMDB (~> 2.7.2) + - FMDB (>= 2.7.5) - sqlite3 (3.32.3): - sqlite3/common (= 3.32.3) - sqlite3/common (3.32.3) @@ -248,7 +248,7 @@ SPEC CHECKSUMS: FirebaseInstanceID: cef67c4967c7cecb56ea65d8acbb4834825c587b FirebaseMessaging: 29543feb343b09546ab3aa04d008ee8595b43c44 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec - flutter_apns: f516b118e423fe7c0a38771180549c4d6cb67c2f + flutter_apns: ddc629f26016140bf52165040b0a8e8869f9ce32 flutter_app_badger: 65de4d6f0c34a891df49e6cfb8a1c0496426fa68 flutter_keyboard_visibility: 0339d06371254c3eb25eeb90ba8d17dca8f9c069 flutter_local_notifications: 0c0b1ae97e741e1521e4c1629a459d04b9aec743 @@ -262,7 +262,7 @@ SPEC CHECKSUMS: Protobuf: 3dac39b34a08151c6d949560efe3f86134a3f748 SDWebImage: a31ee8e90a97303529e03fb0c333eae0eacb88e9 shared_preferences: af6bfa751691cdc24be3045c43ec037377ada40d - sqflite: 4001a31ff81d210346b500c55b17f4d6c7589dd0 + sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 sqlite3: 8f7d2078ae27778699a622a94b853285793422a2 sqlite3_flutter_libs: 5651f8ff48e3b44d910863c4ea5916085b1b245f Starscream: 5178aed56b316f13fa3bc55694e583d35dd414d9 diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift index 69a7daf4..e024c1ef 100644 --- a/example/ios/Runner/AppDelegate.swift +++ b/example/ios/Runner/AppDelegate.swift @@ -14,6 +14,10 @@ import Flutter sharedDefaults?.removeObject(forKey: "messageQueue") } + if #available(iOS 10.0, *) { + UNUserNotificationCenter.current().delegate = self + } + GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist index 6c2c8e27..b41f1c19 100644 --- a/example/ios/Runner/Info.plist +++ b/example/ios/Runner/Info.plist @@ -58,5 +58,9 @@ remote-notification + UIUserInterfaceStyle + Light + UIViewControllerBasedStatusBarAppearance + diff --git a/example/pubspec.yaml b/example/pubspec.yaml index c73804eb..dac40d3b 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,6 +1,6 @@ name: example description: A new Flutter project. -version: 1.0.36+38 +version: 1.0.37+39 environment: sdk: ">=2.2.2 <3.0.0" diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart deleted file mode 100644 index 747db1da..00000000 --- a/example/test/widget_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility that Flutter provides. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:example/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/lib/src/channel_header.dart b/lib/src/channel_header.dart index 16aa70fc..81f95a87 100644 --- a/lib/src/channel_header.dart +++ b/lib/src/channel_header.dart @@ -78,6 +78,7 @@ class ChannelHeader extends StatelessWidget implements PreferredSizeWidget { Widget build(BuildContext context) { final channel = StreamChannel.of(context).channel; return AppBar( + brightness: Theme.of(context).brightness, elevation: 1, leading: showBackButton ? StreamBackButton(onPressed: onBackPressed) diff --git a/lib/src/message_actions_modal.dart b/lib/src/message_actions_modal.dart index 93e1c0db..9144de1e 100644 --- a/lib/src/message_actions_modal.dart +++ b/lib/src/message_actions_modal.dart @@ -58,7 +58,7 @@ class MessageActionsModal extends StatelessWidget { sigmaY: 10.8731, ), child: Container( - color: Colors.black.withOpacity(0.2), + color: Colors.black.withOpacity(0.1), ), ), ), diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index 375da94e..88e2525d 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -49,7 +49,7 @@ class MessageReactionsModal extends StatelessWidget { sigmaY: 10.8731, ), child: Container( - color: Colors.black.withOpacity(0.2), + color: Colors.black.withOpacity(0.1), ), ), ), From 8424e3a9721caec56c448667e4f0f24f841e7d8e Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 29 Oct 2020 12:33:18 +0100 Subject: [PATCH 02/13] center user avatar in modal --- lib/src/message_actions_modal.dart | 8 ++++---- lib/src/message_reactions_modal.dart | 8 ++++---- lib/src/message_widget.dart | 18 +++++++++++++++++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/lib/src/message_actions_modal.dart b/lib/src/message_actions_modal.dart index 9144de1e..b675a688 100644 --- a/lib/src/message_actions_modal.dart +++ b/lib/src/message_actions_modal.dart @@ -25,6 +25,7 @@ class MessageActionsModal extends StatelessWidget { final bool showReply; final bool reverse; final ShapeBorder messageShape; + final DisplayWidget showUserAvatar; const MessageActionsModal({ Key key, @@ -36,6 +37,7 @@ class MessageActionsModal extends StatelessWidget { this.onThreadTap, this.showCopyMessage = true, this.showReply = true, + this.showUserAvatar = DisplayWidget.show, this.editMessageInputBuilder, this.messageShape, this.reverse = false, @@ -43,7 +45,6 @@ class MessageActionsModal extends StatelessWidget { @override Widget build(BuildContext context) { - final ownId = StreamChat.of(context).user.id; return GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { @@ -92,10 +93,9 @@ class MessageActionsModal extends StatelessWidget { showReactions: false, showUsername: false, showReplyIndicator: false, - showUserAvatar: message.user.id == ownId - ? DisplayWidget.gone - : DisplayWidget.show, + showUserAvatar: showUserAvatar, showTimestamp: false, + translateUserAvatar: false, showSendingIndicator: DisplayWidget.gone, shape: messageShape, ), diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index 88e2525d..a8013fde 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -17,6 +17,7 @@ class MessageReactionsModal extends StatelessWidget { final MessageTheme messageTheme; final bool reverse; final bool showReactions; + final DisplayWidget showUserAvatar; final ShapeBorder messageShape; final void Function(User) onUserAvatarTap; @@ -29,12 +30,12 @@ class MessageReactionsModal extends StatelessWidget { this.editMessageInputBuilder, this.messageShape, this.reverse = false, + this.showUserAvatar = DisplayWidget.show, this.onUserAvatarTap, }) : super(key: key); @override Widget build(BuildContext context) { - final ownId = StreamChat.of(context).user.id; return GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { @@ -82,11 +83,10 @@ class MessageReactionsModal extends StatelessWidget { messageTheme: messageTheme, showReactions: false, showUsername: false, - showUserAvatar: message.user.id == ownId - ? DisplayWidget.gone - : DisplayWidget.show, + showUserAvatar: showUserAvatar, showReplyIndicator: false, showTimestamp: false, + translateUserAvatar: false, showSendingIndicator: DisplayWidget.gone, shape: messageShape, ), diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 0e703fa0..4378086f 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -115,11 +115,15 @@ class MessageWidget extends StatefulWidget { final bool showEditMessage; final Map attachmentBuilders; + /// Center user avatar with bottom of the message + final bool translateUserAvatar; + MessageWidget({ Key key, @required this.message, @required this.messageTheme, this.reverse = false, + this.translateUserAvatar = true, this.shape, this.attachmentShape, this.borderSide, @@ -423,6 +427,10 @@ class _MessageWidgetState extends State { return StreamChannel( channel: channel, child: MessageActionsModal( + showUserAvatar: + widget.message.user.id == channel.client.state.user.id + ? DisplayWidget.gone + : DisplayWidget.show, messageTheme: widget.messageTheme, messageShape: widget.shape ?? _getDefaultShape(context), reverse: widget.reverse, @@ -447,6 +455,10 @@ class _MessageWidgetState extends State { return StreamChannel( channel: channel, child: MessageReactionsModal( + showUserAvatar: + widget.message.user.id == channel.client.state.user.id + ? DisplayWidget.gone + : DisplayWidget.show, onUserAvatarTap: widget.onUserAvatarTap, messageTheme: widget.messageTheme, messageShape: widget.shape ?? _getDefaultShape(context), @@ -614,7 +626,11 @@ class _MessageWidgetState extends State { padding: const EdgeInsets.symmetric(horizontal: 4.0), child: Transform.translate( offset: Offset( - 0, widget.messageTheme.avatarTheme.constraints.maxHeight / 2), + 0, + widget.translateUserAvatar + ? widget.messageTheme.avatarTheme.constraints.maxHeight / 2 + : 0, + ), child: UserAvatar( user: widget.message.user, onTap: widget.onUserAvatarTap, From daf028d805acac440c24a7090eb6b4f2f6c46660 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 29 Oct 2020 12:49:25 +0100 Subject: [PATCH 03/13] align reaction picker bubbles --- lib/src/message_actions_modal.dart | 1 + lib/src/message_reactions_modal.dart | 1 + lib/src/message_widget.dart | 85 +++++++++++++++++--------- lib/src/reaction_picker.dart | 90 ++++++++++++---------------- 4 files changed, 95 insertions(+), 82 deletions(-) diff --git a/lib/src/message_actions_modal.dart b/lib/src/message_actions_modal.dart index b675a688..9562a797 100644 --- a/lib/src/message_actions_modal.dart +++ b/lib/src/message_actions_modal.dart @@ -96,6 +96,7 @@ class MessageActionsModal extends StatelessWidget { showUserAvatar: showUserAvatar, showTimestamp: false, translateUserAvatar: false, + showReactionPickerIndicator: true, showSendingIndicator: DisplayWidget.gone, shape: messageShape, ), diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index a8013fde..4ef35be2 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -89,6 +89,7 @@ class MessageReactionsModal extends StatelessWidget { translateUserAvatar: false, showSendingIndicator: DisplayWidget.gone, shape: messageShape, + showReactionPickerIndicator: true, ), ), SizedBox( diff --git a/lib/src/message_widget.dart b/lib/src/message_widget.dart index 4378086f..e65da576 100644 --- a/lib/src/message_widget.dart +++ b/lib/src/message_widget.dart @@ -106,6 +106,9 @@ class MessageWidget extends StatefulWidget { /// The function called when tapping on a link final void Function(String) onLinkTap; + /// Used in [MessageReactionsModal] and [MessageActionsModal] + final bool showReactionPickerIndicator; + final List readList; /// If true show the users username next to the timestamp of the message @@ -131,6 +134,7 @@ class MessageWidget extends StatefulWidget { this.borderRadiusGeometry, this.attachmentBorderRadiusGeometry, this.onMentionTap, + this.showReactionPickerIndicator = false, this.showUserAvatar = DisplayWidget.show, this.showSendingIndicator = DisplayWidget.show, this.showReplyIndicator = true, @@ -251,39 +255,62 @@ class _MessageWidgetState extends State { ), portalAnchor: Alignment(-1.0, -1.0), childAnchor: Alignment(1, -1.0), - child: Padding( - padding: widget.showReactions - ? EdgeInsets.only( - top: widget.message.reactionCounts - ?.isNotEmpty == - true - ? 18 - : 0, - ) - : EdgeInsets.zero, - child: (widget.message.isDeleted && - widget.message.status != - MessageSendingStatus.FAILED_DELETE) - ? Transform( - alignment: Alignment.center, + child: Stack( + clipBehavior: Clip.none, + children: [ + Padding( + padding: widget.showReactions + ? EdgeInsets.only( + top: widget.message.reactionCounts + ?.isNotEmpty == + true + ? 18 + : 0, + ) + : EdgeInsets.zero, + child: (widget.message.isDeleted && + widget.message.status != + MessageSendingStatus + .FAILED_DELETE) + ? Transform( + alignment: Alignment.center, + transform: Matrix4.rotationY( + widget.reverse ? pi : 0), + child: DeletedMessage( + messageTheme: widget.messageTheme, + ), + ) + : Column( + crossAxisAlignment: + CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + ..._parseAttachments(context), + if (widget.message.text + .trim() + .isNotEmpty) + _buildTextBubble(context), + ], + ), + ), + if (widget.showReactionPickerIndicator) + Positioned( + right: 0, + top: -6, + child: Transform( transform: Matrix4.rotationY( widget.reverse ? pi : 0), - child: DeletedMessage( - messageTheme: widget.messageTheme, + child: CustomPaint( + painter: ReactionBubblePainter( + widget.messageTheme + .reactionsBackgroundColor, + widget.messageTheme + .reactionsBorderColor, + ), ), - ) - : Column( - crossAxisAlignment: - CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - ..._parseAttachments(context), - if (widget.message.text - .trim() - .isNotEmpty) - _buildTextBubble(context), - ], ), + ), + ], ), ), ), diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index 87487cde..bf4c4ed0 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:stream_chat_flutter/src/reaction_bubble.dart'; import '../stream_chat_flutter.dart'; @@ -22,59 +21,44 @@ class ReactionPicker extends StatelessWidget { @override Widget build(BuildContext context) { final reactionIcons = StreamChatTheme.of(context).reactionIcons; - return Stack( - fit: StackFit.passthrough, - children: [ - Material( - color: messageTheme.reactionsBackgroundColor, - clipBehavior: Clip.hardEdge, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(24), - ), - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: reactionIcons.map((reactionIcon) { - final ownReactionIndex = message.ownReactions?.indexWhere( - (reaction) => reaction.type == reactionIcon.type) ?? - -1; - return IconButton( - iconSize: 24, - icon: Icon( - reactionIcon.iconData, - color: ownReactionIndex != -1 - ? StreamChatTheme.of(context).accentColor - : Theme.of(context).iconTheme.color.withOpacity(.5), - ), - onPressed: () { - if (ownReactionIndex != -1) { - removeReaction( - context, - message.ownReactions[ownReactionIndex], - ); - } else { - sendReaction( - context, - reactionIcon.type, - ); - } - }, - ); - }).toList(), - ), - ), - Positioned( - right: 14, - bottom: 0, - child: CustomPaint( - painter: ReactionBubblePainter( - messageTheme.reactionsBackgroundColor, - messageTheme.reactionsBorderColor, + return Material( + color: messageTheme.reactionsBackgroundColor, + clipBehavior: Clip.hardEdge, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(24), + ), + child: Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: reactionIcons.map((reactionIcon) { + final ownReactionIndex = message.ownReactions?.indexWhere( + (reaction) => reaction.type == reactionIcon.type) ?? + -1; + return IconButton( + iconSize: 24, + icon: Icon( + reactionIcon.iconData, + color: ownReactionIndex != -1 + ? StreamChatTheme.of(context).accentColor + : Theme.of(context).iconTheme.color.withOpacity(.5), ), - ), - ), - ], + onPressed: () { + if (ownReactionIndex != -1) { + removeReaction( + context, + message.ownReactions[ownReactionIndex], + ); + } else { + sendReaction( + context, + reactionIcon.type, + ); + } + }, + ); + }).toList(), + ), ); } From 6566a3fc8f2ccc4062d590f0c7c9e6776d850189 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 29 Oct 2020 12:50:27 +0100 Subject: [PATCH 04/13] revert analysis options --- analysis_options.yaml | 126 +++++++++++++++++++++--------------------- 1 file changed, 63 insertions(+), 63 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index ef7efa9f..8d6f9064 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,63 +1,63 @@ -#include: package:pedantic/analysis_options.yaml -# -#analyzer: -# enable-experiment: -# - extension-methods -# exclude: -# - lib/**/*.g.dart -# - example/** -# -#linter: -# rules: -# # these rules are documented on and in the same order as -# # the Dart Lint rules page to make maintenance easier -# # https://github.com/dart-lang/linter/blob/master/example/all.yaml -# # - always_declare_return_types -# # - always_specify_types -# # - annotate_overrides -# # - avoid_as -# - avoid_empty_else -# - avoid_init_to_null -# - avoid_return_types_on_setters -# - avoid_web_libraries_in_flutter -# - await_only_futures -# - camel_case_types -# - cancel_subscriptions -# - close_sinks -# # - comment_references # we do not presume as to what people want to reference in their dartdocs -# # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 -# - control_flow_in_finally -# - empty_constructor_bodies -# - empty_statements -# - hash_and_equals -# - implementation_imports -# # - invariant_booleans -# # - iterable_contains_unrelated_type -# - library_names -# # - library_prefixes -# # - list_remove_unrelated_type -# # - literal_only_boolean_expressions -# - non_constant_identifier_names -# # - one_member_abstracts -# # - only_throw_errors -# # - overridden_fields -## - package_api_docs -# - package_names -# - package_prefixed_library_names -# - prefer_is_not_empty -# # - prefer_mixin # https://github.com/dart-lang/language/issues/32 -# - public_member_api_docs -# - slash_for_doc_comments -# # - sort_constructors_first -# # - sort_unnamed_constructors_first -# # - super_goes_last # no longer needed w/ Dart 2 -# - test_types_in_equals -# - throw_in_finally -# # - type_annotate_public_apis # subset of always_specify_types -# - type_init_formals -# # - unawaited_futures -# - unnecessary_brace_in_string_interps -# - unnecessary_getters_setters -# - unnecessary_statements -# - unrelated_type_equality_checks -# - valid_regexps +include: package:pedantic/analysis_options.yaml + +analyzer: + enable-experiment: + - extension-methods + exclude: + - lib/**/*.g.dart + - example/** + +linter: + rules: + # these rules are documented on and in the same order as + # the Dart Lint rules page to make maintenance easier + # https://github.com/dart-lang/linter/blob/master/example/all.yaml + # - always_declare_return_types + # - always_specify_types + # - annotate_overrides + # - avoid_as + - avoid_empty_else + - avoid_init_to_null + - avoid_return_types_on_setters + - avoid_web_libraries_in_flutter + - await_only_futures + - camel_case_types + - cancel_subscriptions + - close_sinks + # - comment_references # we do not presume as to what people want to reference in their dartdocs + # - constant_identifier_names # https://github.com/dart-lang/linter/issues/204 + - control_flow_in_finally + - empty_constructor_bodies + - empty_statements + - hash_and_equals + - implementation_imports + # - invariant_booleans + # - iterable_contains_unrelated_type + - library_names + # - library_prefixes + # - list_remove_unrelated_type + # - literal_only_boolean_expressions + - non_constant_identifier_names + # - one_member_abstracts + # - only_throw_errors + # - overridden_fields +# - package_api_docs + - package_names + - package_prefixed_library_names + - prefer_is_not_empty + # - prefer_mixin # https://github.com/dart-lang/language/issues/32 + - public_member_api_docs + - slash_for_doc_comments + # - sort_constructors_first + # - sort_unnamed_constructors_first + # - super_goes_last # no longer needed w/ Dart 2 + - test_types_in_equals + - throw_in_finally + # - type_annotate_public_apis # subset of always_specify_types + - type_init_formals + # - unawaited_futures + - unnecessary_brace_in_string_interps + - unnecessary_getters_setters + - unnecessary_statements + - unrelated_type_equality_checks + - valid_regexps From 6138389a8183f145499840dd0ec380081b427f4c Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 29 Oct 2020 17:54:42 +0100 Subject: [PATCH 05/13] fix reaction picker alignment --- lib/src/message_actions_modal.dart | 3 ++- lib/src/message_reactions_modal.dart | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/message_actions_modal.dart b/lib/src/message_actions_modal.dart index 9562a797..15210f4b 100644 --- a/lib/src/message_actions_modal.dart +++ b/lib/src/message_actions_modal.dart @@ -74,7 +74,8 @@ class MessageActionsModal extends StatelessWidget { if (showReactions && (message.status == MessageSendingStatus.SENT || message.status == null)) - Center( + Align( + alignment: Alignment(-0.3, 0.0), child: ReactionPicker( message: message, messageTheme: messageTheme, diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index 4ef35be2..99a48730 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -65,7 +65,8 @@ class MessageReactionsModal extends StatelessWidget { if (showReactions && (message.status == MessageSendingStatus.SENT || message.status == null)) - Center( + Align( + alignment: Alignment(-0.3, 0.0), child: ReactionPicker( message: message, messageTheme: messageTheme, From 59748a88f751b1e32d498e13bb53a34c88c038bf Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 30 Oct 2020 09:07:51 +0100 Subject: [PATCH 06/13] update llc dependency --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index d61e6874..452eb69a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -24,7 +24,7 @@ dependencies: file_picker: ^2.0.8+1 image_picker: ^0.6.7+2 flutter_keyboard_visibility: ^3.2.1 - stream_chat: ^0.2.10 + stream_chat: ^0.2.10+1 mime: ^0.9.6+3 visibility_detector: ^0.1.5 http_parser: ^3.1.4 From 67499020cb25eeaa51a38e82b740be291390cdb7 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 17:04:12 +0530 Subject: [PATCH 07/13] feat: Tried fix --- lib/src/reaction_picker.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index bf4c4ed0..87e413ed 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -20,6 +20,7 @@ class ReactionPicker extends StatelessWidget { @override Widget build(BuildContext context) { + var user = StreamChat.of(context).user; final reactionIcons = StreamChatTheme.of(context).reactionIcons; return Material( color: messageTheme.reactionsBackgroundColor, @@ -29,7 +30,7 @@ class ReactionPicker extends StatelessWidget { ), child: Row( crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: user.id == message.user.id ? MainAxisAlignment.end : MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: reactionIcons.map((reactionIcon) { final ownReactionIndex = message.ownReactions?.indexWhere( From f10d63f713ae0c76b5313f7dde5a322c272f3007 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 17:10:06 +0530 Subject: [PATCH 08/13] feat: Tried fix --- lib/src/reaction_picker.dart | 67 +++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index 87e413ed..3a0600fe 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -29,37 +29,42 @@ class ReactionPicker extends StatelessWidget { borderRadius: BorderRadius.circular(24), ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: user.id == message.user.id ? MainAxisAlignment.end : MainAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: reactionIcons.map((reactionIcon) { - final ownReactionIndex = message.ownReactions?.indexWhere( - (reaction) => reaction.type == reactionIcon.type) ?? - -1; - return IconButton( - iconSize: 24, - icon: Icon( - reactionIcon.iconData, - color: ownReactionIndex != -1 - ? StreamChatTheme.of(context).accentColor - : Theme.of(context).iconTheme.color.withOpacity(.5), - ), - onPressed: () { - if (ownReactionIndex != -1) { - removeReaction( - context, - message.ownReactions[ownReactionIndex], - ); - } else { - sendReaction( - context, - reactionIcon.type, - ); - } - }, - ); - }).toList(), - ), + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: [ + if(user.id == message.id) + SizedBox( + width: 50.0, + ), + ...reactionIcons.map((reactionIcon) { + final ownReactionIndex = message.ownReactions?.indexWhere( + (reaction) => reaction.type == reactionIcon.type) ?? + -1; + return IconButton( + iconSize: 24, + icon: Icon( + reactionIcon.iconData, + color: ownReactionIndex != -1 + ? StreamChatTheme.of(context).accentColor + : Theme.of(context).iconTheme.color.withOpacity(.5), + ), + onPressed: () { + if (ownReactionIndex != -1) { + removeReaction( + context, + message.ownReactions[ownReactionIndex], + ); + } else { + sendReaction( + context, + reactionIcon.type, + ); + } + }, + ); + }).toList(), + ]), ); } From d36b1c64ea4c408725f44ca72f1e680065ebc7f2 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 17:17:55 +0530 Subject: [PATCH 09/13] feat: Tried fix --- lib/src/message_reactions_modal.dart | 16 ++++++++++------ lib/src/reaction_picker.dart | 10 ++-------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index 99a48730..af1d81ee 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -66,12 +66,16 @@ class MessageReactionsModal extends StatelessWidget { (message.status == MessageSendingStatus.SENT || message.status == null)) Align( - alignment: Alignment(-0.3, 0.0), - child: ReactionPicker( - message: message, - messageTheme: messageTheme, - ), - ), + alignment: Alignment(-0.3, 0.0), + child: Row( + mainAxisSize: MainAxisSize.min, + children: [ + ReactionPicker( + message: message, + messageTheme: messageTheme, + ), + ], + )), IgnorePointer( child: MessageWidget( key: Key('MessageWidget'), diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index 3a0600fe..e4a8bdf8 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -20,7 +20,6 @@ class ReactionPicker extends StatelessWidget { @override Widget build(BuildContext context) { - var user = StreamChat.of(context).user; final reactionIcons = StreamChatTheme.of(context).reactionIcons; return Material( color: messageTheme.reactionsBackgroundColor, @@ -32,12 +31,7 @@ class ReactionPicker extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.end, mainAxisSize: MainAxisSize.min, - children: [ - if(user.id == message.id) - SizedBox( - width: 50.0, - ), - ...reactionIcons.map((reactionIcon) { + children: reactionIcons.map((reactionIcon) { final ownReactionIndex = message.ownReactions?.indexWhere( (reaction) => reaction.type == reactionIcon.type) ?? -1; @@ -64,7 +58,7 @@ class ReactionPicker extends StatelessWidget { }, ); }).toList(), - ]), + ), ); } From 5ff432eb794e41389f385de1eb19fb971addab92 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 17:21:45 +0530 Subject: [PATCH 10/13] feat: Tried fix --- lib/src/message_reactions_modal.dart | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index af1d81ee..7e1e100a 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -36,6 +36,7 @@ class MessageReactionsModal extends StatelessWidget { @override Widget build(BuildContext context) { + var user = StreamChat.of(context).user; return GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { @@ -66,16 +67,12 @@ class MessageReactionsModal extends StatelessWidget { (message.status == MessageSendingStatus.SENT || message.status == null)) Align( - alignment: Alignment(-0.3, 0.0), - child: Row( - mainAxisSize: MainAxisSize.min, - children: [ - ReactionPicker( - message: message, - messageTheme: messageTheme, - ), - ], - )), + alignment: Alignment(-0.3 + (user.id == message.id ? 0.2 : 0.0), 0.0), + child: ReactionPicker( + message: message, + messageTheme: messageTheme, + ), + ), IgnorePointer( child: MessageWidget( key: Key('MessageWidget'), From b39038d0ab1a8cfb66fe8423ca14f5b9538d7981 Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 17:56:31 +0530 Subject: [PATCH 11/13] feat: Alignment is now calculated --- lib/src/message_reactions_modal.dart | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index 7e1e100a..559e475c 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -36,7 +36,17 @@ class MessageReactionsModal extends StatelessWidget { @override Widget build(BuildContext context) { + var size = MediaQuery.of(context).size; var user = StreamChat.of(context).user; + + var roughMaxSize = 2 * size.width / 3; + var roughSentenceSize = message.text.length * messageTheme.messageText.fontSize * 1.2; + var divFactor = roughSentenceSize / roughMaxSize; + + print(roughMaxSize); + print(roughSentenceSize); + print(divFactor); + return GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { @@ -67,7 +77,7 @@ class MessageReactionsModal extends StatelessWidget { (message.status == MessageSendingStatus.SENT || message.status == null)) Align( - alignment: Alignment(-0.3 + (user.id == message.id ? 0.2 : 0.0), 0.0), + alignment: Alignment(user.id == message.user.id ? (divFactor > 1.0 ? 0.0 : (1.0 - divFactor)) : (divFactor > 1.0 ? 0.0 : -(1.0 - divFactor)), 0.0), child: ReactionPicker( message: message, messageTheme: messageTheme, @@ -144,10 +154,10 @@ class MessageReactionsModal extends StatelessWidget { alignment: WrapAlignment.start, children: message.latestReactions .map((e) => _buildReaction( - e, - currentUser, - context, - )) + e, + currentUser, + context, + )) .toList(), ), ), @@ -160,10 +170,10 @@ class MessageReactionsModal extends StatelessWidget { } Widget _buildReaction( - Reaction reaction, - User currentUser, - BuildContext context, - ) { + Reaction reaction, + User currentUser, + BuildContext context, + ) { final isCurrentUser = reaction.user.id == currentUser.id; return ConstrainedBox( constraints: BoxConstraints.loose(Size( From 2859c257e9e193f7f77c5e5e7318be9bccf17aea Mon Sep 17 00:00:00 2001 From: Deven Joshi Date: Fri, 30 Oct 2020 17:58:53 +0530 Subject: [PATCH 12/13] removed print and dartfmt --- lib/src/message_reactions_modal.dart | 29 ++++++------- lib/src/reaction_picker.dart | 62 ++++++++++++++-------------- 2 files changed, 46 insertions(+), 45 deletions(-) diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index 559e475c..1c3c3e0f 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -40,13 +40,10 @@ class MessageReactionsModal extends StatelessWidget { var user = StreamChat.of(context).user; var roughMaxSize = 2 * size.width / 3; - var roughSentenceSize = message.text.length * messageTheme.messageText.fontSize * 1.2; + var roughSentenceSize = + message.text.length * messageTheme.messageText.fontSize * 1.2; var divFactor = roughSentenceSize / roughMaxSize; - print(roughMaxSize); - print(roughSentenceSize); - print(divFactor); - return GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { @@ -77,7 +74,11 @@ class MessageReactionsModal extends StatelessWidget { (message.status == MessageSendingStatus.SENT || message.status == null)) Align( - alignment: Alignment(user.id == message.user.id ? (divFactor > 1.0 ? 0.0 : (1.0 - divFactor)) : (divFactor > 1.0 ? 0.0 : -(1.0 - divFactor)), 0.0), + alignment: Alignment( + user.id == message.user.id + ? (divFactor > 1.0 ? 0.0 : (1.0 - divFactor)) + : (divFactor > 1.0 ? 0.0 : -(1.0 - divFactor)), + 0.0), child: ReactionPicker( message: message, messageTheme: messageTheme, @@ -154,10 +155,10 @@ class MessageReactionsModal extends StatelessWidget { alignment: WrapAlignment.start, children: message.latestReactions .map((e) => _buildReaction( - e, - currentUser, - context, - )) + e, + currentUser, + context, + )) .toList(), ), ), @@ -170,10 +171,10 @@ class MessageReactionsModal extends StatelessWidget { } Widget _buildReaction( - Reaction reaction, - User currentUser, - BuildContext context, - ) { + Reaction reaction, + User currentUser, + BuildContext context, + ) { final isCurrentUser = reaction.user.id == currentUser.id; return ConstrainedBox( constraints: BoxConstraints.loose(Size( diff --git a/lib/src/reaction_picker.dart b/lib/src/reaction_picker.dart index e4a8bdf8..e7d302e6 100644 --- a/lib/src/reaction_picker.dart +++ b/lib/src/reaction_picker.dart @@ -28,37 +28,37 @@ class ReactionPicker extends StatelessWidget { borderRadius: BorderRadius.circular(24), ), child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.end, - mainAxisSize: MainAxisSize.min, - children: reactionIcons.map((reactionIcon) { - final ownReactionIndex = message.ownReactions?.indexWhere( - (reaction) => reaction.type == reactionIcon.type) ?? - -1; - return IconButton( - iconSize: 24, - icon: Icon( - reactionIcon.iconData, - color: ownReactionIndex != -1 - ? StreamChatTheme.of(context).accentColor - : Theme.of(context).iconTheme.color.withOpacity(.5), - ), - onPressed: () { - if (ownReactionIndex != -1) { - removeReaction( - context, - message.ownReactions[ownReactionIndex], - ); - } else { - sendReaction( - context, - reactionIcon.type, - ); - } - }, - ); - }).toList(), - ), + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.end, + mainAxisSize: MainAxisSize.min, + children: reactionIcons.map((reactionIcon) { + final ownReactionIndex = message.ownReactions?.indexWhere( + (reaction) => reaction.type == reactionIcon.type) ?? + -1; + return IconButton( + iconSize: 24, + icon: Icon( + reactionIcon.iconData, + color: ownReactionIndex != -1 + ? StreamChatTheme.of(context).accentColor + : Theme.of(context).iconTheme.color.withOpacity(.5), + ), + onPressed: () { + if (ownReactionIndex != -1) { + removeReaction( + context, + message.ownReactions[ownReactionIndex], + ); + } else { + sendReaction( + context, + reactionIcon.type, + ); + } + }, + ); + }).toList(), + ), ); } From 93101f99c4dd665b768584f320c1d3139efb3d84 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Fri, 30 Oct 2020 14:45:47 +0100 Subject: [PATCH 13/13] fix reaction picker for messages without text --- lib/src/message_actions_modal.dart | 15 ++++++++++++++- lib/src/message_reactions_modal.dart | 3 ++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/src/message_actions_modal.dart b/lib/src/message_actions_modal.dart index 15210f4b..00354a49 100644 --- a/lib/src/message_actions_modal.dart +++ b/lib/src/message_actions_modal.dart @@ -45,6 +45,15 @@ class MessageActionsModal extends StatelessWidget { @override Widget build(BuildContext context) { + var size = MediaQuery.of(context).size; + var user = StreamChat.of(context).user; + + var roughMaxSize = 2 * size.width / 3; + var roughSentenceSize = + message.text.length * messageTheme.messageText.fontSize * 1.2; + var divFactor = + roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize); + return GestureDetector( behavior: HitTestBehavior.translucent, onTap: () { @@ -75,7 +84,11 @@ class MessageActionsModal extends StatelessWidget { (message.status == MessageSendingStatus.SENT || message.status == null)) Align( - alignment: Alignment(-0.3, 0.0), + alignment: Alignment( + user.id == message.user.id + ? (divFactor > 1.0 ? 0.0 : (1.0 - divFactor)) + : (divFactor > 1.0 ? 0.0 : -(1.0 - divFactor)), + 0.0), child: ReactionPicker( message: message, messageTheme: messageTheme, diff --git a/lib/src/message_reactions_modal.dart b/lib/src/message_reactions_modal.dart index 1c3c3e0f..fc3f68a4 100644 --- a/lib/src/message_reactions_modal.dart +++ b/lib/src/message_reactions_modal.dart @@ -42,7 +42,8 @@ class MessageReactionsModal extends StatelessWidget { var roughMaxSize = 2 * size.width / 3; var roughSentenceSize = message.text.length * messageTheme.messageText.fontSize * 1.2; - var divFactor = roughSentenceSize / roughMaxSize; + var divFactor = + roughSentenceSize == 0 ? 1 : (roughSentenceSize / roughMaxSize); return GestureDetector( behavior: HitTestBehavior.translucent,