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