更新消息设置

This commit is contained in:
wyf
2025-12-05 17:37:01 +08:00
parent 1cc26aa46d
commit db51c42664
44 changed files with 7510 additions and 1059 deletions

View File

@@ -56,6 +56,66 @@ 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,
@@ -65,6 +125,9 @@ Widget getOnePickers(
void Function(int)? onChanged,
bool isMonthName = false,
Key? pickerKey,
/// ⭐ 新增:可选的自定义显示,但不影响旧用法
String Function(dynamic value)? customDisplay,
}) {
ThemeController themeController = Get.find();
final bool isEn = Get.locale?.languageCode.startsWith('en') ?? false;
@@ -89,13 +152,26 @@ Widget getOnePickers(
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"; // 中文附带单位
String value = arr[index].toString();
String displayText = "";
// ⭐ 1. 优先使用自定义展示
if (customDisplay != null) {
String? custom = customDisplay(arr[index]);
if (custom != null && custom.isNotEmpty) {
displayText = custom;
}
}
// ⭐ 2. 若自定义没给或返回空,则使用你原本的逻辑
if (displayText.isEmpty) {
if (isMonthName && isEn && arr[index] is int) {
// 英文月份
displayText = DateFormat.MMMM('en').format(DateTime(0, arr[index]));
} else {
// 中文 + 单位(你原来的逻辑)
displayText = "$value$unit";
}
}
return Center(
@@ -1839,3 +1915,165 @@ DialogColorScheme _getDialogColors(int entType) {
);
}
}
Future showTHDayTimeSelectionDialog(
BuildContext context, {
required List<int> dayTimeArr,
Function(List<int>)? checkChange,
String title = "选择时间",
}) {
ThemeController themeController = Get.find();
final List<int> hours = List.generate(24, (i) => i);
final List<int> minutes = List.generate(60, (i) => i);
final RxInt hoursIndex = hours.indexOf(dayTimeArr[0]).obs;
final RxInt minutesIndex = minutes.indexOf(dayTimeArr[1]).obs;
return showDialog(
context: context,
barrierDismissible: true,
builder: (BuildContext context) {
return Stack(
children: [
Positioned(
bottom: 0,
left: 0,
right: 0,
child: Material(
color: Colors.transparent,
child: Dialog(
backgroundColor: themeController.currentColor.sc17, // 修改:使用主题颜色
insetPadding: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(0),
),
child: Container(
width: double.infinity,
padding: EdgeInsets.fromLTRB(0.rpx, 0.rpx, 0.rpx, 90.rpx),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
// 顶部栏:取消 - 标题 - 确定
Container(
padding:
EdgeInsets.fromLTRB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
color: themeController.currentColor.sc5, // 修改:使用主题颜色
height: 80.rpx,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.zero,
onTap: () => Navigator.of(context).pop(),
child: Container(
width: 110.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text(
"取消".tr,
style: TextStyle(
fontSize: 30.rpx,
color: Colors.white, // 保持不变
),
),
),
),
Text(
title.tr,
style: TextStyle(
fontFamily: 'Readex Pro',
color: themeController
.currentColor.sc3, // 修改:使用主题颜色
fontSize: 30.rpx,
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.zero,
onTap: () {
checkChange?.call([
hours[hoursIndex.value],
minutes[minutesIndex.value],
]);
Get.back();
},
child: Container(
width: 110.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text(
"确定".tr,
style: TextStyle(
fontSize: 30.rpx,
color: themeController
.currentColor.sc2, // 修改:使用主题颜色
),
),
),
),
],
),
),
SizedBox(height: 20.rpx),
Stack(
children: [
Positioned.fill(
child: IgnorePointer(
child: Center(
child: Container(
height: 90.rpx,
margin:
EdgeInsets.symmetric(horizontal: 95.rpx),
decoration: BoxDecoration(
color: themeController
.currentColor.sc2, // 修改:使用主题颜色
borderRadius: BorderRadius.circular(16.rpx),
),
),
),
),
),
SizedBox(
height: 240.rpx,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 95.rpx),
child: Row(
children: [
Expanded(
child: getOnePickers(
context,
hours,
hoursIndex,
unit: "".tr,
),
),
Expanded(
child: getOnePickers(
context,
minutes,
minutesIndex,
unit: "".tr,
),
),
],
),
),
),
],
),
],
),
),
),
),
),
],
);
},
);
}