89 lines
3.2 KiB
Dart
Executable File
89 lines
3.2 KiB
Dart
Executable File
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/flavors.dart';
|
||
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 {
|
||
LockMallPage({Key? key, this.showAppBar = true, this.allowReturn = true})
|
||
: super(key: key);
|
||
bool showAppBar;
|
||
bool allowReturn;
|
||
|
||
@override
|
||
State<LockMallPage> createState() => _LockMallPageState();
|
||
}
|
||
|
||
class _LockMallPageState extends State<LockMallPage> with AutomaticKeepAliveClientMixin {
|
||
@override
|
||
void initState() {
|
||
super.initState();
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
// 如果未登录状态,应先跳转登录页
|
||
// url应该使用接口获取,接口名称 “获取商城跳转地址:/mall/getUrl“ POST请求,无参数,需要登录
|
||
// String url = 'https://ge.mall.star-lock.cn/quick_login?id=4&key=1ffb9d37109b8351ebb04ccfcca02c8e';
|
||
return GetBuilder<LockMallLogic>(
|
||
init: LockMallLogic(allowReturn: widget.allowReturn),
|
||
builder: (LockMallLogic logic) {
|
||
return Scaffold(
|
||
resizeToAvoidBottomInset: false,
|
||
backgroundColor: const Color(0xFFFFFFFF),
|
||
appBar: widget.showAppBar
|
||
? TitleAppBar(
|
||
barTitle: getWebTitle(logic),
|
||
haveBack: logic.state.canGoBack || logic.state.allowReturn,
|
||
backgroundColor: F.sw(
|
||
skyCall: () => AppColors.mainColor,
|
||
xhjCall: () => Colors.white),
|
||
titleColor: F.sw(
|
||
skyCall: () => null,
|
||
xhjCall: () => AppColors.blackColor),
|
||
iconColor: F.sw(
|
||
skyCall: () => null,
|
||
xhjCall: () => AppColors.blackColor),
|
||
backAction: () => logic.canGoBack(false),
|
||
)
|
||
: null,
|
||
body: Obx(() => Column(
|
||
children: <Widget>[
|
||
PopScope(
|
||
onPopInvoked: logic.canGoBack,
|
||
canPop: false,
|
||
child: const SizedBox(),
|
||
),
|
||
Container(
|
||
padding: EdgeInsets.only(bottom: 10.w),
|
||
child: LinearProgressIndicator(
|
||
value: logic.state.webProgress.value,
|
||
backgroundColor: Colors.grey,
|
||
valueColor:
|
||
AlwaysStoppedAnimation<Color>(AppColors.mainColor),
|
||
),
|
||
),
|
||
Expanded(
|
||
child: WebViewWidget(controller: logic.state.mallWebView),
|
||
),
|
||
],
|
||
)),
|
||
);
|
||
});
|
||
}
|
||
|
||
String getWebTitle(LockMallLogic logic) {
|
||
String webTitleStr = '配件商城'.tr;
|
||
logic.state.mallWebView.getTitle().then((result) {
|
||
webTitleStr = result!;
|
||
});
|
||
return webTitleStr;
|
||
}
|
||
|
||
@override
|
||
bool get wantKeepAlive => true;
|
||
}
|