设备分享

This commit is contained in:
czz
2025-07-22 14:02:52 +08:00
parent 210617c6ff
commit 7ef7f89507
3 changed files with 276 additions and 477 deletions

View File

@@ -22,12 +22,17 @@ class ShareDeviceWidget extends GetView<MHDeviceShareController> {
final _formKey = GlobalKey<FormState>();
final _phoneController = TextEditingController();
fetchData() async {
await controller.shareDeviceList(data["mac"]);
}
@override
Widget build(BuildContext context) {
controller.model.msg = "";
controller.model.code = 0;
controller.model.type = 1;
controller.model.account = '';
fetchData();
return GestureDetector(
// onTap: () => FocusScope.of(context).unfocus(),,
child: Container(
@@ -278,135 +283,6 @@ class ShareDeviceWidget extends GetView<MHDeviceShareController> {
),
),
),
// Obx(
// () => GestureDetector(
// onTap: () {
// controller.model.type = 2;
// controller.updateAll();
// },
// child: Container(
// width: MediaQuery.sizeOf(context).width,
// constraints: const BoxConstraints(
// minHeight: 46,
// ),
// decoration: BoxDecoration(
// borderRadius:
// BorderRadius.circular(0),
// ),
// child: Row(
// mainAxisSize: MainAxisSize.max,
// mainAxisAlignment:
// MainAxisAlignment.spaceBetween,
// children: [
// Text(
// '仅允许对方查看该设备'.tr,
// style: TextStyle(
// fontFamily: 'Readex Pro',
// color: Colors.white,
// fontSize: 26.rpx,
// letterSpacing: 0.0,
// ),
// ),
// // Theme(
// // data:
// // Theme.of(context).copyWith(
// // unselectedWidgetColor: Color(
// // 0xFFC8CBD2), // 改变未选中状态边框颜色
// // ),
// // child: Radio<int>(
// // value: 2,
// // groupValue:
// // controller.model.type,
// // onChanged: (value) {
// // controller.model.type =
// // value!;
// // controller.updateAll();
// // },
// // activeColor:
// // const Color(0xFF6BFDAC),
// // materialTapTargetSize:
// // MaterialTapTargetSize
// // .shrinkWrap, // 减少内边距
// // visualDensity: VisualDensity(
// // horizontal: -4,
// // vertical: -4), // 缩小视觉密度
// // ))
// ClipOval(
// child: Container(
// height:
// MediaQuery.sizeOf(context)
// .height *
// 0.0449,
// child: AspectRatio(
// aspectRatio: 1,
// child: Center(
// child: LayoutBuilder(
// builder: (context,
// constraints) {
// double h =
// MediaQuery.sizeOf(
// context)
// .height *
// 0.0326;
// bool check = controller
// .model.type ==
// 2;
// if (check) {
// return Container(
// height: h,
// width: h,
// decoration:
// BoxDecoration(
// borderRadius:
// BorderRadius
// .circular(
// h / 2),
// border: Border.all(
// width: 1,
// color: Color(
// 0xFF6BFDAC)),
// ),
// child: Center(
// child: ClipOval(
// child: Container(
// width:
// h * 0.6,
// height:
// h * 0.6,
// color: Color(
// 0xFF6BFDAC)),
// ),
// ),
// );
// } else {
// return Container(
// height: h,
// width: h,
// decoration:
// BoxDecoration(
// borderRadius:
// BorderRadius
// .circular(
// h / 2),
// border: Border.all(
// width: 0.5,
// color: Colors
// .white),
// ),
// );
// }
// },
// ),
// ),
// ),
// ),
// ),
// ],
// ),
// ),
// ),
// ),
GestureDetector(
onTap: () {
controller.model.type = 2;
@@ -476,7 +352,6 @@ class ShareDeviceWidget extends GetView<MHDeviceShareController> {
),
),
),
Align(
alignment: const AlignmentDirectional(0, 0),
child: Padding(

View File

@@ -309,155 +309,38 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
),
getLine(),
Obx(
() => Container(
() => InkWell(
onTap: () {
// 延迟执行的代码
FocusScope.of(context)
.requestFocus(
FocusNode());
Future.delayed(
const Duration(
milliseconds: 250),
() {
showOneSelectionDialog(
context,
arr: ["", ""],
checkIndex: controller
.model
.peopleList[
index]['gender'],
checkChange: (sindex) {
controller.model.peopleList[
index]['gender'] =
sindex; // 👈 保存为 0 / 1
controller.updateAll();
});
});
},
child: Container(
margin: EdgeInsets.only(
left: 40.rpx,
right: 35.rpx),
width: double.infinity,
height: 90.rpx,
decoration: BoxDecoration(),
child: InkWell(
onTap: () {
// 延迟执行的代码
FocusScope.of(context)
.requestFocus(
FocusNode());
Future.delayed(
const Duration(
milliseconds:
250), () {
showOneSelectionDialog(
context,
arr: ["", ""],
checkIndex: controller
.model
.peopleList[index]
[
'gender'] ==
""
? 0
: 1,
checkChange:
(sindex) {
controller.model.peopleList[
index]
['gender'] =
sindex; // 👈 保存为 0 / 1
controller
.updateAll();
});
});
},
child: Row(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
'性别',
style: TextStyle(
fontFamily:
'Readex Pro',
color: Color(
0xFF9EA4B7),
fontSize: 30.rpx,
letterSpacing: 0,
),
),
Row(
mainAxisSize:
MainAxisSize.max,
children: [
Container(
width: 200.rpx,
child: Text(
'${controller.model.peopleList[index]['gender'] == 1 ? '' : ''}',
textAlign:
TextAlign
.right,
style:
TextStyle(
fontFamily:
'Readex Pro',
color: Colors
.white,
fontSize:
30.rpx,
letterSpacing:
0,
),
),
),
SizedBox(
width: 16.rpx,
),
Container(
height: 30.rpx,
width: 30.rpx,
child:
SvgPicture
.asset(
'assets/img/icon/expand_more.svg',
color: Colors
.white,
))
],
),
],
),
)),
),
getLine(),
Container(
width: double.infinity,
height: 90.rpx,
margin: EdgeInsets.only(
left: 40.rpx,
right: 35.rpx),
decoration: BoxDecoration(),
child: InkWell(
onTap: () {
// Convert string height to int for initial value
final currentHeight =
controller.model
.peopleList[
index]['height'];
final initialHeight =
currentHeight != null
? int.tryParse(
currentHeight
.toString()) ??
170
: 170;
FocusScope.of(context)
.requestFocus(
FocusNode());
Future.delayed(
const Duration(
milliseconds: 250),
() {
showHeightPickerDialog(
context,
initialHeight:
initialHeight,
onConfirm: (int
selectedHeight) {
controller.model.peopleList[
index]
['height'] =
selectedHeight
.toString();
controller
.updateAll();
print(
"身高: $selectedHeight cm");
},
);
});
},
child: Row(
mainAxisSize:
MainAxisSize.max,
@@ -466,7 +349,205 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
.spaceBetween,
children: [
Text(
'身高(cm)',
'性别',
style: TextStyle(
fontFamily:
'Readex Pro',
color:
Color(0xFF9EA4B7),
fontSize: 30.rpx,
letterSpacing: 0,
),
),
Row(
mainAxisSize:
MainAxisSize.max,
children: [
Container(
width: 200.rpx,
child: Text(
controller.model.peopleList[
index]
[
'gender'] ==
0
? ''
: '',
textAlign:
TextAlign
.right,
style: TextStyle(
fontFamily:
'Readex Pro',
color: Colors
.white,
fontSize:
30.rpx,
letterSpacing:
0,
),
),
),
SizedBox(
width: 16.rpx,
),
Container(
height: 30.rpx,
width: 30.rpx,
child: SvgPicture
.asset(
'assets/img/icon/expand_more.svg',
color: Colors
.white,
))
],
),
],
),
),
),
),
getLine(),
InkWell(
onTap: () {
// Convert string height to int for initial value
final currentHeight = controller
.model.peopleList[index]
['height'];
final initialHeight =
currentHeight != null
? int.tryParse(
currentHeight
.toString()) ??
170
: 170;
FocusScope.of(context)
.requestFocus(FocusNode());
Future.delayed(
const Duration(
milliseconds: 250), () {
showHeightPickerDialog(
context,
initialHeight:
initialHeight,
onConfirm:
(int selectedHeight) {
controller.model.peopleList[
index]['height'] =
selectedHeight
.toString();
controller.updateAll();
print(
"身高: $selectedHeight cm");
},
);
});
},
child: Container(
width: double.infinity,
height: 90.rpx,
margin: EdgeInsets.only(
left: 40.rpx,
right: 35.rpx),
decoration: BoxDecoration(),
child: Row(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
'身高(cm)',
style: TextStyle(
fontFamily:
'Readex Pro',
color:
Color(0xFF9EA4B7),
fontSize: 30.rpx,
letterSpacing: 0,
),
),
Row(
children: [
Text(
controller.model.peopleList[
index]
[
'height'] !=
null
? "${controller.model.peopleList[index]['height']} cm"
: '',
style: TextStyle(
fontFamily:
'Readex Pro',
color: Colors.white,
fontSize: 30.rpx,
),
),
SizedBox(width: 16.rpx),
Container(
height: 30.rpx,
width: 30.rpx,
child: SvgPicture
.asset(
'assets/img/icon/expand_more.svg',
color:
Colors.white,
))
],
),
],
),
),
),
getLine(),
Obx(
() => InkWell(
onTap: () {
FocusScope.of(context)
.requestFocus(
FocusNode());
Future.delayed(
const Duration(
milliseconds: 250),
() {
showWeightPickerDialog(
context,
initialWeight: controller
.model
.peopleList[
index]['weight'] ??
"",
onConfirm:
(int selectedWeight) {
controller.model
.peopleList[
index]['weight'] =
selectedWeight
.toString(); // ✅ 转成字符串
controller.updateAll();
},
);
});
},
child: Container(
width: double.infinity,
height: 90.rpx,
margin: EdgeInsets.only(
left: 40.rpx,
right: 35.rpx),
decoration: BoxDecoration(),
child: Row(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
'体重(kg)',
style: TextStyle(
fontFamily:
'Readex Pro',
@@ -482,9 +563,9 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
controller.model.peopleList[
index]
[
'height'] !=
'weight'] !=
null
? "${controller.model.peopleList[index]['height']} cm"
? "${controller.model.peopleList[index]['weight']} kg"
: '',
style: TextStyle(
fontFamily:
@@ -509,158 +590,50 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
),
],
),
)),
getLine(),
Obx(
() => Container(
width: double.infinity,
height: 90.rpx,
margin: EdgeInsets.only(
left: 40.rpx,
right: 35.rpx),
decoration: BoxDecoration(),
child: InkWell(
onTap: () {
FocusScope.of(context)
.requestFocus(
FocusNode());
Future.delayed(
const Duration(
milliseconds:
250), () {
showWeightPickerDialog(
context,
initialWeight: controller
.model
.peopleList[
index]
['weight'] ??
"",
onConfirm: (int
selectedWeight) {
controller.model.peopleList[
index]
['weight'] =
selectedWeight
.toString(); // ✅ 转成字符串
controller
.updateAll();
print(
"体重: $selectedWeight kg");
},
);
});
},
child: Row(
mainAxisSize:
MainAxisSize.max,
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [
Text(
'体重(kg)',
style: TextStyle(
fontFamily:
'Readex Pro',
color: Color(
0xFF9EA4B7),
fontSize: 30.rpx,
letterSpacing: 0,
),
),
Row(
children: [
Text(
controller.model.peopleList[
index]
[
'weight'] !=
null
? "${controller.model.peopleList[index]['weight']} kg"
: '',
style: TextStyle(
fontFamily:
'Readex Pro',
color: Colors
.white,
fontSize:
30.rpx,
),
),
SizedBox(
width: 16.rpx),
Container(
height: 30.rpx,
width: 30.rpx,
child:
SvgPicture
.asset(
'assets/img/icon/expand_more.svg',
color: Colors
.white,
))
],
),
],
),
)),
),
),
),
getLine(),
Obx(
() => Container(
width: double.infinity,
height: 90.rpx,
margin: EdgeInsets.only(
left: 40.rpx,
right: 35.rpx),
decoration: BoxDecoration(),
child: InkWell(
onTap: () {
// 延迟执行的代码
FocusScope.of(context)
.requestFocus(
FocusNode());
Future.delayed(
const Duration(
milliseconds:
250), () {
showDateSelectionDialog(
context,
checkDate: controller
.model
.peopleList[index]['birthday']
is DateTime
? controller
.model
.peopleList[index]
['birthday']
: DateTime.tryParse(
controller.model.peopleList[index]['birthday'] ??
'') ??
DateTime.now(),
checkChange:
(DateTime d) {
controller.model
.peopleList[
index]
['birthday'] = d;
controller
.updateAll();
print("$d");
// final String dateStr =
// "${d.year}-${d.month.toString().padLeft(2, '0')}";
// controller.model.peopleList[
// index]
// ['birthday'] =
// dateStr;
// controller
// .updateAll();
// print(dateStr);
});
Obx(() => InkWell(
onTap: () {
// 延迟执行的代码
FocusScope.of(context)
.requestFocus(
FocusNode());
Future.delayed(
const Duration(
milliseconds: 250),
() {
showDateSelectionDialog(
context,
checkDate: controller
.model
.peopleList[index]
['birthday']
is DateTime
? controller.model
.peopleList[index]
['birthday']
: DateTime.tryParse(
controller.model.peopleList[index]['birthday'] ??
'') ??
DateTime.now(),
checkChange: (DateTime d) {
controller.model
.peopleList[
index]
['birthday'] = d;
controller.updateAll();
});
},
});
},
child: Container(
width: double.infinity,
height: 90.rpx,
margin: EdgeInsets.only(
left: 40.rpx,
right: 35.rpx),
decoration: BoxDecoration(),
child: Row(
mainAxisSize:
MainAxisSize.max,
@@ -732,8 +705,8 @@ class PeopleInfoPage extends GetView<PeopleInfoController> {
),
],
),
)),
),
),
)),
getLine(),
Container(
width: double.infinity,