From ec8cb421b0502d0666c363105198667c15039f86 Mon Sep 17 00:00:00 2001 From: Tommy Chow Date: Tue, 6 Sep 2022 14:44:44 -0400 Subject: [PATCH] Close emote menu when going back on Android (#193) --- .../channel/chat/emote_menu/emote_menu.dart | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/screens/channel/chat/emote_menu/emote_menu.dart b/lib/screens/channel/chat/emote_menu/emote_menu.dart index 3bd57a13..11a26898 100644 --- a/lib/screens/channel/chat/emote_menu/emote_menu.dart +++ b/lib/screens/channel/chat/emote_menu/emote_menu.dart @@ -1,3 +1,5 @@ +import 'dart:io'; + import 'package:collection/collection.dart'; import 'package:flutter/material.dart'; import 'package:flutter_mobx/flutter_mobx.dart'; @@ -31,7 +33,7 @@ class _EmoteMenuState extends State { '7TV', ]; - return Column( + final emoteMenu = Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Divider( @@ -107,6 +109,23 @@ class _EmoteMenuState extends State { ), ], ); + + if (Platform.isAndroid) { + return WillPopScope( + onWillPop: () async { + // If pressing the back button on Android while the emote menu is open, close it instead of going back to the streams list. + if (widget.chatStore.assetsStore.showEmoteMenu) { + widget.chatStore.assetsStore.showEmoteMenu = false; + return false; + } else { + return true; + } + }, + child: emoteMenu, + ); + } + + return emoteMenu; } @override