Merge pull request #1031 from GetStream/feat/slidable-1.2.0

feat(ui): Update slidable to 1.2.0
This commit is contained in:
Salvatore Giordano
2022-03-21 16:34:48 +01:00
committed by GitHub
11 changed files with 107 additions and 92 deletions
@@ -38,6 +38,10 @@ dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
dependency_overrides:
stream_chat_flutter:
path: ../
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec
@@ -207,8 +207,6 @@ class ChannelListView extends StatefulWidget {
} }
class _ChannelListViewState extends State<ChannelListView> { class _ChannelListViewState extends State<ChannelListView> {
final _slideController = SlidableController();
late final _defaultController = ChannelListController(); late final _defaultController = ChannelListController();
ChannelListController get _channelListController => ChannelListController get _channelListController =>
@@ -270,7 +268,8 @@ class _ChannelListViewState extends State<ChannelListView> {
_gridItemBuilder(context, index, channels), _gridItemBuilder(context, index, channels),
); );
} }
return ListView.separated( return SlidableAutoCloseBehavior(
child: ListView.separated(
padding: widget.padding, padding: widget.padding,
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
// all channels + progress loader // all channels + progress loader
@@ -283,6 +282,7 @@ class _ChannelListViewState extends State<ChannelListView> {
}, },
itemBuilder: (context, index) => itemBuilder: (context, index) =>
_listItemBuilder(context, index, channels), _listItemBuilder(context, index, channels),
),
); );
} }
@@ -510,32 +510,34 @@ class _ChannelListViewState extends State<ChannelListView> {
final backgroundColor = chatThemeData.colorTheme.inputBg; final backgroundColor = chatThemeData.colorTheme.inputBg;
final channel = channels[i]; final channel = channels[i];
final canDeleteChannel =
channel.ownCapabilities.contains(PermissionType.deleteChannel);
return StreamChannel( return StreamChannel(
key: ValueKey<String>('CHANNEL-${channel.cid}'), key: ValueKey<String>('CHANNEL-${channel.cid}'),
channel: channel, channel: channel,
child: Slidable( child: Slidable(
controller: _slideController,
enabled: widget.swipeToAction, enabled: widget.swipeToAction,
actionPane: const SlidableBehindActionPane(), endActionPane: ActionPane(
actionExtentRatio: 0.12, extentRatio: canDeleteChannel ? 0.4 : 0.2,
secondaryActions: widget.swipeActions motion: const BehindMotion(),
?.map((e) => IconSlideAction( children: widget.swipeActions
color: e.color, ?.map((e) => CustomSlidableAction(
iconWidget: e.iconWidget, backgroundColor: e.color ?? Colors.white,
onTap: () { child: e.iconWidget,
onPressed: (_) {
e.onTap?.call(channel); e.onTap?.call(channel);
}, },
)) ))
.toList() ?? .toList() ??
<Widget>[ <Widget>[
IconSlideAction( CustomSlidableAction(
color: backgroundColor, backgroundColor: backgroundColor,
icon: Icons.more_horiz, onPressed: widget.onMoreDetailsPressed != null
onTap: widget.onMoreDetailsPressed != null ? (_) {
? () {
widget.onMoreDetailsPressed!(channel); widget.onMoreDetailsPressed!(channel);
} }
: () { : (_) {
showModalBottomSheet( showModalBottomSheet(
clipBehavior: Clip.hardEdge, clipBehavior: Clip.hardEdge,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
@@ -556,24 +558,22 @@ class _ChannelListViewState extends State<ChannelListView> {
), ),
); );
}, },
child: const Icon(Icons.more_horiz),
), ),
if (channel.ownCapabilities if (canDeleteChannel)
.contains(PermissionType.deleteChannel)) CustomSlidableAction(
IconSlideAction( backgroundColor: backgroundColor,
color: backgroundColor, onPressed: widget.onDeletePressed != null
iconWidget: StreamSvgIcon.delete( ? (_) {
color: chatThemeData.colorTheme.accentError,
),
onTap: widget.onDeletePressed != null
? () {
widget.onDeletePressed?.call(channel); widget.onDeletePressed?.call(channel);
} }
: () async { : (_) async {
final res = await showConfirmationDialog( final res = await showConfirmationDialog(
context, context,
title: context.translations.deleteConversationLabel, title:
question: context.translations.deleteConversationLabel,
context.translations.deleteConversationQuestion, question: context
.translations.deleteConversationQuestion,
okText: context.translations.deleteLabel, okText: context.translations.deleteLabel,
cancelText: context.translations.cancelLabel, cancelText: context.translations.cancelLabel,
icon: StreamSvgIcon.delete( icon: StreamSvgIcon.delete(
@@ -584,8 +584,12 @@ class _ChannelListViewState extends State<ChannelListView> {
await channel.delete(); await channel.delete();
} }
}, },
child: StreamSvgIcon.delete(
color: chatThemeData.colorTheme.accentError,
),
), ),
], ],
),
child: widget.channelPreviewBuilder?.call(context, channel) ?? child: widget.channelPreviewBuilder?.call(context, channel) ??
DecoratedBox( DecoratedBox(
decoration: BoxDecoration( decoration: BoxDecoration(
+1 -1
View File
@@ -22,7 +22,7 @@ dependencies:
sdk: flutter sdk: flutter
flutter_markdown: ^0.6.1 flutter_markdown: ^0.6.1
flutter_portal: ^0.4.0 flutter_portal: ^0.4.0
flutter_slidable: ^0.6.0 flutter_slidable: ^1.2.0
flutter_svg: ^1.0.1 flutter_svg: ^1.0.1
http_parser: ^4.0.0 http_parser: ^4.0.0
image_gallery_saver: ^1.7.0 image_gallery_saver: ^1.7.0
@@ -6,7 +6,7 @@
additional functionality it is fine to subclass or reimplement additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. --> FlutterApplication and put your custom class here. -->
<application <application
android:name="io.flutter.app.FlutterApplication" android:name="${applicationName}"
android:label="example" android:label="example"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<activity <activity
@@ -21,6 +21,6 @@
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0</string> <string>1.0</string>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>8.0</string> <string>9.0</string>
</dict> </dict>
</plist> </plist>
@@ -3,7 +3,7 @@
archiveVersion = 1; archiveVersion = 1;
classes = { classes = {
}; };
objectVersion = 46; objectVersion = 50;
objects = { objects = {
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
@@ -156,7 +156,7 @@
97C146E61CF9000F007C117D /* Project object */ = { 97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject; isa = PBXProject;
attributes = { attributes = {
LastUpgradeCheck = 1020; LastUpgradeCheck = 1300;
ORGANIZATIONNAME = ""; ORGANIZATIONNAME = "";
TargetAttributes = { TargetAttributes = {
97C146ED1CF9000F007C117D = { 97C146ED1CF9000F007C117D = {
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<Scheme <Scheme
LastUpgradeVersion = "1020" LastUpgradeVersion = "1300"
version = "1.3"> version = "1.3">
<BuildAction <BuildAction
parallelizeBuildables = "YES" parallelizeBuildables = "YES"
@@ -11,8 +11,15 @@ dependencies:
cupertino_icons: ^1.0.3 cupertino_icons: ^1.0.3
flutter: flutter:
sdk: flutter sdk: flutter
stream_chat_flutter: ^2.2.1 stream_chat_flutter:
stream_chat_localizations: ^1.1.0 path: ../../stream_chat_flutter
stream_chat_localizations:
path: ../
dependency_overrides:
stream_chat_flutter:
path: ../../stream_chat_flutter
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
@@ -26,7 +26,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android { android {
compileSdkVersion 29 compileSdkVersion 31
sourceSets { sourceSets {
main.java.srcDirs += 'src/main/kotlin' main.java.srcDirs += 'src/main/kotlin'
@@ -6,7 +6,7 @@
additional functionality it is fine to subclass or reimplement additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. --> FlutterApplication and put your custom class here. -->
<application <application
android:name="io.flutter.app.FlutterApplication" android:name="${applicationName}"
android:label="example" android:label="example"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<activity <activity
@@ -1,5 +1,5 @@
buildscript { buildscript {
ext.kotlin_version = '1.3.50' ext.kotlin_version = '1.6.0'
repositories { repositories {
google() google()
jcenter() jcenter()