c9df43c8
Key
feat: 修改个人信息、接口
|
1
|
import 'package:flutter/cupertino.dart';
|
49e626e9
Key
feat: log_util.dart
|
2
|
import 'package:flutter/material.dart';
|
c9df43c8
Key
feat: 修改个人信息、接口
|
3
|
import 'package:flutter/services.dart';
|
49e626e9
Key
feat: log_util.dart
|
4
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
c9df43c8
Key
feat: 修改个人信息、接口
|
5
6
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/core/assets_const.dart';
|
e6a4e63c
Key
fixed: 修改个人信息性别
|
7
|
import 'package:wow_english/common/core/user_util.dart';
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
8
|
import 'package:wow_english/common/dialogs/show_dialog.dart';
|
c9df43c8
Key
feat: 修改个人信息、接口
|
9
|
import 'package:wow_english/common/widgets/textfield_customer_widget.dart';
|
49e626e9
Key
feat: log_util.dart
|
10
11
|
import 'package:wow_english/common/widgets/we_app_bar.dart';
import 'package:wow_english/pages/user/bloc/user_bloc.dart';
|
c948a9ea
liangchengyou
feat:个人信息更改模块功能
|
12
13
14
|
import 'package:wow_english/pages/user/modify/user_info_bloc/user_info_bloc.dart';
import 'package:wow_english/route/route.dart';
import 'package:wow_english/utils/toast_util.dart';
|
49e626e9
Key
feat: log_util.dart
|
15
16
|
enum ModifyUserInformationType {
|
c9df43c8
Key
feat: 修改个人信息、接口
|
17
18
19
20
|
avatar('头像'),
name('名字'),
age('年龄'),
gender('性别');
|
49e626e9
Key
feat: log_util.dart
|
21
22
23
24
25
26
27
28
29
30
31
|
const ModifyUserInformationType(this.title);
final String title;
}
class ModifyUserInformationPage extends StatelessWidget {
final ModifyUserInformationType type;
const ModifyUserInformationPage({super.key, required this.type});
|
c9df43c8
Key
feat: 修改个人信息、接口
|
32
33
34
35
36
37
|
static push(BuildContext context, ModifyUserInformationType type) {
Navigator.of(context).push(CupertinoPageRoute(builder: (context) {
return ModifyUserInformationPage(type: type);
}));
}
|
49e626e9
Key
feat: log_util.dart
|
38
39
|
@override
Widget build(BuildContext context) {
|
c948a9ea
liangchengyou
feat:个人信息更改模块功能
|
40
41
42
43
44
45
|
String text = '';
if (type == ModifyUserInformationType.age) {
text = UserUtil.getUser()!.age.toString();
} else if (type == ModifyUserInformationType.name) {
text = UserUtil.getUser()!.name;
}
|
49e626e9
Key
feat: log_util.dart
|
46
|
return BlocProvider(
|
c948a9ea
liangchengyou
feat:个人信息更改模块功能
|
47
48
49
|
create: (context) => UserInfoBloc()..add(InitControllerTextEvent(text)),
child: MultiBlocListener(
listeners: [
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
50
|
BlocListener<UserBloc, UserState>(listener: (context, state) {
|
c948a9ea
liangchengyou
feat:个人信息更改模块功能
|
51
52
53
54
55
56
|
if (state is UserInfoUpdated) {
showToast('修改成功');
popPage();
}
})
],
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
57
58
59
60
61
62
63
64
65
66
|
child: BlocBuilder<UserInfoBloc, UserInfoState>(
builder: (context, state) {
final bloc = BlocProvider.of<UserInfoBloc>(context);
return Scaffold(
backgroundColor: Colors.white,
appBar: WEAppBar(
titleText: '修改${type.title}',
onBack: () {
final bloc = BlocProvider.of<UserInfoBloc>(context);
if (bloc.isChangeInfo) {
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
67
68
|
showTwoActionDialog('提示', '确定离开', '继续修改', '您的信息尚未保存',
leftTap: () {
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
69
|
popPage();
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
70
71
|
popPage();
}, rightTap: () {
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
72
73
74
75
76
77
78
79
80
|
popPage();
});
} else {
popPage();
}
},
),
body: SingleChildScrollView(
child: Column(
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
81
82
83
84
85
|
children: [
Padding(
padding:
EdgeInsets.only(left: 65.w, right: 55.w, top: 38.h),
child: Row(
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
86
|
children: [
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
87
88
89
90
91
92
93
|
Text(
type.title,
style: TextStyle(
fontWeight: FontWeight.w700,
color: const Color(0xFF333333),
fontSize: 21.sp,
),
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
94
|
),
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
95
96
97
98
99
100
|
20.horizontalSpace,
// 输入框 or 选择框
_buildTextFieldWidget(context),
// 占位
Expanded(
child: Container(),
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
101
|
),
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
// 按钮
GestureDetector(
onTap: () {
var text = '';
if (type == ModifyUserInformationType.name ||
type == ModifyUserInformationType.age) {
if (bloc.modifyTextController.text.isEmpty) {
showToast('内容不能为空');
return;
}
text = bloc.modifyTextController.text;
}
if (type == ModifyUserInformationType.gender) {
text = bloc.gender.toString();
}
// 更新type类型的字段
context
.read<UserBloc>()
.add(UserUpdate(type, text));
},
child: Container(
alignment: Alignment.center,
width: 90.w,
height: 44.h,
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage(AssetsConst.bgButtonBlue),
fit: BoxFit.fill),
),
child: Text(
'确定',
style: TextStyle(
fontSize: 17.sp, color: Colors.white),
),
),
)
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
139
|
],
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
140
141
142
143
144
145
146
147
148
149
150
151
152
|
)),
Stack(
alignment: Alignment.topRight,
children: [
Image.asset(
AssetsConst.bgEditUserInformation,
width: double.infinity,
),
Positioned(
right: 125.w,
top: 10.h,
child: Image.asset(AssetsConst.bgIcSteveWrite,
width: 161.w, height: 249.w),
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
153
154
|
),
],
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
155
156
157
|
),
],
)),
|
68dd7ba8
liangchengyou
feat:首页主题颜色+已知问题修改
|
158
159
|
);
},
|
49e626e9
Key
feat: log_util.dart
|
160
161
162
163
|
),
),
);
}
|
23b46e8e
Key
feat: 修改个人信息性别
|
164
165
|
Widget _buildTextFieldWidget(BuildContext context) {
|
23b46e8e
Key
feat: 修改个人信息性别
|
166
|
if (type == ModifyUserInformationType.gender) {
|
c948a9ea
liangchengyou
feat:个人信息更改模块功能
|
167
|
return BlocBuilder<UserInfoBloc, UserInfoState>(
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
builder: (context, state) {
final bloc = BlocProvider.of<UserInfoBloc>(context);
return Row(
children: <Widget>[
GestureDetector(
onTap: () => bloc.add(ChangeGenderEvent(0)),
child: _buildSexWidget('男', bloc.gender == 0),
),
70.horizontalSpace,
GestureDetector(
onTap: () => bloc.add(ChangeGenderEvent(1)),
child: _buildSexWidget('女', bloc.gender == 1),
)
],
);
});
|
23b46e8e
Key
feat: 修改个人信息性别
|
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
}
var formatters = [
LengthLimitingTextInputFormatter(12),
FilteringTextInputFormatter.deny(RegExp('[ ]')),
];
var inputType = TextInputType.name;
// 当输入年龄时
if (type == ModifyUserInformationType.age) {
formatters = [
LengthLimitingTextInputFormatter(2),
FilteringTextInputFormatter.deny(RegExp('[ ]')),
];
inputType = TextInputType.number;
}
|
e6a4e63c
Key
fixed: 修改个人信息性别
|
199
|
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
|
return BlocBuilder<UserInfoBloc, UserInfoState>(builder: (context, state) {
final bloc = BlocProvider.of<UserInfoBloc>(context);
return TextFieldCustomerWidget(
height: 65.h,
width: 222.w,
textStyle: TextStyle(
fontWeight: FontWeight.w700,
color: const Color(0xFF333333),
fontSize: 21.sp,
),
bgImageName: 'Input_layer_up',
textInputType: inputType,
inputFormatters: formatters,
controller: bloc.modifyTextController,
onChangeValue: (String value) {
bloc.add(ChangeTextFieldEvent(value));
},
);
});
|
23b46e8e
Key
feat: 修改个人信息性别
|
219
|
}
|
e5c9e98f
liangchengyou
feat:首页模块颜色
|
220
|
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
221
|
Widget _buildSexWidget(String title, bool isSelect) {
|
e5c9e98f
liangchengyou
feat:首页模块颜色
|
222
223
224
225
226
227
228
229
|
return Row(
children: [
Container(
width: 21.h,
height: 21.h,
padding: EdgeInsets.all(4.h),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(21.r),
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
230
|
border: Border.all(color: const Color(0xFF140C10), width: 1.5)),
|
e5c9e98f
liangchengyou
feat:首页模块颜色
|
231
|
child: Offstage(
|
80aafd80
biao
修复 新用户修改年龄页面显示nul...
|
232
|
offstage: !isSelect,
|
e5c9e98f
liangchengyou
feat:首页模块颜色
|
233
234
235
236
237
238
239
240
241
242
243
244
245
|
child: ClipRRect(
borderRadius: BorderRadius.circular(13.r),
child: Container(
color: Colors.blue,
),
),
),
),
5.horizontalSpace,
Text(title)
],
);
}
|
49e626e9
Key
feat: log_util.dart
|
246
|
}
|