Browse Source

1.优化昵称修改

tags/0.0.15+2
“yanghuaxuan” 3 years ago
parent
commit
c54d262c7f
1 changed files with 21 additions and 16 deletions
  1. +21
    -16
      lib/pages/mine_detail_page/mine_detail_page.dart

+ 21
- 16
lib/pages/mine_detail_page/mine_detail_page.dart View File

@@ -83,11 +83,23 @@ class _MineDetailContainer extends StatefulWidget {
class _MineDetailContainerState extends State<_MineDetailContainer> { class _MineDetailContainerState extends State<_MineDetailContainer> {
MineDetailBloc _bloc; MineDetailBloc _bloc;
TextEditingController _nickController = TextEditingController(); TextEditingController _nickController = TextEditingController();
FocusNode nickNameFocusNode;


@override @override
void initState() { void initState() {
_bloc = BlocProvider.of<MineDetailBloc>(context); _bloc = BlocProvider.of<MineDetailBloc>(context);
_bloc.loadData(); _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(); super.initState();
} }


@@ -117,19 +129,11 @@ class _MineDetailContainerState extends State<_MineDetailContainer> {
_selectSex(); _selectSex();
}), }),
_createLine(), _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(); _selectBrithday();
}), }),
_createLine(), _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(
padding: const EdgeInsets.only(top: 8), padding: const EdgeInsets.only(top: 8),
child: _createItem('填写微信号', user?.is_upload_wx == '1' ? '已上传' : '未上传微信号与二维码', onTap: () { child: _createItem('填写微信号', user?.is_upload_wx == '1' ? '已上传' : '未上传微信号与二维码', onTap: () {
@@ -234,17 +238,18 @@ class _MineDetailContainerState extends State<_MineDetailContainer> {
textInputAction: TextInputAction.done, textInputAction: TextInputAction.done,
controller: controller, controller: controller,
textAlign: TextAlign.right, textAlign: TextAlign.right,
focusNode: nickNameFocusNode,
placeholder: '输入昵称', placeholder: '输入昵称',
style: TextStyle( style: TextStyle(
fontSize: 13, fontSize: 13,
color: Color(0xff999999), color: Color(0xff999999),
), ),
onSubmitted: (value) { 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; return;
} }
Loading.show(context); 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); _bloc.uploadAvatar(resultFile);
} }


Loading…
Cancel
Save