From f907450f1c5740a1933d8d022e452f397d27ff7e Mon Sep 17 00:00:00 2001 From: Sahil Kumar Date: Mon, 21 Mar 2022 16:57:40 +0530 Subject: [PATCH 1/8] feat(ui): Update slidable to 1.2.0 Signed-off-by: xsahil03x --- .../lib/src/channel_list_view.dart | 164 +++++++++--------- packages/stream_chat_flutter/pubspec.yaml | 2 +- 2 files changed, 85 insertions(+), 81 deletions(-) diff --git a/packages/stream_chat_flutter/lib/src/channel_list_view.dart b/packages/stream_chat_flutter/lib/src/channel_list_view.dart index f7c39e8eb..7280d8262 100644 --- a/packages/stream_chat_flutter/lib/src/channel_list_view.dart +++ b/packages/stream_chat_flutter/lib/src/channel_list_view.dart @@ -207,8 +207,6 @@ class ChannelListView extends StatefulWidget { } class _ChannelListViewState extends State { - final _slideController = SlidableController(); - late final _defaultController = ChannelListController(); ChannelListController get _channelListController => @@ -270,19 +268,21 @@ class _ChannelListViewState extends State { _gridItemBuilder(context, index, channels), ); } - return ListView.separated( - padding: widget.padding, - physics: const AlwaysScrollableScrollPhysics(), - // all channels + progress loader - itemCount: channels.length + 1, - separatorBuilder: (_, index) { - if (widget.separatorBuilder != null) { - return widget.separatorBuilder!(context, index); - } - return _separatorBuilder(context, index); - }, - itemBuilder: (context, index) => - _listItemBuilder(context, index, channels), + return SlidableAutoCloseBehavior( + child: ListView.separated( + padding: widget.padding, + physics: const AlwaysScrollableScrollPhysics(), + // all channels + progress loader + itemCount: channels.length + 1, + separatorBuilder: (_, index) { + if (widget.separatorBuilder != null) { + return widget.separatorBuilder!(context, index); + } + return _separatorBuilder(context, index); + }, + itemBuilder: (context, index) => + _listItemBuilder(context, index, channels), + ), ); } @@ -510,82 +510,86 @@ class _ChannelListViewState extends State { final backgroundColor = chatThemeData.colorTheme.inputBg; final channel = channels[i]; + final canDeleteChannel = + channel.ownCapabilities.contains(PermissionType.deleteChannel); + return StreamChannel( key: ValueKey('CHANNEL-${channel.cid}'), channel: channel, child: Slidable( - controller: _slideController, enabled: widget.swipeToAction, - actionPane: const SlidableBehindActionPane(), - actionExtentRatio: 0.12, - secondaryActions: widget.swipeActions - ?.map((e) => IconSlideAction( - color: e.color, - iconWidget: e.iconWidget, - onTap: () { - e.onTap?.call(channel); - }, - )) - .toList() ?? - [ - IconSlideAction( - color: backgroundColor, - icon: Icons.more_horiz, - onTap: widget.onMoreDetailsPressed != null - ? () { - widget.onMoreDetailsPressed!(channel); - } - : () { - showModalBottomSheet( - clipBehavior: Clip.hardEdge, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(32), - topRight: Radius.circular(32), + endActionPane: ActionPane( + extentRatio: canDeleteChannel ? 0.4 : 0.2, + motion: const BehindMotion(), + children: widget.swipeActions + ?.map((e) => CustomSlidableAction( + backgroundColor: e.color ?? Colors.white, + child: e.iconWidget, + onPressed: (_) { + e.onTap?.call(channel); + }, + )) + .toList() ?? + [ + CustomSlidableAction( + backgroundColor: backgroundColor, + onPressed: widget.onMoreDetailsPressed != null + ? (_) { + widget.onMoreDetailsPressed!(channel); + } + : (_) { + showModalBottomSheet( + clipBehavior: Clip.hardEdge, + shape: const RoundedRectangleBorder( + borderRadius: BorderRadius.only( + topLeft: Radius.circular(32), + topRight: Radius.circular(32), + ), ), - ), - context: context, - builder: (context) => StreamChannel( - channel: channel, - child: StreamChannelInfoBottomSheet( + context: context, + builder: (context) => StreamChannel( channel: channel, - onViewInfoTap: () { - widget.onViewInfoTap?.call(channel); - }, - ), - ), - ); - }, - ), - if (channel.ownCapabilities - .contains(PermissionType.deleteChannel)) - IconSlideAction( - color: backgroundColor, - iconWidget: StreamSvgIcon.delete( - color: chatThemeData.colorTheme.accentError, - ), - onTap: widget.onDeletePressed != null - ? () { - widget.onDeletePressed?.call(channel); - } - : () async { - final res = await showConfirmationDialog( - context, - title: context.translations.deleteConversationLabel, - question: - context.translations.deleteConversationQuestion, - okText: context.translations.deleteLabel, - cancelText: context.translations.cancelLabel, - icon: StreamSvgIcon.delete( - color: chatThemeData.colorTheme.accentError, + child: StreamChannelInfoBottomSheet( + channel: channel, + onViewInfoTap: () { + widget.onViewInfoTap?.call(channel); + }, + ), ), ); - if (res == true) { - await channel.delete(); - } }, + child: const Icon(Icons.more_horiz), ), - ], + if (canDeleteChannel) + CustomSlidableAction( + backgroundColor: backgroundColor, + onPressed: widget.onDeletePressed != null + ? (_) { + widget.onDeletePressed?.call(channel); + } + : (_) async { + final res = await showConfirmationDialog( + context, + title: + context.translations.deleteConversationLabel, + question: context + .translations.deleteConversationQuestion, + okText: context.translations.deleteLabel, + cancelText: context.translations.cancelLabel, + icon: StreamSvgIcon.delete( + color: chatThemeData.colorTheme.accentError, + ), + ); + if (res == true) { + await channel.delete(); + } + }, + child: StreamSvgIcon.delete( + color: chatThemeData.colorTheme.accentError, + ), + ), + ], + ), child: widget.channelPreviewBuilder?.call(context, channel) ?? DecoratedBox( decoration: BoxDecoration( diff --git a/packages/stream_chat_flutter/pubspec.yaml b/packages/stream_chat_flutter/pubspec.yaml index 9b7690393..7305d74b5 100644 --- a/packages/stream_chat_flutter/pubspec.yaml +++ b/packages/stream_chat_flutter/pubspec.yaml @@ -22,7 +22,7 @@ dependencies: sdk: flutter flutter_markdown: ^0.6.1 flutter_portal: ^0.4.0 - flutter_slidable: ^0.6.0 + flutter_slidable: ^1.2.0 flutter_svg: ^1.0.1 http_parser: ^4.0.0 image_gallery_saver: ^1.7.0 From 4be9ff24a97ef6418135890489cd6fb2085c4d17 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Mar 2022 13:26:20 +0100 Subject: [PATCH 2/8] add dependency override to example --- packages/stream_chat_flutter/example/pubspec.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/stream_chat_flutter/example/pubspec.yaml b/packages/stream_chat_flutter/example/pubspec.yaml index bd785a29d..ead5158ad 100644 --- a/packages/stream_chat_flutter/example/pubspec.yaml +++ b/packages/stream_chat_flutter/example/pubspec.yaml @@ -38,6 +38,10 @@ dev_dependencies: flutter_test: sdk: flutter +dependency_overrides: + stream_chat_flutter: + path: ../ + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec From 9f120d65c3aff12b7f9be031bcd9c84be74fabb1 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Mar 2022 13:54:32 +0100 Subject: [PATCH 3/8] use local deps --- packages/stream_chat_localizations/example/pubspec.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_localizations/example/pubspec.yaml b/packages/stream_chat_localizations/example/pubspec.yaml index 9aaa23c68..904347e62 100644 --- a/packages/stream_chat_localizations/example/pubspec.yaml +++ b/packages/stream_chat_localizations/example/pubspec.yaml @@ -11,8 +11,10 @@ dependencies: cupertino_icons: ^1.0.3 flutter: sdk: flutter - stream_chat_flutter: ^2.2.1 - stream_chat_localizations: ^1.1.0 + stream_chat_flutter: + path: ../stream_chat_flutter + stream_chat_localizations: + path: ../ dev_dependencies: flutter_test: From bd7c74a6f3f9d2b9c906af1f83c30cde7f542b9a Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Mar 2022 14:35:38 +0100 Subject: [PATCH 4/8] fix deps --- packages/stream_chat_localizations/example/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/stream_chat_localizations/example/pubspec.yaml b/packages/stream_chat_localizations/example/pubspec.yaml index 904347e62..6f37dfc4c 100644 --- a/packages/stream_chat_localizations/example/pubspec.yaml +++ b/packages/stream_chat_localizations/example/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter stream_chat_flutter: - path: ../stream_chat_flutter + path: ../../stream_chat_flutter stream_chat_localizations: path: ../ From d39988fcde59392311f2f1a2a84d4d607958b154 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Mar 2022 15:01:41 +0100 Subject: [PATCH 5/8] use local deps --- packages/stream_chat_localizations/example/pubspec.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/stream_chat_localizations/example/pubspec.yaml b/packages/stream_chat_localizations/example/pubspec.yaml index 6f37dfc4c..52363f4bc 100644 --- a/packages/stream_chat_localizations/example/pubspec.yaml +++ b/packages/stream_chat_localizations/example/pubspec.yaml @@ -16,6 +16,11 @@ dependencies: stream_chat_localizations: path: ../ + +dependency_overrides: + stream_chat_flutter: + path: ../ + dev_dependencies: flutter_test: sdk: flutter From ed72f290524764f4cf046c7326686d830e7e29ca Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Mar 2022 15:20:51 +0100 Subject: [PATCH 6/8] use local deps --- packages/stream_chat_localizations/example/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/stream_chat_localizations/example/pubspec.yaml b/packages/stream_chat_localizations/example/pubspec.yaml index 52363f4bc..db4476181 100644 --- a/packages/stream_chat_localizations/example/pubspec.yaml +++ b/packages/stream_chat_localizations/example/pubspec.yaml @@ -19,8 +19,8 @@ dependencies: dependency_overrides: stream_chat_flutter: - path: ../ - + path: ../../stream_chat_flutter + dev_dependencies: flutter_test: sdk: flutter From 48b93fd6304b95ed23a13fbcff023e636b347960 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Mon, 21 Mar 2022 15:36:08 +0100 Subject: [PATCH 7/8] fix android build? --- .../example/android/app/src/main/AndroidManifest.xml | 2 +- .../example/ios/Flutter/AppFrameworkInfo.plist | 2 +- .../example/ios/Runner.xcodeproj/project.pbxproj | 4 ++-- .../Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/stream_chat_localizations/example/android/app/src/main/AndroidManifest.xml b/packages/stream_chat_localizations/example/android/app/src/main/AndroidManifest.xml index 55ca830c3..9b3997fe8 100644 --- a/packages/stream_chat_localizations/example/android/app/src/main/AndroidManifest.xml +++ b/packages/stream_chat_localizations/example/android/app/src/main/AndroidManifest.xml @@ -6,7 +6,7 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. --> CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/packages/stream_chat_localizations/example/ios/Runner.xcodeproj/project.pbxproj b/packages/stream_chat_localizations/example/ios/Runner.xcodeproj/project.pbxproj index 3ea4f8267..52fdc7407 100644 --- a/packages/stream_chat_localizations/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/stream_chat_localizations/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -156,7 +156,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { diff --git a/packages/stream_chat_localizations/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/stream_chat_localizations/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index a28140cfd..3db53b6e1 100644 --- a/packages/stream_chat_localizations/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/stream_chat_localizations/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ Date: Mon, 21 Mar 2022 16:07:48 +0100 Subject: [PATCH 8/8] fix android build for persistence --- .../stream_chat_persistence/example/android/app/build.gradle | 2 +- .../example/android/app/src/main/AndroidManifest.xml | 2 +- packages/stream_chat_persistence/example/android/build.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/stream_chat_persistence/example/android/app/build.gradle b/packages/stream_chat_persistence/example/android/app/build.gradle index 3932aa910..31d3553ba 100644 --- a/packages/stream_chat_persistence/example/android/app/build.gradle +++ b/packages/stream_chat_persistence/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 29 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' diff --git a/packages/stream_chat_persistence/example/android/app/src/main/AndroidManifest.xml b/packages/stream_chat_persistence/example/android/app/src/main/AndroidManifest.xml index 55ca830c3..9b3997fe8 100644 --- a/packages/stream_chat_persistence/example/android/app/src/main/AndroidManifest.xml +++ b/packages/stream_chat_persistence/example/android/app/src/main/AndroidManifest.xml @@ -6,7 +6,7 @@ additional functionality it is fine to subclass or reimplement FlutterApplication and put your custom class here. -->