配件商城页面新增顶部进度条
This commit is contained in:
parent
b68b9dc7da
commit
c9ca7228f6
@ -1,6 +1,7 @@
|
||||
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';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
import '../../tools/baseGetXController.dart';
|
||||
|
||||
@ -12,6 +13,27 @@ class LockMallLogic extends BaseGetXController {
|
||||
LockMallDataEntity entity = await ApiRepository.to.getMallURLData();
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
state.lockMallUrl.value = entity.data!.url!;
|
||||
state.mallWebView.setNavigationDelegate(
|
||||
NavigationDelegate(
|
||||
onProgress: (int progress) {
|
||||
// Update loading bar.
|
||||
state.webProgress.value = progress / 100;
|
||||
},
|
||||
onPageStarted: (String url) {
|
||||
state.webProgress.value = 0.0;
|
||||
},
|
||||
onPageFinished: (String url) {
|
||||
state.webProgress.value = 1.0;
|
||||
},
|
||||
onWebResourceError: (WebResourceError error) {},
|
||||
onNavigationRequest: (NavigationRequest request) {
|
||||
// if (request.url.startsWith('https://www.youtube.com/')) {
|
||||
// return NavigationDecision.prevent;
|
||||
// }
|
||||
return NavigationDecision.navigate;
|
||||
},
|
||||
),
|
||||
);
|
||||
state.mallWebView.loadRequest(Uri.parse(state.lockMallUrl.value));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:star_lock/app_settings/app_colors.dart';
|
||||
import 'package:star_lock/mine/mall/lockMall_logic.dart';
|
||||
@ -36,7 +37,22 @@ class _LockMallPageState extends State<LockMallPage> {
|
||||
haveBack: true,
|
||||
backgroundColor: AppColors.mainColor,
|
||||
),
|
||||
body: WebViewWidget(controller: state.mallWebView));
|
||||
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),
|
||||
),
|
||||
],
|
||||
)));
|
||||
}
|
||||
|
||||
String getWebTitle() {
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
class LockMallState {
|
||||
var lockMallUrl = "".obs;
|
||||
var webProgress = 0.0.obs;
|
||||
late WebViewController mallWebView = WebViewController()
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted);
|
||||
..setJavaScriptMode(JavaScriptMode.unrestricted)
|
||||
..setBackgroundColor(Colors.white);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user