mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 09:54:19 +01:00
web page close will close bottom sheet first and fix open history bug
This commit is contained in:
@@ -54,6 +54,7 @@ class WebProvider extends ChangeNotifier {
|
|||||||
void goHome(WebInfo webInfo) {
|
void goHome(WebInfo webInfo) {
|
||||||
webInfo.url = "";
|
webInfo.url = "";
|
||||||
webInfo.title = null;
|
webInfo.title = null;
|
||||||
|
webInfo.controller = null;
|
||||||
updateWebInfo(webInfo);
|
updateWebInfo(webInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import 'package:provider/provider.dart';
|
|||||||
import '../../component/webview/webview_component.dart';
|
import '../../component/webview/webview_component.dart';
|
||||||
import '../../provider/android_signer_mixin.dart';
|
import '../../provider/android_signer_mixin.dart';
|
||||||
import '../../provider/permission_check_mixin.dart';
|
import '../../provider/permission_check_mixin.dart';
|
||||||
|
import 'web_control_component.dart';
|
||||||
|
|
||||||
class IndexRouter extends StatefulWidget {
|
class IndexRouter extends StatefulWidget {
|
||||||
@override
|
@override
|
||||||
@@ -19,6 +20,8 @@ class IndexRouter extends StatefulWidget {
|
|||||||
|
|
||||||
class _IndexRouter extends CustState<IndexRouter>
|
class _IndexRouter extends CustState<IndexRouter>
|
||||||
with PermissionCheckMixin, AndroidSignerMixin {
|
with PermissionCheckMixin, AndroidSignerMixin {
|
||||||
|
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
Map<String, WebViewComponent> webViewComponentMap = {};
|
Map<String, WebViewComponent> webViewComponentMap = {};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -41,7 +44,7 @@ class _IndexRouter extends CustState<IndexRouter>
|
|||||||
builder: (context, webNumInfo, child) {
|
builder: (context, webNumInfo, child) {
|
||||||
List<Widget> list = [];
|
List<Widget> list = [];
|
||||||
for (var i = 0; i < webNumInfo.length; i++) {
|
for (var i = 0; i < webNumInfo.length; i++) {
|
||||||
list.add(IndexWebComponent(i));
|
list.add(IndexWebComponent(i, showControl));
|
||||||
}
|
}
|
||||||
return IndexedStack(
|
return IndexedStack(
|
||||||
index: webNumInfo.index,
|
index: webNumInfo.index,
|
||||||
@@ -54,14 +57,44 @@ class _IndexRouter extends CustState<IndexRouter>
|
|||||||
return PopScope(
|
return PopScope(
|
||||||
canPop: false,
|
canPop: false,
|
||||||
onPopInvoked: (didPop) async {
|
onPopInvoked: (didPop) async {
|
||||||
|
var closeBottomSheet = closeControl();
|
||||||
|
if (closeBottomSheet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var webInfo = webProvider.currentWebInfo();
|
var webInfo = webProvider.currentWebInfo();
|
||||||
if (webInfo != null) {
|
if (webInfo != null) {
|
||||||
webProvider.goBack(webInfo);
|
webProvider.goBack(webInfo);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
|
key: _scaffoldKey,
|
||||||
body: main,
|
body: main,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PersistentBottomSheetController? bottomSheetController;
|
||||||
|
|
||||||
|
showControl() {
|
||||||
|
bottomSheetController = _scaffoldKey.currentState!.showBottomSheet(
|
||||||
|
(context) {
|
||||||
|
return WebControlComponent();
|
||||||
|
},
|
||||||
|
enableDrag: true,
|
||||||
|
showDragHandle: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool closeControl() {
|
||||||
|
bool closeAble = false;
|
||||||
|
try {
|
||||||
|
if (bottomSheetController != null) {
|
||||||
|
bottomSheetController!.close();
|
||||||
|
closeAble = true;
|
||||||
|
}
|
||||||
|
} catch (e) {}
|
||||||
|
bottomSheetController = null;
|
||||||
|
return closeAble;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,9 @@ import 'web_control_component.dart';
|
|||||||
class IndexWebComponent extends StatefulWidget {
|
class IndexWebComponent extends StatefulWidget {
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
IndexWebComponent(this.index);
|
Function showControl;
|
||||||
|
|
||||||
|
IndexWebComponent(this.index, this.showControl);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
@@ -130,8 +132,9 @@ class _IndexWebComponent extends State<IndexWebComponent> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
wrapBottomBtn(const Icon(Icons.space_dashboard),
|
wrapBottomBtn(const Icon(Icons.space_dashboard), onTap: () {
|
||||||
onTap: showControl, left: 8, right: 8),
|
widget.showControl();
|
||||||
|
}, left: 8, right: 8),
|
||||||
wrapBottomBtn(const Icon(Icons.segment), left: 8, right: 13,
|
wrapBottomBtn(const Icon(Icons.segment), left: 8, right: 13,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
RouterUtil.router(context, RouterPath.ME);
|
RouterUtil.router(context, RouterPath.ME);
|
||||||
@@ -166,14 +169,4 @@ class _IndexWebComponent extends State<IndexWebComponent> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
showControl() {
|
|
||||||
showBottomSheet(
|
|
||||||
context: context,
|
|
||||||
showDragHandle: true,
|
|
||||||
builder: (context) {
|
|
||||||
return WebControlComponent();
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user