Merge branch 'master' of 192.168.2.201:laiiihz/akuCommunity

* 'master' of 192.168.2.201:laiiihz/akuCommunity:
  add change nick name
hmxc
小赖 4 years ago
commit 7db743624b

@ -36,6 +36,9 @@ class _User {
///退
String get logout => '/user/signOut';
///
String get updateNickName =>'/user/personalData/updateNickName';
}
class _Manager {

@ -0,0 +1,84 @@
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:provider/provider.dart';
import 'package:random_character/random_character.dart';
import 'package:velocity_x/velocity_x.dart';
class ChangeNickName extends StatefulWidget {
ChangeNickName({Key key}) : super(key: key);
@override
_ChangeNickNameState createState() => _ChangeNickNameState();
}
class _ChangeNickNameState extends State<ChangeNickName> {
TextEditingController _textEditingController;
@override
void initState() {
final userProvider = Provider.of<UserProvider>(context, listen: false);
super.initState();
_textEditingController =
TextEditingController(text: userProvider.userInfoModel.nickName);
}
@override
void dispose() {
_textEditingController?.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
return BeeScaffold(
title: '修改昵称',
body: Material(
color: Colors.white,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
55.heightBox,
'昵称'.text.black.size(28.sp).make(),
TextFormField(
controller: _textEditingController,
decoration: InputDecoration(
contentPadding: EdgeInsets.zero,
hintText: '${userProvider.userInfoModel.nickName}',
border: UnderlineInputBorder(
borderSide: BorderSide(
color: Color(0xFFEEEEEE),
width: 1.w,
)),
),
),
150.heightBox,
MaterialButton(
onPressed: () {
userProvider.setName(_textEditingController.text);
Get.back();
},
child: '保存'.text.black.size(32.sp).make(),
color: Color(0xFFFFC40C),
elevation: 0,
minWidth: 686.w,
height: 85.w,
),
24.heightBox,
'为保护个人隐私,在与邻里交往时显示昵称,默认为真实姓名,您可自行修改'
.text
.color(Color(0xFF999999))
.size(24.sp)
.maxLines(2)
.make()
],
),
),
),
);
}
}

@ -1,4 +1,5 @@
import 'package:akuCommunity/base/base_style.dart';
import 'package:akuCommunity/pages/personal/change_nick_name_page.dart';
import 'package:akuCommunity/provider/user_provider.dart';
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:akuCommunity/utils/headers.dart';
@ -70,7 +71,9 @@ class _UserProfilePageState extends State<UserProfilePage> {
_buildTile(
'昵称',
userProvider.userInfoModel.nickName.text.make(),
onPressed: () {},
onPressed: () {
ChangeNickName().to();
},
),
_buildTile(
'手机号',

@ -76,6 +76,14 @@ class UserProvider extends ChangeNotifier {
//
Future setName(String name) async {
//TODO set name
BaseModel baseModel = await NetUtil().post(
API.user.updateNickName,
params: {'nickName': name},
showMessage: true,
);
if (baseModel.status) {
_userInfoModel.nickName = name;
notifyListeners();
}
}
}

Loading…
Cancel
Save