更新城市选择
This commit is contained in:
@@ -6,6 +6,7 @@ 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/pojo/city.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';
|
||||
@@ -18,6 +19,7 @@ import 'package:vbvs_app/controller/person/person_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
import 'package:vbvs_app/pages/person/select_city.dart';
|
||||
import 'package:vbvs_app/pages/person/select_time.dart';
|
||||
|
||||
class PersonPage extends StatefulWidget {
|
||||
@@ -34,6 +36,9 @@ class _EPageState extends State<PersonPage> {
|
||||
PersonController personController = Get.find();
|
||||
ThemeController themeController = Get.find();
|
||||
|
||||
final CityModelController cityController = Get.find<CityModelController>();
|
||||
late Future<List<CityModel>> cityDataFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -55,6 +60,10 @@ class _EPageState extends State<PersonPage> {
|
||||
personController.weight.value = "";
|
||||
personController.height.value = "";
|
||||
personController.dateTime = null;
|
||||
|
||||
cityDataFuture = cityController.loadAndSetCityData().then((success) {
|
||||
return cityController.cityList;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -533,6 +542,65 @@ class _EPageState extends State<PersonPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
70.rpx, 50.rpx, 70.rpx, 0),
|
||||
child: Container(
|
||||
height: 100.rpx,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(50.rpx),
|
||||
border: Border.all(
|
||||
color: themeController.currentColor.sc4
|
||||
.withOpacity(0.5),
|
||||
width: AppConstants().border_width,
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(FocusNode());
|
||||
Future.delayed(Duration(milliseconds: 250),
|
||||
() {
|
||||
// 使用当前选中的城市数据,如果没有则创建默认
|
||||
CityModel currentCity =
|
||||
personController.cityModel ??
|
||||
CityModel();
|
||||
showCitySelectionDialog(
|
||||
context,
|
||||
selectedCity: currentCity,
|
||||
onCityChanged: (CityModel newCity) {
|
||||
// 处理城市选择变化
|
||||
print(
|
||||
'Selected city: ${newCity.toJson()}');
|
||||
personController.cityModel = newCity;
|
||||
personController.updateAll();
|
||||
},
|
||||
title: "选择城市".tr,
|
||||
cityDataFuture:
|
||||
cityDataFuture, // 传入预加载的数据
|
||||
);
|
||||
});
|
||||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
_getDetailedCityDisplayText(
|
||||
personController.cityModel),
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: personController.cityModel !=
|
||||
null
|
||||
? themeController.currentColor.sc3
|
||||
: themeController.currentColor.sc4,
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 117.rpx, 0, 0),
|
||||
@@ -696,6 +764,29 @@ class _EPageState extends State<PersonPage> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getDetailedCityDisplayText(CityModel? cityModel) {
|
||||
if (cityModel == null) {
|
||||
return '选择城市'.tr;
|
||||
}
|
||||
|
||||
// 根据数据层级显示不同的格式
|
||||
if (cityModel.city != null && cityModel.city!.isNotEmpty) {
|
||||
// 三级数据:国家-省份-城市
|
||||
return '${cityModel.country ?? ''}-${cityModel.province ?? ''}-${cityModel.city ?? cityModel.value ?? ''}';
|
||||
} else if (cityModel.province != null && cityModel.province!.isNotEmpty) {
|
||||
// 二级数据:国家-省份
|
||||
return '${cityModel.country ?? ''}-${cityModel.province ?? cityModel.value ?? ''}';
|
||||
} else if (cityModel.country != null && cityModel.country!.isNotEmpty) {
|
||||
// 一级数据:国家
|
||||
return cityModel.country!;
|
||||
} else if (cityModel.value != null && cityModel.value!.isNotEmpty) {
|
||||
// 只有 value 字段
|
||||
return cityModel.value!;
|
||||
} else {
|
||||
return '选择城市'.tr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void updateDeviceBindStatus(String mac) {
|
||||
|
||||
1221
lib/pages/person/select_city.dart
Normal file
1221
lib/pages/person/select_city.dart
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,17 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/pojo/city.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/language/AppLanguage.dart';
|
||||
import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
|
||||
// Future showDateSelectionDialog(BuildContext context,
|
||||
@@ -814,3 +820,4 @@ Future<void> showWeightPickerDialog(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ 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/pojo/city.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';
|
||||
@@ -20,6 +21,7 @@ import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/enum/BindType.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
import 'package:vbvs_app/pages/person/select_city.dart';
|
||||
import 'package:vbvs_app/pages/person/select_time.dart';
|
||||
|
||||
class UpdatePersonPage extends StatefulWidget {
|
||||
@@ -38,6 +40,9 @@ class _UpdatePageState extends State<UpdatePersonPage> {
|
||||
BodyDeviceController bodyDeviceController = Get.find();
|
||||
ThemeController themeController = Get.find();
|
||||
|
||||
final CityModelController cityController = Get.find<CityModelController>();
|
||||
late Future<List<CityModel>> cityDataFuture;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -51,6 +56,9 @@ class _UpdatePageState extends State<UpdatePersonPage> {
|
||||
);
|
||||
}
|
||||
});
|
||||
cityDataFuture = cityController.loadAndSetCityData().then((success) {
|
||||
return cityController.cityList;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -66,6 +74,7 @@ class _UpdatePageState extends State<UpdatePersonPage> {
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: Colors.transparent, // 加上这一行
|
||||
appBar: AppBar(
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
@@ -575,6 +584,72 @@ class _UpdatePageState extends State<UpdatePersonPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
70.rpx, 50.rpx, 70.rpx, 0),
|
||||
child: Container(
|
||||
height: 100.rpx,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(50.rpx),
|
||||
border: Border.all(
|
||||
color: themeController.currentColor.sc4
|
||||
.withOpacity(0.5),
|
||||
width: AppConstants().border_width,
|
||||
),
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
if (widget.status == BindType.share.code) {
|
||||
TopSlideNotification.show(context,
|
||||
text: "被分享用户只能修改用户名称",
|
||||
textColor:
|
||||
themeController.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
FocusScope.of(context)
|
||||
.requestFocus(FocusNode());
|
||||
Future.delayed(Duration(milliseconds: 250),
|
||||
() {
|
||||
// 使用当前选中的城市数据,如果没有则创建默认
|
||||
CityModel currentCity =
|
||||
personController.cityModel ??
|
||||
CityModel();
|
||||
showCitySelectionDialog(
|
||||
context,
|
||||
selectedCity: currentCity,
|
||||
onCityChanged: (CityModel newCity) {
|
||||
// 处理城市选择变化
|
||||
print(
|
||||
'Selected city: ${newCity.toJson()}');
|
||||
personController.cityModel = newCity;
|
||||
personController.updateAll();
|
||||
},
|
||||
title: "选择城市".tr,
|
||||
cityDataFuture:
|
||||
cityDataFuture, // 传入预加载的数据
|
||||
);
|
||||
});
|
||||
},
|
||||
child: Center(
|
||||
child: Text(
|
||||
_getDetailedCityDisplayText(
|
||||
personController.cityModel),
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Readex Pro',
|
||||
color: personController.cityModel !=
|
||||
null
|
||||
? themeController.currentColor.sc3
|
||||
: themeController.currentColor.sc4,
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize,
|
||||
letterSpacing: 0,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 117.rpx, 0, 0),
|
||||
@@ -782,4 +857,29 @@ class _UpdatePageState extends State<UpdatePersonPage> {
|
||||
onFailure: (res) {},
|
||||
);
|
||||
}
|
||||
|
||||
// 获取城市显示文本
|
||||
// 更详细的显示逻辑(可选)
|
||||
String _getDetailedCityDisplayText(CityModel? cityModel) {
|
||||
if (cityModel == null) {
|
||||
return '选择城市'.tr;
|
||||
}
|
||||
|
||||
// 根据数据层级显示不同的格式
|
||||
if (cityModel.city != null && cityModel.city!.isNotEmpty) {
|
||||
// 三级数据:国家-省份-城市
|
||||
return '${cityModel.country ?? ''}-${cityModel.province ?? ''}-${cityModel.city ?? cityModel.value ?? ''}';
|
||||
} else if (cityModel.province != null && cityModel.province!.isNotEmpty) {
|
||||
// 二级数据:国家-省份
|
||||
return '${cityModel.country ?? ''}-${cityModel.province ?? cityModel.value ?? ''}';
|
||||
} else if (cityModel.country != null && cityModel.country!.isNotEmpty) {
|
||||
// 一级数据:国家
|
||||
return cityModel.country!;
|
||||
} else if (cityModel.value != null && cityModel.value!.isNotEmpty) {
|
||||
// 只有 value 字段
|
||||
return cityModel.value!;
|
||||
} else {
|
||||
return '选择城市'.tr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user