YSContact.dart 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:ysairplane2/base/YSBase.dart';
  4. import 'package:ysairplane2/tools/YSNetWorking.dart';
  5. import 'package:ysairplane2/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. showModalBottomSheet(
  55. context: context,
  56. barrierColor: Colors.transparent,
  57. backgroundColor: Colors.transparent,
  58. isScrollControlled: true,
  59. builder: (context){
  60. return SingleChildScrollView(
  61. padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
  62. child: Container(
  63. height: 50,
  64. decoration: BoxDecoration(
  65. color: Colors.white,
  66. borderRadius: BorderRadius.only(topRight: Radius.circular(10),topLeft: Radius.circular(10))
  67. ),
  68. child: Row(
  69. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  70. children: [
  71. Container(
  72. width: MediaQuery.of(context).size.width-100,
  73. child: CupertinoTextField(
  74. placeholder: index==0?'请输入姓名':index==2?'请输入身份证号码':'请输入电话号码',
  75. style: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  76. placeholderStyle: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  77. autofocus: true,
  78. decoration: BoxDecoration(),
  79. maxLength: index==0?10:index==2?18:11,
  80. textInputAction: TextInputAction.done,
  81. keyboardType: index==3?TextInputType.phone:TextInputType.text,
  82. controller: index==0?_name:index==2?_idCard:_phone,
  83. onSubmitted: (value){
  84. Navigator.pop(context);
  85. },
  86. ),
  87. ),
  88. Icon(Icons.alternate_email,size: 25,color: Color(0xFFA1A1A2),),
  89. Icon(Icons.tag_faces,size: 25,color: Color(0xFFA1A1A2),),
  90. ],
  91. ),
  92. ),
  93. );
  94. }
  95. );
  96. // Navigator.push(context, PopRoute(child: BottomInputDialog(
  97. // height: 50,
  98. // inputView: Row(
  99. // mainAxisAlignment: MainAxisAlignment.spaceBetween,
  100. // children: [
  101. // Container(
  102. // width: MediaQuery.of(context).size.width-100,
  103. // child: CupertinoTextField(
  104. // placeholder: index==0?'请输入姓名':index==2?'请输入身份证号码':'请输入电话号码',
  105. // style: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  106. // placeholderStyle: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal),
  107. // autofocus: true,
  108. // decoration: BoxDecoration(),
  109. // maxLength: index==0?10:index==2?18:11,
  110. // textInputAction: TextInputAction.done,
  111. // keyboardType: index==3?TextInputType.phone:TextInputType.text,
  112. // controller: index==0?_name:index==2?_idCard:_phone,
  113. // ),
  114. // ),
  115. // Icon(Icons.alternate_email,size: 25,color: Color(0xFFA1A1A2),),
  116. // Icon(Icons.tag_faces,size: 25,color: Color(0xFFA1A1A2),),
  117. // ],
  118. // ),
  119. // )));
  120. },
  121. child: Container(
  122. padding: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(40),right: hsp(40)),
  123. color: Colors.white,
  124. width: MediaQuery.of(context).size.width,
  125. child: Row(
  126. children: [
  127. Container(
  128. child: Text('${_dataArray[index]['title']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF6C6C6C)),),
  129. width: wsp(200),
  130. ),
  131. Text(index==0?(_name.text.isNotEmpty?_name.text:'${_dataArray[index]['content']}'):index==2?(_idCard.text.isNotEmpty?_idCard.text:'${_dataArray[index]['content']}'):
  132. index==3?(_phone.text.isNotEmpty?_phone.text:'${_dataArray[index]['content']}'):'${_dataArray[index]['content']}'
  133. ,style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000)),)
  134. ],
  135. )
  136. ),
  137. );
  138. },
  139. separatorBuilder: (context,index){
  140. return Divider(height: index==0?hsp(12):0.5,thickness: index==0?hsp(12):0.5,color: Color(0xFFF1F2F3),);
  141. },
  142. itemCount: _dataArray.length,
  143. padding: EdgeInsets.all(0),
  144. shrinkWrap: true,
  145. ),
  146. ),
  147. );
  148. }
  149. }