提交 428947d3 authored 作者: maodou's avatar maodou

我的-用户信息-性别及昵称修改

上级 d94d3a81
......@@ -181,7 +181,7 @@ abstract class MineAPI {
///
static Future <bool> changeInfo({
String? name,
String? sex,
num? sex,
String? headImg
}) async {
Map<String,dynamic> params = {};
......
library user_feedback;
import 'package:flutter/material.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_book/utils/index.dart';
import '../../widgets/index.dart';
......
......@@ -16,10 +16,9 @@ class _UserFeedbackPageState extends State<UserFeedbackPage> {
centerTitle: true,
),
body: Container(
margin: const EdgeInsets.symmetric(horizontal: AppTheme.margin),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
color: Colors.transparent,
),
child: Column(
mainAxisSize: MainAxisSize.min,
......@@ -40,7 +39,9 @@ class _UserFeedbackPageState extends State<UserFeedbackPage> {
])),
),
Container(
padding: const EdgeInsets.only(left: 10, right:10,top: 6.5,bottom: 10),
padding: const EdgeInsets.only(
left: 10, right: 10, top: 6.5, bottom: 10),
child: const CustomInput(
maxLines: 5,
hintText: '请描述你的问题,我们会尽快处理并回复',
......@@ -49,48 +50,26 @@ class _UserFeedbackPageState extends State<UserFeedbackPage> {
// _buildTextField(context),
Container(
padding: const EdgeInsets.only(left: 10, right:10,top: 35,bottom: 20),
padding: const EdgeInsets.only(
left: 10, right: 10, top: 35, bottom: 20),
width: double.infinity,
child: ElevatedButton(
child:
CustomGradientButton(
text: '提交反馈',
isEnabled: true,
onPressed: () {
print("提交反馈");
print('提交反馈');
// controller.onLogin(context);
},
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colours.cAB1941),
shape: MaterialStateProperty.all(BeveledRectangleBorder(borderRadius: BorderRadius.circular(2))),//圆角弧度
),
child: const Text(
"提交反馈",
style: TextStyle(fontSize: 14, color: Colours.cFF),
)),
)
),
],
),
));
}
)
Widget _buildTextField(BuildContext context) {
return Container(
padding: const EdgeInsets.only(left: 10, right:10,top:30),
width: double.infinity,
child: TextField(
style: const TextStyle(color: Colors.blue,height: 3,),
minLines: 5,
maxLines: 5,
cursorColor: Colours.c3,
cursorRadius: const Radius.circular(3),
cursorWidth: 1,
showCursor: true,
decoration: const InputDecoration(
contentPadding: EdgeInsets.all(10),
hintText: "请描述你的问题,我们会尽快处理并回复",
border: OutlineInputBorder(),
),
onChanged: (v) {},
),
);
}
}
part of user_gender;
class UserGenderController extends GetxController {
final UserInfoModel userInfo;
UserGenderController(this.userInfo);
/// 修改用用户信息
void _changeInfo(num sex) async {
final result = await MineAPI.changeInfo(sex: sex);
if (result) {
Toast.show('修改成功');
userInfo.sex = sex ;
update();
}
}
}
library user_gender;
import 'dart:ffi';
import 'package:flutter/material.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_book/utils/index.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get_state_manager/src/simple/get_state.dart';
import 'package:go_router/go_router.dart';
import '../../apis/index.dart';
import '../../models/index.dart';
part 'view.dart';
part 'controller.dart';
\ No newline at end of file
part of user_gender;
class UserGenderPage extends StatefulWidget {
final UserInfoModel userInfo;
const UserGenderPage({Key? key, required this.userInfo}) : super(key: key);
@override
State<UserGenderPage> createState() => _UserGenderPageState();
}
class _UserGenderPageState extends State<UserGenderPage> {
late num? selectedGender ; // 选中的性别
@override
void initState() {
super.initState();
selectedGender = widget.userInfo.sex;
// 在这里可以使用 localVariable 进行操作
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () async {
context.pop(true);
return false;
},
child: GetBuilder<UserGenderController>(
init: UserGenderController(widget.userInfo),
builder: (controller) => Scaffold(
appBar: CustomAppBar(
title: const Text('设置性别'),
actions: [],
),
body: Container(
margin: const EdgeInsets.symmetric(
horizontal: AppTheme.margin, vertical: AppTheme.margin),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
boxShadow: [
BoxShadow(
color: const Color(0xFFC7C7C7).withOpacity(0.5),
offset: const Offset(3, 0),
blurRadius: 10.w,
spreadRadius: 0.w,
),
],
),
child: ClipRRect(
borderRadius: BorderRadius.circular(8),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
/// 男
GestureDetector(
onTap: () {
// print("点击了男");
setState(() {
controller._changeInfo(1);
selectedGender = 1;
});
},
child: Container(
padding: const EdgeInsets.only(left: 15, right: 15),
color: Colors.transparent,
height: 35,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
"男",
style: TextStyle(
fontSize: 14,
color: Colours.c3,
),
),
Visibility(
visible: selectedGender == 1,
// child: Image.asset('assets/images/check.png'))
child: Image(
image:
const AssetImage("assets/images/check.png"),
height: 15.w,
width: 15.w,
)),
],
),
),
/* Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildItem(
'男',
),
Padding(
padding: const EdgeInsets.only(right: 18),
child: Visibility(
visible: selectedGender == 1,
child: Image.asset('assets/images/check.png'))),
],
)*/
),
Container(
color: Colours.cLine,
margin: const EdgeInsets.symmetric(horizontal: 10),
height: 1,
),
GestureDetector(
onTap: () {
setState(() {
controller._changeInfo(2);
selectedGender = 2;
});
},
child: Container(
padding: const EdgeInsets.only(left: 15, right: 15),
color: Colors.transparent,
height: 35,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
"女",
style: TextStyle(
fontSize: 14,
color: Colours.c3,
),
),
Visibility(
visible: selectedGender == 2,
child: Image(
image:
const AssetImage("assets/images/check.png"),
height: 15.w,
width: 15.w,
))
],
),
),
/*Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildItem(
'女',
),
Padding(
padding: const EdgeInsets.only(right: 18),
child: Visibility(
visible: selectedGender == 2,
child: Image.asset('assets/images/check.png'))),
],
)*/
),
Container(
color: Colours.cLine,
margin: const EdgeInsets.symmetric(horizontal: 10),
height: 1,
),
GestureDetector(
onTap: () {
setState(() {
controller._changeInfo(3);
selectedGender = 3;
});
},
child: /*Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
_buildItem(
'保密',
),
Padding(
padding: const EdgeInsets.only(right: 18),
child: Visibility(
visible: selectedGender == 3,
child: Image.asset('assets/images/check.png'))),
],
)*/
Container(
padding: const EdgeInsets.only(left: 15, right: 15),
color: Colors.transparent,
height: 35,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Text(
"保密",
style: TextStyle(
fontSize: 14,
color: Colours.c3,
),
),
Visibility(
visible: selectedGender == 3,
child: Image(
image:
const AssetImage("assets/images/check.png"),
height: 15.w,
width: 15.w,
))
],
),
),
),
],
),
),
))
),
);
}
}
......@@ -2,10 +2,8 @@ part of user_info;
class UserInfoPage extends StatefulWidget {
final UserInfoModel userInfo;
const UserInfoPage({
Key? key,
required this.userInfo
}) : super(key: key);
const UserInfoPage({Key? key, required this.userInfo}) : super(key: key);
@override
State<UserInfoPage> createState() => _UserInfoPageState();
......@@ -21,13 +19,15 @@ class _UserInfoPageState extends State<UserInfoPage> {
},
child: GetBuilder<UserInfoController>(
init: UserInfoController(widget.userInfo),
builder: (controller) =>Scaffold(
builder: (controller) =>
Scaffold(
appBar: AppBar(
title: const Text('个人信息'),
centerTitle: true,
),
body: Container(
margin: const EdgeInsets.symmetric(horizontal: AppTheme.margin,vertical: AppTheme.margin),
margin: const EdgeInsets.symmetric(
horizontal: AppTheme.margin, vertical: AppTheme.margin),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white,
......@@ -45,10 +45,11 @@ class _UserInfoPageState extends State<UserInfoPage> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
/// 头像
Container(
height: 52,
padding: const EdgeInsets.only(left: 18,right: 15),
padding: const EdgeInsets.only(left: 18, right: 15),
child: GestureDetector(
onTap: () async {
final assets = await AssetsPicker.image(
......@@ -58,14 +59,19 @@ class _UserInfoPageState extends State<UserInfoPage> {
maxHeight: 512,
);
controller.upload(path: assets!.path);
},
child: Container(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text('头像',style: TextStyle(color: Colours.c3,fontSize: 14,height: 1.6),),
const Text(
'头像',
style: TextStyle(
color: Colours.c3,
fontSize: 14,
height: 1.6),
),
Row(
children: [
Container(
......@@ -75,13 +81,17 @@ class _UserInfoPageState extends State<UserInfoPage> {
shape: BoxShape.circle,
color: Colors.cyan,
),
child: CustomImage.network(url: controller.userInfo.headImg??'',radius: 16.5,),
child: CustomImage.network(
url: controller.userInfo.headImg ?? '',
radius: 16.5,
),
),
Gaps.hGaps10,
SizedBox(
width: 5,
height: 8,
child: Image.asset('assets/images/right_arrow.png'),
child: Image.asset(
'assets/images/right_arrow.png'),
)
],
)
......@@ -90,37 +100,79 @@ class _UserInfoPageState extends State<UserInfoPage> {
),
),
),
Container(color: Colours.cLine,margin: const EdgeInsets.symmetric(horizontal: 15),height: 1,),
Container(
color: Colours.cLine,
margin: const EdgeInsets.symmetric(horizontal: 15),
height: 1,
),
GestureDetector(
onTap: (){
context.pushNamed(Routes.nike);
onTap: () {
context.pushNamed(Routes.nike, extra: controller.userInfo);
},
child: _buildItem('昵称', widget.userInfo.name??'', )
child: _buildItem(
'昵称',
widget.userInfo.name ?? '',
)),
Container(
color: Colours.cLine,
margin: const EdgeInsets.symmetric(horizontal: 15),
height: 1,
),
Container(color: Colours.cLine,margin: const EdgeInsets.symmetric(horizontal: 15),height: 1,),
_buildItem('性别', widget.userInfo.sex ==1?'男':'女',),
GestureDetector(
onTap: () {
context.pushNamed(
Routes.gender, extra: controller.userInfo);
},
child: _buildItem(
'性别',
getGender(widget.userInfo.sex)
// widget.userInfo.sex == 1 ? '男' : '女',
)),
],
),
),
)
),
),
)),)
,
);
}
getGender(num? sex) {
String gender;
if (sex == 1) {
gender = "男";
} else if (sex == 2) {
gender = "女";
} else {
gender = "保密";
}
return gender;
}
Widget _buildItem(String title, String value) {
return Container(
padding: const EdgeInsets.only(left: 18,right: 15),
padding: const EdgeInsets.only(left: 18, right: 15),
color: Colors.transparent,
height: 52,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(title,style: const TextStyle(fontSize: 14,color: Colours.c3,),),
Text(
title,
style: const TextStyle(
fontSize: 14,
color: Colours.c3,
),
),
Row(
children: [
Text(value,style: const TextStyle(fontSize:14,color: Colours.c9,),),
Text(
value,
style: const TextStyle(
fontSize: 14,
color: Colours.c9,
),
),
Gaps.hGaps10,
SizedBox(
width: 5,
......@@ -129,7 +181,6 @@ class _UserInfoPageState extends State<UserInfoPage> {
)
],
)
],
),
);
......
part of user_nick;
class UserNickController extends GetxController {
final UserInfoModel userInfo;
UserNickController(this.userInfo);
/// 修改用用户信息
void _changeInfo(String nick) async {
final result = await MineAPI.changeInfo(name: nick);
if (result) {
Toast.show('修改成功');
userInfo.name = nick ;
update();
}
}
}
......@@ -4,5 +4,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_book/theme.dart';
import 'package:flutter_book/utils/index.dart';
import 'package:flutter_book/widgets/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:get/get_state_manager/src/simple/get_controllers.dart';
import '../../apis/index.dart';
import '../../models/index.dart';
import '../user_gender/index.dart';
part 'view.dart';
part 'controller.dart';
\ No newline at end of file
part of user_nick;
class UserNickPage extends StatefulWidget {
const UserNickPage({Key? key}) : super(key: key);
final UserInfoModel userInfo;
const UserNickPage({Key? key, required this.userInfo}) : super(key: key);
@override
State<UserNickPage> createState() => _UserNickPageState();
}
class _UserNickPageState extends State<UserNickPage> {
TextEditingController _textFieldController = TextEditingController();
@override
void initState() {
super.initState();
_textFieldController.text = widget.userInfo.name!;
// 在这里可以使用 localVariable 进行操作
}
@override
Widget build(BuildContext context) {
return Scaffold(
return GetBuilder<UserNickController>(
init: UserNickController(widget.userInfo),
builder: (controller) => Scaffold(
appBar: CustomAppBar(
title: const Text('设置昵称'),
actions: [
......@@ -19,50 +32,78 @@ class _UserNickPageState extends State<UserNickPage> {
width: 40,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border:Border.all(
color: AppTheme.primary,
width: 1
)
border: Border.all(color: AppTheme.primary, width: 1)),
child: Center(
child: GestureDetector(
onTap: () {
// print("保存昵称");
controller._changeInfo(_textFieldController.text);
},
child: const Text(
'保存',
style: TextStyle(
fontSize: 12, color: AppTheme.primary),
)),
),
child: Center(child: const Text('保存',style: TextStyle(fontSize: 12,color: AppTheme.primary),)),
)
],
),
body: Container(
margin: const EdgeInsets.symmetric(horizontal: AppTheme.margin),
height: 52,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: Colors.white
height: 42,
decoration: BoxDecoration(boxShadow: [
BoxShadow(
color: Colours.cC7.withOpacity(0.5),
spreadRadius: 0,
blurRadius: 10,
offset: const Offset(3, 0),
),
], borderRadius: BorderRadius.circular(8), color: Colors.white),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
padding: const EdgeInsets.only(
left: 15,
right: 15,
),
child: Row(
children: [
Text('昵称'),
const Text(
'昵称',
style: TextStyle(fontSize: 14, color: Colours.c3),
),
Gaps.hGaps15,
Expanded(
child: TextField(
decoration: InputDecoration(
controller: _textFieldController,
style:
const TextStyle(fontSize: 14, color: Colours.c3),
decoration: const InputDecoration(
filled: true,
fillColor: Colors.transparent,
// 设置背景颜色为透明
hintText: '请输入昵称',
border: InputBorder.none,
enabledBorder: InputBorder.none,
focusedBorder: InputBorder.none,
suffixIcon: Center(
child: IconButton(
onPressed: (){
},
icon: Icon(Icons.clear),
suffixIconConstraints: BoxConstraints.tightFor(
height: 15, width: 15)),
),
),
suffixIconConstraints: BoxConstraints.tightFor(height: 15,width: 15)
GestureDetector(
onTap: () {
// 处理点击事件,可以执行任意操作
_textFieldController.clear();
print('Image Clicked!');
},
child: Image(
image: AssetImage('assets/images/del.png'),
height: 15.w,
width: 15.w,
),
),
)
],
),
),
),
);
));
}
}
......@@ -22,6 +22,7 @@ import 'package:flutter_book/pages/user_coin/index.dart';
import 'package:flutter_book/pages/user_coupon/index.dart';
import 'package:flutter_book/pages/user_discuss/index.dart';
import 'package:flutter_book/pages/user_feedback/index.dart';
import 'package:flutter_book/pages/user_gender/index.dart';
import 'package:flutter_book/pages/user_info/index.dart';
import 'package:flutter_book/pages/user_love/index.dart';
import 'package:flutter_book/pages/user_msg/index.dart';
......
......@@ -218,7 +218,7 @@ abstract class Routes {
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: const UserNickPage()
child: UserNickPage(userInfo: state.extra as UserInfoModel,)
)
),
GoRoute(
......@@ -406,7 +406,7 @@ abstract class Routes {
)
),
GoRoute(
path: '/$feedback',
path: '/$feedback', // 意见反馈
name: feedback,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
......@@ -423,7 +423,15 @@ abstract class Routes {
child: UserNotesDesPage(model: state.extra as CourseModel,)
)
),
GoRoute(
path: '/$gender',
name: gender,
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: UserGenderPage(userInfo: state.extra as UserInfoModel,)
)
),
]
);
......
......@@ -78,7 +78,7 @@ packages:
description:
name: cross_file
sha256: "2f9d2cbccb76127ba28528cb3ae2c2326a122446a83de5a056aaa3880d3882c5"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.3.3+7"
crypto:
......@@ -200,7 +200,7 @@ packages:
description:
name: flutter_plugin_android_lifecycle
sha256: b068ffc46f82a55844acfa4fdbb61fad72fa2aef0905548419d97f0f95c456da
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.0.17"
flutter_screenutil:
......@@ -330,7 +330,7 @@ packages:
description:
name: image_picker
sha256: "9978d3510af4e6a902e545ce19229b926e6de6a1828d6134d3aab2e129a4d270"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.8.7+5"
image_picker_android:
......@@ -338,7 +338,7 @@ packages:
description:
name: image_picker_android
sha256: "39f2bfe497e495450c81abcd44b62f56c2a36a37a175da7d137b4454977b51b1"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.8.9+3"
image_picker_for_web:
......@@ -346,7 +346,7 @@ packages:
description:
name: image_picker_for_web
sha256: "869fe8a64771b7afbc99fc433a5f7be2fea4d1cb3d7c11a48b6b579eb9c797f0"
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.2.0"
image_picker_ios:
......@@ -354,7 +354,7 @@ packages:
description:
name: image_picker_ios
sha256: fadafce49e8569257a0cad56d24438a6fa1f0cbd7ee0af9b631f7492818a4ca3
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "0.8.9+1"
image_picker_platform_interface:
......@@ -362,7 +362,7 @@ packages:
description:
name: image_picker_platform_interface
sha256: fa4e815e6fcada50e35718727d83ba1c92f1edf95c0b4436554cec301b56233b
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "2.9.3"
intl:
......@@ -442,7 +442,7 @@ packages:
description:
name: mime
sha256: e4ff8e8564c03f255408decd16e7899da1733852a9110a58fe6d1b817684a63e
url: "https://pub.flutter-io.cn"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
nested:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论