fix: Fixed focus issue

This commit is contained in:
Deven Joshi
2021-01-18 20:04:48 +05:30
parent 57375a4df8
commit 623b6f0c76
2 changed files with 14 additions and 2 deletions
@@ -156,6 +156,9 @@ class _HomePageState extends State<HomePage> {
onNewChatButtonTap: () { onNewChatButtonTap: () {
Navigator.pushNamed(context, Routes.NEW_CHAT); Navigator.pushNamed(context, Routes.NEW_CHAT);
}, },
preNavigationCallback: () {
FocusScope.of(context).requestFocus(FocusNode());
},
), ),
drawer: _buildDrawer(context, user), drawer: _buildDrawer(context, user),
drawerEdgeDragWidth: 50, drawerEdgeDragWidth: 50,
@@ -519,6 +522,7 @@ class _ChannelListPageState extends State<ChannelListPage> {
); );
}, },
onItemTap: (messageResponse) async { onItemTap: (messageResponse) async {
FocusScope.of(context).requestFocus(FocusNode());
final client = StreamChat.of(context).client; final client = StreamChat.of(context).client;
final message = messageResponse.message; final message = messageResponse.message;
final channel = client.channel( final channel = client.channel(
@@ -55,6 +55,7 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
this.onUserAvatarTap, this.onUserAvatarTap,
this.onNewChatButtonTap, this.onNewChatButtonTap,
this.showConnectionStateTile = false, this.showConnectionStateTile = false,
this.preNavigationCallback,
}) : super(key: key); }) : super(key: key);
/// Pass this if you don't have a [Client] in your widget tree. /// Pass this if you don't have a [Client] in your widget tree.
@@ -72,6 +73,8 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
final bool showConnectionStateTile; final bool showConnectionStateTile;
final VoidCallback preNavigationCallback;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final _client = client ?? StreamChat.of(context).client; final _client = client ?? StreamChat.of(context).client;
@@ -110,8 +113,13 @@ class ChannelListHeader extends StatelessWidget implements PreferredSizeWidget {
child: UserAvatar( child: UserAvatar(
user: user, user: user,
showOnlineStatus: false, showOnlineStatus: false,
onTap: onTap: onUserAvatarTap ??
onUserAvatarTap ?? (_) => Scaffold.of(context).openDrawer(), (_) {
if (preNavigationCallback != null) {
preNavigationCallback();
}
Scaffold.of(context).openDrawer();
},
borderRadius: BorderRadius.circular(20), borderRadius: BorderRadius.circular(20),
constraints: BoxConstraints.tightFor( constraints: BoxConstraints.tightFor(
height: 40, height: 40,