Blame view

lib/login/loginpage/login_page.dart 12.5 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';
062f0df2   liangchengyou   feat:登录模块代码提交
5
  import 'package:wow_english/common/extension/string_extension.dart';
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
6
7
  import 'package:wow_english/common/widgets/textfield_customer_widget.dart';
  import 'package:wow_english/login/loginpage/bloc/login_bloc.dart';
95edef4f   liangchengyou   feat:更新适配代码
8
  import 'package:wow_english/route/route.dart';
2a29701f   liangchengyou   feat:提交代码
9
  
2a29701f   liangchengyou   feat:提交代码
10
  class LoginPage extends StatelessWidget {
062f0df2   liangchengyou   feat:登录模块代码提交
11
    const LoginPage({super.key});
2a29701f   liangchengyou   feat:提交代码
12
13
14
  
    @override
    Widget build(BuildContext context) {
2a29701f   liangchengyou   feat:提交代码
15
16
17
18
19
20
21
22
23
24
      return BlocProvider(
        create: (context) => LoginBloc(),
        child: _buildLoginViewWidget(),
      );
    }
  
    Widget _buildLoginViewWidget() => BlocBuilder<LoginBloc,LoginState> (
      builder: (context, state) {
        final bloc = BlocProvider.of<LoginBloc>(context);
        return Scaffold(
062f0df2   liangchengyou   feat:登录模块代码提交
25
26
          body: SafeArea(
            child: ListView(
2a29701f   liangchengyou   feat:提交代码
27
              children: [
062f0df2   liangchengyou   feat:登录模块代码提交
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
                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: const EdgeInsets.symmetric(horizontal: 18.0),
                              child:  Text(
                                  bloc.loginType == LoginType.sms?'密码登陆':'验证码密码'
                              ),
                            ),
                          )
                      ),
                      Center(
                        child: Column(
                          children: [
                            Image.asset(
                              'wow_logo'.assetPng,
                              height: 81.h,
1a43bf7c   liangchengyou   feat:更新UI
58
59
                              width: 131.w,
                            ),
062f0df2   liangchengyou   feat:登录模块代码提交
60
61
62
63
64
65
66
67
                            Offstage(
                              offstage: bloc.loginType == LoginType.pwd,
                              child: _buildSmsViewWidget(),
                            ),
                            Offstage(
                              offstage: bloc.loginType == LoginType.sms,
                              child: _buildPwdViewWidget(),
                            ),
062f0df2   liangchengyou   feat:登录模块代码提交
68
69
70
71
72
73
74
75
76
77
                            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,
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
                                RichText(
                                  text: TextSpan(
                                      children:[
                                        const TextSpan(
                                            text: '我已阅读并同意',
                                            style: TextStyle(
                                              fontSize: 12,
                                              color: Color(0xFF333333),
                                            )
                                        ),
                                        TextSpan(
                                            text: '《用户隐私协议》',
                                            style: const TextStyle(
                                              fontSize: 12,
                                              color: Color(0xFF333333),
                                            ),
                                            recognizer: TapGestureRecognizer()..onTap = (){
                                              Navigator.of(context).pushNamed(
                                                  AppRouteName.webView,
                                                  arguments: {
                                                    'urlStr':'https://www.zhihu.com',
                                                    'webViewTitle':'用户隐私协议'
                                                  });
                                            }),
                                        const TextSpan(
                                            text: ',',
                                            style: TextStyle(
                                                fontSize: 12,
                                                color: Color(0xFF333333)
                                            )
                                        ),
                                        TextSpan(
                                            text: '《儿童隐私政策》',
                                            style: const TextStyle(
                                                fontSize: 12,
                                                color: Color(0xFF333333)
                                            ),
                                            recognizer: TapGestureRecognizer()..onTap = (){
                                              Navigator.of(context).pushNamed(
                                                  AppRouteName.webView,
                                                  arguments: {
                                                    'urlStr':'https://www.zhihu.com',
                                                    'webViewTitle':'儿童隐私协议'
                                                  });
                                            })
                                      ]
                                  ),
                                )
062f0df2   liangchengyou   feat:登录模块代码提交
126
127
                              ],
                            ),
062f0df2   liangchengyou   feat:登录模块代码提交
128
                            GestureDetector(
1a43bf7c   liangchengyou   feat:更新UI
129
130
131
132
133
                              onTap: () {
                                if (bloc.canLogin) {
                                  bloc.add(RequestLoginEvent());
                                }
                              },
062f0df2   liangchengyou   feat:登录模块代码提交
134
135
136
137
138
139
140
141
142
143
                              child: Container(
                                decoration: BoxDecoration(
                                  image: DecorationImage(
                                      image: AssetImage(
                                          bloc.canLogin?'login_enter'.assetPng:'login_enter_dis'.assetPng
                                      ),
                                      fit: BoxFit.fill
                                  ),
                                ),
                                padding: const EdgeInsets.symmetric(
2ca1b8bf   liangchengyou   feat:更新适配
144
145
                                    horizontal: 28.0,
                                    vertical: 14.0
062f0df2   liangchengyou   feat:登录模块代码提交
146
147
148
149
150
151
152
153
154
155
                                ),
                                child:  const Text(
                                    '登录'
                                ),
                              ),
                            )
                          ],
                        ),
                      )
                    ],
2a29701f   liangchengyou   feat:提交代码
156
157
158
159
160
161
162
163
                  ),
                )
              ],
            ),
          ),
        );
      },
    );
062f0df2   liangchengyou   feat:登录模块代码提交
164
165
166
167
  
    Widget _buildSmsViewWidget()=> BlocBuilder<LoginBloc,LoginState>(
        builder: (context,state){
          final bloc = BlocProvider.of<LoginBloc>(context);
2ca1b8bf   liangchengyou   feat:更新适配
168
          return Padding(
1a43bf7c   liangchengyou   feat:更新UI
169
            padding: EdgeInsets.symmetric(horizontal: 135.w),
2ca1b8bf   liangchengyou   feat:更新适配
170
171
172
            child: Column(
              children: [
                15.verticalSpace,
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
173
                TextFieldCustomerWidget(
4bf67b91   liangchengyou   feat:设置密码
174
175
176
177
178
179
180
181
                  height: 55.h,
                  hitText: '请输入手机号',
                  textInputType: TextInputType.phone,
                  bgImageName: 'Input_layer_up',
                  onChangeValue: (String value) {
                    bloc.add(PhoneNumChangeEvent());
                  },
                  controller: bloc.phoneNumController,
2ca1b8bf   liangchengyou   feat:更新适配
182
183
184
185
186
                ),
                6.5.verticalSpace,
                const Text('未注册用户登录默认注册'),
                4.5.verticalSpace,
                Row(
062f0df2   liangchengyou   feat:登录模块代码提交
187
188
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
1a43bf7c   liangchengyou   feat:更新UI
189
                    Expanded(
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
190
191
192
193
194
195
196
197
198
199
                        child: TextFieldCustomerWidget(
                          height: 50.h,
                          hitText: '请输入验证码',
                          textInputType: TextInputType.number,
                          bgImageName: 'Input_layer_down',
                          onChangeValue: (String value) {
                            bloc.add(CheckFieldChangeEvent());
                          },
                          controller: bloc.checkNumController,
                        )
062f0df2   liangchengyou   feat:登录模块代码提交
200
201
202
203
                    ),
                    GestureDetector(
                      onTap: () {
                        if (bloc.canSendSms) {
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
204
                          bloc.add(CountDownEvent());
062f0df2   liangchengyou   feat:登录模块代码提交
205
206
207
208
209
210
211
212
213
214
215
216
                        }
                      },
                      child: Container(
                        decoration: BoxDecoration(
                          image: DecorationImage(
                              image: AssetImage(
                                  bloc.canSendSms?'securitycode'.assetPng:'securitycode_dis'.assetPng
                              ),
                              fit: BoxFit.fill
                          ),
                        ),
                        padding: const EdgeInsets.symmetric(horizontal:12.0,vertical: 15.0),
bfb40cd0   liangchengyou   feat:忘记密码获取验证码
217
218
                        child:  Text(
                            !bloc.sendSmsIng  ? '获取验证码':'${bloc.countDown}s后在次获取'
062f0df2   liangchengyou   feat:登录模块代码提交
219
220
221
222
                        ),
                      ),
                    )
                  ],
2ca1b8bf   liangchengyou   feat:更新适配
223
224
225
                )
              ],
            ),
062f0df2   liangchengyou   feat:登录模块代码提交
226
227
228
229
230
231
          );
        });
  
    Widget _buildPwdViewWidget()=> BlocBuilder<LoginBloc,LoginState>(
        builder: (context,state){
          final bloc = BlocProvider.of<LoginBloc>(context);
1a43bf7c   liangchengyou   feat:更新UI
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
          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:添加字体,调整文件结构
247
                        child: TextFieldCustomerWidget(
4bf67b91   liangchengyou   feat:设置密码
248
249
250
251
252
253
254
255
256
257
                          height: 50.h,
                          hitText: '请输入手机号',
                          textInputType: TextInputType.phone,
                          bgImageName: 'Input_layer_up',
                          onChangeValue: (String value) {
                            bloc.add(PhoneNumChangeEvent());
                          },
                          controller: bloc.phoneNumController,
                        )
                    ),
1a43bf7c   liangchengyou   feat:更新UI
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
                    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:忘记密码获取验证码
276
277
278
279
280
281
282
283
                        child: TextFieldCustomerWidget(
                          hitText: '请输入密码',
                          bgImageName: 'Input_layer_down',
                          onChangeValue: (String value) {
                            bloc.add(CheckFieldChangeEvent());
                          },
                          controller: bloc.checkNumController,
                        )
1a43bf7c   liangchengyou   feat:更新UI
284
285
286
                    ),
                    5.horizontalSpace,
                    GestureDetector(
95edef4f   liangchengyou   feat:更新适配代码
287
                      onTap: () {
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
288
                        Navigator.of(context).pushNamed(AppRouteName.fogPwd);
95edef4f   liangchengyou   feat:更新适配代码
289
                      },
1a43bf7c   liangchengyou   feat:更新UI
290
291
292
293
294
295
                      child: Container(
                        width: 100.w,
                        height: 55.h,
                        alignment: Alignment.centerLeft,
                        child: const Text(
                            '忘记密码 ?'
2ca1b8bf   liangchengyou   feat:更新适配
296
                        ),
062f0df2   liangchengyou   feat:登录模块代码提交
297
                      ),
1a43bf7c   liangchengyou   feat:更新UI
298
299
300
301
302
                    )
                  ],
                )
              ],
            ),
062f0df2   liangchengyou   feat:登录模块代码提交
303
304
          );
        });
2a29701f   liangchengyou   feat:提交代码
305
  }
bfb40cd0   liangchengyou   feat:忘记密码获取验证码

bfb40cd0   liangchengyou   feat:忘记密码获取验证码