app-starlock/lib/mine/mine/starLockMine_page.dart
sky_min b0506a8910 1.取消用手机号码登陆
2.添加设备页直接跳到扫描设备页
2025-10-31 13:42:25 +08:00

717 lines
24 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/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart';
import 'package:star_lock/flavors.dart';
import 'package:star_lock/mine/mine/starLockMine_state.dart';
import 'package:star_lock/tools/storage.dart';
import 'package:star_lock/tools/wechat/customer_tool.dart';
import '../../appRouters.dart';
import '../../app_settings/app_colors.dart';
import '../../baseWidget.dart';
import '../../tools/commonItem.dart';
import '../../tools/customNetworkImage.dart';
import '../../tools/showTipView.dart';
import '../../tools/submitBtn.dart';
import '../../tools/wechat/wechatManageTool.dart';
import '../../tools/wechat/wx_push_miniProgram/wx_push_miniProgram.dart';
import '../../translations/app_dept.dart';
import '../../translations/current_locale_tool.dart';
import '../mineSet/mineSet/mineSet_logic.dart';
import '../mineSet/mineSet/mineSet_state.dart';
import 'starLockMine_logic.dart';
class StarLockMinePage extends StatefulWidget {
const StarLockMinePage({Key? key, this.showAppBar = true, this.showAbout = true}) : super(key: key);
final bool showAppBar;
final bool showAbout;
@override
State<StarLockMinePage> createState() => StarLockMinePageState();
}
GlobalKey<StarLockMinePageState> starLockMineKey = GlobalKey();
class StarLockMinePageState extends State<StarLockMinePage> with BaseWidget {
final StarLockMineLogic logic = Get.put(StarLockMineLogic());
final StarLockMineState state = Get.find<StarLockMineLogic>().state;
late final MineSetState stateSet;
late final MineSetLogic logicSet;
@override
void initState() {
super.initState();
// 确保 MineSetLogic 存在
if (!Get.isRegistered<MineSetLogic>()) {
Get.put(MineSetLogic());
}
logicSet = Get.find<MineSetLogic>();
stateSet = logicSet.state;
logicSet.userSettingsInfoRequest();
logic.getUserInfoRequest();
// 初始化时检查推送权限状态
_checkNotificationPermission();
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: SingleChildScrollView(child: Container(
margin: EdgeInsets.only(bottom: 20.h),
padding: EdgeInsets.symmetric(horizontal: 20.w),
child: Column(
children: <Widget>[
SizedBox(
height: 20.h,
),
topWidget(),
SizedBox(
height: 20.h,
),
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.r),
),
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 15.h),
child: GestureDetector(
onTap: () {
Get.back();
Get.toNamed(Routers.minePersonInfoPage);
},
child: Row(
children: <Widget>[
Icon(
Icons.person,
size: 32.sp,
),
SizedBox(width: 15.w),
Text(
'个人信息'.tr,
style: TextStyle(fontSize: 28.sp),
),
const Spacer(),
Icon(
Icons.arrow_forward_ios_rounded,
color: Colors.grey[400],
)
],
),
),
),
SizedBox(
height: 20.h,
),
bottomListWidget(),
SizedBox(
height: 20.h,
),
Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.r),
),
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 15.h),
child: getListDataView(),
)])))));
}
Widget topWidget() {
return Row(
children: <Widget>[
GestureDetector(
onTap: () {
Get.back();
Get.toNamed(Routers.minePersonInfoPage);
},
child: Obx(
() => SizedBox(
width: 68.w,
height: 68.w,
child: ClipRRect(
borderRadius: BorderRadius.circular(52.5.w),
child: CustomNetworkImage(
url: state.userHeadUrl.value,
defaultUrl: 'images/controls_user.png',
width: 68.w,
height: 68.h,
),
),
),
),
),
SizedBox(width: 20.w),
Obx(
() => GestureDetector(
onTap: () {
if (!state.isVip.value) {
Get.toNamed(Routers.advancedFeaturesWebPage, arguments: <String, int>{
'webBuyType': XSConstantMacro.webBuyTypeVip,
});
// }
} else {
Get.toNamed(Routers.valueAddedServicesHighFunctionPage);
}
},
child: Container(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
state.userNickName.value.isNotEmpty
? state.userNickName.value
: (state.userMobile.value.isNotEmpty ? state.userMobile.value : state.userEmail.value),
style: TextStyle(
fontSize: 22.sp,
color: Colors.black,
),
),
SizedBox(
width: 5.w,
),
if (!state.isVip.value)
Image.asset(
'images/mine/icon_mine_noPlus.png',
width: 20.w,
height: 20.w,
)
else
Image.asset(
'images/mine/icon_mine_isPlus.png',
width: 20.w,
height: 20.w,
),
],
),
),
),
),
// const Spacer(),
// Container(
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(10.r),
// ),
// padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 10.h),
// child: Row(
// children: [
// if (F.isSKY && Get.locale!.languageCode == 'zh')
// GestureDetector(
// onTap: () {
// Get.back();
// WechatManageTool.getAppInfo(CustomerTool.openCustomerService);
// },
// child: Image.asset(
// 'images/mine/icon_mine_main_supportStaff.png',
// width: 34.w,
// height: 34.w,
// ),
// ),
// SizedBox(
// width: 20.w,
// ),
// GestureDetector(
// onTap: () {
// Get.back();
// Get.toNamed(Routers.messageListPage);
// },
// child: Image.asset(
// 'images/mine/icon_mine_main_message.png',
// width: 36.w,
// height: 36.w,
// ),
// ),
// ],
// ),
// )
],
);
}
Widget bottomListWidget() {
return Container(
width: double.infinity,
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10.w),
),
padding: EdgeInsets.symmetric(horizontal: 20.w, vertical: 20.w),
child: Column(
children: [
// mineItem('images/mine/icon_mine_main_set.png', '设置'.tr, () {
// Get.back();
// Get.toNamed(Routers.mineSetPage);
// }),
// SizedBox(height: 20.h),
mineItem('images/mine/icon_mine_main_vip.png', '增值服务'.tr, () async {
final bool? isVip = await Storage.getBool(saveIsVip);
if (isVip == null || !isVip) {
// vip状态是和账号绑定这里判断用户打开的某个锁是不是LockOwner没意义
// if (CommonDataManage().currentKeyInfo.isLockOwner != 1) {
// logic.showToast('请先添加锁'.tr);
// } else {
//刷新购买状态
Get.toNamed(Routers.advancedFeaturesWebPage, arguments: <String, int>{
'webBuyType': XSConstantMacro.webBuyTypeVip,
})?.then((value) => logic.getUserInfoRequest());
// }
} else {
Get.toNamed(Routers.valueAddedServicesHighFunctionPage);
}
}),
SizedBox(height: 20.h),
mineItem('images/mine/icon_mine_main_about.png', '关于'.tr, () {
Get.back();
Get.toNamed(Routers.aboutPage);
}),
],
),
);
}
Widget mineItem(String lockTypeIcon, String lockTypeTitle, Function() action) {
return GestureDetector(
onTap: action,
child: Row(
children: <Widget>[
Image.asset(
lockTypeIcon,
width: 28.w,
height: 28.w,
),
SizedBox(width: 15.w),
Text(
lockTypeTitle,
style: TextStyle(fontSize: 28.sp),
),
const Spacer(),
Icon(
Icons.arrow_forward_ios_rounded,
color: Colors.grey[400],
)
],
),
);
}
Widget getListDataView() {
// 检测系统语言是否为中文
return Column(
children: <Widget>[
/* 2024-01-12 会议确定去掉“提示音、触摸开锁” by DaisyWu
CommonItem(
leftTitel: TranslationLoader.lanKeys!.prompTone!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w,
height: 50.h,
child: Obx(() => _isPrompToneSwitch()))),
CommonItem(
leftTitel: TranslationLoader.lanKeys!.touchUnlock!.tr,
rightTitle: "",
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w,
height: 50.h,
child: Obx(() => _isTouchUnlockSwitch()))),
*/
F.sw(
skyCall: () => const SizedBox(),
xhjCall: () => CommonItem(
leftTitel: '个人信息'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.minePersonInfoPage);
})),
CommonItem(
leftTitel: '消息推送'.tr,
rightTitle: '',
isHaveRightWidget: true,
isHaveLine: F.sw(
skyCall: () => F.appFlavor == Flavor.sky, xhjCall: () => true),
rightWidget: SizedBox(
width: 60.w,
height: 50.h,
child: Obx(_isPushNotificationSwitch)
)),
// if (F.appFlavor == Flavor.sky)
Visibility(
visible: stateSet.currentLanguageCode == 'zh_CN',
child: CommonItem(
leftTitel: '微信公众号推送'.tr,
rightTitle: '',
isHaveLine: true,
isHaveRightWidget: true,
rightWidget: SizedBox(
width: 60.w,
height: 50.h,
child: Obx(_isWechatPublicAccountPushSwitch),
),
),
),
SizedBox(height: 10.h),
CommonItem(
leftTitel: '锁用户管理'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockUserManageLisPage);
}),
CommonItem(
leftTitel: '授权管理员'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.authorizedAdministratorListPage);
}),
//by DaisyWu 新增--批量授权
if (!F.isProductionEnv)
CommonItem(
leftTitel: '批量授权'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.authorityManagementPage);
// Toast.show(msg: "功能暂未开放");
}),
CommonItem(
leftTitel: '网关'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.gatewayListPage);
}),
CommonItem(
leftTitel: '锁分组'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.lockGroupListPage);
}),
CommonItem(
leftTitel: '转移智能锁'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.transferSmartLockPage);
}),
//暂无网关屏蔽
// CommonItem(
// leftTitel: '转移网关'.tr,
// rightTitle: '',
// isHaveLine: true,
// isHaveDirection: true,
// action: () {
// Get.toNamed(Routers.selectGetewayListPage);
// }),
SizedBox(
height: 10.h,
),
// AppLog.log('state.currentLanguageName: ${state.currentLanguageName} state.currentLanguage.value: ${state.currentLanguage.value}');
CommonItem(
leftTitel: '多语言'.tr,
rightTitle: stateSet.currentLanguageName,
isHaveLine: true,
isHaveDirection: true,
action: () async {
// Get.toNamed(Routers.mineMultiLanguagePage);
await Get.toNamed(Routers.mineMultiLanguagePage)!.then((value) {
setState(() {
if (value.containsKey('currentLanguage')) {
stateSet.currentLanguage.value = value['currentLanguage'];
}
});
});
}),
/* 2024-01-12 会议确定去掉“锁屏” by DaisyWu
Obx(() => CommonItem(
leftTitel: TranslationLoader.lanKeys!.lockScreen!.tr,
rightTitle: (state.lockScreen.value == 1
? TranslationLoader.lanKeys!.opened!.tr
: TranslationLoader.lanKeys!.closed!.tr),
isHaveLine: true,
isHaveDirection: true,
action: () {
Navigator.pushNamed(context, Routers.lockScreenPage,
arguments: {'isOn': state.lockScreen.value}).then((value) {
logic.userSettingsInfoRequest();
});
})),
*/
Obx(() => CommonItem(
leftTitel: '隐藏无效开锁权限'.tr,
rightTitle:
(stateSet.hideExpiredAccessFlag.value == 1 ? '已开启'.tr : '已关闭'.tr),
isHaveLine: true,
isHaveDirection: true,
action: () {
Navigator.pushNamed(
context, Routers.hideInvalidUnlockPermissionsPage,
arguments: <String, int>{
'isOn': stateSet.hideExpiredAccessFlag.value
}).then((Object? value) {
logicSet.userSettingsInfoRequest();
});
})),
otherItem(
leftTitle: 'APP开锁时需手机连网的锁'.tr,
isHaveLine: true,
action: () {
Navigator.pushNamed(
context, Routers.aPPUnlockNeedMobileNetworkingLockPage);
}),
if (!F.isSKY)
CommonItem(
leftTitel: '增值服务'.tr,
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.back();
Get.toNamed(Routers.valueAddedServicesPage);
},
),
SizedBox(
height: 10.h,
),
CommonItem(
leftTitel: 'Amazon Alexa'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.amazonAlexaPage, arguments: <String, dynamic>{
'isAmazonAlexa': stateSet.isAmazonAlexa.value,
'amazonAlexaData': stateSet.amazonAlexaData.value
});
}),
CommonItem(
leftTitel: 'Google Home'.tr,
rightTitle: '',
isHaveLine: true,
isHaveDirection: true,
action: () {
Get.toNamed(Routers.googleHomePage, arguments: <String, dynamic>{
'isGoogleHome': stateSet.isGoogleHome.value,
'googleHomeData': stateSet.googleHomeData.value
})?.then((Object? value) {
logicSet.userSettingsInfoRequest();
});
}),
// if (!F.isProductionEnv)
// CommonItem(
// leftTitel: '小米IOT平台'.tr,
// rightTitle: '',
// isHaveLine: widget.showAbout,
// isHaveDirection: true,
// action: () {
// logic.showToast('功能暂未开放'.tr);
// }),
if (!F.isSKY)
CommonItem(
leftTitel: '客服'.tr,
isHaveLine: widget.showAbout,
isHaveDirection: true,
action: () {
WechatManageTool.getAppInfo(CustomerTool.openCustomerService);
},
),
if (widget.showAbout)
CommonItem(
leftTitel: '关于'.tr,
isHaveLine: false,
isHaveDirection: true,
action: () {
Get.back();
Get.toNamed(Routers.aboutPage);
},
),
// CommonItem(leftTitel:TranslationLoader.lanKeys!.valueAddedServices!.tr, rightTitle:"", isHaveDirection: true, action: (){
//
// }),
SizedBox(
height: F.sw(skyCall: () => 50.h, xhjCall: () => 0.0),
),
// CommonItem(leftTitel:TranslationLoader.lanKeys!.about!.tr, rightTitle:"", isHaveLine: true, isHaveDirection: true, action: (){
//
// }),
// SizedBox(height: 10.h,),
// CommonItem(leftTitel:TranslationLoader.lanKeys!.userAgreement!.tr, rightTitle:"", isHaveLine: true, isHaveDirection: true, action: (){
//
// }),
// CommonItem(leftTitel:TranslationLoader.lanKeys!.privacyPolicy!.tr, rightTitle:"", isHaveLine: true, isHaveDirection: true, action: (){
//
// }),
// CommonItem(leftTitel:TranslationLoader.lanKeys!.personalInformationCollectionList!.tr, rightTitle:"", isHaveLine: true, isHaveDirection: true, action: (){
//
// }),
// CommonItem(leftTitel:TranslationLoader.lanKeys!.applicationPermissionDescription!.tr, rightTitle:"", isHaveLine: true, isHaveDirection: true, action: (){
//
// }),
// CommonItem(leftTitel:TranslationLoader.lanKeys!.thirdPartyInformationSharingList!.tr, rightTitle:"", isHaveLine: true, isHaveDirection: true, action: (){
//
// }),
F.sw(skyCall: keyBottomWidget, xhjCall: () => const SizedBox())
],
);
}
//微信公众号推送开关
CupertinoSwitch _isWechatPublicAccountPushSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: stateSet.isWechatPublicAccountPush.value,
onChanged: (bool value) {
stateSet.isWechatPublicAccountPush.value =
!stateSet.isWechatPublicAccountPush.value;
logicSet.setMpWechatPushSwitchRequest(context);
},
);
}
CupertinoSwitch _isPushNotificationSwitch() {
return CupertinoSwitch(
activeColor: CupertinoColors.activeBlue,
trackColor: CupertinoColors.systemGrey5,
thumbColor: CupertinoColors.white,
value: stateSet.isPushNotification.value,
onChanged: (bool value) async {
// stateSet.isPushNotification.value = !stateSet.isPushNotification.value;
openAppSettings();
final PermissionStatus newStatus = await Permission.notification.status;
stateSet.isPushNotification.value = newStatus.isGranted;
},
);
}
Future<void> _checkNotificationPermission() async {
final PermissionStatus status = await Permission.notification.status;
stateSet.isPushNotification.value = status.isGranted;
}
Widget otherItem(
{String? leftTitle,
bool? isHaveLine,
Function()? action,
double? allHeight}) {
return GestureDetector(
onTap: action,
child: Container(
width: 1.sw,
padding:
EdgeInsets.only(left: 20.w, top: 15.h, bottom: 15.h, right: 10.w),
decoration: BoxDecoration(
color: Colors.white,
border: isHaveLine!
? Border(
bottom: BorderSide(
color: AppColors.greyLineColor, // 设置边框颜色
width: 2.0.h, // 设置边框宽度
),
)
: null,
),
child: Row(
children: <Widget>[
Expanded(
child: Text(leftTitle!, style: TextStyle(fontSize: 22.sp))),
SizedBox(width: 10.w),
if (CurrentLocaleTool.getCurrentLocaleString() ==
ExtensionLanguageType.fromLanguageType(LanguageType.hebrew)
.toString() ||
CurrentLocaleTool.getCurrentLocaleString() ==
ExtensionLanguageType.fromLanguageType(LanguageType.arabic)
.toString())
Image.asset(
'images/icon_left_grey.png',
width: 21.w,
height: 21.w,
)
else
Image.asset(
'images/icon_right_grey.png',
width: 12.w,
height: 21.w,
),
SizedBox(width: 5.w),
],
),
),
);
}
Widget keyBottomWidget() {
return Padding(
padding: F.sw(
skyCall: () => EdgeInsets.zero,
xhjCall: () => EdgeInsets.symmetric(horizontal: 15.w)),
child: Column(
children: <Widget>[
SubmitBtn(
btnName: '退出'.tr,
isDelete: true,
padding: EdgeInsets.symmetric(horizontal: 15.w),
onClick: () {
//退出登录
ShowTipView().showIosTipWithContentDialog(
'确定要退出吗?'.tr, () async {
await logicSet.userLogoutRequest();
// showLoginOutAlertTipDialog();
});
}),
Container(
padding: EdgeInsets.only(left: 30.w, top: 30.h),
// color: Colors.red,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: <Widget>[
TextButton(
child: Text(
'删除账号'.tr,
style: TextStyle(
color: AppColors.darkGrayTextColor, fontSize: 18.sp),
),
onPressed: () {
ShowTipView().showIosTipWithContentDialog(
'删除账号后,你的所有信息及相关记录都会从平台彻底删除,且不可恢复,是否删除?'.tr, () {
//安全验证
Get.toNamed(Routers.safeVerifyPage);
});
},
),
],
),
),
SizedBox(
height: 30.h,
)
],
),
);
}
}