Blame view

lib/pages/login/loginpage/login_page.dart 12 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';
fcc3a982   liangchengyou   feat:全局缓存bloc
5
  import 'package:wow_english/common/blocs/cachebloc/cache_bloc.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 {
062f0df2   liangchengyou   feat:登录模块代码提交
14
    const LoginPage({super.key});
2a29701f   liangchengyou   feat:提交代码
15
16
17
  
    @override
    Widget build(BuildContext context) {
2a29701f   liangchengyou   feat:提交代码
18
19
      return BlocProvider(
        create: (context) => LoginBloc(),
e1f36554   liangchengyou   feat:调整状态监听逻辑
20
21
22
23
24
25
26
27
        child: _LoginPageView(),
      );
    }
  }
  
  class _LoginPageView extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
05f9b20a   Key   fixed: api调用方式,未完善
28
29
30
31
32
      return BlocListener<LoginBloc, LoginState>(
        listener: (context, state) {
          if (state is LoginResultChangeState) {
            context.read<CacheBloc>().add(UserInfoChangeEvent(state.userEntity));
            Navigator.of(context).pushNamed(AppRouteName.home);
6529e5f7   liangchengyou   feat:添加跳转逻辑
33
            // Navigator.of(context).pushNamedAndRemoveUntil(AppRouteName.home, (route) => false);
05f9b20a   Key   fixed: api调用方式,未完善
34
35
          }
        },
2a29701f   liangchengyou   feat:提交代码
36
37
38
39
        child: _buildLoginViewWidget(),
      );
    }
  
05f9b20a   Key   fixed: api调用方式,未完善
40
41
42
43
44
    Widget _buildLoginViewWidget() => BlocBuilder<LoginBloc, LoginState>(
          builder: (context, state) {
            final bloc = BlocProvider.of<LoginBloc>(context);
            return Scaffold(
              body: SafeArea(
39e06486   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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
                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,
                                children: [
                                  GestureDetector(
                                    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(
                                    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: {
c95453ce   Key   feat: User界面完善
107
                                                'urlStr': 'http://page.kouyuxingqiu.com/%E7%94%A8%E6%88%B7%E6%B3%A8%E5%86%8C%E5%8F%8A%E4%BD%BF%E7%94%A8APP%E9%9A%90%E7%A7%81%E5%8D%8F%E8%AE%AE.html',
39e06486   liangchengyou   feat:获取验证码逻辑处理
108
109
110
111
112
113
114
115
116
117
118
                                                '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: {
c95453ce   Key   feat: User界面完善
119
                                                'urlStr': 'https://ishowedu-public-images.ishowedu.com/%E5%8F%A3%E8%AF%AD%E6%98%9F%E7%90%83%E5%84%BF%E7%AB%A5%E9%9A%90%E7%A7%81%E4%BF%9D%E6%8A%A4%E6%94%BF%E7%AD%96_iShowLD%E4%BF%AE%E8%AE%A2_20210913%281%29.html',
39e06486   liangchengyou   feat:获取验证码逻辑处理
120
121
122
123
124
125
126
127
128
129
                                                'webViewTitle': '儿童隐私协议'
                                              });
                                            })
                                    ]),
                                  )
                                ],
                              ),
                              GestureDetector(
                                onTap: () {
                                  if (bloc.canLogin) {
39e06486   liangchengyou   feat:获取验证码逻辑处理
130
131
132
                                    bloc.add(RequestLoginEvent());
                                  }
                                },
05f9b20a   Key   fixed: api调用方式,未完善
133
134
                                child: Container(
                                  decoration: BoxDecoration(
39e06486   liangchengyou   feat:获取验证码逻辑处理
135
136
137
138
                                    image: DecorationImage(
                                        image: AssetImage(
                                            bloc.canLogin ? 'login_enter'.assetPng : 'login_enter_dis'.assetPng),
                                        fit: BoxFit.fill),
05f9b20a   Key   fixed: api调用方式,未完善
139
                                  ),
39e06486   liangchengyou   feat:获取验证码逻辑处理
140
                                  padding: EdgeInsets.symmetric(horizontal: 28.w, vertical: 14.h),
05f9b20a   Key   fixed: api调用方式,未完善
141
                                  child: Text(
39e06486   liangchengyou   feat:获取验证码逻辑处理
142
                                    '登录',
05f9b20a   Key   fixed: api调用方式,未完善
143
144
                                    style: TextStyle(fontSize: 16.sp),
                                  ),
f0d56772   liangchengyou   feat:更新尺寸适配
145
                                ),
39e06486   liangchengyou   feat:获取验证码逻辑处理
146
147
148
149
150
151
152
                              )
                            ],
                          ),
                        )
                      ],
                    ),
                  ),
05f9b20a   Key   fixed: api调用方式,未完善
153
154
155
156
                ),
              ),
            );
          },
2a29701f   liangchengyou   feat:提交代码
157
        );
062f0df2   liangchengyou   feat:登录模块代码提交
158
  
05f9b20a   Key   fixed: api调用方式,未完善
159
    Widget _buildSmsViewWidget() => BlocBuilder<LoginBloc, LoginState>(builder: (context, state) {
062f0df2   liangchengyou   feat:登录模块代码提交
160
          final bloc = BlocProvider.of<LoginBloc>(context);
2ca1b8bf   liangchengyou   feat:更新适配
161
          return Padding(
1a43bf7c   liangchengyou   feat:更新UI
162
            padding: EdgeInsets.symmetric(horizontal: 135.w),
2ca1b8bf   liangchengyou   feat:更新适配
163
164
165
            child: Column(
              children: [
                15.verticalSpace,
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
166
                TextFieldCustomerWidget(
4bf67b91   liangchengyou   feat:设置密码
167
168
169
170
171
172
173
174
                  height: 55.h,
                  hitText: '请输入手机号',
                  textInputType: TextInputType.phone,
                  bgImageName: 'Input_layer_up',
                  onChangeValue: (String value) {
                    bloc.add(PhoneNumChangeEvent());
                  },
                  controller: bloc.phoneNumController,
2ca1b8bf   liangchengyou   feat:更新适配
175
176
                ),
                6.5.verticalSpace,
05f9b20a   Key   fixed: api调用方式,未完善
177
178
179
180
                Text(
                  '未注册用户登录默认注册',
                  style: TextStyle(fontSize: 12.sp, color: const Color(0xFF999999)),
                ),
2ca1b8bf   liangchengyou   feat:更新适配
181
182
                4.5.verticalSpace,
                Row(
062f0df2   liangchengyou   feat:登录模块代码提交
183
184
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
1a43bf7c   liangchengyou   feat:更新UI
185
                    Expanded(
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
186
                        child: TextFieldCustomerWidget(
05f9b20a   Key   fixed: api调用方式,未完善
187
188
189
190
191
192
193
194
195
                      height: 50.h,
                      hitText: '请输入验证码',
                      textInputType: TextInputType.number,
                      bgImageName: 'Input_layer_down',
                      onChangeValue: (String value) {
                        bloc.add(CheckFieldChangeEvent());
                      },
                      controller: bloc.checkNumController,
                    )),
39e06486   liangchengyou   feat:获取验证码逻辑处理
196
197
198
199
                    TimerWidget(
                      canSendSms: bloc.canSendSms,
                      sendSmsEvent: () => bloc.add(RequestSmsCodeEvent()),
                    )
062f0df2   liangchengyou   feat:登录模块代码提交
200
                  ],
2ca1b8bf   liangchengyou   feat:更新适配
201
202
203
                )
              ],
            ),
062f0df2   liangchengyou   feat:登录模块代码提交
204
205
206
          );
        });
  
05f9b20a   Key   fixed: api调用方式,未完善
207
    Widget _buildPwdViewWidget() => BlocBuilder<LoginBloc, LoginState>(builder: (context, state) {
062f0df2   liangchengyou   feat:登录模块代码提交
208
          final bloc = BlocProvider.of<LoginBloc>(context);
1a43bf7c   liangchengyou   feat:更新UI
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
          return Padding(
            padding: EdgeInsets.symmetric(horizontal: 90.w),
            child: Column(
              children: [
                15.verticalSpace,
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Image.asset(
                      'phone'.assetPng,
                      height: 45.h,
                      width: 35.w,
                    ),
                    10.5.horizontalSpace,
                    Expanded(
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
224
                        child: TextFieldCustomerWidget(
05f9b20a   Key   fixed: api调用方式,未完善
225
226
227
228
229
230
231
232
233
                      height: 50.h,
                      hitText: '请输入手机号',
                      textInputType: TextInputType.phone,
                      bgImageName: 'Input_layer_up',
                      onChangeValue: (String value) {
                        bloc.add(PhoneNumChangeEvent());
                      },
                      controller: bloc.phoneNumController,
                    )),
1a43bf7c   liangchengyou   feat:更新UI
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
                    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,
                    ),
                    10.5.horizontalSpace,
                    Expanded(
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
252
                        child: TextFieldCustomerWidget(
05f9b20a   Key   fixed: api调用方式,未完善
253
254
255
256
257
258
259
                      hitText: '请输入密码',
                      bgImageName: 'Input_layer_down',
                      onChangeValue: (String value) {
                        bloc.add(CheckFieldChangeEvent());
                      },
                      controller: bloc.checkNumController,
                    )),
1a43bf7c   liangchengyou   feat:更新UI
260
261
                    5.horizontalSpace,
                    GestureDetector(
95edef4f   liangchengyou   feat:更新适配代码
262
                      onTap: () {
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
263
                        Navigator.of(context).pushNamed(AppRouteName.fogPwd);
95edef4f   liangchengyou   feat:更新适配代码
264
                      },
1a43bf7c   liangchengyou   feat:更新UI
265
266
267
268
                      child: Container(
                        width: 100.w,
                        height: 55.h,
                        alignment: Alignment.centerLeft,
f0d56772   liangchengyou   feat:更新尺寸适配
269
270
                        child: Text(
                          '忘记密码 ?',
05f9b20a   Key   fixed: api调用方式,未完善
271
                          style: TextStyle(fontSize: 12.sp),
2ca1b8bf   liangchengyou   feat:更新适配
272
                        ),
062f0df2   liangchengyou   feat:登录模块代码提交
273
                      ),
1a43bf7c   liangchengyou   feat:更新UI
274
275
276
277
278
                    )
                  ],
                )
              ],
            ),
062f0df2   liangchengyou   feat:登录模块代码提交
279
280
          );
        });
2a29701f   liangchengyou   feat:提交代码
281
  }