更新城市选择语言

This commit is contained in:
wyf
2025-12-17 17:24:00 +08:00
parent 0ad6a1e326
commit 8e7411cf92
9 changed files with 309 additions and 177 deletions

View File

@@ -40,9 +40,9 @@ Future<List<CityModel>> loadCityData() async {
// 定义城市选择器颜色配置
class CitySelectionColors {
final Color? pickerBackgroundColor; // 选择器整体背景色
final Color? confirmTextColor; // 确定按钮文字颜色
final Color? selectedCityColor; // 选中的城市背景色
final Color? confirmTextColor; // 确定按钮文字颜色
final Color? selectedCityColor; // 选中的城市背景色
const CitySelectionColors({
this.pickerBackgroundColor,
this.confirmTextColor,
@@ -59,12 +59,15 @@ Future showCitySelectionDialog(
CitySelectionColors? colors, // 新增:颜色配置参数
}) {
ThemeController themeController = Get.find();
final bool isChinese = Get.locale?.languageCode == 'zh' ?? true;
final bool isChinese = Get.locale?.languageCode == 'zh_CN' ?? true;
// 使用传入的颜色,如果没传则使用主题颜色
final Color pickerBackgroundColor = colors?.pickerBackgroundColor ?? themeController.currentColor.sc17;
final Color confirmTextColor = colors?.confirmTextColor ?? themeController.currentColor.sc2;
final Color selectedCityColor = colors?.selectedCityColor ?? themeController.currentColor.sc2;
final Color pickerBackgroundColor =
colors?.pickerBackgroundColor ?? themeController.currentColor.sc17;
final Color confirmTextColor =
colors?.confirmTextColor ?? themeController.currentColor.sc2;
final Color selectedCityColor =
colors?.selectedCityColor ?? themeController.currentColor.sc2;
final RxList<String> countries = <String>[].obs;
final RxList<String> provinces = <String>[].obs;
@@ -263,7 +266,7 @@ Future showCitySelectionDialog(
// 数据加载中
if (snapshot.connectionState == ConnectionState.waiting) {
return _buildLoadingBottomSheet(
themeController,
themeController,
pickerBackgroundColor,
confirmTextColor,
);
@@ -272,8 +275,8 @@ Future showCitySelectionDialog(
// 数据加载错误
if (snapshot.hasError || !snapshot.hasData) {
return _buildErrorBottomSheet(
themeController,
context,
themeController,
context,
pickerBackgroundColor,
confirmTextColor,
);
@@ -282,9 +285,10 @@ Future showCitySelectionDialog(
final cityData = snapshot.data!;
// 只在第一次初始化数据
if (countries.isEmpty) {
initializePickerData(cityData);
}
// if (countries.isEmpty) {
// }
initializePickerData(cityData);
return _buildCityPickerContent(
context,
@@ -796,4 +800,4 @@ Widget _buildErrorBottomSheet(
],
),
);
}
}