YSContact.dart 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:ysairplane/base/YSBase.dart';
  4. import 'package:ysairplane/tools/YSNetWorking.dart';
  5. import 'package:ysairplane/tools/YSTools.dart';
  6. class YSContact extends StatefulWidget {
  7. @override
  8. _YSContactState createState() => _YSContactState();
  9. }
  10. class _YSContactState extends State<YSContact> {
  11. List _dataArray = [{'title':'姓名','content':'请输入姓名'},{'title':'证件类型','content':'身份证'},{'title':'证件号码','content':'请输入身份证号码'},{'title':'手机号码','content':'请输入电话号码'}];
  12. TextEditingController _name = TextEditingController();
  13. TextEditingController _phone = TextEditingController();
  14. TextEditingController _idCard = TextEditingController();
  15. @override
  16. Widget build(BuildContext context) {
  17. return YSBase(
  18. ystitle: '编辑信息',
  19. ysright: GestureDetector(
  20. child: Text('保存',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(36),color: Color(0xFF2C7CF6)),),
  21. onTap: (){
  22. if(_name.text.isEmpty){
  23. ysFlutterToast(context, '请输入姓名');
  24. return;
  25. }
  26. if(_phone.text.isEmpty){
  27. ysFlutterToast(context, '请输入电话号码');
  28. return;
  29. }
  30. if(_idCard.text.isEmpty){
  31. ysFlutterToast(context, '请输入身份证号码');
  32. return;
  33. }
  34. if(isChinaPhoneLegal(_phone.text)==false){
  35. ysFlutterToast(context, '手机号格式不正确');
  36. return;
  37. }
  38. if(isIdCard(_idCard.text)==false){
  39. ysFlutterToast(context, '身份证号格式不正确');
  40. return;
  41. }
  42. Navigator.of(context).pop({'username':_name.text,'phone':_phone.text,'cardid':_idCard.text});
  43. },
  44. ),
  45. yschild: Container(
  46. height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44,
  47. width: MediaQuery.of(context).size.width,
  48. color: Color(0xFFF1F2F3),
  49. child: ListView.separated(
  50. itemBuilder: (context,index){
  51. return GestureDetector(
  52. onTap: (){
  53. if(index==1)return;
  54. Navigator.push(context, PopRoute(child: BottomInputDialog(
  55. height: 50,
  56. inputView: Row(
  57. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  58. children: [
  59. Container(
  60. width: MediaQuery.of(context).size.width-100,
  61. child: CupertinoTextField(
  62. placeholder: index==0?'请输入姓名':index==2?'请输入身份证号码':'请输入电话号码',
  63. style: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  64. placeholderStyle: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  65. autofocus: true,
  66. decoration: BoxDecoration(),
  67. maxLength: index==0?10:index==2?18:11,
  68. textInputAction: TextInputAction.done,
  69. keyboardType: index==3?TextInputType.phone:TextInputType.text,
  70. controller: index==0?_name:index==2?_idCard:_phone,
  71. ),
  72. ),
  73. Icon(Icons.alternate_email,size: 25,color: Color(0xFFA1A1A2),),
  74. Icon(Icons.tag_faces,size: 25,color: Color(0xFFA1A1A2),),
  75. ],
  76. ),
  77. )));
  78. },
  79. child: Container(
  80. padding: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(40),right: hsp(40)),
  81. color: Colors.white,
  82. width: MediaQuery.of(context).size.width,
  83. child: Row(
  84. children: [
  85. Container(
  86. child: Text('${_dataArray[index]['title']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF6C6C6C)),),
  87. width: wsp(200),
  88. ),
  89. Text(index==0?(_name.text.isNotEmpty?_name.text:'${_dataArray[index]['content']}'):index==2?(_idCard.text.isNotEmpty?_idCard.text:'${_dataArray[index]['content']}'):
  90. index==3?(_phone.text.isNotEmpty?_phone.text:'${_dataArray[index]['content']}'):'${_dataArray[index]['content']}'
  91. ,style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000)),)
  92. ],
  93. )
  94. ),
  95. );
  96. },
  97. separatorBuilder: (context,index){
  98. return Divider(height: index==0?hsp(12):0.5,thickness: index==0?hsp(12):0.5,color: Color(0xFFF1F2F3),);
  99. },
  100. itemCount: _dataArray.length,
  101. padding: EdgeInsets.all(0),
  102. shrinkWrap: true,
  103. ),
  104. ),
  105. );
  106. }
  107. }