base_info_step2.dart 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_svg/svg.dart';
  3. import 'package:get/get.dart';
  4. import 'package:link/view/component/link_btn.dart';
  5. import '../constants.dart';
  6. import '../utils/api.dart';
  7. import '../utils/http_utils.dart';
  8. import '../utils/size_fit.dart';
  9. import '../utils/storage.dart';
  10. import 'component/link_step.dart';
  11. import 'component/toast.dart';
  12. import 'component/top_container.dart';
  13. class EditBaseInfo extends StatefulWidget {
  14. const EditBaseInfo({Key? key}) : super(key: key);
  15. @override
  16. State<EditBaseInfo> createState() => _EditBaseInfoState();
  17. }
  18. class _EditBaseInfoState extends State<EditBaseInfo> {
  19. bool isBoy = true;
  20. String intro = '';
  21. TextEditingController controller = TextEditingController();
  22. @override
  23. void initState() {
  24. // TODO: implement initState
  25. var userInfo = StorageUtil().getJSON('tempUser1');
  26. if (userInfo != null) {
  27. if (userInfo['gender'] != null) {
  28. isBoy = userInfo['gender']=='1';
  29. }
  30. if (userInfo['intro'] != null) {
  31. intro = userInfo['intro'];
  32. controller.text = intro;
  33. }
  34. } else {
  35. StorageUtil().setJSON('tempUser1', {});
  36. }
  37. super.initState();
  38. }
  39. @override
  40. void dispose() {
  41. // TODO: implement dispose
  42. controller.dispose();
  43. super.dispose();
  44. }
  45. updateCache() {
  46. StorageUtil()
  47. .setJSON('tempUser1', {"gender": isBoy ? '1' : '0', "intro": intro});
  48. }
  49. Future commit() async {
  50. Toast().showHud(context: context);
  51. var data2 = await HttpUtils.post(Api.userInfo, data: {
  52. 'sex': isBoy ? 'MALE' : 'FEMALE',
  53. 'signature': intro,
  54. 'area': '北京',
  55. 'city': '北京',
  56. 'province': '北京',
  57. 'country': '中国'
  58. });
  59. if (data2 != null) {
  60. print(data2.toString());
  61. }
  62. Toast().hideHud();
  63. Get.toNamed('/begin_add_first_link');
  64. StorageUtil().remove('tempUser1');
  65. }
  66. body() {
  67. TextStyle style = TextStyle(
  68. color: kThemeColor, fontSize: 16.px, fontWeight: FontWeight.bold);
  69. return Material(
  70. color: kBgColor,
  71. child: TopContainer(
  72. child: Stack(children: [
  73. Positioned(
  74. left: 0,
  75. top: 0,
  76. right: 0,
  77. bottom: 0,
  78. child: Padding(
  79. padding: EdgeInsets.only(
  80. bottom: MediaQuery.of(context).viewInsets.bottom),
  81. child: SingleChildScrollView(
  82. child: Column(
  83. children: [
  84. SizedBox(
  85. height: 32.px,
  86. ),
  87. Row(
  88. mainAxisAlignment: MainAxisAlignment.center,
  89. children: [
  90. LinkStep(
  91. step: 1, content: '完善基本信息', hasShadow: true),
  92. Container(
  93. width: 60.px,
  94. height: 8.px,
  95. transform: Matrix4.translationValues(-1, 0, 0),
  96. decoration: const BoxDecoration(
  97. gradient: LinearGradient(
  98. begin: Alignment.centerLeft,
  99. end: Alignment.centerRight,
  100. colors: [
  101. kThemeColor,
  102. kThemeColor,
  103. Color(0xFF74747A)
  104. ])),
  105. ),
  106. Container(
  107. transform: Matrix4.translationValues(-2, 0, 0),
  108. child: LinkStep(
  109. step: 2, content: '', hasShadow: false),
  110. )
  111. ]),
  112. SizedBox(
  113. height: 32.px,
  114. ),
  115. Container(
  116. width: 343.px,
  117. padding: EdgeInsets.only(
  118. left: 20.px,
  119. right: 20.px,
  120. top: 18.px,
  121. bottom: 18.px),
  122. decoration: BoxDecoration(
  123. color: const Color(0xFF2C2C2E),
  124. borderRadius: BorderRadius.circular(24.px)),
  125. child: Column(
  126. mainAxisAlignment: MainAxisAlignment.start,
  127. crossAxisAlignment: CrossAxisAlignment.start,
  128. children: [
  129. Row(
  130. children: [
  131. Text(
  132. '性别',
  133. style: style,
  134. ),
  135. Expanded(child: Container()),
  136. GestureDetector(
  137. onTap: () {
  138. setState(() {
  139. isBoy = true;
  140. });
  141. updateCache();
  142. },
  143. child: Container(
  144. alignment: Alignment.center,
  145. width: 40.px,
  146. height: 40.px,
  147. decoration: BoxDecoration(
  148. borderRadius:
  149. BorderRadius.circular(20.px),
  150. color: isBoy
  151. ? const Color(0xFF00FFFF)
  152. : const Color(0xFF444447)),
  153. child: SvgPicture.asset(
  154. 'assets/icons/gender_male.svg',
  155. width: 24.px,
  156. height: 24.px,
  157. ),
  158. ),
  159. ),
  160. SizedBox(
  161. width: 16.px,
  162. ),
  163. GestureDetector(
  164. onTap: () {
  165. setState(() {
  166. isBoy = false;
  167. });
  168. updateCache();
  169. },
  170. child: Container(
  171. alignment: Alignment.center,
  172. width: 40.px,
  173. height: 40.px,
  174. decoration: BoxDecoration(
  175. borderRadius:
  176. BorderRadius.circular(20.px),
  177. color: !isBoy
  178. ? const Color(0xFFFF00AA)
  179. : const Color(0xFF444447)),
  180. child: SvgPicture.asset(
  181. 'assets/icons/gender_female.svg',
  182. width: 24.px,
  183. height: 24.px,
  184. ),
  185. ),
  186. )
  187. ],
  188. ),
  189. Container(
  190. margin: EdgeInsets.only(
  191. top: 18.px, bottom: 18.px),
  192. height: 1.px,
  193. color: const Color(0xFF404040),
  194. ),
  195. GestureDetector(
  196. child: Row(
  197. children: [
  198. Text('地区', style: style),
  199. Expanded(child: Container()),
  200. Text(
  201. '中国 北京',
  202. style: TextStyle(
  203. color: Colors.white,
  204. fontSize: 14.px),
  205. ),
  206. Image.asset(
  207. 'assets/images/arrow_right.png',
  208. width: 20.px,
  209. height: 20.px,
  210. )
  211. // SvgPicture.asset(
  212. // 'assets/icons/arrow_right.svg',
  213. // color: const Color(0xFF444447),
  214. // width: 20.px,
  215. // height: 20.px,
  216. // )
  217. ],
  218. ),
  219. ),
  220. Container(
  221. margin: EdgeInsets.only(
  222. top: 18.px, bottom: 18.px),
  223. height: 1.px,
  224. color: const Color(0xFF404040),
  225. ),
  226. Container(
  227. color: Colors.transparent,
  228. child: Text('简介', style: style),
  229. ),
  230. SizedBox(
  231. height: 8.px,
  232. ),
  233. Container(
  234. color: Colors.transparent,
  235. child: TextField(
  236. maxLength: 1000,
  237. maxLines: 1000,
  238. minLines: 1,
  239. cursorColor: kBtnColor,
  240. controller: controller,
  241. style: TextStyle(
  242. color: Colors.white,
  243. fontSize: 14.px,
  244. ),
  245. onChanged: (e) {
  246. setState(() {
  247. intro = e;
  248. });
  249. updateCache();
  250. },
  251. decoration: InputDecoration(
  252. border: InputBorder.none,
  253. hintText: '请填写您的简介(选填)',
  254. hintStyle: TextStyle(
  255. fontSize: 14.px,
  256. color: const Color(0xFF74747A)),
  257. counterText: "",
  258. )),
  259. )
  260. // Text('个性签名', style: style),
  261. // TextField(
  262. // maxLength: 1000,
  263. // maxLines: 1000,
  264. // minLines: 1,
  265. // cursorColor: kBtnColor,
  266. // style: TextStyle(
  267. // color: Colors.white,
  268. // fontSize: 14.px,
  269. // ),
  270. // onChanged: (e){
  271. // setState(() {
  272. // intro = e;
  273. // });
  274. // },
  275. // decoration: InputDecoration(
  276. // border: InputBorder.none,
  277. // hintText: '请填写您的个性签名(选填)',
  278. // hintStyle: TextStyle(
  279. // fontSize: 14.px,
  280. // color: const Color(0xFF74747A)),
  281. // counterText: "",
  282. // )),
  283. ]),
  284. ),
  285. SizedBox(
  286. height: 144.px,
  287. )
  288. ],
  289. ),
  290. ))),
  291. Positioned(
  292. left: 0,
  293. right: 0,
  294. bottom: 0,
  295. child: Container(
  296. width: 375.px,
  297. height: 144.px,
  298. alignment: Alignment.bottomCenter,
  299. padding: EdgeInsets.only(bottom: 56.px),
  300. decoration: const BoxDecoration(
  301. gradient: LinearGradient(
  302. begin: Alignment.topCenter,
  303. end: Alignment.bottomCenter,
  304. colors: [
  305. Color(0x00131314),
  306. Color(0xFF131314),
  307. Color(0xFF131314),
  308. Color(0xFF131314)
  309. ])),
  310. child: LinkButton(
  311. title: '下一步',
  312. disable: false,
  313. isBlack: false,
  314. callback: () {
  315. commit();
  316. }),
  317. ))
  318. ])));
  319. }
  320. @override
  321. Widget build(BuildContext context) {
  322. SizeFit.initialize(context);
  323. // return Padding(padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),child: body(),);
  324. return body();
  325. }
  326. }