Blame view

lib/login/login_page.dart 12.2 KB
2a29701f   liangchengyou   feat:提交代码
1
2
  import 'package:flutter/material.dart';
  import 'package:flutter_bloc/flutter_bloc.dart';
062f0df2   liangchengyou   feat:登录模块代码提交
3
4
  import 'package:flutter_screenutil/flutter_screenutil.dart';
  import 'package:wow_english/common/extension/string_extension.dart';
2a29701f   liangchengyou   feat:提交代码
5
  import 'package:wow_english/login/blocs/login_bloc.dart';
2a29701f   liangchengyou   feat:提交代码
6
7
  
  class LoginPage extends StatelessWidget {
062f0df2   liangchengyou   feat:登录模块代码提交
8
    const LoginPage({super.key});
2a29701f   liangchengyou   feat:提交代码
9
10
11
  
    @override
    Widget build(BuildContext context) {
2a29701f   liangchengyou   feat:提交代码
12
13
14
15
16
17
18
19
20
21
      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:登录模块代码提交
22
23
          body: SafeArea(
            child: ListView(
2a29701f   liangchengyou   feat:提交代码
24
              children: [
062f0df2   liangchengyou   feat:登录模块代码提交
25
26
27
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
                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
55
56
                              width: 131.w,
                            ),
062f0df2   liangchengyou   feat:登录模块代码提交
57
58
59
60
61
62
63
64
                            Offstage(
                              offstage: bloc.loginType == LoginType.pwd,
                              child: _buildSmsViewWidget(),
                            ),
                            Offstage(
                              offstage: bloc.loginType == LoginType.sms,
                              child: _buildPwdViewWidget(),
                            ),
062f0df2   liangchengyou   feat:登录模块代码提交
65
66
67
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,
                                const Text('我已阅读并同意《用户隐私协议》,《儿童隐私策略》')
                              ],
                            ),
062f0df2   liangchengyou   feat:登录模块代码提交
78
                            GestureDetector(
1a43bf7c   liangchengyou   feat:更新UI
79
80
81
82
83
                              onTap: () {
                                if (bloc.canLogin) {
                                  bloc.add(RequestLoginEvent());
                                }
                              },
062f0df2   liangchengyou   feat:登录模块代码提交
84
85
86
87
88
89
90
91
92
93
                              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:更新适配
94
95
                                    horizontal: 28.0,
                                    vertical: 14.0
062f0df2   liangchengyou   feat:登录模块代码提交
96
97
98
99
100
101
102
103
104
105
                                ),
                                child:  const Text(
                                    '登录'
                                ),
                              ),
                            )
                          ],
                        ),
                      )
                    ],
2a29701f   liangchengyou   feat:提交代码
106
107
108
109
110
111
112
113
                  ),
                )
              ],
            ),
          ),
        );
      },
    );
062f0df2   liangchengyou   feat:登录模块代码提交
114
115
116
117
  
    Widget _buildSmsViewWidget()=> BlocBuilder<LoginBloc,LoginState>(
        builder: (context,state){
          final bloc = BlocProvider.of<LoginBloc>(context);
2ca1b8bf   liangchengyou   feat:更新适配
118
          return Padding(
1a43bf7c   liangchengyou   feat:更新UI
119
            padding: EdgeInsets.symmetric(horizontal: 135.w),
2ca1b8bf   liangchengyou   feat:更新适配
120
121
122
123
            child: Column(
              children: [
                15.verticalSpace,
                Container(
1a43bf7c   liangchengyou   feat:更新UI
124
                    height: 55.h,
2ca1b8bf   liangchengyou   feat:更新适配
125
126
127
                    width: double.infinity,
                    alignment: Alignment.center,
                    decoration: BoxDecoration(
062f0df2   liangchengyou   feat:登录模块代码提交
128
129
130
                      image: DecorationImage(
                          image: AssetImage(
                              'Input_layer_up'.assetPng
2ca1b8bf   liangchengyou   feat:更新适配
131
                          ),
1a43bf7c   liangchengyou   feat:更新UI
132
                        fit: BoxFit.fitWidth
2ca1b8bf   liangchengyou   feat:更新适配
133
                      ),
062f0df2   liangchengyou   feat:登录模块代码提交
134
                    ),
2ca1b8bf   liangchengyou   feat:更新适配
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
                    child: TextField(
                      controller: bloc.phoneNumController,
                      textAlign: TextAlign.center,
                      textInputAction: TextInputAction.done,
                      keyboardType: TextInputType.phone,
                      decoration: const InputDecoration(
                        hintText: '请输入手机号',
                        border: InputBorder.none,
                      ),
                      onChanged: (String value) {
                        bloc.add(PhoneNumChangeEvent());
                      },
                    )
                ),
                6.5.verticalSpace,
                const Text('未注册用户登录默认注册'),
                4.5.verticalSpace,
                Row(
062f0df2   liangchengyou   feat:登录模块代码提交
153
154
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
1a43bf7c   liangchengyou   feat:更新UI
155
156
157
158
159
160
161
162
163
164
165
                    Expanded(
                      child: Container(
                          height: 50.h,
                          width: double.infinity,
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                              image: DecorationImage(
                                  image: AssetImage(
                                      'Input_layer_down'.assetPng,
                                  ),
                              )
062f0df2   liangchengyou   feat:登录模块代码提交
166
                          ),
1a43bf7c   liangchengyou   feat:更新UI
167
168
169
170
171
172
173
174
175
176
177
178
179
180
                          child: TextField(
                            controller: bloc.checkNumController,
                            textAlign: TextAlign.center,
                            textInputAction: TextInputAction.done,
                            keyboardType: TextInputType.number,
                            decoration: const InputDecoration(
                              hintText: '请输入验证码',
                              border: InputBorder.none,
                            ),
                            onChanged: (String value) {
                              bloc.add(CheckFieldChangeEvent());
                            },
                          )
                      ),
062f0df2   liangchengyou   feat:登录模块代码提交
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
                    ),
                    GestureDetector(
                      onTap: () {
                        if (bloc.canSendSms) {
                          bloc.add(ChangeLoginTypeEvent());
                        }
                      },
                      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),
                        child:  const Text(
                            '获取验证码'
                        ),
                      ),
                    )
                  ],
2ca1b8bf   liangchengyou   feat:更新适配
204
205
206
                )
              ],
            ),
062f0df2   liangchengyou   feat:登录模块代码提交
207
208
209
210
211
212
          );
        });
  
    Widget _buildPwdViewWidget()=> BlocBuilder<LoginBloc,LoginState>(
        builder: (context,state){
          final bloc = BlocProvider.of<LoginBloc>(context);
1a43bf7c   liangchengyou   feat:更新UI
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
          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(
                        child: Container(
                            height: 55.h,
                            width: double.infinity,
                            alignment: Alignment.center,
                            decoration: BoxDecoration(
                                image: DecorationImage(
                                  image: AssetImage(
                                      'Input_layer_up'.assetPng
                                  ),
                                  fit: BoxFit.fitWidth,
                                )
2ca1b8bf   liangchengyou   feat:更新适配
239
                            ),
1a43bf7c   liangchengyou   feat:更新UI
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
                            child: TextField(
                              controller: bloc.phoneNumController,
                              textAlign: TextAlign.center,
                              textInputAction: TextInputAction.done,
                              decoration: const InputDecoration(
                                hintText: '请输入手机号',
                                border: InputBorder.none,
                              ),
                              keyboardType: TextInputType.phone,
                              onChanged: (String value) {bloc.add(PhoneNumChangeEvent());},)
                        )),
                    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(
                      child: Container(
                          width: 397.5,
                          height: 55,
                          alignment: Alignment.center,
                          decoration: BoxDecoration(
                              image: DecorationImage(
                                image: AssetImage(
                                    'Input_layer_down'.assetPng
                                ),
                                fit: BoxFit.fill,
                              )
                          ),
                          child: TextField(
                            controller: bloc.checkNumController,
                            textAlign: TextAlign.center,
                            textInputAction: TextInputAction.done,
                            decoration: const InputDecoration(
                              hintText: '请输入密码',
                              border: InputBorder.none,
2ca1b8bf   liangchengyou   feat:更新适配
288
                            ),
1a43bf7c   liangchengyou   feat:更新UI
289
290
291
                            onChanged: (String value) {
                              bloc.add(CheckFieldChangeEvent());
                            },
2ca1b8bf   liangchengyou   feat:更新适配
292
293
                          )
                      ),
1a43bf7c   liangchengyou   feat:更新UI
294
295
296
297
298
299
300
301
302
303
                    ),
                    5.horizontalSpace,
                    GestureDetector(
                      onTap: () => bloc.add(ForgetPasswordEvent()),
                      child: Container(
                        width: 100.w,
                        height: 55.h,
                        alignment: Alignment.centerLeft,
                        child: const Text(
                            '忘记密码 ?'
2ca1b8bf   liangchengyou   feat:更新适配
304
                        ),
062f0df2   liangchengyou   feat:登录模块代码提交
305
                      ),
1a43bf7c   liangchengyou   feat:更新UI
306
307
308
309
310
                    )
                  ],
                )
              ],
            ),
062f0df2   liangchengyou   feat:登录模块代码提交
311
312
313
          );
        });
  
2a29701f   liangchengyou   feat:提交代码
314
  }