Hide keyboard on scrolling user list
This commit is contained in:
@@ -164,59 +164,63 @@ class _GroupChatDetailsScreenState extends State<GroupChatDetailsScreen> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.separated(
|
child: GestureDetector(
|
||||||
itemCount: _selectedUsers.length + 1,
|
behavior: HitTestBehavior.opaque,
|
||||||
separatorBuilder: (_, __) => Container(
|
onPanDown: (_) => FocusScope.of(context).unfocus(),
|
||||||
height: 1,
|
child: ListView.separated(
|
||||||
color: Theme.of(context).brightness == Brightness.dark
|
itemCount: _selectedUsers.length + 1,
|
||||||
? Colors.white.withOpacity(0.1)
|
separatorBuilder: (_, __) => Container(
|
||||||
: Colors.black.withOpacity(0.1),
|
height: 1,
|
||||||
),
|
color: Theme.of(context).brightness == Brightness.dark
|
||||||
itemBuilder: (_, index) {
|
? Colors.white.withOpacity(0.1)
|
||||||
if (index == _selectedUsers.length) {
|
: Colors.black.withOpacity(0.1),
|
||||||
return Container(
|
),
|
||||||
height: 1,
|
itemBuilder: (_, index) {
|
||||||
color: Theme.of(context).brightness == Brightness.dark
|
if (index == _selectedUsers.length) {
|
||||||
? Colors.white.withOpacity(0.1)
|
return Container(
|
||||||
: Colors.black.withOpacity(0.1),
|
height: 1,
|
||||||
|
color: Theme.of(context).brightness == Brightness.dark
|
||||||
|
? Colors.white.withOpacity(0.1)
|
||||||
|
: Colors.black.withOpacity(0.1),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
final user = _selectedUsers[index];
|
||||||
|
return ListTile(
|
||||||
|
key: ObjectKey(user),
|
||||||
|
leading: UserAvatar(
|
||||||
|
user: user,
|
||||||
|
constraints: BoxConstraints.tightFor(
|
||||||
|
width: 40,
|
||||||
|
height: 40,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
title: Text(
|
||||||
|
user.name,
|
||||||
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
contentPadding: const EdgeInsets.symmetric(
|
||||||
|
horizontal: 12,
|
||||||
|
vertical: 8,
|
||||||
|
),
|
||||||
|
trailing: IconButton(
|
||||||
|
icon: Icon(
|
||||||
|
Icons.clear_rounded,
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
padding: const EdgeInsets.all(0),
|
||||||
|
splashRadius: 24,
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
_selectedUsers.remove(user);
|
||||||
|
});
|
||||||
|
if (_selectedUsers.isEmpty) {
|
||||||
|
Navigator.pop(context, _selectedUsers);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
final user = _selectedUsers[index];
|
),
|
||||||
return ListTile(
|
|
||||||
key: ObjectKey(user),
|
|
||||||
leading: UserAvatar(
|
|
||||||
user: user,
|
|
||||||
constraints: BoxConstraints.tightFor(
|
|
||||||
width: 40,
|
|
||||||
height: 40,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
title: Text(
|
|
||||||
user.name,
|
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
contentPadding: const EdgeInsets.symmetric(
|
|
||||||
horizontal: 12,
|
|
||||||
vertical: 8,
|
|
||||||
),
|
|
||||||
trailing: IconButton(
|
|
||||||
icon: Icon(
|
|
||||||
Icons.clear_rounded,
|
|
||||||
color: Colors.black,
|
|
||||||
),
|
|
||||||
padding: const EdgeInsets.all(0),
|
|
||||||
splashRadius: 24,
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
_selectedUsers.remove(user);
|
|
||||||
});
|
|
||||||
if (_selectedUsers.isEmpty) {
|
|
||||||
Navigator.pop(context, _selectedUsers);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -243,67 +243,71 @@ class _NewChatScreenState extends State<NewChatScreen> {
|
|||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: _showUserList
|
child: _showUserList
|
||||||
? UsersBloc(
|
? GestureDetector(
|
||||||
child: UserListView(
|
behavior: HitTestBehavior.opaque,
|
||||||
selectedUsers: _selectedUsers,
|
onPanDown: (_) => FocusScope.of(context).unfocus(),
|
||||||
groupAlphabetically: _isSearchActive ? false : true,
|
child: UsersBloc(
|
||||||
onUserTap: (user, _) {
|
child: UserListView(
|
||||||
_controller.clear();
|
selectedUsers: _selectedUsers,
|
||||||
if (!_selectedUsers.contains(user)) {
|
groupAlphabetically: _isSearchActive ? false : true,
|
||||||
_chipInputTextFieldState
|
onUserTap: (user, _) {
|
||||||
..addItem(user)
|
_controller.clear();
|
||||||
..pauseItemAddition();
|
if (!_selectedUsers.contains(user)) {
|
||||||
} else {
|
_chipInputTextFieldState
|
||||||
_chipInputTextFieldState.removeItem(user);
|
..addItem(user)
|
||||||
}
|
..pauseItemAddition();
|
||||||
},
|
} else {
|
||||||
pagination: PaginationParams(
|
_chipInputTextFieldState.removeItem(user);
|
||||||
limit: 25,
|
}
|
||||||
),
|
|
||||||
filter: {
|
|
||||||
if (_userNameQuery.isNotEmpty)
|
|
||||||
'name': {
|
|
||||||
r'$autocomplete': _userNameQuery,
|
|
||||||
},
|
|
||||||
'id': {
|
|
||||||
r'$ne': StreamChat.of(context).user.id,
|
|
||||||
},
|
},
|
||||||
},
|
pagination: PaginationParams(
|
||||||
sort: [
|
limit: 25,
|
||||||
SortOption(
|
|
||||||
'name',
|
|
||||||
direction: 1,
|
|
||||||
),
|
),
|
||||||
],
|
filter: {
|
||||||
emptyBuilder: (_) {
|
if (_userNameQuery.isNotEmpty)
|
||||||
return LayoutBuilder(
|
'name': {
|
||||||
builder: (context, viewportConstraints) {
|
r'$autocomplete': _userNameQuery,
|
||||||
return SingleChildScrollView(
|
},
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
'id': {
|
||||||
child: ConstrainedBox(
|
r'$ne': StreamChat.of(context).user.id,
|
||||||
constraints: BoxConstraints(
|
},
|
||||||
minHeight: viewportConstraints.maxHeight,
|
},
|
||||||
),
|
sort: [
|
||||||
child: Center(
|
SortOption(
|
||||||
child: Column(
|
'name',
|
||||||
children: [
|
direction: 1,
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.all(24),
|
],
|
||||||
child: StreamSvgIcon.search(
|
emptyBuilder: (_) {
|
||||||
size: 96,
|
return LayoutBuilder(
|
||||||
color: Colors.grey,
|
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: Colors.grey,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Text(
|
||||||
Text(
|
'No user matches these keywords...'),
|
||||||
'No user matches these keywords...'),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
: MessageListView(),
|
: MessageListView(),
|
||||||
|
|||||||
@@ -238,68 +238,72 @@ class _NewGroupChatScreenState extends State<NewGroupChatScreen> {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
body: UsersBloc(
|
body: GestureDetector(
|
||||||
child: UserListView(
|
behavior: HitTestBehavior.opaque,
|
||||||
selectedUsers: _selectedUsers,
|
onPanDown: (_) => FocusScope.of(context).unfocus(),
|
||||||
pullToRefresh: false,
|
child: UsersBloc(
|
||||||
groupAlphabetically: _isSearchActive ? false : true,
|
child: UserListView(
|
||||||
onUserTap: (user, _) {
|
selectedUsers: _selectedUsers,
|
||||||
if (!_selectedUsers.contains(user)) {
|
pullToRefresh: false,
|
||||||
setState(() {
|
groupAlphabetically: _isSearchActive ? false : true,
|
||||||
_selectedUsers.add(user);
|
onUserTap: (user, _) {
|
||||||
});
|
if (!_selectedUsers.contains(user)) {
|
||||||
} else {
|
setState(() {
|
||||||
setState(() {
|
_selectedUsers.add(user);
|
||||||
_selectedUsers.remove(user);
|
});
|
||||||
});
|
} else {
|
||||||
}
|
setState(() {
|
||||||
},
|
_selectedUsers.remove(user);
|
||||||
pagination: PaginationParams(
|
});
|
||||||
limit: 25,
|
}
|
||||||
),
|
},
|
||||||
filter: {
|
pagination: PaginationParams(
|
||||||
if (_userNameQuery.isNotEmpty)
|
limit: 25,
|
||||||
'name': {
|
|
||||||
r'$autocomplete': _userNameQuery,
|
|
||||||
},
|
|
||||||
'id': {
|
|
||||||
r'$ne': StreamChat.of(context).user.id,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
sort: [
|
|
||||||
SortOption(
|
|
||||||
'name',
|
|
||||||
direction: 1,
|
|
||||||
),
|
),
|
||||||
],
|
filter: {
|
||||||
emptyBuilder: (_) {
|
if (_userNameQuery.isNotEmpty)
|
||||||
return LayoutBuilder(
|
'name': {
|
||||||
builder: (context, viewportConstraints) {
|
r'$autocomplete': _userNameQuery,
|
||||||
return SingleChildScrollView(
|
},
|
||||||
physics: AlwaysScrollableScrollPhysics(),
|
'id': {
|
||||||
child: ConstrainedBox(
|
r'$ne': StreamChat.of(context).user.id,
|
||||||
constraints: BoxConstraints(
|
}
|
||||||
minHeight: viewportConstraints.maxHeight,
|
},
|
||||||
),
|
sort: [
|
||||||
child: Center(
|
SortOption(
|
||||||
child: Column(
|
'name',
|
||||||
children: [
|
direction: 1,
|
||||||
Padding(
|
),
|
||||||
padding: const EdgeInsets.all(24),
|
],
|
||||||
child: StreamSvgIcon.search(
|
emptyBuilder: (_) {
|
||||||
size: 96,
|
return LayoutBuilder(
|
||||||
color: Colors.grey,
|
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: Colors.grey,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
Text('No user matches these keywords...'),
|
||||||
Text('No user matches these keywords...'),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
);
|
||||||
);
|
},
|
||||||
},
|
);
|
||||||
);
|
},
|
||||||
},
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user