From 75240997323bf55080c057862ba570212e7c40b9 Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Sat, 20 Feb 2021 14:39:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AF=B9=E6=8E=A5=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=98=B5=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/const/api.dart | 3 +++ lib/ui/settings/nick_name_change_page.dart | 23 ++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/const/api.dart b/lib/const/api.dart index d8ee73a..5ec3d5d 100644 --- a/lib/const/api.dart +++ b/lib/const/api.dart @@ -32,4 +32,7 @@ class _User { ///个人资料:获取用户信息 String get info => '/user/personalData/getUserDetail'; + + ///个人资料:修改管家用户昵称 + String get updateNickName => '/user/personalData/updateNickName'; } diff --git a/lib/ui/settings/nick_name_change_page.dart b/lib/ui/settings/nick_name_change_page.dart index afe38c1..7f1e2ff 100644 --- a/lib/ui/settings/nick_name_change_page.dart +++ b/lib/ui/settings/nick_name_change_page.dart @@ -1,6 +1,12 @@ +import 'package:aku_community_manager/const/api.dart'; +import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_community_manager/utils/network/base_model.dart'; +import 'package:aku_community_manager/utils/network/net_util.dart'; +import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; @@ -27,6 +33,7 @@ class _NickNameChangePageState extends State { @override Widget build(BuildContext context) { + UserProvider userProvider = Provider.of(context); return AkuScaffold( title: '修改昵称', body: Material( @@ -42,7 +49,7 @@ class _NickNameChangePageState extends State { controller: _textEditingController, decoration: InputDecoration( contentPadding: EdgeInsets.zero, - hintText: '', + hintText: '${userProvider.userInfoModel.nickName}', hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 34.sp), border: UnderlineInputBorder( @@ -54,9 +61,17 @@ class _NickNameChangePageState extends State { ), 150.w.heightBox, MaterialButton( - onPressed: () { - // userProvider.setName(_textEditingController.text); - Get.back(); + onPressed: () async { + BaseModel baseModel = await NetUtil().get( + API.user.updateNickName, + params: {'nickName': _textEditingController.text}); + + if (baseModel.status == true) { + userProvider.setNickName(_textEditingController.text); + Get.back(); + } else { + BotToast.showText(text: baseModel.message); + } }, child: '保存'.text.black.size(32.sp).make(), color: Color(0xFFFFC40C), From 3dea5d7bfdd184f1dc76eab8e4559a376ecc776a Mon Sep 17 00:00:00 2001 From: zhang <494089941@qq.com> Date: Sat, 20 Feb 2021 15:11:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/ui/settings/nick_name_change_page.dart | 4 ++-- lib/ui/settings/user_info_page.dart | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/ui/settings/nick_name_change_page.dart b/lib/ui/settings/nick_name_change_page.dart index 7f1e2ff..f2c95df 100644 --- a/lib/ui/settings/nick_name_change_page.dart +++ b/lib/ui/settings/nick_name_change_page.dart @@ -49,7 +49,7 @@ class _NickNameChangePageState extends State { controller: _textEditingController, decoration: InputDecoration( contentPadding: EdgeInsets.zero, - hintText: '${userProvider.userInfoModel.nickName}', + hintText: '${userProvider.infoModel.nickName}', hintStyle: TextStyle(color: Color(0xFF999999), fontSize: 34.sp), border: UnderlineInputBorder( @@ -62,7 +62,7 @@ class _NickNameChangePageState extends State { 150.w.heightBox, MaterialButton( onPressed: () async { - BaseModel baseModel = await NetUtil().get( + BaseModel baseModel = await NetUtil().post( API.user.updateNickName, params: {'nickName': _textEditingController.text}); diff --git a/lib/ui/settings/user_info_page.dart b/lib/ui/settings/user_info_page.dart index d928bd2..94bce98 100644 --- a/lib/ui/settings/user_info_page.dart +++ b/lib/ui/settings/user_info_page.dart @@ -1,5 +1,6 @@ // Flutter imports: import 'package:aku_community_manager/tools/aku_divider.dart'; +import 'package:aku_community_manager/ui/settings/nick_name_change_page.dart'; import 'package:flutter/material.dart'; // Package imports: @@ -14,6 +15,7 @@ import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_tile.dart'; import 'package:aku_community_manager/ui/widgets/inner/pick_image.dart'; import 'package:aku_community_manager/tools/extensions/list_extension_tool.dart'; +import 'package:aku_community_manager/tools/extensions/router_extension_tool.dart'; class UserInfoPage extends StatefulWidget { UserInfoPage({Key key}) : super(key: key); @@ -42,7 +44,10 @@ class _UserInfoPageState extends State { suffix: AkuAvatar(), ), AkuTile( - onTap: () {}, + onTap: () async { + await NickNameChangePage().to(); + setState(() {}); + }, title: Text('昵称'), suffix: Text(userProvider.infoModel.nickName), ),