feat(ui): Update slidable to 1.2.0
Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
@@ -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,19 +268,21 @@ class _ChannelListViewState extends State<ChannelListView> {
|
|||||||
_gridItemBuilder(context, index, channels),
|
_gridItemBuilder(context, index, channels),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return ListView.separated(
|
return SlidableAutoCloseBehavior(
|
||||||
padding: widget.padding,
|
child: ListView.separated(
|
||||||
physics: const AlwaysScrollableScrollPhysics(),
|
padding: widget.padding,
|
||||||
// all channels + progress loader
|
physics: const AlwaysScrollableScrollPhysics(),
|
||||||
itemCount: channels.length + 1,
|
// all channels + progress loader
|
||||||
separatorBuilder: (_, index) {
|
itemCount: channels.length + 1,
|
||||||
if (widget.separatorBuilder != null) {
|
separatorBuilder: (_, index) {
|
||||||
return widget.separatorBuilder!(context, index);
|
if (widget.separatorBuilder != null) {
|
||||||
}
|
return widget.separatorBuilder!(context, index);
|
||||||
return _separatorBuilder(context, index);
|
}
|
||||||
},
|
return _separatorBuilder(context, index);
|
||||||
itemBuilder: (context, index) =>
|
},
|
||||||
_listItemBuilder(context, index, channels),
|
itemBuilder: (context, index) =>
|
||||||
|
_listItemBuilder(context, index, channels),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -510,82 +510,86 @@ 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,
|
||||||
e.onTap?.call(channel);
|
onPressed: (_) {
|
||||||
},
|
e.onTap?.call(channel);
|
||||||
))
|
},
|
||||||
.toList() ??
|
))
|
||||||
<Widget>[
|
.toList() ??
|
||||||
IconSlideAction(
|
<Widget>[
|
||||||
color: backgroundColor,
|
CustomSlidableAction(
|
||||||
icon: Icons.more_horiz,
|
backgroundColor: backgroundColor,
|
||||||
onTap: widget.onMoreDetailsPressed != null
|
onPressed: widget.onMoreDetailsPressed != null
|
||||||
? () {
|
? (_) {
|
||||||
widget.onMoreDetailsPressed!(channel);
|
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(
|
|
||||||
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(
|
showModalBottomSheet(
|
||||||
context,
|
clipBehavior: Clip.hardEdge,
|
||||||
title: context.translations.deleteConversationLabel,
|
shape: const RoundedRectangleBorder(
|
||||||
question:
|
borderRadius: BorderRadius.only(
|
||||||
context.translations.deleteConversationQuestion,
|
topLeft: Radius.circular(32),
|
||||||
okText: context.translations.deleteLabel,
|
topRight: Radius.circular(32),
|
||||||
cancelText: context.translations.cancelLabel,
|
),
|
||||||
icon: StreamSvgIcon.delete(
|
),
|
||||||
color: chatThemeData.colorTheme.accentError,
|
context: context,
|
||||||
|
builder: (context) => StreamChannel(
|
||||||
|
channel: channel,
|
||||||
|
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) ??
|
child: widget.channelPreviewBuilder?.call(context, channel) ??
|
||||||
DecoratedBox(
|
DecoratedBox(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user