align with v4
This commit is contained in:
@@ -40,16 +40,52 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
|
||||
ValueNotifier<bool?> mutedBool = ValueNotifier(false);
|
||||
|
||||
late final channel = StreamChannel.of(context).channel;
|
||||
|
||||
late final userListController = StreamUserListController(
|
||||
client: StreamChat.of(context).client,
|
||||
limit: 25,
|
||||
filter: Filter.and(
|
||||
[
|
||||
if (_searchController!.text.isNotEmpty)
|
||||
Filter.autoComplete('name', _userNameQuery),
|
||||
Filter.notIn('id', [
|
||||
StreamChat.of(context).currentUser!.id,
|
||||
...channel.state!.members
|
||||
.map<String?>(((e) => e.userId))
|
||||
.whereType<String>(),
|
||||
]),
|
||||
],
|
||||
),
|
||||
sort: [
|
||||
SortOption(
|
||||
'name',
|
||||
direction: 1,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
void _userNameListener() {
|
||||
if (_searchController!.text == _userNameQuery) {
|
||||
return;
|
||||
}
|
||||
if (_debounce?.isActive ?? false) _debounce!.cancel();
|
||||
_debounce = Timer(const Duration(milliseconds: 350), () {
|
||||
if (mounted && modalSetStateCallback != null) {
|
||||
modalSetStateCallback!(() {
|
||||
_userNameQuery = _searchController!.text;
|
||||
});
|
||||
if (mounted) {
|
||||
_userNameQuery = _searchController!.text;
|
||||
userListController.filter = Filter.and(
|
||||
[
|
||||
if (_searchController!.text.isNotEmpty)
|
||||
Filter.autoComplete('name', _userNameQuery),
|
||||
Filter.notIn('id', [
|
||||
StreamChat.of(context).currentUser!.id,
|
||||
...channel.state!.members
|
||||
.map<String?>(((e) => e.userId))
|
||||
.whereType<String>(),
|
||||
]),
|
||||
],
|
||||
);
|
||||
userListController.doInitialLoad();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -57,25 +93,28 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
var channel = StreamChannel.of(context);
|
||||
|
||||
_nameController = TextEditingController.fromValue(
|
||||
TextEditingValue(
|
||||
text: (channel.channel.extraData['name'] as String?) ?? ''),
|
||||
TextEditingValue(text: (channel.extraData['name'] as String?) ?? ''),
|
||||
);
|
||||
_searchController = TextEditingController()..addListener(_userNameListener);
|
||||
|
||||
_nameController!.addListener(() {
|
||||
setState(() {});
|
||||
});
|
||||
mutedBool = ValueNotifier(StreamChannel.of(context).channel.isMuted);
|
||||
mutedBool = ValueNotifier(channel.isMuted);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
userListController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var channel = StreamChannel.of(context);
|
||||
|
||||
return StreamBuilder<List<Member>>(
|
||||
stream: channel.channel.state!.membersStream,
|
||||
stream: channel.state!.membersStream,
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return Container(
|
||||
@@ -94,7 +133,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
title: Column(
|
||||
children: [
|
||||
StreamBuilder<ChannelState>(
|
||||
stream: channel.channelStateStream,
|
||||
stream: channel.state?.channelStateStream,
|
||||
builder: (context, state) {
|
||||
if (!state.hasData) {
|
||||
return Text(
|
||||
@@ -131,7 +170,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
height: 3.0,
|
||||
),
|
||||
Text(
|
||||
'${channel.channel.memberCount} ${AppLocalizations.of(context).members}, ${snapshot.data?.where((e) => e.user!.online).length ?? 0} ${AppLocalizations.of(context).online}',
|
||||
'${channel.memberCount} ${AppLocalizations.of(context).members}, ${snapshot.data?.where((e) => e.user!.online).length ?? 0} ${AppLocalizations.of(context).online}',
|
||||
style: TextStyle(
|
||||
color: StreamChatTheme.of(context)
|
||||
.colorTheme
|
||||
@@ -144,7 +183,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
if (channel.channel.ownCapabilities
|
||||
if (channel.ownCapabilities
|
||||
.contains(PermissionType.updateChannelMembers))
|
||||
StreamNeumorphicButton(
|
||||
child: InkWell(
|
||||
@@ -169,7 +208,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
height: 8.0,
|
||||
color: StreamChatTheme.of(context).colorTheme.disabled,
|
||||
),
|
||||
if (channel.channel.ownCapabilities
|
||||
if (channel.ownCapabilities
|
||||
.contains(PermissionType.updateChannel))
|
||||
_buildNameTile(),
|
||||
_buildOptionListTiles(),
|
||||
@@ -336,7 +375,6 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
}
|
||||
|
||||
Widget _buildNameTile() {
|
||||
var channel = StreamChannel.of(context).channel;
|
||||
var channelName = (channel.extraData['name'] as String?) ?? '';
|
||||
|
||||
return Material(
|
||||
@@ -412,7 +450,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
size: 24.0,
|
||||
),
|
||||
onTap: () {
|
||||
StreamChannel.of(context).channel.update({
|
||||
channel.update({
|
||||
'name': _nameController!.text.trim(),
|
||||
}).catchError((err) {
|
||||
setState(() {
|
||||
@@ -432,8 +470,6 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
}
|
||||
|
||||
Widget _buildOptionListTiles() {
|
||||
var channel = StreamChannel.of(context);
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
// OptionListTile(
|
||||
@@ -448,10 +484,9 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
// ),
|
||||
// onTap: () {},
|
||||
// ),
|
||||
if (channel.channel.ownCapabilities
|
||||
.contains(PermissionType.muteChannel))
|
||||
if (channel.ownCapabilities.contains(PermissionType.muteChannel))
|
||||
StreamBuilder<bool>(
|
||||
stream: StreamChannel.of(context).channel.isMutedStream,
|
||||
stream: channel.isMutedStream,
|
||||
builder: (context, snapshot) {
|
||||
mutedBool.value = snapshot.data;
|
||||
|
||||
@@ -482,9 +517,9 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
mutedBool.value = val;
|
||||
|
||||
if (snapshot.data!) {
|
||||
channel.channel.unmute();
|
||||
channel.unmute();
|
||||
} else {
|
||||
channel.channel.mute();
|
||||
channel.mute();
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -517,36 +552,7 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StreamChannel(
|
||||
channel: channel,
|
||||
child: MessageSearchBloc(
|
||||
child: PinnedMessagesScreen(
|
||||
messageTheme: widget.messageTheme,
|
||||
sortOptions: [
|
||||
SortOption(
|
||||
'created_at',
|
||||
direction: SortOption.ASC,
|
||||
),
|
||||
],
|
||||
onShowMessage: (m, c) async {
|
||||
final client = StreamChat.of(context).client;
|
||||
final message = m;
|
||||
final channel = client.channel(
|
||||
c.type,
|
||||
id: c.id,
|
||||
);
|
||||
if (channel.state == null) {
|
||||
await channel.watch();
|
||||
}
|
||||
Navigator.pushNamed(
|
||||
context,
|
||||
Routes.CHANNEL_PAGE,
|
||||
arguments: ChannelPageArgs(
|
||||
channel: channel,
|
||||
initialMessage: message,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
child: PinnedMessagesScreen(),
|
||||
),
|
||||
),
|
||||
);
|
||||
@@ -578,36 +584,8 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StreamChannel(
|
||||
channel: channel,
|
||||
child: MessageSearchBloc(
|
||||
child: ChannelMediaDisplayScreen(
|
||||
messageTheme: widget.messageTheme,
|
||||
sortOptions: [
|
||||
SortOption(
|
||||
'created_at',
|
||||
direction: SortOption.ASC,
|
||||
),
|
||||
],
|
||||
paginationParams: PaginationParams(limit: 20),
|
||||
onShowMessage: (m, c) async {
|
||||
final client = StreamChat.of(context).client;
|
||||
final message = m;
|
||||
final channel = client.channel(
|
||||
c.type,
|
||||
id: c.id,
|
||||
);
|
||||
if (channel.state == null) {
|
||||
await channel.watch();
|
||||
}
|
||||
await Navigator.pushNamed(
|
||||
context,
|
||||
Routes.CHANNEL_PAGE,
|
||||
arguments: ChannelPageArgs(
|
||||
channel: channel,
|
||||
initialMessage: message,
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
child: ChannelMediaDisplayScreen(
|
||||
messageTheme: widget.messageTheme,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -640,25 +618,16 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => StreamChannel(
|
||||
channel: channel,
|
||||
child: MessageSearchBloc(
|
||||
child: ChannelFileDisplayScreen(
|
||||
sortOptions: [
|
||||
SortOption(
|
||||
'created_at',
|
||||
direction: SortOption.ASC,
|
||||
),
|
||||
],
|
||||
paginationParams: PaginationParams(limit: 20),
|
||||
),
|
||||
child: ChannelFileDisplayScreen(
|
||||
messageTheme: widget.messageTheme,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
if (!channel.channel.isDistinct &&
|
||||
channel.channel.ownCapabilities
|
||||
.contains(PermissionType.leaveChannel))
|
||||
if (!channel.isDistinct &&
|
||||
channel.ownCapabilities.contains(PermissionType.leaveChannel))
|
||||
StreamOptionListTile(
|
||||
tileColor: StreamChatTheme.of(context).colorTheme.appBg,
|
||||
separatorColor: StreamChatTheme.of(context).colorTheme.disabled,
|
||||
@@ -703,106 +672,81 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
}
|
||||
|
||||
void _buildAddUserModal(context) {
|
||||
var channel = StreamChannel.of(context).channel;
|
||||
final userListController = StreamUserListController(
|
||||
client: channel.client,
|
||||
limit: 25,
|
||||
filter: Filter.and(
|
||||
[
|
||||
if (_searchController!.text.isNotEmpty)
|
||||
Filter.autoComplete('name', _userNameQuery),
|
||||
Filter.notIn('id', [
|
||||
StreamChat.of(context).currentUser!.id,
|
||||
...channel.state!.members
|
||||
.map<String?>(((e) => e.userId))
|
||||
.whereType<String>(),
|
||||
]),
|
||||
],
|
||||
),
|
||||
sort: [
|
||||
SortOption(
|
||||
'name',
|
||||
direction: 1,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
showDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
barrierColor: StreamChatTheme.of(context).colorTheme.overlay,
|
||||
builder: (context) {
|
||||
return StatefulBuilder(builder: (context, modalSetState) {
|
||||
modalSetStateCallback = modalSetState;
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(top: 16.0, left: 8.0, right: 8.0),
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(16.0),
|
||||
topRight: Radius.circular(16.0),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _buildTextInputSection(modalSetState),
|
||||
),
|
||||
Expanded(
|
||||
child: StreamUserListView(
|
||||
controller: userListController,
|
||||
onUserTap: (user) async {
|
||||
_searchController!.clear();
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(top: 16.0, left: 8.0, right: 8.0),
|
||||
child: Material(
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(16.0),
|
||||
topRight: Radius.circular(16.0),
|
||||
),
|
||||
clipBehavior: Clip.antiAlias,
|
||||
child: Scaffold(
|
||||
body: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(16),
|
||||
child: _buildTextInputSection(),
|
||||
),
|
||||
Expanded(
|
||||
child: StreamUserGridView(
|
||||
controller: userListController,
|
||||
onUserTap: (user) async {
|
||||
_searchController!.clear();
|
||||
|
||||
await channel.addMembers([user.id]);
|
||||
Navigator.pop(context);
|
||||
setState(() {});
|
||||
},
|
||||
emptyBuilder: (_) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, viewportConstraints) {
|
||||
return SingleChildScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: viewportConstraints.maxHeight,
|
||||
),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: StreamSvgIcon.search(
|
||||
size: 96,
|
||||
color: StreamChatTheme.of(context)
|
||||
.colorTheme
|
||||
.textLowEmphasis,
|
||||
),
|
||||
await channel.addMembers([user.id]);
|
||||
Navigator.pop(context);
|
||||
setState(() {});
|
||||
},
|
||||
emptyBuilder: (_) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, viewportConstraints) {
|
||||
return SingleChildScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: viewportConstraints.maxHeight,
|
||||
),
|
||||
child: Center(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
child: StreamSvgIcon.search(
|
||||
size: 96,
|
||||
color: StreamChatTheme.of(context)
|
||||
.colorTheme
|
||||
.textLowEmphasis,
|
||||
),
|
||||
Text(AppLocalizations.of(context)
|
||||
.noUserMatchesTheseKeywords),
|
||||
],
|
||||
),
|
||||
),
|
||||
Text(AppLocalizations.of(context)
|
||||
.noUserMatchesTheseKeywords),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
});
|
||||
),
|
||||
);
|
||||
},
|
||||
).then((_) => userListController.dispose());
|
||||
).whenComplete(() {
|
||||
_searchController?.clear();
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildTextInputSection(modalSetState) {
|
||||
Widget _buildTextInputSection() {
|
||||
final theme = StreamChatTheme.of(context);
|
||||
return Column(
|
||||
children: [
|
||||
@@ -862,7 +806,6 @@ class _GroupInfoScreenState extends State<GroupInfoScreen> {
|
||||
}
|
||||
|
||||
void _showUserInfoModal(User? user, bool isUserAdmin) {
|
||||
var channel = StreamChannel.of(context).channel;
|
||||
final color = StreamChatTheme.of(context).colorTheme.barsBg;
|
||||
|
||||
showModalBottomSheet(
|
||||
|
||||
Reference in New Issue
Block a user