Commit 23b46e8e3df0e20a602108774441890d4be680a0

Authored by Key
1 parent cb38bc90

feat: 修改个人信息性别

lib/models/user_entity.dart
@@ -15,7 +15,7 @@ class UserEntity { @@ -15,7 +15,7 @@ class UserEntity {
15 15
16 int? age; 16 int? age;
17 17
18 - /// 性别:0, 1 18 + /// 性别:0男, 1女
19 int? gender; 19 int? gender;
20 String? avatarUrl; 20 String? avatarUrl;
21 late String phoneNum; 21 late String phoneNum;
lib/pages/user/information/user_information_page.dart
@@ -91,7 +91,8 @@ class _UserInformationContentView extends StatelessWidget { @@ -91,7 +91,8 @@ class _UserInformationContentView extends StatelessWidget {
91 color: const Color(0xFF333333), 91 color: const Color(0xFF333333),
92 fontSize: 21.sp, 92 fontSize: 21.sp,
93 ), 93 ),
94 - )), 94 + ),
  95 + onTap: () => _openModifyPage(context, ModifyUserInformationType.age)),
95 11.verticalSpace, 96 11.verticalSpace,
96 _buildContentRow( 97 _buildContentRow(
97 '性别', 98 '性别',
@@ -102,7 +103,8 @@ class _UserInformationContentView extends StatelessWidget { @@ -102,7 +103,8 @@ class _UserInformationContentView extends StatelessWidget {
102 color: const Color(0xFF333333), 103 color: const Color(0xFF333333),
103 fontSize: 21.sp, 104 fontSize: 21.sp,
104 ), 105 ),
105 - )), 106 + ),
  107 + onTap: () => _openModifyPage(context, ModifyUserInformationType.gender)),
106 11.verticalSpace, 108 11.verticalSpace,
107 _buildContentRow( 109 _buildContentRow(
108 '账号', 110 '账号',
lib/pages/user/modify/modify_user_avatar_page.dart 0 → 100644
lib/pages/user/modify/modify_user_information_page.dart
@@ -7,6 +7,7 @@ import 'package:wow_english/common/core/assets_const.dart'; @@ -7,6 +7,7 @@ import 'package:wow_english/common/core/assets_const.dart';
7 import 'package:wow_english/common/widgets/textfield_customer_widget.dart'; 7 import 'package:wow_english/common/widgets/textfield_customer_widget.dart';
8 import 'package:wow_english/common/widgets/we_app_bar.dart'; 8 import 'package:wow_english/common/widgets/we_app_bar.dart';
9 import 'package:wow_english/pages/user/bloc/user_bloc.dart'; 9 import 'package:wow_english/pages/user/bloc/user_bloc.dart';
  10 +import 'package:wow_english/utils/log_util.dart';
10 11
11 enum ModifyUserInformationType { 12 enum ModifyUserInformationType {
12 avatar('头像'), 13 avatar('头像'),
@@ -40,8 +41,7 @@ class ModifyUserInformationPage extends StatelessWidget { @@ -40,8 +41,7 @@ class ModifyUserInformationPage extends StatelessWidget {
40 titleText: '修改${type.title}', 41 titleText: '修改${type.title}',
41 ), 42 ),
42 body: BlocListener<UserBloc, UserState>( 43 body: BlocListener<UserBloc, UserState>(
43 - listener: (context, state) {  
44 - }, 44 + listener: (context, state) {},
45 child: BlocBuilder<UserBloc, UserState>(builder: (context, state) { 45 child: BlocBuilder<UserBloc, UserState>(builder: (context, state) {
46 //final bloc = context.read<UserBloc>(); 46 //final bloc = context.read<UserBloc>();
47 // 区别是什么? 47 // 区别是什么?
@@ -62,20 +62,9 @@ class ModifyUserInformationPage extends StatelessWidget { @@ -62,20 +62,9 @@ class ModifyUserInformationPage extends StatelessWidget {
62 ), 62 ),
63 ), 63 ),
64 20.horizontalSpace, 64 20.horizontalSpace,
65 - TextFieldCustomerWidget(  
66 - height: 65.h,  
67 - width: 222.w,  
68 - bgImageName: 'Input_layer_up',  
69 - textInputType: TextInputType.name,  
70 - inputFormatters: [  
71 - LengthLimitingTextInputFormatter(12),  
72 - FilteringTextInputFormatter.deny(RegExp('[ ]')),  
73 - ],  
74 - //controller: bloc.modifyTextController,  
75 - /*onChangeValue: (String value) {  
76 - bloc.add(CodeNumberChangeEvent());  
77 - },*/  
78 - ), 65 + // 输入框 or 选择框
  66 + _buildTextFieldWidget(context),
  67 + // 占位
79 Expanded( 68 Expanded(
80 child: Container(), 69 child: Container(),
81 ), 70 ),
@@ -83,7 +72,7 @@ class ModifyUserInformationPage extends StatelessWidget { @@ -83,7 +72,7 @@ class ModifyUserInformationPage extends StatelessWidget {
83 GestureDetector( 72 GestureDetector(
84 onTap: () { 73 onTap: () {
85 // 更新type类型的字段 74 // 更新type类型的字段
86 - //bloc.add(UserUpdate(type)); 75 + context.read<UserBloc>().add(UserUpdate(type));
87 }, 76 },
88 child: Container( 77 child: Container(
89 alignment: Alignment.center, 78 alignment: Alignment.center,
@@ -107,4 +96,54 @@ class ModifyUserInformationPage extends StatelessWidget { @@ -107,4 +96,54 @@ class ModifyUserInformationPage extends StatelessWidget {
107 ), 96 ),
108 ); 97 );
109 } 98 }
  99 +
  100 + Widget _buildTextFieldWidget(BuildContext context) {
  101 + if (type == ModifyUserInformationType.gender) {
  102 + return Row(
  103 + children: <Widget>[
  104 + RadioListTile(
  105 + title: const Text('男'),
  106 + value: 0,
  107 + groupValue: type,
  108 + onChanged: (value) {
  109 + Log.d('男value = $value');
  110 + },
  111 + ),
  112 + RadioListTile(
  113 + title: const Text('女'),
  114 + value: 1,
  115 + groupValue: type,
  116 + onChanged: (value) {
  117 + Log.d('女value = $value');
  118 + },
  119 + ),
  120 + ],
  121 + );
  122 + }
  123 +
  124 + var formatters = [
  125 + LengthLimitingTextInputFormatter(12),
  126 + FilteringTextInputFormatter.deny(RegExp('[ ]')),
  127 + ];
  128 + var inputType = TextInputType.name;
  129 + // 当输入年龄时
  130 + if (type == ModifyUserInformationType.age) {
  131 + formatters = [
  132 + LengthLimitingTextInputFormatter(2),
  133 + FilteringTextInputFormatter.deny(RegExp('[ ]')),
  134 + ];
  135 + inputType = TextInputType.number;
  136 + }
  137 + return TextFieldCustomerWidget(
  138 + height: 65.h,
  139 + width: 222.w,
  140 + bgImageName: 'Input_layer_up',
  141 + textInputType: inputType,
  142 + inputFormatters: formatters,
  143 + controller: context.read<UserBloc>().modifyTextController,
  144 + /*onChangeValue: (String value) {
  145 + bloc.add(CodeNumberChangeEvent());
  146 + },*/
  147 + );
  148 + }
110 } 149 }