import 'dart:async'; import 'package:ef/base/widget/flutterflow/FlutterFlowTheme.dart'; import 'package:ef/ef.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:flutterflow_ui/flutterflow_ui.dart'; import 'package:vbvs_app/common/util/FitTool.dart'; import 'package:vbvs_app/common/util/MyUtils.dart'; import 'package:vbvs_app/component/tool/CustomCard.dart'; import 'package:vbvs_app/controller/main_bottom/global_controller.dart'; import 'package:vbvs_app/controller/mh/people_info_controller.dart'; import 'package:vbvs_app/pages/common/selectDialog.dart'; class PeopleInfoPage extends StatefulWidget { const PeopleInfoPage({super.key}); @override State createState() => _PeopleInfoState(); } class _PeopleInfoState extends State { get controller => Get.find(); get glcontroller => Get.find(); // @override // void initState() { // super.initState(); // Timer(const Duration(milliseconds: 100), () { // controller.getPeoples(); // }); // } getLine() { return Container( height: 1, color: stringToColor("#152676"), ); } @override Widget build(BuildContext context) { return LayoutBuilder( builder: (context, boxConstraints) => GestureDetector( // onTap: () => FocusScope.of(context).unfocus(), onTap: () { // 触摸收起键盘 FocusScope.of(context).requestFocus(FocusNode()); }, child: Container( decoration: const BoxDecoration( image: DecorationImage( image: AssetImage('assets/images/new_background.png'), // 本地图片 fit: BoxFit.fill, // 填满整个 Container ), ), child: Scaffold( backgroundColor: Colors.transparent, appBar: AppBar( backgroundColor: Colors.transparent, automaticallyImplyLeading: false, iconTheme: IconThemeData(color: Colors.white), titleSpacing: 0, title: AppBar( backgroundColor: Colors.transparent, iconTheme: const IconThemeData(color: Colors.white), automaticallyImplyLeading: false, titleSpacing: 0, title: SizedBox( width: double.infinity, height: 180.rpx, child: Stack( alignment: Alignment.center, children: [ // 中间居中的标题 Text( '人员资料', textAlign: TextAlign.center, style: TextStyle( color: Colors.white, fontSize: 30.rpx, ), ), // 左侧图标 Positioned( left: 20.rpx, child: returnIconButtomNew, ), Positioned( right: 30.rpx, child: CustomCard( borderRadius: 10, gradientDirection: GradientDirection.vertical, onTap: () { // bool isOk = true; // for (var i = 0; i < 2; i++) { // var d = controller.model.peopleList[i]; // print("${d.toJson()}"); // String before = "人员信息${i == 0 ? "A" : "B"}:"; // if (isOk && // d.height != null && // d.height != "" && // int.tryParse("${d.height}") == null) { // showToast("$before身高请输入数字"); // isOk = false; // } // if (isOk && // d.weight != null && // d.weight != "" && // int.tryParse("${d.weight}") == null) { // showToast("$before体重请输入数字"); // isOk = false; // } // if (isOk && // d.tel != null && // d.tel != "" && // MyUtils.isValidPhoneNumber("${d.tel}") == // false) { // showToast("$before请输入正确的电话"); // isOk = false; // } // if (isOk && // d.emergencyContact != null && // d.emergencyContact != "" && // MyUtils.isValidPhoneNumber( // "${d.emergencyContact}") == // false) { // showToast("$before请输入正确的紧急联系人电话"); // isOk = false; // } // if (isOk) { // controller.savePeoples().then((d) { // showToast("保存成功", color: color_success); // }).catchError((d) { // print("$d"); // showToast("保存失败"); // }); // } // } // controller.model.peopleList.forEach((d) {}); }, colors: const [ Color(0xFFFCFCFC), Color(0xFFF8FAF9), Color(0XFFECF6F3), Color(0XFFD9F0E9), Color(0xFFCEECE3) ], child: Container( width: 120.rpx, height: 60.rpx, alignment: Alignment.center, // decoration: BoxDecoration( // borderRadius: BorderRadius.circular(5), // color: stringToColor("#182B7C"), // ), child: Text( "保存", style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: stringToColor("#9EA4B7"), letterSpacing: 0, fontSize: 30.rpx, ), ), ), )) ], ), ), actions: [], centerTitle: false, ), centerTitle: false, ), body: SafeArea( top: true, child: Container( padding: EdgeInsets.only(left: 30.rpx, right: 30.rpx), width: MediaQuery.sizeOf(context).width, height: MediaQuery.sizeOf(context).height * 1.123, // decoration: BoxDecoration( // color: Colors.transparent, // image: DecorationImage( // image: AssetImage("assets/images/background.png"), // fit: BoxFit.cover, // ), // ), child: SingleChildScrollView( child: Column( children: [ ...List.generate( "${glcontroller.model.deviceMain["bindMacB"]}" .length > 6 ? 2 : 1, (index) { String location_ = ""; if ("${glcontroller.model.deviceMain["bindMacB"]}" .length > 6 && (glcontroller.model.mainDevicePeople[0] ?["direction"] == 1 || glcontroller.model.mainDevicePeople[1] ?["direction"] == 1)) { location_ = "${glcontroller.model.mainDevicePeople[index]?["direction"] == 1 ? '左侧' : '右侧'}"; } return Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( margin: EdgeInsets.only( top: index == 0 ? 30.rpx : 90.rpx, bottom: 20.rpx), child: Text( "人员信息${index == 0 ? "A" : "B"}", style: TextStyle( color: Colors.white, fontSize: 30.rpx), ), ), Container( padding: EdgeInsets.only(left: 30.rpx, right: 30.rpx), child: Column( children: [ if (location_.isNotEmpty) Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.064, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '校准位置', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), fontSize: 30.rpx, letterSpacing: 0, ), ), Text( '$location_', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), fontSize: 30.rpx, letterSpacing: 0, ), ), ], ), ), getLine(), Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.064, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '性名', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), fontSize: 30.rpx, letterSpacing: 0, ), ), Container( width: 300.rpx, child: TextField( obscureText: false, textAlign: TextAlign.right, style: TextStyle( fontSize: 30.rpx, color: Colors.white), decoration: const InputDecoration( fillColor: Colors.transparent, filled: true, hintText: "请输入姓名", hintStyle: TextStyle( color: Colors.white), border: InputBorder.none, contentPadding: EdgeInsets.all(0)), onChanged: (value) { controller.model.peopleList[index] .name = value; controller.updateAll(); }, controller: controller.onReDraw( TextEditingController( text: controller .model .peopleList[index] .name ?? ""), (textEditingController) { textEditingController.text = controller .model .peopleList[index] .name ?? ""; }, "people_name_$index"), ), ), ], ), ), getLine(), Obx( () => Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.064, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '性别', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), fontSize: 30.rpx, letterSpacing: 0, ), ), InkWell( onTap: () { // 触摸收起键盘 FocusScope.of(context) .requestFocus(FocusNode()); Future.delayed( const Duration( milliseconds: 250), () { // 延迟执行的代码 showOneSelectionDialog(context, arr: ["女", "男"], checkIndex: controller .model .peopleList[ index] .sex == "女" ? 0 : 1, checkChange: (sindex) { controller .model .peopleList[index] .sex = (sindex == 0 ? '女' : '男'); controller.updateAll(); print("sex $sindex"); }).then((d) { // Timer(Duration.zero, () { // FocusScope.of(context).unfocus(); // }); }); }); }, child: Row( mainAxisSize: MainAxisSize.max, children: [ Container( width: 200.rpx, child: Text( '${controller.model.peopleList[index].sex}', textAlign: TextAlign.right, style: FlutterFlowTheme.of( context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Colors.white, fontSize: 30.rpx, letterSpacing: 0, ), ), ), SizedBox( width: 16.rpx, ), Icon( Icons.expand_more, color: Colors.white, size: 48.rpx, ), ], ), ), ], ), ), ), getLine(), Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.064, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '身高(cm)', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), fontSize: 30.rpx, letterSpacing: 0, ), ), Container( width: 300.rpx, child: TextField( obscureText: false, keyboardType: TextInputType.number, textInputAction: TextInputAction.done, textAlign: TextAlign.right, style: TextStyle( fontSize: 30.rpx, color: Colors.white), decoration: InputDecoration( fillColor: Colors.transparent, filled: true, hintText: "请输入身高(厘米)", hintStyle: TextStyle( color: Colors.white), border: InputBorder.none, contentPadding: EdgeInsets.all(0)), onChanged: (value) { controller.model.peopleList[index] .height = value; controller.updateAll(); }, controller: controller.onReDraw( TextEditingController( text: controller .model .peopleList[index] .height ?? ""), (textEditingController) { textEditingController.text = controller .model .peopleList[index] .height ?? ""; }, "people_height_$index"), ), ) ], ), ), getLine(), Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.064, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '体重(kg)', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), fontSize: 30.rpx, letterSpacing: 0, ), ), Container( width: 300.rpx, child: TextField( obscureText: false, keyboardType: TextInputType.number, textInputAction: TextInputAction.done, textAlign: TextAlign.right, style: TextStyle( fontSize: 30.rpx, color: Colors.white), decoration: InputDecoration( fillColor: Colors.transparent, filled: true, hintText: "请输入体重(公斤)", hintStyle: TextStyle( color: Colors.white), border: InputBorder.none, contentPadding: EdgeInsets.all(0)), onChanged: (value) { controller.model.peopleList[index] .weight = value; controller.updateAll(); }, controller: controller.onReDraw( TextEditingController( text: controller .model .peopleList[index] .weight ?? ""), (textEditingController) { textEditingController.text = controller .model .peopleList[index] .weight ?? ""; }, "people_weight_$index"), ), ), ], ), ), getLine(), Obx( () => Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.064, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '生日', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), fontSize: 30.rpx, letterSpacing: 0, ), ), InkWell( onTap: () { // 触摸收起键盘 FocusScope.of(context) .requestFocus(FocusNode()); Future.delayed( const Duration( milliseconds: 250), () { // 延迟执行的代码 showDateSelectionDialog(context, checkDate: controller .model .peopleList[index] .birthday ?? DateTime.now(), checkChange: (DateTime d) { controller .model .peopleList[index] .birthday = d; controller.updateAll(); print("$d"); }).then((d) { // Timer(Duration.zero, () { // FocusScope.of(context).unfocus(); // }); }); }); }, child: Row( mainAxisSize: MainAxisSize.max, children: [ Container( constraints: BoxConstraints( minWidth: 200.rpx), child: Text( controller .model .peopleList[ index] .birthday != null ? DateFormat( "yyyy年MM月dd日") .format(controller .model .peopleList[ index] .birthday!) : '', textAlign: TextAlign.right, style: FlutterFlowTheme.of( context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Colors.white, fontSize: 30.rpx, letterSpacing: 0, ), ), ), SizedBox( width: 16.rpx, ), Icon( Icons.expand_more, color: Colors.white, size: 48.rpx, ), ], ), ), ], ), ), ), // getLine(), // Container( // width: double.infinity, // height: MediaQuery.sizeOf(context).height * // 0.064, // decoration: BoxDecoration(), // child: Row( // mainAxisSize: MainAxisSize.max, // mainAxisAlignment: // MainAxisAlignment.spaceBetween, // children: [ // Text( // '电话', // style: FlutterFlowTheme.of(context) // .bodyMedium // .override( // fontFamily: 'Readex Pro', // color: Color(0xFF9EA4B7), // fontSize: 30.rpx, // letterSpacing: 0, // ), // ), // Container( // width: 300.rpx, // child: TextField( // obscureText: false, // keyboardType: TextInputType.number, // textInputAction: // TextInputAction.done, // textAlign: TextAlign.right, // style: TextStyle( // fontSize: 30.rpx, // color: Colors.white), // decoration: InputDecoration( // fillColor: Colors.transparent, // filled: true, // hintText: "请输入电话", // hintStyle: TextStyle( // color: Colors.white), // border: InputBorder.none, // contentPadding: // EdgeInsets.all(0)), // onChanged: (value) { // controller.model.peopleList[index] // .tel = value; // controller.updateAll(); // }, // controller: controller.onReDraw( // TextEditingController( // text: controller // .model // .peopleList[index] // .tel ?? // ""), // (textEditingController) { // textEditingController.text = // controller // .model // .peopleList[index] // .tel ?? // ""; // }, "people_tel_$index"), // ), // ), // ], // ), // ), getLine(), Container( width: double.infinity, height: MediaQuery.sizeOf(context).height * 0.064, decoration: BoxDecoration(), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( '联系人', style: FlutterFlowTheme.of(context) .bodyMedium .override( fontFamily: 'Readex Pro', color: Color(0xFF9EA4B7), fontSize: 30.rpx, letterSpacing: 0, ), ), Container( width: 300.rpx, child: TextField( obscureText: false, keyboardType: TextInputType.number, textInputAction: TextInputAction.done, textAlign: TextAlign.right, style: TextStyle( fontSize: 30.rpx, color: Colors.white), decoration: InputDecoration( fillColor: Colors.transparent, filled: true, hintText: "请输入联系人", hintStyle: TextStyle( color: Colors.white), border: InputBorder.none, contentPadding: EdgeInsets.all(0)), onChanged: (value) { controller.model.peopleList[index] .emergencyContact = value; controller.updateAll(); }, controller: controller.onReDraw( TextEditingController( text: controller .model .peopleList[index] .emergencyContact ?? ""), (textEditingController) { textEditingController.text = controller .model .peopleList[index] .emergencyContact ?? ""; }, "people_emergencyContact_$index"), ), ), ], ), ), ], ), ) ], ); }), SizedBox( height: 100.rpx, ), ], )), ), ), ), )), ); } }