更新部分显示样式

This commit is contained in:
wyf
2025-12-09 15:47:05 +08:00
parent 5e63f2dfdc
commit e7c51bea52
15 changed files with 223 additions and 122 deletions

View File

@@ -571,7 +571,7 @@
"输入关键词": "Enter keywords",
"输入国家、省份或城市": "Enter country, province, or city",
"手机号码": "Phone number",
"邮箱": "email",
"邮箱": "Email",
"微信": "WeChat",
"更换": "Change",
"换绑": "Rebind",
@@ -608,5 +608,9 @@
"离床时长": "Bed Exit Duration",
"已关闭": "Disabled",
"时": " h",
"允许对方配置wifi": "Allow other to configure WiFi"
"允许对方配置wifi": "Allow other to configure WiFi",
"去绑定": "Go Bind",
"解除分享": "Unshare",
"详情": "Detail",
"更新成功": "Update Success"
}

View File

@@ -608,5 +608,8 @@
"离床时长": "离床时长",
"已关闭": "已关闭",
"时": "时",
"允许对方配置wifi": "允许对方配置wifi"
"允许对方配置wifi": "允许对方配置wifi",
"去绑定": "去绑定",
"解除分享": "解除分享",
"详情": "详情"
}

View File

@@ -604,5 +604,9 @@
"离床时长": "離床時長",
"已关闭": "已關閉",
"时": "時",
"允许对方配置wifi": "允許對方設定wifi"
"允许对方配置wifi": "允許對方設定wifi",
"去绑定": "去綁定",
"解除分享": "解除分享",
"详情": "詳情",
"更新成功": "更新成功"
}

View File

@@ -159,7 +159,7 @@ class _DynamicReportDetailWidgetState extends State<DynamicReportDetailWidget> {
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc3,
color: themeController.currentColor.sc2,
),
),
Padding(

View File

@@ -146,7 +146,12 @@ class UserInfoController extends GetControllerEx<UserInfoModel> {
LoginController loginController = Get.find();
ApiResponse apiResponse = ApiResponse(code: -1, msg: "保存失败".tr);
UserModel user = model.user!;
if (user.tmpNickName == null || user.tmpNickName!.isEmpty) {
final bool hasContactUpdate = (phone != null && phone.isNotEmpty) ||
(email != null && email.isNotEmpty);
/// 只有在【没有更新 phone/email】时才要求昵称不为空
if (!hasContactUpdate &&
(user.tmpNickName == null || user.tmpNickName!.isEmpty)) {
apiResponse.msg = "昵称为空".tr;
return apiResponse;
}

View File

@@ -143,8 +143,8 @@ void initServiceAddress() {
ServiceConstant.baseHost = "zhmht.swes.com.cn:27020";
} else if (AppConstants().ent_type == APPPackageType.TH.code) {
// 太和
// ServiceConstant.baseHost = "vsbst-api.he-info.com";
ServiceConstant.baseHost = "vsbs-test.he-info.cn";
ServiceConstant.baseHost = "vsbst-api.he-info.com";
// ServiceConstant.baseHost = "vsbs-test.he-info.cn";
} else {
//默认
ServiceConstant.baseHost = "vsbst-api.he-info.com";

View File

@@ -56,66 +56,6 @@ getOnePicker(BuildContext context, List arr, int checkIndex,
);
}
// Widget getOnePickers(
// BuildContext context,
// List arr,
// RxInt selectedIndex, {
// String unit = '',
// bool looping = false,
// void Function(int)? onChanged,
// bool isMonthName = false,
// Key? pickerKey,
// }) {
// ThemeController themeController = Get.find();
// final bool isEn = Get.locale?.languageCode.startsWith('en') ?? false;
// return Obx(() {
// final dynamicKey = ValueKey('picker_${arr.length}_${selectedIndex.value}');
// return CupertinoPicker.builder(
// key: pickerKey ?? dynamicKey,
// itemExtent: 90.rpx,
// useMagnifier: false,
// magnification: 1,
// diameterRatio: 1.3,
// squeeze: 1,
// scrollController:
// FixedExtentScrollController(initialItem: selectedIndex.value),
// selectionOverlay: Container(),
// onSelectedItemChanged: (int index) {
// selectedIndex.value = index;
// if (onChanged != null) onChanged(index);
// },
// childCount: arr.length,
// itemBuilder: (context, index) {
// bool isSelected = index == selectedIndex.value;
// // 处理显示文本
// String displayText;
// if (isMonthName && isEn && arr[index] is int) {
// displayText = DateFormat.MMMM('en').format(DateTime(0, arr[index]));
// } else {
// // displayText = isEn ? "${arr[index]}" : "${arr[index]}$unit"; // 中文附带单位
// displayText = "${arr[index]}$unit"; // 中文附带单位
// }
// return Center(
// child: Text(
// displayText,
// style: TextStyle(
// fontFamily: 'Readex Pro',
// color: isSelected
// ? themeController.currentColor.sc3
// : const Color(0xFF9AA0B3),
// fontSize: 30.rpx,
// fontWeight: FontWeight.normal,
// ),
// ),
// );
// },
// );
// });
// }
Widget getOnePickers(
BuildContext context,
List arr,
@@ -125,6 +65,66 @@ Widget getOnePickers(
void Function(int)? onChanged,
bool isMonthName = false,
Key? pickerKey,
}) {
ThemeController themeController = Get.find();
final bool isEn = Get.locale?.languageCode.startsWith('en') ?? false;
return Obx(() {
final dynamicKey = ValueKey('picker_${arr.length}_${selectedIndex.value}');
return CupertinoPicker.builder(
key: pickerKey ?? dynamicKey,
itemExtent: 90.rpx,
useMagnifier: false,
magnification: 1,
diameterRatio: 1.3,
squeeze: 1,
scrollController:
FixedExtentScrollController(initialItem: selectedIndex.value),
selectionOverlay: Container(),
onSelectedItemChanged: (int index) {
selectedIndex.value = index;
if (onChanged != null) onChanged(index);
},
childCount: arr.length,
itemBuilder: (context, index) {
bool isSelected = index == selectedIndex.value;
// 处理显示文本
String displayText;
if (isMonthName && isEn && arr[index] is int) {
displayText = DateFormat.MMMM('en').format(DateTime(0, arr[index]));
} else {
// displayText = isEn ? "${arr[index]}" : "${arr[index]}$unit"; // 中文附带单位
displayText = "${arr[index]}$unit"; // 中文附带单位
}
return Center(
child: Text(
displayText,
style: TextStyle(
fontFamily: 'Readex Pro',
color: isSelected
? themeController.currentColor.sc3
: const Color(0xFF9AA0B3),
fontSize: 30.rpx,
fontWeight: FontWeight.normal,
),
),
);
},
);
});
}
Widget getOnePickersSpe(
BuildContext context,
List arr,
RxInt selectedIndex, {
String unit = '',
bool looping = false,
void Function(int)? onChanged,
bool isMonthName = false,
Key? pickerKey,
/// ⭐ 新增:可选的自定义显示,但不影响旧用法
String Function(dynamic value)? customDisplay,

View File

@@ -207,6 +207,7 @@ class THShareDeviceDetailWidget extends GetView {
return;
}
await _updateDeviceInfo(context);
Get.back();
},
child: Container(
width: MediaQuery.sizeOf(context).width,
@@ -341,10 +342,10 @@ class THShareDeviceDetailWidget extends GetView {
),
// 解除分享按钮
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
0,
0,
padding: EdgeInsetsDirectional.fromSTEB(
100.rpx,
0,
100.rpx,
AppConstants.page_button_bottom_padding,
),
child: Container(
@@ -352,12 +353,13 @@ class THShareDeviceDetailWidget extends GetView {
height: MediaQuery.sizeOf(context).height * 0.056,
constraints: const BoxConstraints(minHeight: 46),
decoration: BoxDecoration(
color:
FlutterFlowTheme.of(context).secondaryBackground,
color: Colors.transparent,
borderRadius: BorderRadius.circular(16.rpx),
),
child: CustomCard(
borderRadius: 16.rpx,
// borderRadius: 16.rpx,
borderRadius:
AppConstants().button_container_radius, // 圆角半径
gradientDirection: GradientDirection.vertical,
onTap: () async {
if (uid != null) {
@@ -402,12 +404,8 @@ class THShareDeviceDetailWidget extends GetView {
}, onCancel: () {});
}
},
colors: const [
Color(0xFFFCFCFC),
Color(0xFFF8FAF9),
Color(0XFFECF6F3),
Color(0XFFD9F0E9),
Color(0xFFCEECE3)
colors: [
themeController.currentColor.sc9,
],
child: Container(
width: double.infinity,
@@ -419,7 +417,7 @@ class THShareDeviceDetailWidget extends GetView {
child: Text(
"解除分享".tr,
style: TextStyle(
color: const Color(0xFF003058),
color: themeController.currentColor.sc3,
fontSize: 30.rpx,
),
),
@@ -440,6 +438,7 @@ class THShareDeviceDetailWidget extends GetView {
// 构建数据项列表k:v格式
List<Widget> _buildDataItems() {
List<Widget> widgets = [];
bool isFirst = true; // 标记第一个有效元素
for (var item in dataList) {
// 只显示包含k和v的项
@@ -450,7 +449,7 @@ class THShareDeviceDetailWidget extends GetView {
String key = item['k'].toString();
String value = item['v'].toString();
// 跳过opType相关的显示,因为我们在下面单独处理了
// 跳过 opType
if (key.toLowerCase().contains('optype')) {
continue;
}
@@ -462,13 +461,17 @@ class THShareDeviceDetailWidget extends GetView {
'$key: $value',
style: TextStyle(
fontFamily: 'Readex Pro',
color: key == '名称' ? Color(0xFFFFFFFF) : Color(0xFF9EA4B7),
fontSize: key == '名称' ? 28.rpx : 20.rpx,
color:
isFirst ? const Color(0xFFFFFFFF) : const Color(0xFF9EA4B7),
fontSize: isFirst ? 28.rpx : 20.rpx,
letterSpacing: 0.0,
),
),
),
);
// 第一个有效元素处理完后,标记为 false
isFirst = false;
}
}

View File

@@ -1787,7 +1787,8 @@ Future<String?> showMessageConfirmDialog({
enableBorder: true,
borderColor: themeController.currentColor.sc4,
gradientDirection: GradientDirection.vertical,
borderRadius: 16.rpx,
// borderRadius: 16.rpx,
borderRadius: AppConstants().button_container_radius,
onTap: () {
Get.back(result: 'cancel');
},
@@ -1798,12 +1799,13 @@ Future<String?> showMessageConfirmDialog({
alignment: Alignment.center,
child: Text(
'取消'.tr,
style: TextStyle(fontSize: 26.rpx, color: Colors.black),
style: TextStyle(fontSize: 26.rpx, color: Colors.white),
),
),
),
CustomCard(
borderRadius: 16.rpx,
// borderRadius: 16.rpx,
borderRadius: AppConstants().button_container_radius,
onTap: () {
Get.back(result: 'confirm');
},

View File

@@ -216,8 +216,7 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
height:
33.rpx *
0.6,
color: const Color(
0xFF6BFDAC),
color: themeController.currentColor.sc2,
),
),
)

View File

@@ -187,8 +187,21 @@ class _MinePageState extends State<MinePage> {
Text(
limitText(
login == 1
? userInfoController
.model.user?.nick_name
? (userInfoController
.model
.user
?.nick_name ==
null ||
userInfoController
.model
.user
?.nick_name ==
""
? '未命名'.tr
: userInfoController
.model
.user
?.nick_name)
: '未命名'.tr,
AppConstants()
.text_length, // 这里设置最大长度,按你需求改,比如 6~10 字符
@@ -259,7 +272,7 @@ class _MinePageState extends State<MinePage> {
style: TextStyle(
fontFamily: 'Inter',
color: themeController
.currentColor.sc3,
.currentColor.sc2,
fontSize: AppConstants()
.normal_text_fontSize,
letterSpacing: 0.0,
@@ -690,7 +703,7 @@ class _MinePageState extends State<MinePage> {
mainAxisSize: MainAxisSize.max,
children: [
Text(
'V1.0.2512.08',
'V1.0.2512.09',
style: TextStyle(
fontFamily: 'Inter',
// color: Color(0xFFD9E3EB),

View File

@@ -564,7 +564,6 @@ Future<void> showHeightPickerDialog(
// int tempIndex = selectedIndex;
final RxInt tempIndex = RxInt(selectedIndex); // ✅ 改为 RxInt
ThemeController themeController = Get.find();
await showDialog(
context: context,
barrierDismissible: true,
@@ -1134,11 +1133,10 @@ Future<void> showIntervalPickerDialog(
),
SizedBox(
height: 240.rpx,
child: getOnePickers(
child: getOnePickersSpe(
context,
values,
tempIndex,
/// → 替换显示文本(核心)
customDisplay: (val) => formatValue(val),
),

View File

@@ -225,7 +225,8 @@ class _SettingPageState extends State<SettingPage> {
.language_name!,
style: TextStyle(
fontFamily: 'Inter',
color: Color(0xFFD9E3EB),
color: themeController
.currentColor.sc2,
fontSize: 26.rpx,
letterSpacing: 0.0,
),
@@ -609,7 +610,7 @@ class _SettingPageState extends State<SettingPage> {
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0.rpx, 50.rpx, 0.rpx, 100.rpx),
0.rpx, 100.rpx, 0.rpx, 100.rpx),
child: ClickableContainer(
borderRadius:
AppConstants().button_container_radius, // 圆角半径
@@ -656,7 +657,7 @@ class _SettingPageState extends State<SettingPage> {
),
),
].divide(SizedBox(
height: 17.rpx,
height: 4.rpx,
))),
),
),

View File

@@ -116,8 +116,10 @@ class _UpdateUserEmailPageState extends State<UpdateUserEmailPage> {
userInfoController.model.user!.tmpNickName = null;
loginController.model.updatePhone = null;
await userInfoController.getUserInfo();
userInfoController.model.user!.tmpNickName = userInfoController.model.user!.nick_name;
userInfoController.model.user!.tmpHead = userInfoController.model.user!.avatar;
userInfoController.model.user!.tmpNickName =
userInfoController.model.user!.nick_name;
userInfoController.model.user!.tmpHead =
userInfoController.model.user!.avatar;
userInfoController.updateAll();
Get.back();
}
@@ -177,7 +179,7 @@ class _UpdateUserEmailPageState extends State<UpdateUserEmailPage> {
padding: EdgeInsetsDirectional.fromSTEB(
60.rpx, 0, 35.rpx, 0),
child: Text(
"原邮箱号" + ":" + "${getHideEmail()}",
"原邮箱号".tr + ":" + "${getHideEmail()}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().normal_text_fontSize,
@@ -199,7 +201,7 @@ class _UpdateUserEmailPageState extends State<UpdateUserEmailPage> {
alignment: AlignmentDirectional(-1, 0),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 20.rpx),
0, 20.rpx, 0, 20.rpx),
child: Container(
width: double.infinity,
height: bodySize.maxHeight * 0.056,
@@ -354,7 +356,7 @@ class _UpdateUserEmailPageState extends State<UpdateUserEmailPage> {
alignment: AlignmentDirectional(-1, 0),
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
0, 0.rpx, 0, 0),
0, 0.rpx, 0, 20.rpx),
child: Container(
height: bodySize.maxHeight * 0.056,
width: double.infinity,

View File

@@ -418,7 +418,9 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
letterSpacing: 0.0,
),
),
].divide(SizedBox(width: 22.rpx)),
SizedBox(width: 22.rpx),
getNowInfoByType('phone'),
],
),
Row(
mainAxisSize: MainAxisSize.max,
@@ -427,9 +429,8 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
getTextByUserInfo('phone'),
style: TextStyle(
fontFamily: 'Inter',
// color: Color(0xFFD9E3EB),
color: themeController
.currentColor.sc2,
color: getColorByUserInfo(
'phone'),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
@@ -485,7 +486,9 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
letterSpacing: 0.0,
),
),
].divide(SizedBox(width: 22.rpx)),
SizedBox(width: 22.rpx),
getNowInfoByType('email'),
],
),
Row(
mainAxisSize: MainAxisSize.max,
@@ -495,8 +498,8 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
style: TextStyle(
fontFamily: 'Inter',
// color: Color(0xFFD9E3EB),
color: themeController
.currentColor.sc2,
color: getColorByUserInfo(
'email'),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
@@ -589,13 +592,8 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
style: TextStyle(
fontFamily: 'Inter',
// color: Color(0xFFD9E3EB),
color: getTextByUserInfo(
'wechat') ==
"解绑".tr
? themeController
.currentColor.sc4
: themeController
.currentColor.sc2,
color: getColorByUserInfo(
'wechat'),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
@@ -621,7 +619,6 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
),
),
),
],
),
),
@@ -669,25 +666,95 @@ class _UpdateUserPageState extends State<UpdateUserPage> {
}
if (type == "phone") {
if (userInfo.phone == null || userInfo.phone!.isEmpty) {
return "更换".tr;
return "去绑定".tr;
} else {
return "换绑".tr;
}
}
if (type == "email") {
if (userInfo.email == null || userInfo.email!.isEmpty) {
return "绑定".tr;
return "绑定".tr;
} else {
return "换绑".tr;
}
}
if (type == "wechat") {
if (userInfo.bindWx == null || userInfo.bindWx == false) {
return "绑定".tr;
return "绑定".tr;
} else {
return "解绑".tr;
}
}
return "";
}
Color getColorByUserInfo(String type) {
final text = getTextByUserInfo(type);
// 去绑定 = 未绑定
return text == "去绑定".tr
? themeController.currentColor.sc4
: themeController.currentColor.sc2;
}
getNowInfoByType(String type) {
UserInfoController userInfoController = Get.find();
UserModel userInfo = userInfoController.model.user!;
if (type == "phone") {
if (userInfo.phone == null || userInfo.phone!.isEmpty) {
return Text(
"(" + "暂未绑定".tr + ")",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
);
} else {
return Text(
"(" + "${getHidePhone()}" + ")",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
);
}
}
if (type == "email") {
if (userInfo.email == null || userInfo.email!.isEmpty) {
return Text(
"(" + "暂未绑定".tr + ")",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
);
} else {
return Text(
"(" + "${getHideEmail()}" + ")",
style: TextStyle(
color: themeController.currentColor.sc4,
fontSize: AppConstants().normal_text_fontSize,
),
);
}
}
return Container();
}
getHidePhone() {
UserModel userModel = userInfoController.model.user!;
if (userModel.phone == null || userModel.phone == "") {
return "暂无".tr;
}
return "${userModel.phone!.substring(0, 3)}****${userModel.phone!.substring(7, 11)}";
}
getHideEmail() {
UserModel userModel = userInfoController.model.user!;
if (userModel.email == null || userModel.email == "") {
return "暂无".tr;
}
return userModel.email!
.replaceRange(3, userModel.email!.length - 3, "****");
}
}