c9df43c8
Key
feat: 修改个人信息、接口
|
1
|
import 'package:flutter/cupertino.dart';
|
4bf67b91
liangchengyou
feat:设置密码
|
2
3
4
5
|
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
|
4b358e22
liangchengyou
feat:调整文件结构
|
6
|
import 'package:wow_english/common/widgets/textfield_customer_widget.dart';
|
e1f36554
liangchengyou
feat:调整状态监听逻辑
|
7
|
import 'package:wow_english/route/route.dart';
|
4b2c2f07
Key
feat: 三种修改密码的类型及接口
|
8
|
import 'package:wow_english/utils/toast_util.dart';
|
4bf67b91
liangchengyou
feat:设置密码
|
9
|
|
4b358e22
liangchengyou
feat:调整文件结构
|
10
11
|
import 'bloc/set_pwd_bloc.dart';
|
c61b3c1a
Key
feat: toast_util....
|
12
13
|
enum SetPwdPageType {
/// 第一次设置密码
|
4b2c2f07
Key
feat: 三种修改密码的类型及接口
|
14
|
initPwd,
|
c61b3c1a
Key
feat: toast_util....
|
15
16
17
18
|
/// 忘记重设密码,必传手机号和验证码
resetPwd,
|
da82bd70
Key
feat: user_inform...
|
19
|
/// 修改密码,必传手机号和验证码,现在和忘记密码走一样的流程
|
c61b3c1a
Key
feat: toast_util....
|
20
21
|
changePwd,
}
|
4bf67b91
liangchengyou
feat:设置密码
|
22
|
|
1d5315dd
liangchengyou
feat:添加字体,调整文件结构
|
23
|
class SetPassWordPage extends StatelessWidget {
|
c61b3c1a
Key
feat: toast_util....
|
24
25
26
|
const SetPassWordPage({super.key, this.phoneNum, this.smsCode, required this.pageType});
final SetPwdPageType pageType;
|
4bf67b91
liangchengyou
feat:设置密码
|
27
|
final String? phoneNum;
|
c61b3c1a
Key
feat: toast_util....
|
28
|
final String? smsCode;
|
4bf67b91
liangchengyou
feat:设置密码
|
29
30
31
|
@override
Widget build(BuildContext context) {
|
4bf67b91
liangchengyou
feat:设置密码
|
32
|
return BlocProvider(
|
c61b3c1a
Key
feat: toast_util....
|
33
|
create: (context) => SetPwdBloc(phoneNum, smsCode, pageType),
|
e1f36554
liangchengyou
feat:调整状态监听逻辑
|
34
35
36
|
child: _SetPassWordPageView(),
);
}
|
c61b3c1a
Key
feat: toast_util....
|
37
|
|
c9df43c8
Key
feat: 修改个人信息、接口
|
38
|
/// [pageType]= [resetPwd] or [changePwd] 时,必传手机号和验证码
|
c61b3c1a
Key
feat: toast_util....
|
39
|
static push(BuildContext context, SetPwdPageType pageType, {String? phoneNum, String? smsCode}) {
|
c9df43c8
Key
feat: 修改个人信息、接口
|
40
41
42
43
44
45
46
|
Navigator.of(context).push(CupertinoPageRoute(builder: (context) {
return SetPassWordPage(
phoneNum: phoneNum,
smsCode: smsCode,
pageType: pageType,
);
}));
|
c61b3c1a
Key
feat: toast_util....
|
47
|
}
|
e1f36554
liangchengyou
feat:调整状态监听逻辑
|
48
49
50
|
}
class _SetPassWordPageView extends StatelessWidget {
|
c61b3c1a
Key
feat: toast_util....
|
51
52
|
late final SetPwdBloc bloc;
|
e1f36554
liangchengyou
feat:调整状态监听逻辑
|
53
54
|
@override
Widget build(BuildContext context) {
|
c61b3c1a
Key
feat: toast_util....
|
55
|
bloc = BlocProvider.of<SetPwdBloc>(context);
|
e1f36554
liangchengyou
feat:调整状态监听逻辑
|
56
|
return BlocListener<SetPwdBloc, SetPwdState>(
|
4b2c2f07
Key
feat: 三种修改密码的类型及接口
|
57
58
59
60
61
62
63
|
listener: (context, state) {
if (state is PasswordSetSuccessState) {
if (bloc.pageType == SetPwdPageType.initPwd) {
showToast('密码设置成功');
} else {
showToast('密码修改成功');
}
|
08a0f5a8
liangchengyou
feat:路由方式更新
|
64
|
pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
|
4b2c2f07
Key
feat: 三种修改密码的类型及接口
|
65
66
|
} else if (state is PasswordSetFailedState) {
state.message.toast();
|
e1f36554
liangchengyou
feat:调整状态监听逻辑
|
67
68
|
}
},
|
1d5315dd
liangchengyou
feat:添加字体,调整文件结构
|
69
70
71
72
|
child: _buildSetPwdView(),
);
}
|
c61b3c1a
Key
feat: toast_util....
|
73
|
String _getTipsText() {
|
da82bd70
Key
feat: user_inform...
|
74
|
String text = '接下来请设置一下您的新密码吧!';
|
c61b3c1a
Key
feat: toast_util....
|
75
76
|
switch (bloc.pageType) {
|
4b2c2f07
Key
feat: 三种修改密码的类型及接口
|
77
|
case SetPwdPageType.initPwd:
|
c61b3c1a
Key
feat: toast_util....
|
78
79
80
81
82
83
84
85
86
87
88
|
text = '欢迎登录wow english\n接下来请设置一下您的密码吧!';
break;
case SetPwdPageType.resetPwd:
case SetPwdPageType.changePwd:
text = '修改密码\n接下来请设置一下您的新密码吧!';
break;
}
return text;
}
Widget _buildSetPwdView() => BlocBuilder<SetPwdBloc, SetPwdState>(builder: (context, state) {
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
89
90
91
92
93
94
95
96
97
98
99
100
|
return Scaffold(
body: Container(
color: Colors.white,
child: SafeArea(
child: ListView(
children: [
Padding(
padding: EdgeInsets.symmetric(horizontal: 40.w),
child: Column(
children: [
34.verticalSpace,
Row(
|
1d5315dd
liangchengyou
feat:添加字体,调整文件结构
|
101
|
children: [
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
102
103
104
105
|
Image.asset(
'wow_logo'.assetPng,
height: 49.w,
width: 83.5.h,
|
4bf67b91
liangchengyou
feat:设置密码
|
106
|
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
12.5.horizontalSpace,
Text(
_getTipsText(),
style: TextStyle(fontSize: 16.5.sp, color: const Color(0xFF666666)),
)
],
),
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
43.verticalSpace,
Row(
|
1d5315dd
liangchengyou
feat:添加字体,调整文件结构
|
123
|
children: [
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
124
125
|
Expanded(
child: TextFieldCustomerWidget(
|
c61b3c1a
Key
feat: toast_util....
|
126
127
128
129
130
131
132
133
|
height: 55.h,
hitText: '请输入八位以上密码',
bgImageName: 'Input_layer_up',
controller: bloc.passWordFirstController,
obscureText: true,
textInputType: TextInputType.emailAddress,
onChangeValue: (String value) => bloc.add(PwdEnsureEvent()),
)),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
10.horizontalSpace,
Opacity(
opacity: bloc.showPwdIcon ? 1 : 0,
child: Image.asset(
bloc.passwordEnsure ? 'login_pass'.assetPng : 'login_error'.assetPng,
height: 30,
width: 30,
),
)
],
),
9.verticalSpace,
Offstage(
offstage: !bloc.passwordLarger,
child: const Text('您已达到密码最大输入数,请妥善调整密码'),
),
9.verticalSpace,
Row(
children: [
Expanded(
child: TextFieldCustomerWidget(
|
c61b3c1a
Key
feat: toast_util....
|
155
156
157
158
159
160
161
162
|
height: 55.h,
hitText: '请再次输入相同密码',
bgImageName: 'Input_layer_up',
obscureText: true,
textInputType: TextInputType.emailAddress,
controller: bloc.passWordSecondController,
onChangeValue: (String value) => bloc.add(PwdCheckEvent()),
)),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
163
164
165
166
167
168
169
|
10.horizontalSpace,
Opacity(
opacity: bloc.showCheckPwdIcon ? 1 : 0,
child: Image.asset(
bloc.passwordCheck ? 'login_pass'.assetPng : 'login_error'.assetPng,
height: 30,
width: 30,
|
4bf67b91
liangchengyou
feat:设置密码
|
170
|
),
|
1d5315dd
liangchengyou
feat:添加字体,调整文件结构
|
171
172
173
|
)
],
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
9.verticalSpace,
Offstage(
offstage: bloc.passwordCheck,
child: Text(
'请确认两次输入的密码是否一致',
style: TextStyle(fontSize: 16.sp, color: const Color(0xFF333333)),
),
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
GestureDetector(
onTap: () {
if (!bloc.ensure) {
return;
}
bloc.add(SetPasswordEvent());
},
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(
bloc.ensure ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng),
fit: BoxFit.fill),
),
padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h),
child: Text(
'确定',
style: TextStyle(color: Colors.white, fontSize: 16.sp),
),
),
),
50.horizontalSpace
],
)
],
),
|
4bf67b91
liangchengyou
feat:设置密码
|
211
|
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
212
213
214
215
216
217
|
30.horizontalSpace,
Image.asset(
'steven'.assetPng,
height: 254.h,
width: 100.w,
)
|
1d5315dd
liangchengyou
feat:添加字体,调整文件结构
|
218
219
|
],
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
220
221
222
223
|
],
),
)
],
|
4bf67b91
liangchengyou
feat:设置密码
|
224
|
),
|
cb38bc90
liangchengyou
feat:视频跟读逻辑处理
|
225
226
227
228
|
),
),
);
});
|
c61b3c1a
Key
feat: toast_util....
|
229
|
}
|