mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-22 18:16:54 +08:00
feat: add configurable main page back behavior (#870)
* feat: add configurable main page back behavior Add setting to control whether back button exits directly or returns to first tab * update --------- Co-authored-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -159,6 +159,14 @@ class _MainAppState extends State<MainApp>
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
void onBack() {
|
||||
if (Platform.isAndroid) {
|
||||
Utils.channel.invokeMethod('back');
|
||||
} else {
|
||||
SystemNavigator.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final theme = Theme.of(context);
|
||||
@@ -166,15 +174,15 @@ class _MainAppState extends State<MainApp>
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvokedWithResult: (bool didPop, Object? result) {
|
||||
if (_mainController.selectedIndex.value != 0) {
|
||||
setIndex(0);
|
||||
_mainController.bottomBarStream?.add(true);
|
||||
_homeController.searchBarStream?.add(true);
|
||||
if (_mainController.directExitOnBack) {
|
||||
onBack();
|
||||
} else {
|
||||
if (Platform.isAndroid) {
|
||||
Utils.channel.invokeMethod('back');
|
||||
if (_mainController.selectedIndex.value != 0) {
|
||||
setIndex(0);
|
||||
_mainController.bottomBarStream?.add(true);
|
||||
_homeController.searchBarStream?.add(true);
|
||||
} else {
|
||||
SystemNavigator.pop();
|
||||
onBack();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user