Blame view

lib/pages/login/loginpage/login_page.dart 11.1 KB
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
1
  import 'package:flutter/gestures.dart';
2a29701f   liangchengyou   feat:提交代码
2
3
  import 'package:flutter/material.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
062f0df2   liangchengyou   feat:登录模块代码提交
4
  import 'package:flutter_screenutil/flutter_screenutil.dart';
c61b3c1a   Key   feat: toast_util....
5
  import 'package:wow_english/common/core/app_consts.dart';
062f0df2   liangchengyou   feat:登录模块代码提交
6
  import 'package:wow_english/common/extension/string_extension.dart';
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
7
  import 'package:wow_english/common/widgets/textfield_customer_widget.dart';
4b358e22   liangchengyou   feat:调整文件结构
8
  import 'package:wow_english/pages/login/loginpage/time_widget.dart';
95edef4f   liangchengyou   feat:更新适配代码
9
  import 'package:wow_english/route/route.dart';
2a29701f   liangchengyou   feat:提交代码
10
  
4b358e22   liangchengyou   feat:调整文件结构
11
12
  import 'bloc/login_bloc.dart';
  
2a29701f   liangchengyou   feat:提交代码
13
  class LoginPage extends StatelessWidget {
578f1729   吴启风   fix:修复老bug:修改密码后跳...
14
15
16
17
18
  
    // 优先展示密码登录
    final bool preferencesPasswordLogin;
  
    const LoginPage({super.key, this.preferencesPasswordLogin = false});
2a29701f   liangchengyou   feat:提交代码
19
20
21
  
    @override
    Widget build(BuildContext context) {
2a29701f   liangchengyou   feat:提交代码
22
      return BlocProvider(
578f1729   吴启风   fix:修复老bug:修改密码后跳...
23
        create: (context) => LoginBloc(preferencesPasswordLogin),
e1f36554   liangchengyou   feat:调整状态监听逻辑
24
25
26
27
28
29
30
31
        child: _LoginPageView(),
      );
    }
  }
  
  class _LoginPageView extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
05f9b20a   Key   fixed: api调用方式,未完善
32
33
34
      return BlocListener<LoginBloc, LoginState>(
        listener: (context, state) {
          if (state is LoginResultChangeState) {
aa4e28be   Key   removed: cache_bl...
35
36
            // 调试用
            // Navigator.of(context).pushNamed(AppRouteName.home);
2187c85f   吴启风   feat:课程结构调整
37
            pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
05f9b20a   Key   fixed: api调用方式,未完善
38
39
          }
        },
2a29701f   liangchengyou   feat:提交代码
40
41
42
43
        child: _buildLoginViewWidget(),
      );
    }
  
05f9b20a   Key   fixed: api调用方式,未完善
44
    Widget _buildLoginViewWidget() => BlocBuilder<LoginBloc, LoginState>(
15987941   liangchengyou   feat:兑换码接口+本地密码加密
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
      builder: (context, state) {
        final bloc = BlocProvider.of<LoginBloc>(context);
        return Scaffold(
          body: SafeArea(
            child: SingleChildScrollView(
              child: Container(
                padding: EdgeInsets.only(top: 25.h),
                child: Stack(
                  children: [
                    Positioned(
                        right: 29.w,
                        child: GestureDetector(
                          onTap: () => bloc.add(ChangeLoginTypeEvent()),
                          child: Container(
                            decoration: BoxDecoration(
                              image: DecorationImage(image: AssetImage('login_logo'.assetPng), fit: BoxFit.fill),
                            ),
                            padding: EdgeInsets.symmetric(horizontal: 18.w, vertical: 5.h),
                            child: Text(
                              bloc.isSmsLoginType ? '密码登录' : '验证码登录',
                              style: TextStyle(fontSize: 16.sp),
                            ),
                          ),
                        )),
                    Center(
                      child: Column(
                        children: [
                          Image.asset(
                            'wow_logo'.assetPng,
                            height: 81.h,
                            width: 131.w,
                          ),
                          Offstage(
                            offstage: !bloc.isSmsLoginType,
                            child: _buildSmsViewWidget(),
                          ),
                          Offstage(
                            offstage: bloc.isSmsLoginType,
                            child: _buildPwdViewWidget(),
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.center,
39e06486   liangchengyou   feat:获取验证码逻辑处理
87
                            children: [
39e06486   liangchengyou   feat:获取验证码逻辑处理
88
                              GestureDetector(
15987941   liangchengyou   feat:兑换码接口+本地密码加密
89
90
91
92
93
94
                                onTap: () => bloc.add(AgreementChangeEvent()),
                                child: Icon(bloc.agreement ? Icons.check_circle_outlined : Icons.circle_outlined,
                                    color: bloc.agreement ? Colors.green : Colors.black),
                              ),
                              6.horizontalSpace,
                              RichText(
3840b7fe   liangchengyou   feat:更新设置页面
95
96
97
98
99
100
101
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
                                text: TextSpan(
                                    children: [
                                      TextSpan(
                                          text: '我已阅读并同意',
                                          style: TextStyle(
                                            fontSize: 12.sp,
                                            color: const Color(0xFF333333),
                                          )),
                                      TextSpan(
                                          text: '《用户隐私协议》',
                                          style: TextStyle(
                                            fontSize: 12.sp,
                                            color: const Color(0xFF333333),
                                          ),
                                          recognizer: TapGestureRecognizer()
                                            ..onTap = () {
                                              Navigator.of(context).pushNamed(AppRouteName.webView, arguments: {
                                                'urlStr': AppConsts.userPrivacyPolicyUrl,
                                                'webViewTitle': '用户隐私协议'
                                              });
                                            }),
                                      TextSpan(
                                          text: ',', style: TextStyle(fontSize: 12.sp, color: const Color(0xFF333333))),
                                      TextSpan(
                                          text: '《儿童隐私政策》',
                                          style: TextStyle(fontSize: 12.sp, color: const Color(0xFF333333)),
                                          recognizer: TapGestureRecognizer()
                                            ..onTap = () {
                                              Navigator.of(context).pushNamed(AppRouteName.webView, arguments: {
                                                'urlStr': AppConsts.childrenPrivacyPolicyUrl,
                                                'webViewTitle': '儿童隐私协议'
                                              });
                                            })
                                    ]),
39e06486   liangchengyou   feat:获取验证码逻辑处理
129
130
131
                              )
                            ],
                          ),
15987941   liangchengyou   feat:兑换码接口+本地密码加密
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
                          GestureDetector(
                            onTap: () {
                              if (bloc.canLogin) {
                                bloc.add(RequestLoginEvent());
                              }
                            },
                            child: Container(
                              decoration: BoxDecoration(
                                image: DecorationImage(
                                    image: AssetImage(
                                        bloc.canLogin ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng),
                                    fit: BoxFit.fill),
                              ),
                              padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h),
                              child: Text(
                                '登录',
                                style: TextStyle(fontSize: 16.sp),
                              ),
                            ),
                          )
                        ],
                      ),
                    )
                  ],
05f9b20a   Key   fixed: api调用方式,未完善
156
157
                ),
              ),
15987941   liangchengyou   feat:兑换码接口+本地密码加密
158
159
            ),
          ),
2a29701f   liangchengyou   feat:提交代码
160
        );
15987941   liangchengyou   feat:兑换码接口+本地密码加密
161
162
      },
    );
062f0df2   liangchengyou   feat:登录模块代码提交
163
  
05f9b20a   Key   fixed: api调用方式,未完善
164
    Widget _buildSmsViewWidget() => BlocBuilder<LoginBloc, LoginState>(builder: (context, state) {
15987941   liangchengyou   feat:兑换码接口+本地密码加密
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
      final bloc = BlocProvider.of<LoginBloc>(context);
      return Padding(
        padding: EdgeInsets.symmetric(horizontal: 135.w),
        child: Column(
          children: [
            15.verticalSpace,
            TextFieldCustomerWidget(
              height: 55.h,
              hitText: '请输入手机号',
              textInputType: TextInputType.phone,
              bgImageName: 'Input_layer_up',
              onChangeValue: (String value) {
                bloc.add(PhoneNumChangeEvent());
              },
              controller: bloc.phoneNumController,
            ),
            6.5.verticalSpace,
            Text(
              '未注册用户登录默认注册',
              style: TextStyle(fontSize: 12.sp, color: const Color(0xFF999999)),
            ),
            4.5.verticalSpace,
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
2ca1b8bf   liangchengyou   feat:更新适配
189
              children: [
15987941   liangchengyou   feat:兑换码接口+本地密码加密
190
191
                Expanded(
                    child: TextFieldCustomerWidget(
05f9b20a   Key   fixed: api调用方式,未完善
192
193
194
195
196
197
198
199
200
                      height: 50.h,
                      hitText: '请输入验证码',
                      textInputType: TextInputType.number,
                      bgImageName: 'Input_layer_down',
                      onChangeValue: (String value) {
                        bloc.add(CheckFieldChangeEvent());
                      },
                      controller: bloc.checkNumController,
                    )),
15987941   liangchengyou   feat:兑换码接口+本地密码加密
201
202
203
                TimerWidget(
                  canSendSms: bloc.canSendSms,
                  sendSmsEvent: () => bloc.add(RequestSmsCodeEvent()),
2ca1b8bf   liangchengyou   feat:更新适配
204
205
                )
              ],
15987941   liangchengyou   feat:兑换码接口+本地密码加密
206
207
208
209
210
            )
          ],
        ),
      );
    });
062f0df2   liangchengyou   feat:登录模块代码提交
211
  
05f9b20a   Key   fixed: api调用方式,未完善
212
    Widget _buildPwdViewWidget() => BlocBuilder<LoginBloc, LoginState>(builder: (context, state) {
15987941   liangchengyou   feat:兑换码接口+本地密码加密
213
214
215
216
217
218
219
220
      final bloc = BlocProvider.of<LoginBloc>(context);
      return Padding(
        padding: EdgeInsets.symmetric(horizontal: 90.w),
        child: Column(
          children: [
            15.verticalSpace,
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
1a43bf7c   liangchengyou   feat:更新UI
221
              children: [
15987941   liangchengyou   feat:兑换码接口+本地密码加密
222
223
224
225
226
227
228
229
                Image.asset(
                  'phone'.assetPng,
                  height: 45.h,
                  width: 35.w,
                ),
                10.5.horizontalSpace,
                Expanded(
                    child: TextFieldCustomerWidget(
05f9b20a   Key   fixed: api调用方式,未完善
230
231
232
233
234
235
236
237
238
                      height: 50.h,
                      hitText: '请输入手机号',
                      textInputType: TextInputType.phone,
                      bgImageName: 'Input_layer_up',
                      onChangeValue: (String value) {
                        bloc.add(PhoneNumChangeEvent());
                      },
                      controller: bloc.phoneNumController,
                    )),
15987941   liangchengyou   feat:兑换码接口+本地密码加密
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
                5.horizontalSpace,
                SizedBox(
                  width: 100.w,
                  height: 55.h,
                )
              ],
            ),
            12.verticalSpace,
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Image.asset(
                  'lock'.assetPng,
                  height: 34.h,
                  width: 31.w,
1a43bf7c   liangchengyou   feat:更新UI
254
                ),
15987941   liangchengyou   feat:兑换码接口+本地密码加密
255
256
257
                10.5.horizontalSpace,
                Expanded(
                    child: TextFieldCustomerWidget(
05f9b20a   Key   fixed: api调用方式,未完善
258
                      hitText: '请输入密码',
15987941   liangchengyou   feat:兑换码接口+本地密码加密
259
                      obscureText: true,
05f9b20a   Key   fixed: api调用方式,未完善
260
261
262
263
264
265
                      bgImageName: 'Input_layer_down',
                      onChangeValue: (String value) {
                        bloc.add(CheckFieldChangeEvent());
                      },
                      controller: bloc.checkNumController,
                    )),
15987941   liangchengyou   feat:兑换码接口+本地密码加密
266
267
268
269
270
271
272
273
274
275
276
277
278
279
                5.horizontalSpace,
                GestureDetector(
                  onTap: () {
                    Navigator.of(context).pushNamed(AppRouteName.fogPwd);
                  },
                  child: Container(
                    width: 100.w,
                    height: 55.h,
                    alignment: Alignment.centerLeft,
                    child: Text(
                      '忘记密码 ?',
                      style: TextStyle(fontSize: 12.sp),
                    ),
                  ),
1a43bf7c   liangchengyou   feat:更新UI
280
281
                )
              ],
15987941   liangchengyou   feat:兑换码接口+本地密码加密
282
283
284
285
286
            )
          ],
        ),
      );
    });
2a29701f   liangchengyou   feat:提交代码
287
  }