import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:ysairplane/base/YSBase.dart'; import 'package:ysairplane/tools/YSNetWorking.dart'; import 'package:ysairplane/tools/YSTools.dart'; class YSContact extends StatefulWidget { @override _YSContactState createState() => _YSContactState(); } class _YSContactState extends State { List _dataArray = [{'title':'姓名','content':'请输入姓名'},{'title':'证件类型','content':'身份证'},{'title':'证件号码','content':'请输入身份证号码'},{'title':'手机号码','content':'请输入电话号码'}]; TextEditingController _name = TextEditingController(); TextEditingController _phone = TextEditingController(); TextEditingController _idCard = TextEditingController(); @override Widget build(BuildContext context) { return YSBase( ystitle: '编辑信息', ysright: GestureDetector( child: Text('保存',style: TextStyle(fontWeight: FontWeight.bold,fontSize: zsp(36),color: Color(0xFF2C7CF6)),), onTap: (){ if(_name.text.isEmpty){ ysFlutterToast(context, '请输入姓名'); return; } if(_phone.text.isEmpty){ ysFlutterToast(context, '请输入电话号码'); return; } if(_idCard.text.isEmpty){ ysFlutterToast(context, '请输入身份证号码'); return; } if(isChinaPhoneLegal(_phone.text)==false){ ysFlutterToast(context, '手机号格式不正确'); return; } if(isIdCard(_idCard.text)==false){ ysFlutterToast(context, '身份证号格式不正确'); return; } Navigator.of(context).pop({'username':_name.text,'phone':_phone.text,'cardid':_idCard.text}); }, ), yschild: Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44, width: MediaQuery.of(context).size.width, color: Color(0xFFF1F2F3), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ if(index==1)return; Navigator.push(context, PopRoute(child: BottomInputDialog( height: 50, inputView: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: MediaQuery.of(context).size.width-100, child: CupertinoTextField( placeholder: index==0?'请输入姓名':index==2?'请输入身份证号码':'请输入电话号码', style: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal), placeholderStyle: TextStyle(fontSize: 15,color: Color(0xFF5A5A5A),decoration: TextDecoration.none,fontWeight: FontWeight.normal), autofocus: true, decoration: BoxDecoration(), maxLength: index==0?10:index==2?18:11, textInputAction: TextInputAction.done, keyboardType: index==3?TextInputType.phone:TextInputType.text, controller: index==0?_name:index==2?_idCard:_phone, ), ), Icon(Icons.alternate_email,size: 25,color: Color(0xFFA1A1A2),), Icon(Icons.tag_faces,size: 25,color: Color(0xFFA1A1A2),), ], ), ))); }, child: Container( padding: EdgeInsets.only(top: hsp(20),bottom: hsp(20),left: hsp(40),right: hsp(40)), color: Colors.white, width: MediaQuery.of(context).size.width, child: Row( children: [ Container( child: Text('${_dataArray[index]['title']}',style: TextStyle(fontSize: zsp(30),color: Color(0xFF6C6C6C)),), width: wsp(200), ), Text(index==0?(_name.text.isNotEmpty?_name.text:'${_dataArray[index]['content']}'):index==2?(_idCard.text.isNotEmpty?_idCard.text:'${_dataArray[index]['content']}'): index==3?(_phone.text.isNotEmpty?_phone.text:'${_dataArray[index]['content']}'):'${_dataArray[index]['content']}' ,style: TextStyle(fontSize: zsp(30),color: Color(0xFF000000)),) ], ) ), ); }, separatorBuilder: (context,index){ return Divider(height: index==0?hsp(12):0.5,thickness: index==0?hsp(12):0.5,color: Color(0xFFF1F2F3),); }, itemCount: _dataArray.length, padding: EdgeInsets.all(0), shrinkWrap: true, ), ), ); } }