多语言

This commit is contained in:
czz
2025-07-30 16:48:48 +08:00
parent 92b6896176
commit 300e3b31f6
96 changed files with 3741 additions and 2710 deletions

View File

@@ -1,6 +1,7 @@
import 'package:ef/ef.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutterflow_ui/flutterflow_ui.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
@@ -53,16 +54,17 @@ getOnePicker(BuildContext context, List arr, int checkIndex,
);
}
//支持选中时文字变色
getOnePickers(
Widget getOnePickers(
BuildContext context,
List arr,
RxInt selectedIndex, {
String unit = '',
bool looping = false,
void Function(int)? onChanged,
bool isMonthName = false,
}) {
ThemeController themeController = Get.find();
final bool isEn = Get.locale?.languageCode.startsWith('en') ?? false;
return Obx(() {
return CupertinoPicker.builder(
@@ -71,24 +73,33 @@ getOnePickers(
magnification: 1,
diameterRatio: 3,
squeeze: 1,
// looping: looping,
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"; // 中文附带单位
}
return Center(
child: Text(
"${arr[index]}$unit",
displayText,
style: TextStyle(
fontFamily: 'Readex Pro',
color: isSelected
? const Color(0xFF011D33) // ✅ 选中项颜色
: Color(0xFF9AA0B3), // 未选中颜色
? const Color(0xFF011D33)
: const Color(0xFF9AA0B3),
fontSize: 30.rpx,
fontWeight: FontWeight.normal,
),
@@ -99,11 +110,14 @@ getOnePickers(
});
}
Future showDateSelectionDialog(BuildContext context,
{required DateTime checkDate,
Function? checkChange,
String title = "选择生日"}) {
ThemeController themeController = Get.find();
final bool isEn = Get.locale?.languageCode.startsWith('en') ?? false;
Color checkColor = stringToColor("#D3B684");
final List<int> years = List.generate(100, (i) => DateTime.now().year - i)
@@ -162,10 +176,10 @@ Future showDateSelectionDialog(BuildContext context,
padding: EdgeInsets.zero,
onTap: () => Navigator.of(context).pop(),
child: Container(
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text("取消",
child: Text("取消".tr,
style: TextStyle(
fontSize: 30.rpx, color: Colors.white)),
),
@@ -192,10 +206,10 @@ Future showDateSelectionDialog(BuildContext context,
Get.back();
},
child: Container(
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text("确定",
child: Text("确定".tr,
style: TextStyle(
fontSize: 30.rpx,
color: stringToColor("#84F5FF"))),
@@ -226,34 +240,61 @@ Future showDateSelectionDialog(BuildContext context,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 95.rpx),
child: Row(
children: [
Expanded(
child: getOnePickers(
context,
years,
yearIndex,
unit: "",
onChanged: (_) => updateDays(),
),
),
Expanded(
child: getOnePickers(
context,
months,
monthIndex,
unit: "",
onChanged: (_) => updateDays(),
),
),
Expanded(
child: getOnePickers(
context,
daysSelect,
dayIndex,
unit: "",
),
),
],
children: isEn
? [
Expanded(
child: getOnePickers(
context,
months,
monthIndex,
isMonthName: true,
onChanged: (_) => updateDays(),
),
),
Expanded(
child: getOnePickers(
context,
daysSelect,
dayIndex,
),
),
Expanded(
child: getOnePickers(
context,
years,
yearIndex,
onChanged: (_) => updateDays(),
),
),
]
: [
Expanded(
child: getOnePickers(
context,
years,
yearIndex,
unit: "",
onChanged: (_) => updateDays(),
),
),
Expanded(
child: getOnePickers(
context,
months,
monthIndex,
unit: "",
onChanged: (_) => updateDays(),
),
),
Expanded(
child: getOnePickers(
context,
daysSelect,
dayIndex,
unit: "",
),
),
],
),
),
),
@@ -271,153 +312,6 @@ Future showDateSelectionDialog(BuildContext context,
);
}
// Future showMonthSelectionDialog(
// BuildContext context, {
// required DateTime checkDate,
// Function(DateTime)? checkChange,
// String title = "选择月份",
// }) {
// ThemeController themeController = Get.find();
// final List<int> years = List.generate(100, (i) => DateTime.now().year - i)
// ..sort();
// final List<int> months = List.generate(12, (i) => i + 1);
// final RxInt yearIndex = years.indexOf(checkDate.year).obs;
// final RxInt monthIndex = months.indexOf(checkDate.month).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: const Color(0xFF003058),
// insetPadding: EdgeInsets.zero,
// shape: RoundedRectangleBorder(
// borderRadius: BorderRadius.circular(0),
// ),
// child: Container(
// width: double.infinity,
// padding: EdgeInsets.fromLTRB(30.rpx, 10.rpx, 30.rpx, 90.rpx),
// child: Column(
// mainAxisSize: MainAxisSize.min,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: <Widget>[
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [
// ClickableContainer(
// backgroundColor: Colors.transparent,
// highlightColor: Colors.transparent,
// padding: EdgeInsets.zero,
// onTap: () => Navigator.of(context).pop(),
// child: Container(
// width: 100.rpx,
// height: 60.rpx,
// alignment: Alignment.center,
// child: Text("取消",
// style: TextStyle(
// fontSize: 30.rpx, color: Colors.white)),
// ),
// ),
// Text(
// title,
// style: TextStyle(
// fontFamily: 'Readex Pro',
// color: themeController.currentColor.sc3,
// fontSize: 30.rpx,
// ),
// ),
// ClickableContainer(
// backgroundColor: Colors.transparent,
// highlightColor: Colors.transparent,
// padding: EdgeInsets.zero,
// onTap: () {
// final selectedDate = DateTime(
// years[yearIndex.value],
// months[monthIndex.value],
// );
// Navigator.of(context).pop();
// checkChange?.call(selectedDate);
// },
// child: Container(
// width: 100.rpx,
// height: 60.rpx,
// alignment: Alignment.center,
// child: Text("确定",
// style: TextStyle(
// fontSize: 30.rpx,
// color: stringToColor("#84F5FF"))),
// ),
// ),
// ],
// ),
// 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: const Color(0xFF84F5FF),
// borderRadius: BorderRadius.circular(16.rpx),
// ),
// ),
// ),
// ),
// ),
// SizedBox(
// height: 240.rpx,
// child: Padding(
// padding: EdgeInsets.symmetric(horizontal: 95.rpx),
// child: Row(
// children: [
// Expanded(
// child: getOnePickers(
// context,
// years,
// yearIndex,
// unit: "年",
// ),
// ),
// Expanded(
// child: getOnePickers(
// context,
// months,
// monthIndex,
// unit: "月",
// ),
// ),
// ],
// ),
// ),
// ),
// ],
// ),
// ],
// ),
// ),
// ),
// ),
// ),
// ],
// );
// },
// );
// }
Future showMonthSelectionDialog(
BuildContext context, {
required DateTime checkDate,
@@ -498,11 +392,11 @@ Future showMonthSelectionDialog(
padding: EdgeInsets.zero,
onTap: () => Navigator.of(context).pop(),
child: Container(
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text(
"取消",
"取消".tr,
style: TextStyle(
fontSize: 30.rpx,
color: Colors.white,
@@ -531,11 +425,11 @@ Future showMonthSelectionDialog(
checkChange?.call(selectedDate);
},
child: Container(
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text(
"确定",
"确定".tr,
style: TextStyle(
fontSize: 30.rpx,
color: stringToColor("#84F5FF"),
@@ -576,7 +470,7 @@ Future showMonthSelectionDialog(
context,
years,
yearIndex,
unit: "",
unit: "".tr,
),
),
Expanded(
@@ -584,7 +478,7 @@ Future showMonthSelectionDialog(
context,
months, // 注意这里取 .value
monthIndex,
unit: "",
unit: "".tr,
),
),
],
@@ -653,10 +547,10 @@ Future<void> showWeightPickerDialog(
},
child: Container(
alignment: Alignment.center,
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
child: Text(
"取消",
"取消".tr,
style: TextStyle(
fontSize: 30.rpx,
color: Colors.white,
@@ -680,10 +574,10 @@ Future<void> showWeightPickerDialog(
},
child: Container(
alignment: Alignment.center,
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
child: Text(
"确定",
"确定".tr,
style: TextStyle(
fontSize: 30.rpx,
color: stringToColor("#84F5FF"),
@@ -780,10 +674,10 @@ Future<void> showHeightPickerDialog(
},
child: Container(
alignment: Alignment.center,
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
child: Text(
"取消",
"取消".tr,
style: TextStyle(
fontSize: 30.rpx,
color: Colors.white,
@@ -807,10 +701,10 @@ Future<void> showHeightPickerDialog(
},
child: Container(
alignment: Alignment.center,
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
child: Text(
"确定",
"确定".tr,
style: TextStyle(
fontSize: 30.rpx,
color: stringToColor("#84F5FF"),
@@ -1046,7 +940,7 @@ Future showDayTimeSelectionDialog(
padding: EdgeInsets.zero,
onTap: () => Navigator.of(context).pop(),
child: Container(
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text("取消".tr,
@@ -1074,7 +968,7 @@ Future showDayTimeSelectionDialog(
Get.back();
},
child: Container(
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
alignment: Alignment.center,
child: Text("确定".tr,
@@ -1190,7 +1084,7 @@ Future showOneSelectionDialog(
onTap: () => Get.back(),
child: Container(
alignment: Alignment.center,
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
child: Text("取消".tr,
style: TextStyle(
@@ -1213,7 +1107,7 @@ Future showOneSelectionDialog(
},
child: Container(
alignment: Alignment.center,
width: 100.rpx,
width: 110.rpx,
height: 60.rpx,
child: Text("确定".tr,
style: TextStyle(