From 52ea9866a863d0dad30af97eed8ee065153c4f9d Mon Sep 17 00:00:00 2001 From: ante <448468458@qq.com> Date: Mon, 15 Apr 2024 16:20:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockMain/xhj/lockMain_xhj_page.dart | 34 +++++---- star_lock/lib/mine/mall/lockMall_logic.dart | 7 +- star_lock/lib/mine/mall/lockMall_page.dart | 76 ++++++++++--------- star_lock/lib/mine/mall/lockMall_state.dart | 4 +- .../minePersonInfo_page.dart | 27 ++++++- star_lock/lib/tools/tf_loginInput.dart | 14 ++-- 6 files changed, 101 insertions(+), 61 deletions(-) diff --git a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart index 5ed23c91..e3cea087 100644 --- a/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart +++ b/star_lock/lib/main/lockMian/lockMain/xhj/lockMain_xhj_page.dart @@ -53,23 +53,27 @@ class _StarLockMainXHJPageState extends State index: 0, ), pageView( - widget: MessageListPage( - showAppBar: false, - ), - logic: logic, - index: 1), + widget: MessageListPage( + showAppBar: false, + ), + logic: logic, + index: 1, + ), pageView( - widget: LockMallPage( - showAppBar: false, - ), - logic: logic, - index: 2), + widget: LockMallPage( + showAppBar: false, + ), + logic: logic, + index: 2, + ), pageView( - widget: MinePersonInfoPage( - showAppBar: false, - ), - logic: logic, - index: 3), + widget: MinePersonInfoPage( + showAppBar: false, + showAbout: true, + ), + logic: logic, + index: 3, + ), ], ), ), diff --git a/star_lock/lib/mine/mall/lockMall_logic.dart b/star_lock/lib/mine/mall/lockMall_logic.dart index 57f62ad8..9705be81 100644 --- a/star_lock/lib/mine/mall/lockMall_logic.dart +++ b/star_lock/lib/mine/mall/lockMall_logic.dart @@ -13,7 +13,10 @@ import 'package:webview_flutter/webview_flutter.dart'; import '../../tools/baseGetXController.dart'; class LockMallLogic extends BaseGetXController { - final LockMallState state = LockMallState(); + late LockMallState state; + + LockMallLogic({required bool allowReturn}) + : state = LockMallState(allowReturn: allowReturn); //获取商城跳转地址 Future getMallURLRequest() async { @@ -96,7 +99,7 @@ class LockMallLogic extends BaseGetXController { if (canGoBack) { await state.mallWebView.goBack(); } else { - Get.back(); + if (state.allowReturn) Get.back(); } return false; } diff --git a/star_lock/lib/mine/mall/lockMall_page.dart b/star_lock/lib/mine/mall/lockMall_page.dart index f93202f6..6d648536 100644 --- a/star_lock/lib/mine/mall/lockMall_page.dart +++ b/star_lock/lib/mine/mall/lockMall_page.dart @@ -7,17 +7,16 @@ import 'package:star_lock/tools/titleAppBar.dart'; import 'package:webview_flutter/webview_flutter.dart'; class LockMallPage extends StatefulWidget { - LockMallPage({Key? key, this.showAppBar = true}) : super(key: key); + LockMallPage({Key? key, this.showAppBar = true, this.allowReturn = true}) + : super(key: key); bool showAppBar; + bool allowReturn; @override State createState() => _LockMallPageState(); } class _LockMallPageState extends State { - final logic = Get.put(LockMallLogic()); - final state = Get.find().state; - @override void initState() { super.initState(); @@ -28,41 +27,46 @@ class _LockMallPageState extends State { // FIXME 如果未登录状态,应先跳转登录页 // FIXME url应该使用接口获取,接口名称 “获取商城跳转地址:/mall/getUrl“ POST请求,无参数,需要登录 // String url = 'https://ge.mall.star-lock.cn/quick_login?id=4&key=1ffb9d37109b8351ebb04ccfcca02c8e'; - return PopScope( - onPopInvoked: logic.canGoBack, - canPop: false, - child: Scaffold( - resizeToAvoidBottomInset: false, - backgroundColor: const Color(0xFFFFFFFF), - appBar: widget.showAppBar - ? TitleAppBar( - barTitle: getWebTitle(), - haveBack: true, - backgroundColor: AppColors.mainColor, - ) - : null, - body: Obx(() => Column( - children: [ - Container( - padding: EdgeInsets.only(bottom: 10.w), - child: LinearProgressIndicator( - value: state.webProgress.value, - backgroundColor: Colors.grey, - valueColor: - AlwaysStoppedAnimation(AppColors.mainColor), - ), - ), - Expanded( - child: WebViewWidget(controller: state.mallWebView), - ), - ], - ))), - ); + return GetBuilder( + init: LockMallLogic(allowReturn: widget.allowReturn), + builder: (LockMallLogic logic) { + return PopScope( + onPopInvoked: logic.canGoBack, + canPop: false, + child: Scaffold( + resizeToAvoidBottomInset: false, + backgroundColor: const Color(0xFFFFFFFF), + appBar: widget.showAppBar + ? TitleAppBar( + barTitle: getWebTitle(logic), + haveBack: true, + backgroundColor: AppColors.mainColor, + ) + : null, + body: Obx(() => Column( + children: [ + Container( + padding: EdgeInsets.only(bottom: 10.w), + child: LinearProgressIndicator( + value: logic.state.webProgress.value, + backgroundColor: Colors.grey, + valueColor: AlwaysStoppedAnimation( + AppColors.mainColor), + ), + ), + Expanded( + child: WebViewWidget( + controller: logic.state.mallWebView), + ), + ], + ))), + ); + }); } - String getWebTitle() { + String getWebTitle(LockMallLogic logic) { String webTitleStr = "配件商城".tr; - state.mallWebView.getTitle().then((result) { + logic.state.mallWebView.getTitle().then((result) { webTitleStr = result!; }); return webTitleStr; diff --git a/star_lock/lib/mine/mall/lockMall_state.dart b/star_lock/lib/mine/mall/lockMall_state.dart index e0c4bb72..a9636f15 100644 --- a/star_lock/lib/mine/mall/lockMall_state.dart +++ b/star_lock/lib/mine/mall/lockMall_state.dart @@ -4,8 +4,11 @@ import 'package:star_lock/webview/webview_logic.dart'; import 'package:webview_flutter/webview_flutter.dart'; class LockMallState { + LockMallState({required this.allowReturn}); + var lockMallUrl = "".obs; var webProgress = 0.0.obs; + bool allowReturn; late WebViewController mallWebView = initWebViewController(); //初始化webView控制器 @@ -16,5 +19,4 @@ class LockMallState { allWebView.setUserAgent(WebViewLogic.userAgent); return allWebView; } - } diff --git a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart index 7f368dea..0d5e1802 100644 --- a/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart +++ b/star_lock/lib/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart @@ -3,6 +3,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:star_lock/app_settings/app_colors.dart'; +import 'package:star_lock/flavors.dart'; import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_logic.dart'; import 'package:star_lock/tools/custom_bottom_sheet.dart'; @@ -13,8 +14,10 @@ import '../../../tools/titleAppBar.dart'; import '../../../translations/trans_lib.dart'; class MinePersonInfoPage extends StatefulWidget { - MinePersonInfoPage({Key? key, this.showAppBar = true}) : super(key: key); + MinePersonInfoPage({Key? key, this.showAppBar = true, this.showAbout = false}) + : super(key: key); bool showAppBar; + bool showAbout; @override State createState() => _MinePersonInfoPageState(); @@ -146,8 +149,28 @@ class _MinePersonInfoPageState extends State { rightTitle: state.mineInfoData.value.countryName != null ? state.mineInfoData.value.countryName! : "", - isHaveLine: false, + isHaveLine: true, isHaveDirection: false)), + if (F.isLite == false && widget.showAbout) + CommonItem( + leftTitel: TranslationLoader.lanKeys!.valueAddedServices!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.back(); + Get.toNamed(Routers.valueAddedServicesPage); + }, + ), + if (widget.showAbout) + CommonItem( + leftTitel: TranslationLoader.lanKeys!.about!.tr, + isHaveLine: false, + isHaveDirection: true, + action: () { + Get.back(); + Get.toNamed(Routers.aboutPage); + }, + ), ], )); } diff --git a/star_lock/lib/tools/tf_loginInput.dart b/star_lock/lib/tools/tf_loginInput.dart index 9bd285e0..34a08940 100644 --- a/star_lock/lib/tools/tf_loginInput.dart +++ b/star_lock/lib/tools/tf_loginInput.dart @@ -9,6 +9,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; typedef BlockStrCallback = void Function(dynamic textStr); typedef BlockClickCallback = void Function(); + class LoginInput extends StatelessWidget { TextEditingController? controller; FocusNode? focusNode; @@ -24,6 +25,7 @@ class LoginInput extends StatelessWidget { Widget? rightSlot; BlockStrCallback? onchangeAction; BlockClickCallback? onTapAction; + LoginInput( {Key? key, required this.controller, @@ -58,7 +60,7 @@ class LoginInput extends StatelessWidget { onChanged: onchangeAction, onTap: onTapAction, autofocus: false, - inputFormatters:inputFormatters, + inputFormatters: inputFormatters, decoration: InputDecoration( //输入里面输入文字内边距设置 contentPadding: const EdgeInsets.only( @@ -69,10 +71,12 @@ class LoginInput extends StatelessWidget { hintText: hintText, //不需要输入框下划线 border: InputBorder.none, - suffixIcon: isSuffixIcon! ? IconButton( - icon: const Icon(Icons.clear), - onPressed: controller!.clear, - ) : null, + suffixIcon: (isSuffixIcon ?? false) + ? IconButton( + icon: const Icon(Icons.clear), + onPressed: controller!.clear, + ) + : null, //左边图标设置 icon: isHaveLeftWidget == true ? leftWidget