mirror of
https://github.com/haorendashu/nowser.git
synced 2025-12-17 01:44: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) {
|
||||
webInfo.url = "";
|
||||
webInfo.title = null;
|
||||
webInfo.controller = null;
|
||||
updateWebInfo(webInfo);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:provider/provider.dart';
|
||||
import '../../component/webview/webview_component.dart';
|
||||
import '../../provider/android_signer_mixin.dart';
|
||||
import '../../provider/permission_check_mixin.dart';
|
||||
import 'web_control_component.dart';
|
||||
|
||||
class IndexRouter extends StatefulWidget {
|
||||
@override
|
||||
@@ -19,6 +20,8 @@ class IndexRouter extends StatefulWidget {
|
||||
|
||||
class _IndexRouter extends CustState<IndexRouter>
|
||||
with PermissionCheckMixin, AndroidSignerMixin {
|
||||
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
|
||||
|
||||
Map<String, WebViewComponent> webViewComponentMap = {};
|
||||
|
||||
@override
|
||||
@@ -41,7 +44,7 @@ class _IndexRouter extends CustState<IndexRouter>
|
||||
builder: (context, webNumInfo, child) {
|
||||
List<Widget> list = [];
|
||||
for (var i = 0; i < webNumInfo.length; i++) {
|
||||
list.add(IndexWebComponent(i));
|
||||
list.add(IndexWebComponent(i, showControl));
|
||||
}
|
||||
return IndexedStack(
|
||||
index: webNumInfo.index,
|
||||
@@ -54,14 +57,44 @@ class _IndexRouter extends CustState<IndexRouter>
|
||||
return PopScope(
|
||||
canPop: false,
|
||||
onPopInvoked: (didPop) async {
|
||||
var closeBottomSheet = closeControl();
|
||||
if (closeBottomSheet) {
|
||||
return;
|
||||
}
|
||||
|
||||
var webInfo = webProvider.currentWebInfo();
|
||||
if (webInfo != null) {
|
||||
webProvider.goBack(webInfo);
|
||||
}
|
||||
},
|
||||
child: Scaffold(
|
||||
key: _scaffoldKey,
|
||||
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 {
|
||||
int index;
|
||||
|
||||
IndexWebComponent(this.index);
|
||||
Function showControl;
|
||||
|
||||
IndexWebComponent(this.index, this.showControl);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@@ -130,8 +132,9 @@ class _IndexWebComponent extends State<IndexWebComponent> {
|
||||
),
|
||||
),
|
||||
),
|
||||
wrapBottomBtn(const Icon(Icons.space_dashboard),
|
||||
onTap: showControl, left: 8, right: 8),
|
||||
wrapBottomBtn(const Icon(Icons.space_dashboard), onTap: () {
|
||||
widget.showControl();
|
||||
}, left: 8, right: 8),
|
||||
wrapBottomBtn(const Icon(Icons.segment), left: 8, right: 13,
|
||||
onTap: () {
|
||||
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