diff --git a/lib/pages/connection_page.dart b/lib/pages/connection_page.dart index 083b762fa..eb2d9f784 100644 --- a/lib/pages/connection_page.dart +++ b/lib/pages/connection_page.dart @@ -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 { icon: Icon(Icons.arrow_forward, color: MyTheme.darkGray, size: 45), onPressed: onConnect, - autofocus: _idController.text.isNotEmpty, ), ) ], diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 2900da268..0f3ecf65e 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -29,27 +29,38 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { - return Scaffold( - backgroundColor: MyTheme.grayBg, - appBar: AppBar( - centerTitle: true, - title: Text("RustDesk"), - actions: _pages.elementAt(_selectedIndex).appBarActions, - ), - bottomNavigationBar: BottomNavigationBar( - items: _pages - .map((page) => - BottomNavigationBarItem(icon: page.icon, label: page.title)) - .toList(), - currentIndex: _selectedIndex, - type: BottomNavigationBarType.fixed, - selectedItemColor: MyTheme.accent, - unselectedItemColor: MyTheme.darkGray, - onTap: (index) => setState(() { - _selectedIndex = index; - }), - ), - body: _pages.elementAt(_selectedIndex), - ); + return WillPopScope( + onWillPop: () async { + if (_selectedIndex != 0) { + setState(() { + _selectedIndex = 0; + }); + } else { + return true; + } + return false; + }, + child: Scaffold( + backgroundColor: MyTheme.grayBg, + appBar: AppBar( + centerTitle: true, + title: Text("RustDesk"), + actions: _pages.elementAt(_selectedIndex).appBarActions, + ), + bottomNavigationBar: BottomNavigationBar( + items: _pages + .map((page) => + BottomNavigationBarItem(icon: page.icon, label: page.title)) + .toList(), + currentIndex: _selectedIndex, + type: BottomNavigationBarType.fixed, + selectedItemColor: MyTheme.accent, + unselectedItemColor: MyTheme.darkGray, + onTap: (index) => setState(() { + _selectedIndex = index; + }), + ), + body: _pages.elementAt(_selectedIndex), + )); } } diff --git a/lib/pages/server_page.dart b/lib/pages/server_page.dart index b2a80be08..eb407bdac 100644 --- a/lib/pages/server_page.dart +++ b/lib/pages/server_page.dart @@ -209,40 +209,44 @@ void showLoginReqAlert(String peerID, String name) async { builder: (alertContext) { DialogManager.reset(); DialogManager.register(alertContext); - return AlertDialog( - title: Text("Control Request"), - content: Container( - height: 100, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text(translate("Do you accept?")), - SizedBox(height: 20), - getConnInfo(name, peerID), - ], - )), - actions: [ - TextButton( - child: Text(translate("Dismiss")), - onPressed: () { - FFI.setByName("login_res", "false"); - DialogManager.reset(); - }), - ElevatedButton( - child: Text(translate("Accept")), - onPressed: () { - FFI.setByName("login_res", "true"); - if (!FFI.serverModel.isFileTransfer) { - _toAndroidStartCapture(); - } - FFI.serverModel.setPeer(true); - DialogManager.reset(); - }), - ], - ); + return WillPopScope( + onWillPop: () async { + return false; + }, + child: AlertDialog( + title: Text("Control Request"), + content: Container( + height: 100, + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text(translate("Do you accept?")), + SizedBox(height: 20), + getConnInfo(name, peerID), + ], + )), + actions: [ + TextButton( + child: Text(translate("Dismiss")), + onPressed: () { + FFI.setByName("login_res", "false"); + DialogManager.reset(); + }), + ElevatedButton( + child: Text(translate("Accept")), + onPressed: () { + FFI.setByName("login_res", "true"); + if (!FFI.serverModel.isFileTransfer) { + _toAndroidStartCapture(); + } + FFI.serverModel.setPeer(true); + DialogManager.reset(); + }), + ], + )); }); - DialogManager.reset(); + DialogManager.drop(); } class PermissionRow extends StatelessWidget { @@ -403,7 +407,7 @@ showInputWarnAlert() async { ], ); }); - DialogManager.reset(); + DialogManager.drop(); } void toAndroidChannelInit() {