Files
tuiche/lib/pages/user/setting_page.dart
2026-04-07 14:49:31 +08:00

793 lines
44 KiB
Dart
Raw Permalink 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:ef/ef.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/ServiceConstant.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/color/app_uri_status.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/common/util/requestWithLog.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
import 'package:vbvs_app/controller/setting/language/language_controller.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/enum/APPPackageType.dart';
import 'package:vbvs_app/model/api_response.dart';
import 'package:flutter/services.dart';
class SettingPage extends StatefulWidget {
const SettingPage({super.key});
@override
State<SettingPage> createState() => _SettingPageState();
}
class _SettingPageState extends State<SettingPage> {
GlobalController globalController = Get.find();
UserInfoController userInfoController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
ThemeController themeController = Get.find();
LanguageController languageController = Get.find();
@override
void initState() {
languageController.initLanuageList();
super.initState();
}
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, bodySize) => GestureDetector(
// onTap: () => FocusScope.of(context).unfocus(),,
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(getBackgroundImageNoImage()), // 本地图片
fit: BoxFit.fill, // 填满个 Container
),
),
child: Scaffold(
backgroundColor: Colors.transparent, // 加上这一行
appBar: AppBar(
systemOverlayStyle: SystemUiOverlayStyle(
statusBarColor: Colors.transparent, // 状态栏背景色
statusBarIconBrightness: Brightness.light, // 图标颜色Android
statusBarBrightness: Brightness.light, // 图标颜色iOS
),
// backgroundColor: themeController.currentColor.sc17,
backgroundColor: themeController.currentColor.sc5,
automaticallyImplyLeading: false,
iconTheme: IconThemeData(
color: themeController.currentColor.sc3,
),
titleSpacing: 0.rpx,
// leading: returnIconButtom,
title: Container(
width: double.infinity,
height: 180.rpx,
child: Stack(
alignment: Alignment.center,
children: [
/// 居中标题
Text(
'设置页.标题'.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3,
letterSpacing: 0,
fontSize: 30.rpx,
),
),
/// 左边返回按钮
Positioned(
left: 0,
child: returnIconButtom,
),
],
),
),
actions: [],
centerTitle: false,
),
body: SafeArea(
top: true,
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(30.rpx, 0, 30.rpx, 0),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
SingleChildScrollView(
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 25.rpx, 0.rpx, 0),
child: Container(
width: double.infinity,
decoration: BoxDecoration(
// color: Color(0xFF242835),
color: themeController.currentColor.sc5,
borderRadius: BorderRadius.circular(
AppConstants().normal_container_radius),
),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 0, 0.rpx, 0),
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
// ClickableContainer(
// backgroundColor: Colors.transparent, // 容器背景色
// highlightColor: themeController
// .currentColor.sc21, // 点击时的背景色
// padding: EdgeInsetsDirectional.fromSTEB(
// 40.rpx, 0.rpx, 40.rpx, 0.rpx),
// onTap: () {
// // TopSlideNotification.show(context,
// // text: "待开发功能".tr);
// Get.toNamed("/themeSetting");
// },
// child: Container(
// child: Padding(
// padding: EdgeInsetsDirectional.fromSTEB(
// 0.rpx, 30.rpx, 0.rpx, 30.rpx),
// child: Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Row(
// mainAxisSize: MainAxisSize.max,
// children: [
// Text(
// '设置页.主题模式'.tr,
// style: TextStyle(
// fontFamily: 'Inter',
// color: themeController
// .currentColor.sc3,
// fontSize: AppConstants()
// .title_text_fontSize,
// letterSpacing: 0.0,
// ),
// ),
// ].divide(SizedBox(width: 22.rpx)),
// ),
// Row(
// mainAxisSize: MainAxisSize.max,
// children: [
// Text(
// '深色'.tr,
// style: TextStyle(
// fontFamily: 'Inter',
// color: Color(0xFFD9E3EB),
// fontSize: 26.rpx,
// letterSpacing: 0.0,
// ),
// ),
// SvgPicture.asset(
// 'assets/img/icon/arrow_right.svg',
// width: 8.rpx,
// height: 15
// .rpx, // 如果 SVG 中没有固定颜色,可以这样设置
// color: themeController
// .currentColor.sc3,
// ),
// ].divide(SizedBox(width: 28.rpx)),
// ),
// ],
// ),
// ),
// ),
// ),
ClickableContainer(
backgroundColor:
Colors.transparent, // 容器背景色
highlightColor: themeController
.currentColor.sc21, // 点击时的背景色
padding: EdgeInsetsDirectional.fromSTEB(
40.rpx, 0.rpx, 40.rpx, 0.rpx),
onTap: () {
// TopSlideNotification.show(context,
// text: "待开发功能".tr);
Get.toNamed("/languageSetting");
},
child: Container(
child: Padding(
padding:
EdgeInsetsDirectional.fromSTEB(
0.rpx, 30.rpx, 0.rpx, 30.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
'设置页.选择语言'.tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController
.currentColor.sc3,
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(
SizedBox(width: 22.rpx)),
),
Row(
mainAxisSize: MainAxisSize.max,
children: [
Obx(() {
return Text(
languageController
.selectLanguage
.value!
.language_name!,
style: TextStyle(
fontFamily: 'Inter',
color: themeController
.currentColor.sc2,
fontSize: 26.rpx,
letterSpacing: 0.0,
),
);
}),
SvgPicture.asset(
'assets/img/icon/arrow_right.svg',
width: 8.rpx,
height: 15
.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
color: themeController
.currentColor.sc3,
),
].divide(
SizedBox(width: 28.rpx)),
),
],
),
),
),
),
ClickableContainer(
backgroundColor:
Colors.transparent, // 容器背景色
highlightColor: themeController
.currentColor.sc21, // 点击时的背景色
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 0.rpx, 0.rpx, 0.rpx),
onTap: () {
print('点击了容器');
Get.toNamed(
"/commonMessageSettingPage");
},
child: Container(
child: Padding(
padding:
EdgeInsetsDirectional.fromSTEB(
40.rpx,
30.rpx,
40.rpx,
30.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment.spaceBetween,
children: [
Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
'消息通知'.tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController
.currentColor.sc3,
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(
SizedBox(width: 22.rpx)),
),
SvgPicture.asset(
'assets/img/icon/arrow_right.svg',
width: 8.rpx,
height: 14
.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
color: themeController
.currentColor.sc3,
),
],
),
),
),
),
if (AppConstants().ent_type ==
APPPackageType.TH.code)
ClickableContainer(
backgroundColor:
Colors.transparent, // 容器背景色
highlightColor: themeController
.currentColor.sc21, // 点击时的背景色
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 0.rpx, 0.rpx, 0.rpx),
onTap: () async {
String url =
"https://mp.weixin.qq.com/s/IAr4RNBy0hGJXGKyMxe7eQ";
String serviceAddress =
ServiceConstant.service_address;
String serviceName =
ServiceConstant.server_service;
String serviceApi =
ServiceConstant.user_setting;
String queryUrl =
"$serviceAddress$serviceName$serviceApi";
String type = "app_about_us";
String code = "th";
if (AppConstants().ent_type ==
APPPackageType.TH.code) {
code = "th";
} else if (AppConstants().ent_type ==
APPPackageType.HUANSHUI.code) {
code = "hs";
} else {
code = 'th';
}
queryUrl =
"$queryUrl?type=$type&code=$code";
await requestWithLog(
logTitle: "查询操作说明",
method: MyHttpMethod.get,
queryUrl: queryUrl,
onSuccess: (res) {
String? language = "zh_CN";
if (AppConstants().ent_type ==
APPPackageType.MHT.code) {
if (mhLanguageController
.selectLanguage !=
null) {
language =
mhLanguageController
.selectLanguage
.value!
.language_code;
}
} else {
if (languageController
.selectLanguage !=
null) {
language = languageController
.selectLanguage
.value!
.language_code;
}
}
if (language == "zh_CN") {
url = res.data['url'];
} else {
url = res.data['en_url'];
}
},
);
print('点击了容器');
Get.toNamed("/aboutUsPage",
arguments: url);
},
child: Container(
child: Padding(
padding:
EdgeInsetsDirectional.fromSTEB(
40.rpx,
30.rpx,
40.rpx,
30.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Row(
mainAxisSize:
MainAxisSize.max,
children: [
Text(
'关于我们'.tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController
.currentColor.sc3,
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(
SizedBox(width: 22.rpx)),
),
SvgPicture.asset(
'assets/img/icon/arrow_right.svg',
width: 8.rpx,
height: 14
.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
color: themeController
.currentColor.sc3,
),
],
),
),
),
),
if (isHaveProvicy())
ClickableContainer(
backgroundColor:
Colors.transparent, // 容器背景色
highlightColor: themeController
.currentColor.sc21, // 点击时的背景色
padding: EdgeInsetsDirectional.fromSTEB(
40.rpx, 0.rpx, 40.rpx, 0.rpx),
onTap: () {
// TopSlideNotification.show(context,
// text: "待开发功能".tr);
// Get.toNamed("/userSchemePage");
Get.toNamed("/userPolicyPageNew",
arguments: getPrivacy(2));
},
child: Container(
child: Padding(
padding:
EdgeInsetsDirectional.fromSTEB(
0.rpx,
30.rpx,
0.rpx,
30.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Row(
mainAxisSize:
MainAxisSize.max,
children: [
Text(
'用户协议'.tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController
.currentColor.sc3,
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(
SizedBox(width: 22.rpx)),
),
SvgPicture.asset(
'assets/img/icon/arrow_right.svg',
width: 8.rpx,
height: 15
.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
color: themeController
.currentColor.sc3,
),
],
),
),
),
),
if (isHaveProvicy())
ClickableContainer(
backgroundColor:
Colors.transparent, // 容器背景色
highlightColor: themeController
.currentColor.sc21, // 点击时的背景色
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 0.rpx, 0.rpx, 0.rpx),
onTap: () {
// TopSlideNotification.show(context,
// text: "待开发功能".tr);
// Get.toNamed("/privacyPage");
Get.toNamed("/privacyPolicyPageNew",
arguments: getPrivacy(1));
},
child: Container(
child: Padding(
padding:
EdgeInsetsDirectional.fromSTEB(
40.rpx,
30.rpx,
40.rpx,
30.rpx),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Row(
mainAxisSize:
MainAxisSize.max,
children: [
Text(
'隐私协议'.tr,
style: TextStyle(
fontFamily: 'Inter',
color: themeController
.currentColor.sc3,
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(
SizedBox(width: 22.rpx)),
),
SvgPicture.asset(
'assets/img/icon/arrow_right.svg',
width: 8.rpx,
height: 14
.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
color: themeController
.currentColor.sc3,
),
],
),
),
),
),
]
.divide(SizedBox(height: 0.rpx))
.addToStart(SizedBox(height: 30.rpx))
.addToEnd(SizedBox(height: 30.rpx)),
),
),
),
),
],
),
),
Column(
children: [
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
100.rpx, 0.rpx, 100.rpx, 0),
child: CustomCard(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
onTap: () {
ApiResponse apiResponse =
userInfoController.logOut();
TopSlideNotification.show(
context,
text: apiResponse.msg!,
textColor:
apiResponse.code == HttpStatusCodes.ok
? themeController.currentColor.sc2
: themeController.currentColor.sc9,
);
if (apiResponse.code == HttpStatusCodes.ok) {
Get.offAllNamed("/mianPageBottomChange");
}
},
colors: [
themeController.currentColor.sc9,
], // 渐变色是同一个色,也可以根据需要调整
child: Container(
width:
// MediaQuery.sizeOf(context).width * 0.66,
bodySize.maxWidth,
height: MediaQuery.sizeOf(context).height * 0.055,
constraints: BoxConstraints(
minWidth: 500.rpx,
minHeight: 90.rpx,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'设置页.退出登录'.tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontFamily: 'Inter',
fontSize:
AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(SizedBox(
width: 17.rpx,
)),
),
),
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
100.rpx, 20.rpx, 100.rpx, 0),
child: CustomCard(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
onTap: () {
// TopSlideNotification.show(
// context,
// text: "待开发功能".tr,
// );
Get.toNamed("/deleteAccount");
},
colors: [
Colors.transparent,
], // 渐变色是同一个色,也可以根据需要调整
child: Container(
width:
// MediaQuery.sizeOf(context).width * 0.66,
bodySize.maxWidth,
height: MediaQuery.sizeOf(context).height * 0.055,
constraints: BoxConstraints(
minWidth: 500.rpx,
minHeight: 90.rpx,
),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'注销账号'.tr,
style: TextStyle(
color: themeController.currentColor.sc9,
fontFamily: 'Inter',
fontSize:
AppConstants().normal_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(SizedBox(
width: 17.rpx,
)),
),
),
),
),
// if (isHaveBeiAn())
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 100.rpx, 0.rpx, 100.rpx),
child: ClickableContainer(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
onTap: () {},
backgroundColor:
Colors.transparent, // 渐变色是同一个色,也可以根据需要调整
highlightColor: Colors.transparent,
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 0.rpx, 0.rpx, 0),
child: Container(
width:
// MediaQuery.sizeOf(context).width * 0.66,
bodySize.maxWidth,
// height: MediaQuery.sizeOf(context).height * 0.055,
constraints: BoxConstraints(
minWidth: 500.rpx,
minHeight: 90.rpx,
),
child: Column(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (isHaveBeiAn())
Text(
'icp备案号'.tr,
style: TextStyle(
color:
themeController.currentColor.sc4,
fontFamily: 'Inter',
fontSize: AppConstants()
.smaller_text_fontSize,
letterSpacing: 0.0,
),
),
Text(
getCopyrightText(AppConstants().ent_type),
style: TextStyle(
color: themeController.currentColor.sc4,
fontFamily: 'Inter',
fontSize: AppConstants()
.smaller_text_fontSize,
letterSpacing: 0.0,
),
),
].divide(SizedBox(
height: 4.rpx,
))),
),
),
),
],
),
],
),
),
),
),
),
),
);
}
Widget _buildDeviceCard(BuildContext context,
{required String title, required String imageUrl, required String type}) {
return CustomCard(
borderRadius: 20.rpx, // 圆角大小
onTap: () {
if (type != null) {
if (type == '1') {
Get.toNamed("/blueteethDevice");
}
}
},
colors: [themeController.currentColor.sc17], // 背景色
child: Container(
width: double.infinity,
height: MediaQuery.sizeOf(context).height * 0.135,
constraints: BoxConstraints(
minHeight: 220.rpx,
),
padding: EdgeInsetsDirectional.fromSTEB(77.rpx, 0, 21.rpx, 0),
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: TextStyle(
fontFamily: 'Inter',
color: const Color(0xFFC2CED7),
fontSize: 30.rpx,
letterSpacing: 0.0,
),
),
ClipRRect(
borderRadius: BorderRadius.circular(8.rpx),
child: Image.asset(
imageUrl,
width: 212.rpx,
height: 168.rpx,
),
),
],
),
),
);
}
String getCopyrightText(int entType) {
final Map<int, String> copyrightMap = {
1: '公司信息'.tr,
2: 'Copyright © 2019-2029 合肥眠花糖家具有限责任公司 版权所有'.tr,
4: 'Copyright © 2020-2030 东华智能睡眠中心 版权所有'.tr,
5: 'Copyright © 2020-2030 青岛沃棣家居有限公司 版权所有'.tr,
};
return copyrightMap[entType] ?? '公司信息'.tr;
}
}