import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:ysairplane/code/YSTabbar.dart'; import 'package:ysairplane/tools/YSNetWorking.dart'; import 'package:ysairplane/tools/YSTools.dart'; class YSBind extends StatefulWidget { @override _YSBindState createState() => _YSBindState(); } class _YSBindState extends State { TextEditingController _userName = TextEditingController(); TextEditingController _password = TextEditingController(); bool _isHave = false; @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: SingleChildScrollView( padding: EdgeInsets.all(wsp(50)), child: Container( width: MediaQuery.of(context).size.width, child: Column( children: [ Container( margin: EdgeInsets.only(top: MediaQuery.of(context).padding.top+hsp(190),bottom: hsp(140)), alignment: Alignment.centerLeft, child: Row( children: [ Container( child: GestureDetector( child: Text('新建账号',style: TextStyle(fontSize: zsp(30),color: _isHave==false?Color(0xFF3B7EF2):Color(0xFF999999)),), onTap: (){ setState(() { _isHave = false; }); }, ), margin: EdgeInsets.only(right: wsp(50)), ), GestureDetector( child: Text('已有账号',style: TextStyle(fontSize: zsp(30),color: _isHave==true?Color(0xFF3B7EF2):Color(0xFF999999)),), onTap: (){ setState(() { _isHave = true; }); }, ) ], ) ), Container( height: hsp(90), padding: EdgeInsets.only(left: wsp(20),right: wsp(20)), color: Color(0xFFF5F5F7), child: CupertinoTextField( placeholder: '请输入账号', style: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)), placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)), decoration: BoxDecoration(), suffix: Icon(Icons.close,color: Color(0xFF75788C),size: hsp(40),), suffixMode: OverlayVisibilityMode.editing, controller: _userName, ), ), Container( height: hsp(90), padding: EdgeInsets.only(left: wsp(20),right: wsp(20)), margin: EdgeInsets.only(top: hsp(50)), color: Color(0xFFF5F5F7), child: CupertinoTextField( placeholder: '请输入密码', style: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)), placeholderStyle: TextStyle(fontSize: zsp(30),color: Color(0xFF75788C)), decoration: BoxDecoration(), suffix: Icon(Icons.remove_red_eye,color: Color(0xFF75788C),size: hsp(40),), suffixMode: OverlayVisibilityMode.editing, controller: _password, ), ), GestureDetector( onTap: (){ showGeneralDialog( context: context, barrierDismissible:true, barrierColor: Colors.black.withOpacity(0.6), barrierLabel: '', transitionDuration: Duration(milliseconds: 200), pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { return Center( child: Container( height: MediaQuery.of(context).size.height-(MediaQuery.of(context).padding.top+hsp(100)*2), width: MediaQuery.of(context).size.width-wsp(100), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(5)) ), child: Column( children: [ Container( height: hsp(100), padding: EdgeInsets.only(left: wsp(30),right: wsp(30)), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container(), Text('隐私声明',style: TextStyle(fontSize: zsp(34),color: Color(0xFF242329),decoration: TextDecoration.none),), Icon(Icons.close,size: hsp(50),color: Color(0xFF242329)) ], ), ), Container( height: MediaQuery.of(context).size.height-(MediaQuery.of(context).padding.top+hsp(100)*2)-hsp(200), width: MediaQuery.of(context).size.width-wsp(100), padding: EdgeInsets.all(wsp(20)), color: Color(0xFFF9F9F9), child: Text('',style: TextStyle(fontSize: zsp(30),color: Color(0xFF242329),decoration: TextDecoration.none,fontWeight: FontWeight.normal),), ), Container( height: hsp(100), alignment: Alignment.center, child: Row( children: [ Container( width: (MediaQuery.of(context).size.width-wsp(100))/2-wsp(1), alignment: Alignment.center, child: Text('不同意',style: TextStyle(fontSize: zsp(34),color: Color(0xFF999999),decoration: TextDecoration.none),), ), Container( height: hsp(100), width: wsp(2), color: Color(0xFFF9F9F9), ), Container( width: (MediaQuery.of(context).size.width-wsp(100))/2-wsp(1), alignment: Alignment.center, child: Text('同意',style: TextStyle(fontSize: zsp(34),color: Color(0xFF0079FF),decoration: TextDecoration.none),), ) ], ) ), ], ), ), ); } ); }, child: GestureDetector( onTap: (){ FocusScope.of(context).unfocus(); _postCreateAccountData(); }, child: Container( height: hsp(90), width: MediaQuery.of(context).size.width-wsp(50)*2, alignment: Alignment.center, margin: EdgeInsets.only(top: hsp(116)), decoration: BoxDecoration( color: Color(0xFF3B7EF2), borderRadius: BorderRadius.all(Radius.circular(5)) ), child: Text('注册绑定',style: TextStyle(fontSize: zsp(34),color: Colors.white),), ), ), ), ], ), ), ), ); } _postCreateAccountData() async{ if(_userName.text.isEmpty){ ysFlutterToast(context, '账号不能为空'); return; } if(_password.text.isEmpty){ ysFlutterToast(context, '密码不能为空'); return; } var result = await ysRequestHttpEncrypt(context,type: requestType.post,api: '/app/applets/createAccount',parameter: {'username':_userName.text,'password':_password.text},isLoading: true,isToken: true); if(result!=null){ Navigator.pushAndRemoveUntil(context, MaterialPageRoute( builder: (context){ return YSTabbar(); } ), (route) => false); } } }