index.dart 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import 'package:farmer_client/widgets/DefaultButton.dart';
  2. import 'package:farmer_client/widgets/layout/BasicPage.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_screenutil/flutter_screenutil.dart';
  5. import 'package:fluttertoast/fluttertoast.dart';
  6. import 'package:get/get.dart';
  7. class UserInfo extends BasicPage {
  8. final name =Rx<String>('');
  9. final phone =Rx<String>('');
  10. late TextEditingController _cName;
  11. late TextEditingController _cPhone;
  12. @override
  13. void beforeShow() {
  14. super.beforeShow();
  15. _cName = TextEditingController(text: name.value);
  16. _cPhone = TextEditingController(text: phone.value);
  17. }
  18. bool disableLogin = false;
  19. RegExp exp = RegExp(r'^1[3456789]\d{9}$');
  20. void handleOk() {
  21. if (name.value == '' && phone.value == '') {
  22. Fluttertoast.showToast(msg: '请输入您的信息');
  23. } else if (phone.value!=''&&!exp.hasMatch(phone.value)) {
  24. Fluttertoast.showToast(msg: '请输入正确的手机号');
  25. } else {
  26. Fluttertoast.showToast(msg: '保存成功');
  27. Get.back();
  28. }
  29. }
  30. @override
  31. Widget builder(BuildContext context) {
  32. naviTitle = '个人信息';
  33. return Container(
  34. height: 700.h,
  35. color: const Color(0xFFffffff),
  36. padding: EdgeInsets.all(15.w),
  37. child: Column(
  38. crossAxisAlignment: CrossAxisAlignment.start,
  39. children: [
  40. Container(
  41. width: 345.w,
  42. margin: EdgeInsets.fromLTRB(0, 0, 0, 40.h),
  43. padding: EdgeInsets.symmetric(vertical: 15.h, horizontal: 0),
  44. decoration: BoxDecoration(
  45. color: const Color(0xFFFFFFFF),
  46. boxShadow: [
  47. BoxShadow(
  48. color: const Color(0x1F000000),
  49. offset: Offset(0, 1.w),
  50. blurRadius: 0,
  51. ),
  52. ],
  53. ),
  54. child: Row(
  55. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  56. children: [
  57. Image.asset(
  58. 'images/userMoren.png',
  59. width: 62.w,
  60. height: 62.w,
  61. ),
  62. Text(
  63. '更换头像',
  64. style: TextStyle(
  65. fontSize: 17.sp,
  66. color: Color(0xFF333333),
  67. letterSpacing: 2,
  68. fontWeight: FontWeight.w500),
  69. ),
  70. ]),
  71. ),
  72. Text(
  73. '姓名:',
  74. style: TextStyle(
  75. color: const Color(0xFF333333),
  76. fontSize: 17.sp,
  77. letterSpacing: 2,
  78. fontWeight: FontWeight.bold),
  79. ),
  80. Container(
  81. width: 345.w,
  82. margin: EdgeInsets.fromLTRB(0, 10.h, 0, 40.h),
  83. padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 0),
  84. decoration: BoxDecoration(
  85. color: const Color(0xFFFFFFFF),
  86. boxShadow: [
  87. BoxShadow(
  88. color: const Color(0x1F000000),
  89. offset: Offset(0, 1.w),
  90. blurRadius: 0,
  91. ),
  92. ],
  93. ),
  94. child: Column(
  95. children: [
  96. Row(
  97. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  98. children: [
  99. Container(
  100. width: 327.w,
  101. child: TextField(
  102. controller: _cName,
  103. style: TextStyle(
  104. color: const Color(0xFF333333),
  105. fontSize: 17.sp,
  106. letterSpacing: 2,
  107. fontWeight: FontWeight.bold),
  108. decoration: const InputDecoration(
  109. isCollapsed: true,
  110. hintText: '请输入您的姓名',
  111. border: InputBorder.none,
  112. counterText: '', //去掉计数
  113. floatingLabelBehavior:
  114. FloatingLabelBehavior.never,
  115. ),
  116. onChanged: (e) {
  117. name.value = e;
  118. },
  119. ),
  120. ),
  121. GestureDetector(
  122. onTap: () {
  123. name.value = '';
  124. _cName.clear();
  125. },
  126. child: Image.asset(
  127. 'images/icons/cancel.png',
  128. width: 18.w,
  129. height: 18.w,
  130. ),
  131. ),
  132. ]),
  133. ],
  134. )),
  135. Text(
  136. '手机号:',
  137. style: TextStyle(
  138. color: const Color(0xFF333333),
  139. fontSize: 17.sp,
  140. letterSpacing: 2,
  141. fontWeight: FontWeight.bold),
  142. ),
  143. Container(
  144. width: 345.w,
  145. margin: EdgeInsets.fromLTRB(0, 10.h, 0, 40.h),
  146. padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 0),
  147. decoration: BoxDecoration(
  148. color: const Color(0xFFFFFFFF),
  149. boxShadow: [
  150. BoxShadow(
  151. color: const Color(0x1F000000),
  152. offset: Offset(0, 1.w),
  153. blurRadius: 0,
  154. ),
  155. ],
  156. ),
  157. child: Column(
  158. children: [
  159. Row(
  160. mainAxisAlignment: MainAxisAlignment.spaceBetween,
  161. children: [
  162. SizedBox(
  163. width: 327.w,
  164. child: TextField(
  165. keyboardType: TextInputType.number,
  166. controller: _cPhone,
  167. maxLength: 11,
  168. style: TextStyle(
  169. color: const Color(0xFF333333),
  170. fontSize: 17.sp,
  171. letterSpacing: 2,
  172. fontWeight: FontWeight.bold),
  173. decoration: const InputDecoration(
  174. isCollapsed: true,
  175. hintText: '请输入您的手机号',
  176. border: InputBorder.none,
  177. counterText: '', //去掉计数
  178. floatingLabelBehavior:
  179. FloatingLabelBehavior.never,
  180. ),
  181. onChanged: (e) {
  182. phone.value = e;
  183. },
  184. ),
  185. ),
  186. GestureDetector(
  187. onTap: () {
  188. phone.value = '';
  189. _cPhone.clear();
  190. },
  191. child: Image.asset(
  192. 'images/icons/cancel.png',
  193. width: 18.w,
  194. height: 18.w,
  195. ),
  196. ),
  197. ]),
  198. ],
  199. )),
  200. const Spacer(),
  201. DefaultButton(
  202. color: const Color(0xffffffff),
  203. backColor: const Color(0xFFFF703B),
  204. width: 345.w,
  205. height: 49.h,
  206. text: '保存',
  207. onPressed: handleOk,
  208. margin: const EdgeInsets.all(0),
  209. fontSize: 20.sp,
  210. radius: 24.5.w,
  211. ),
  212. ],
  213. ),
  214. );
  215. }
  216. }