From c54d262c7f05050adf7962bda7303acf10830454 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cyanghuaxuan=E2=80=9D?= <“646903573@qq.com”> Date: Fri, 23 Apr 2021 14:45:47 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96=E6=98=B5=E7=A7=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mine_detail_page/mine_detail_page.dart | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/pages/mine_detail_page/mine_detail_page.dart b/lib/pages/mine_detail_page/mine_detail_page.dart index c5ce758..2ca74b7 100644 --- a/lib/pages/mine_detail_page/mine_detail_page.dart +++ b/lib/pages/mine_detail_page/mine_detail_page.dart @@ -83,11 +83,23 @@ class _MineDetailContainer extends StatefulWidget { class _MineDetailContainerState extends State<_MineDetailContainer> { MineDetailBloc _bloc; TextEditingController _nickController = TextEditingController(); + FocusNode nickNameFocusNode; @override void initState() { _bloc = BlocProvider.of(context); _bloc.loadData(); + nickNameFocusNode = FocusNode(); + nickNameFocusNode.addListener(() { + if (!nickNameFocusNode.hasFocus) { + FocusScope.of(context).requestFocus(new FocusNode()); + if (_nickController.text == null || _nickController.text == '') { + Fluttertoast.showToast(msg: '昵称不为空'); + return; + } + _bloc.updateUser(nickname: _nickController.text); + } + }); super.initState(); } @@ -117,19 +129,11 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { _selectSex(); }), _createLine(), - _createItem( - '出生日期', - birthday > 0 - ? DateFormat('yyyy-MM-dd').format(DateTime.fromMillisecondsSinceEpoch(birthday * 1000)) - : user?.birthday ?? '', onTap: () { + _createItem('出生日期', birthday > 0 ? DateFormat('yyyy-MM-dd').format(DateTime.fromMillisecondsSinceEpoch(birthday * 1000)) : user?.birthday ?? '', onTap: () { _selectBrithday(); }), _createLine(), - _createItem( - '注册时间', - registTime > 0 - ? DateFormat('yyyy-MM-dd').format(DateTime.fromMillisecondsSinceEpoch(registTime * 1000)) - : user?.registerTime ?? ''), + _createItem('注册时间', registTime > 0 ? DateFormat('yyyy-MM-dd').format(DateTime.fromMillisecondsSinceEpoch(registTime * 1000)) : user?.registerTime ?? ''), Padding( padding: const EdgeInsets.only(top: 8), child: _createItem('填写微信号', user?.is_upload_wx == '1' ? '已上传' : '未上传微信号与二维码', onTap: () { @@ -234,17 +238,18 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { textInputAction: TextInputAction.done, controller: controller, textAlign: TextAlign.right, + focusNode: nickNameFocusNode, placeholder: '输入昵称', style: TextStyle( fontSize: 13, color: Color(0xff999999), ), onSubmitted: (value) { - if (value == null || value == '') { - Fluttertoast.showToast(msg: '昵称不为空'); - return; - } - _bloc.updateUser(nickname: value); + // if (value == null || value == '') { + // Fluttertoast.showToast(msg: '昵称不为空'); + // return; + // } + // _bloc.updateUser(nickname: value); }, ), ), @@ -317,7 +322,7 @@ class _MineDetailContainerState extends State<_MineDetailContainer> { return; } Loading.show(context); - File resultFile = await EncodeUtil.compressImage(context,file:cropperFile,size: 800); + File resultFile = await EncodeUtil.compressImage(context, file: cropperFile, size: 800); _bloc.uploadAvatar(resultFile); }