import 'package:farmer_client/widgets/DefaultButton.dart'; import 'package:farmer_client/widgets/layout/BasicPage.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:get/get.dart'; class UserInfo extends BasicPage { final name =Rx(''); final phone =Rx(''); late TextEditingController _cName; late TextEditingController _cPhone; @override void beforeShow() { super.beforeShow(); _cName = TextEditingController(text: name.value); _cPhone = TextEditingController(text: phone.value); } bool disableLogin = false; RegExp exp = RegExp(r'^1[3456789]\d{9}$'); void handleOk() { if (name.value == '' && phone.value == '') { Fluttertoast.showToast(msg: '请输入您的信息'); } else if (phone.value!=''&&!exp.hasMatch(phone.value)) { Fluttertoast.showToast(msg: '请输入正确的手机号'); } else { Fluttertoast.showToast(msg: '保存成功'); Get.back(); } } @override Widget builder(BuildContext context) { naviTitle = '个人信息'; return Container( height: 700.h, color: const Color(0xFFffffff), padding: EdgeInsets.all(15.w), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( width: 345.w, margin: EdgeInsets.fromLTRB(0, 0, 0, 40.h), padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 0), decoration: BoxDecoration( color: const Color(0xFFFFFFFF), boxShadow: [ BoxShadow( color: const Color(0x1F000000), offset: Offset(0, 1.w), blurRadius: 0, ), ], ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Image.asset( 'images/userMoren.png', width: 62.w, height: 62.w, ), Text( '更换头像', style: TextStyle( fontSize: 17.sp, color: Color(0xFF333333), letterSpacing: 2, fontWeight: FontWeight.w500), ), ]), ), Text( '姓名:', style: TextStyle( color: const Color(0xFF333333), fontSize: 17.sp, letterSpacing: 2, fontWeight: FontWeight.bold), ), Container( width: 345.w, margin: EdgeInsets.fromLTRB(0, 10.h, 0, 40.h), padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 0), decoration: BoxDecoration( color: const Color(0xFFFFFFFF), boxShadow: [ BoxShadow( color: const Color(0x1F000000), offset: Offset(0, 1.w), blurRadius: 0, ), ], ), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Container( width: 327.w, child: TextField( controller: _cName, style: TextStyle( color: const Color(0xFF333333), fontSize: 17.sp, letterSpacing: 2, fontWeight: FontWeight.bold), decoration: const InputDecoration( isCollapsed: true, hintText: '请输入您的姓名', border: InputBorder.none, counterText: '', //去掉计数 floatingLabelBehavior: FloatingLabelBehavior.never, ), onChanged: (e) { name.value = e; }, ), ), GestureDetector( onTap: () { name.value = ''; _cName.clear(); }, child: Image.asset( 'images/icons/cancel.png', width: 18.w, height: 18.w, ), ), ]), ], )), Text( '手机号:', style: TextStyle( color: const Color(0xFF333333), fontSize: 17.sp, letterSpacing: 2, fontWeight: FontWeight.bold), ), Container( width: 345.w, margin: EdgeInsets.fromLTRB(0, 10.h, 0, 40.h), padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 0), decoration: BoxDecoration( color: const Color(0xFFFFFFFF), boxShadow: [ BoxShadow( color: const Color(0x1F000000), offset: Offset(0, 1.w), blurRadius: 0, ), ], ), child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ SizedBox( width: 327.w, child: TextField( keyboardType: TextInputType.number, controller: _cPhone, maxLength: 11, style: TextStyle( color: const Color(0xFF333333), fontSize: 17.sp, letterSpacing: 2, fontWeight: FontWeight.bold), decoration: const InputDecoration( isCollapsed: true, hintText: '请输入您的手机号', border: InputBorder.none, counterText: '', //去掉计数 floatingLabelBehavior: FloatingLabelBehavior.never, ), onChanged: (e) { phone.value = e; }, ), ), GestureDetector( onTap: () { phone.value = ''; _cPhone.clear(); }, child: Image.asset( 'images/icons/cancel.png', width: 18.w, height: 18.w, ), ), ]), ], )), const Spacer(), DefaultButton( color: const Color(0xffffffff), backColor: const Color(0xFFFF703B), width: 345.w, height: 49.h, text: '保存', onPressed: handleOk, margin: const EdgeInsets.all(0), fontSize: 20.sp, radius: 24.5.w, ), ], ), ); } }