import 'package:cached_network_image/cached_network_image.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:sy_flutter_qiniu_storage/sy_flutter_qiniu_storage.dart'; import 'package:ysairplane/base/YSBase.dart'; import 'package:ysairplane/code/YSCity.dart'; import 'package:ysairplane/tools/YSNetWorking.dart'; import 'package:ysairplane/tools/YSTools.dart'; import 'package:image_picker/image_picker.dart'; class YSUserInfo extends StatefulWidget { @override _YSUserInfoState createState() => _YSUserInfoState(); } class _YSUserInfoState extends State { ImagePicker _picker = ImagePicker(); List array = [{'title':'头像','content':''},{'title':'真实姓名','content':'请输入真实姓名'},{'title':'性别','content':'请选择性别'}, {'title':'地区','content':'请选择地区'},{'title':'登录手机','content':''}, {'title':'邮箱地址','content':'请输入邮箱地址'},{'title':'绑定微信','content':''},{'title':'绑定支付宝','content':''}, {'title':'公司名称','content':'请输入公司名称'},{'title':'公司职务','content':'请输入职务'}, {'title':'公司行业','content':'请输入行业'},{'title':'网址','content':'请输入网址'},{'title':'所在地区','content':'请选择公司所在地区'}]; List chooses = ['男','女']; String _phone = ''; String _avatar; String _tokenStr = ''; String _urlStr = ''; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _getQiNiuTokenData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '个人资料', yschild: Container( height: MediaQuery.of(context).size.height-MediaQuery.of(context).padding.top-44, width: MediaQuery.of(context).size.width, color: Color(0xFFF5F6F8), child: ListView.separated( itemBuilder: (context,index){ return GestureDetector( onTap: (){ if(index==0){ showCupertinoModalPopup( context: context, builder: (context) { return CupertinoActionSheet( actions: [ CupertinoActionSheetAction( child: Text('拍摄照片'), onPressed: () { Navigator.pop(context); _picker.getImage(source: ImageSource.camera,imageQuality: 50).then((value){ _onUpload(value); }); }, ), CupertinoActionSheetAction( child: Text('选择图片'), onPressed: () { Navigator.pop(context); _picker.getImage(source: ImageSource.gallery,imageQuality: 50).then((value){ _onUpload(value); }); }, ), ], cancelButton: CupertinoActionSheetAction( child: Text('取消'), onPressed: () { Navigator.pop(context); }, ), ); } ); }else if(index==6||index==7||index==3||index==12){ if(index==3||index==12){ Navigator.of(context).push( CupertinoPageRoute(builder: (context){ return YSCity(); }) ).then((value){ if(value!=null){ } }); }else{ } }else if(index==1||index==5||index==8||index==9||index==10||index==11){ Navigator.push(context, PopRoute(child: BottomInputDialog( height: 185, color: Colors.white, inputView: Column( children: [ Container( padding: EdgeInsets.only(top: 5,bottom: 10,left: 10), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(index==1?'真实姓名':index==5?'邮箱地址':index==8?'公司名称':index==9?'公司职务':index==10?'公司行业':'网址', style: TextStyle(fontSize: 14,color: Color(0xFF000000),decoration: TextDecoration.none,fontWeight: FontWeight.bold),), Icon(Icons.close,size: 20,color: Color(0xFF9A9A9A),) ], ), ), Container( height: 50, width: MediaQuery.of(context).size.width-30, child: CupertinoTextField( placeholder: '请输入', style: TextStyle(fontSize: 15,color: Color(0xFF9A9A9A),decoration: TextDecoration.none,fontWeight: FontWeight.normal,), placeholderStyle: TextStyle(fontSize: 15,color: Color(0xFF9A9A9A),decoration: TextDecoration.none,fontWeight: FontWeight.normal), autofocus: true, decoration: BoxDecoration(), maxLines: 10, ), decoration: BoxDecoration( border: Border(bottom: BorderSide(color: Color(0xFFF5F6F8),width: 0.5)) ), margin: EdgeInsets.only(top: 10), ), Container( margin: EdgeInsets.all(15), height: 40, width: MediaQuery.of(context).size.width-40, alignment: Alignment.center, decoration: BoxDecoration( color: Color(0xFF007AFF), borderRadius: BorderRadius.all(Radius.circular(6)) ), child: Text('完成',style: TextStyle(fontSize: 17,color: Colors.white,fontWeight: FontWeight.bold,decoration: TextDecoration.none),), ) ], ), ))); }else{ } }, child: Container( height: 50, color: Colors.white, padding: EdgeInsets.only(left: 15,right: 15), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('${array[index]['title']}',style: TextStyle(fontSize: 16,color: Color(0xFF000000)),), index==0?Container( height: 40, width: 40, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(20)), color: Colors.black12 ), child: _avatar!=null?ClipRRect( borderRadius: BorderRadius.all(Radius.circular(20)), child: CachedNetworkImage( imageUrl: _avatar, fit: BoxFit.fill, ), ):Container(), ):index==6||index==7||index==3||index==12?Row( children: [ Text('${array[index]['content']}',style: TextStyle(fontSize: 16,color: Color(0xFF9A9A9A)),), Icon(Icons.keyboard_arrow_right,size: 20,color: Color(0xFF9A9A9A),) ], ):index==1||index==4||index==5||index==8||index==9||index==10||index==11?Text( index==4?_phone:'${array[index]['content']}', style: TextStyle(fontSize: 16,color: Color(0xFF9A9A9A)), ):DropdownButton( value: '${chooses[0]}', items: [ for(int i=0;i