Close emote menu when going back on Android (#193)

This commit is contained in:
Tommy Chow 2022-09-06 14:44:44 -04:00 • committed by GitHub
parent fc0f7cbff7
commit ec8cb421b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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<EmoteMenu> {
'7TV',
];
return Column(
final emoteMenu = Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const Divider(
@ -107,6 +109,23 @@ class _EmoteMenuState extends State<EmoteMenu> {
),
],
);
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