Merge remote-tracking branch 'origin/master'

This commit is contained in:
葛佳祥 2024-04-08 15:10:20 +08:00
commit 7e024a67c2
3 changed files with 40 additions and 26 deletions

View File

@ -1,3 +1,5 @@
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_lock/mine/mall/lockMall_entity.dart';
import 'package:star_lock/mine/mall/lockMall_state.dart';
import 'package:star_lock/network/api_repository.dart';
@ -41,6 +43,17 @@ class LockMallLogic extends BaseGetXController {
}
}
//webview 退退
Future<bool> canGoBack(bool didPop) async {
bool canGoBack = await state.mallWebView.canGoBack();
if (canGoBack) {
await state.mallWebView.goBack();
} else {
Get.back();
}
return false;
}
@override
Future<void> onReady() async {
print("ready home");
@ -51,7 +64,6 @@ class LockMallLogic extends BaseGetXController {
void onInit() {
print("init home");
super.onInit();
getMallURLRequest();
}

View File

@ -6,7 +6,6 @@ import 'package:star_lock/mine/mall/lockMall_logic.dart';
import 'package:star_lock/tools/titleAppBar.dart';
import 'package:webview_flutter/webview_flutter.dart';
class LockMallPage extends StatefulWidget {
const LockMallPage({Key? key}) : super(key: key);
@ -28,30 +27,33 @@ class _LockMallPageState extends State<LockMallPage> {
// FIXME
// FIXME url应该使用接口获取 /mall/getUrl POST请求
// String url = 'https://ge.mall.star-lock.cn/quick_login?id=4&key=1ffb9d37109b8351ebb04ccfcca02c8e';
return Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: const Color(0xFFFFFFFF),
appBar: TitleAppBar(
barTitle: getWebTitle(),
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: Obx(() => Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(bottom: 10.w),
child: LinearProgressIndicator(
value: state.webProgress.value,
backgroundColor: Colors.grey,
valueColor:
AlwaysStoppedAnimation<Color>(AppColors.mainColor),
return PopScope(
onPopInvoked: logic.canGoBack,
canPop: false,
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: const Color(0xFFFFFFFF),
appBar: TitleAppBar(
barTitle: getWebTitle(),
haveBack: true,
backgroundColor: AppColors.mainColor,
),
body: Obx(() => Column(
children: <Widget>[
Container(
padding: EdgeInsets.only(bottom: 10.w),
child: LinearProgressIndicator(
value: state.webProgress.value,
backgroundColor: Colors.grey,
valueColor: AlwaysStoppedAnimation<Color>(AppColors.mainColor),
),
),
),
Expanded(
child: WebViewWidget(controller: state.mallWebView),
),
],
)));
Expanded(
child: WebViewWidget(controller: state.mallWebView),
),
],
))),
);
}
String getWebTitle() {

View File

@ -8,7 +8,7 @@ class LockMallState {
var webProgress = 0.0.obs;
late WebViewController mallWebView = initWebViewController();
//webview控制器
//webView控制器
WebViewController initWebViewController() {
WebViewController allWebView = WebViewController();
allWebView.setJavaScriptMode(JavaScriptMode.unrestricted);