fix page pop

This commit is contained in:
csf 2022-03-01 15:46:59 +08:00
parent 6206c8f900
commit b106ed5717
3 changed files with 71 additions and 58 deletions

View File

@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:tuple/tuple.dart';
import 'package:url_launcher/url_launcher.dart';
import 'dart:async';
import '../common.dart';
@ -164,7 +163,6 @@ class _ConnectionPageState extends State<ConnectionPage> {
icon: Icon(Icons.arrow_forward,
color: MyTheme.darkGray, size: 45),
onPressed: onConnect,
autofocus: _idController.text.isNotEmpty,
),
)
],

View File

@ -29,7 +29,18 @@ class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
return WillPopScope(
onWillPop: () async {
if (_selectedIndex != 0) {
setState(() {
_selectedIndex = 0;
});
} else {
return true;
}
return false;
},
child: Scaffold(
backgroundColor: MyTheme.grayBg,
appBar: AppBar(
centerTitle: true,
@ -50,6 +61,6 @@ class _HomePageState extends State<HomePage> {
}),
),
body: _pages.elementAt(_selectedIndex),
);
));
}
}

View File

@ -209,7 +209,11 @@ void showLoginReqAlert(String peerID, String name) async {
builder: (alertContext) {
DialogManager.reset();
DialogManager.register(alertContext);
return AlertDialog(
return WillPopScope(
onWillPop: () async {
return false;
},
child: AlertDialog(
title: Text("Control Request"),
content: Container(
height: 100,
@ -240,9 +244,9 @@ void showLoginReqAlert(String peerID, String name) async {
DialogManager.reset();
}),
],
);
));
});
DialogManager.reset();
DialogManager.drop();
}
class PermissionRow extends StatelessWidget {
@ -403,7 +407,7 @@ showInputWarnAlert() async {
],
);
});
DialogManager.reset();
DialogManager.drop();
}
void toAndroidChannelInit() {