app-starlock/lib/mine/mall/lockMall_page.dart
2024-06-07 11:12:45 +08:00

89 lines
3.2 KiB
Dart
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}