Merge branch 'release/4.0' into migrate/deprecated_code_full_screen
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
import 'package:collection/collection.dart' show IterableExtension;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:jiffy/jiffy.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
|
||||
/*Navigator.push(
|
||||
context,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:imessage/message_list_view.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart'
|
||||
show
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:example/search_text_field.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:flutter_slidable/flutter_slidable.dart';
|
||||
|
||||
import 'channel_page.dart';
|
||||
import 'chat_info_screen.dart';
|
||||
@@ -39,6 +40,16 @@ class _ChannelList extends State<ChannelList> {
|
||||
});
|
||||
}
|
||||
|
||||
late final _channelListController = StreamChannelListController(
|
||||
client: StreamChat.of(context).client,
|
||||
filter: Filter.in_(
|
||||
'members',
|
||||
[StreamChat.of(context).currentUser!.id],
|
||||
),
|
||||
presence: true,
|
||||
limit: 30,
|
||||
);
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -149,59 +160,141 @@ class _ChannelList extends State<ChannelList> {
|
||||
);
|
||||
},
|
||||
)
|
||||
: ChannelListView(
|
||||
onChannelTap: (channel, _) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.CHANNEL_PAGE,
|
||||
arguments: ChannelPageArgs(
|
||||
channel: channel,
|
||||
),
|
||||
);
|
||||
},
|
||||
onStartChatPressed: () {
|
||||
Navigator.pushNamed(context, Routes.NEW_CHAT);
|
||||
},
|
||||
swipeToAction: true,
|
||||
filter: Filter.in_('members', [user!.id]),
|
||||
presence: true,
|
||||
limit: 30,
|
||||
onViewInfoTap: (channel) {
|
||||
Navigator.pop(context);
|
||||
if (channel.memberCount == 2 && channel.isDistinct) {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StreamChannel(
|
||||
: SlidableAutoCloseBehavior(
|
||||
closeWhenOpened: true,
|
||||
child: RefreshIndicator(
|
||||
onRefresh: _channelListController.refresh,
|
||||
child: StreamChannelListView(
|
||||
controller: _channelListController,
|
||||
itemBuilder: (context, channel, tile) {
|
||||
final chatTheme = StreamChatTheme.of(context);
|
||||
final backgroundColor = chatTheme.colorTheme.inputBg;
|
||||
final canDeleteChannel = channel.ownCapabilities
|
||||
.contains(PermissionType.deleteChannel);
|
||||
return Slidable(
|
||||
groupTag: 'channels-actions',
|
||||
endActionPane: ActionPane(
|
||||
extentRatio: canDeleteChannel ? 0.40 : 0.20,
|
||||
motion: const BehindMotion(),
|
||||
children: [
|
||||
CustomSlidableAction(
|
||||
child: Icon(Icons.more_horiz),
|
||||
backgroundColor: backgroundColor,
|
||||
onPressed: (_) {
|
||||
showChannelInfoModalBottomSheet(
|
||||
context: context,
|
||||
channel: channel,
|
||||
onViewInfoTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) {
|
||||
final isOneToOne =
|
||||
channel.memberCount == 2 &&
|
||||
channel.isDistinct;
|
||||
return StreamChannel(
|
||||
channel: channel,
|
||||
child: isOneToOne
|
||||
? ChatInfoScreen(
|
||||
messageTheme: chatTheme
|
||||
.ownMessageTheme,
|
||||
user: channel
|
||||
.state!.members
|
||||
.where((m) =>
|
||||
m.userId !=
|
||||
channel
|
||||
.client
|
||||
.state
|
||||
.currentUser!
|
||||
.id)
|
||||
.first
|
||||
.user,
|
||||
)
|
||||
: GroupInfoScreen(
|
||||
messageTheme: chatTheme
|
||||
.ownMessageTheme,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
if (canDeleteChannel)
|
||||
CustomSlidableAction(
|
||||
backgroundColor: backgroundColor,
|
||||
child: StreamSvgIcon.delete(
|
||||
color: chatTheme.colorTheme.accentError,
|
||||
),
|
||||
onPressed: (_) async {
|
||||
final res = await showConfirmationDialog(
|
||||
context,
|
||||
title: 'Delete Conversation',
|
||||
question:
|
||||
'Are you sure you want to delete this conversation?',
|
||||
okText: 'Delete',
|
||||
cancelText: 'Cancel',
|
||||
icon: StreamSvgIcon.delete(
|
||||
color: chatTheme.colorTheme.accentError,
|
||||
),
|
||||
);
|
||||
if (res == true) {
|
||||
await _channelListController
|
||||
.deleteChannel(channel);
|
||||
}
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
child: tile,
|
||||
);
|
||||
},
|
||||
onChannelTap: (channel) {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.CHANNEL_PAGE,
|
||||
arguments: ChannelPageArgs(
|
||||
channel: channel,
|
||||
child: ChatInfoScreen(
|
||||
messageTheme:
|
||||
StreamChatTheme.of(context).ownMessageTheme,
|
||||
user: channel.state!.members
|
||||
.where((m) =>
|
||||
m.userId !=
|
||||
channel.client.state.currentUser!.id)
|
||||
.first
|
||||
.user,
|
||||
),
|
||||
);
|
||||
},
|
||||
emptyBuilder: (_) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Expanded(child: StreamChannelListEmptyWidget()),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.NEW_CHAT,
|
||||
);
|
||||
},
|
||||
child: Text(
|
||||
'Start a chat',
|
||||
style: StreamChatTheme.of(context)
|
||||
.textTheme
|
||||
.bodyBold
|
||||
.copyWith(
|
||||
color: StreamChatTheme.of(context)
|
||||
.colorTheme
|
||||
.accentPrimary,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StreamChannel(
|
||||
channel: channel,
|
||||
child: GroupInfoScreen(
|
||||
messageTheme:
|
||||
StreamChatTheme.of(context).ownMessageTheme,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -100,10 +100,8 @@ class _ChannelListPageState extends State<ChannelListPage> {
|
||||
body: IndexedStack(
|
||||
index: _currentIndex,
|
||||
children: [
|
||||
ChannelsBloc(
|
||||
child: MessageSearchBloc(
|
||||
child: ChannelList(),
|
||||
),
|
||||
MessageSearchBloc(
|
||||
child: ChannelList(),
|
||||
),
|
||||
UserMentionsPage(),
|
||||
],
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:collection/collection.dart' show IterableExtension;
|
||||
import 'package:example/localizations.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@@ -53,13 +52,7 @@ class _ChatInfoScreenState extends State<ChatInfoScreen> {
|
||||
height: 8.0,
|
||||
color: StreamChatTheme.of(context).colorTheme.disabled,
|
||||
),
|
||||
if ([
|
||||
'admin',
|
||||
'owner',
|
||||
].contains(channel.state!.members
|
||||
.firstWhereOrNull(
|
||||
(m) => m.userId == channel.client.state.currentUser!.id)
|
||||
?.role))
|
||||
if (channel.ownCapabilities.contains(PermissionType.deleteChannel))
|
||||
_buildDeleteListTile(),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -13,20 +13,20 @@ dependencies:
|
||||
stream_chat_flutter:
|
||||
git:
|
||||
url: https://github.com/GetStream/stream-chat-flutter.git
|
||||
ref: develop
|
||||
ref: v4
|
||||
path: packages/stream_chat_flutter
|
||||
stream_chat_persistence:
|
||||
git:
|
||||
url: https://github.com/GetStream/stream-chat-flutter.git
|
||||
ref: develop
|
||||
ref: v4
|
||||
path: packages/stream_chat_persistence
|
||||
stream_chat_localizations:
|
||||
git:
|
||||
url: https://github.com/GetStream/stream-chat-flutter.git
|
||||
ref: feat/capabilities
|
||||
ref: v4
|
||||
path: packages/stream_chat_localizations
|
||||
flutter_local_notifications: ^9.0.0
|
||||
flutter_svg:
|
||||
flutter_svg: ^1.0.1
|
||||
flutter_secure_storage: ^4.2.1
|
||||
yaml: ^3.1.0
|
||||
uuid: ^3.0.5
|
||||
@@ -42,17 +42,17 @@ dependency_overrides:
|
||||
stream_chat:
|
||||
git:
|
||||
url: https://github.com/GetStream/stream-chat-flutter.git
|
||||
ref: 5587622587e1fb31e1935d4209189db0434ef09b
|
||||
ref: v4
|
||||
path: packages/stream_chat
|
||||
stream_chat_flutter_core:
|
||||
git:
|
||||
url: https://github.com/GetStream/stream-chat-flutter.git
|
||||
ref: 5587622587e1fb31e1935d4209189db0434ef09b
|
||||
ref: v4
|
||||
path: packages/stream_chat_flutter_core
|
||||
stream_chat_flutter:
|
||||
git:
|
||||
url: https://github.com/GetStream/stream-chat-flutter.git
|
||||
ref: 5587622587e1fb31e1935d4209189db0434ef09b
|
||||
ref: v4
|
||||
path: packages/stream_chat_flutter
|
||||
|
||||
flutter:
|
||||
|
||||
Reference in New Issue
Block a user