Commit 65e33ae8096c3cd8872f6da1f41f2a1f78c70543

Authored by liangchengyou
1 parent 39e06486

feat:更新代码

lib/pages/home/home_page.dart
1 1 import 'package:flutter/material.dart';
2 2 import 'package:flutter_bloc/flutter_bloc.dart';
3   -import 'package:flutter_easyloading/flutter_easyloading.dart';
4 3 import 'package:flutter_screenutil/flutter_screenutil.dart';
5 4 import 'package:wow_english/common/extension/string_extension.dart';
6 5 import 'package:wow_english/pages/home/widgets/home_lesson_item_widget.dart';
... ... @@ -69,17 +68,12 @@ class _HomePageView extends StatelessWidget {
69 68 },
70 69 ),
71 70 Expanded(
72   - child: PageView.builder(
  71 + child: ListView.builder(
73 72 itemCount: 10,
74   - controller: bloc.pageController,
75   - pageSnapping: false,
76   - onPageChanged: (int index) {
77   - EasyLoading.showToast(index.toString());
78   - },
79   - itemBuilder: (BuildContext context,int index){
  73 + scrollDirection: Axis.horizontal,
  74 + itemBuilder: (BuildContext context, int index){
80 75 return const HomeLessonItem();
81 76 })
82   - ,
83 77 ),
84 78 SafeArea(
85 79 child: Padding(
... ...
lib/pages/home/widgets/home_lesson_item_widget.dart
... ... @@ -7,7 +7,7 @@ class HomeLessonItem extends StatelessWidget {
7 7 @override
8 8 Widget build(BuildContext context) {
9 9 return SizedBox(
10   - width: double.infinity,
  10 + width: 200,
11 11 child: ListView.builder(
12 12 itemCount: 5,
13 13 scrollDirection: Axis.horizontal,
... ... @@ -16,7 +16,9 @@ class HomeLessonItem extends StatelessWidget {
16 16 return Padding(
17 17 padding: EdgeInsets.symmetric(horizontal: 4.w),
18 18 child: Image.network(
19   - 'https://img.liblibai.com/web/648331d5a2cb5.png?image_process=format,webp&x-oss-process=image/resize,w_2980,m_lfit/format,webp',
  19 + 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fsafe-img.xhscdn.com%2Fbw1%2Faa1c2213-820a-4223-8757-5f8cee318a28%3FimageView2%2F2%2Fw%2F1080%2Fformat%2Fjpg&refer=http%3A%2F%2Fsafe-img.xhscdn.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1688713226&t=192b18a613683bcdc5bd76f65c9ff032',
  20 + width: 40,
  21 + fit: BoxFit.fitHeight,
20 22 ),
21 23 );
22 24 }),
... ...
lib/pages/login/forgetpwd/bloc/forget_pwd_home_state.dart
... ... @@ -10,3 +10,5 @@ class SendSmsCodeTypeChangeState extends ForgetPwdHomeState {}
10 10 class SetPwdTypeChangeState extends ForgetPwdHomeState {}
11 11 ///验证码验证是否成功
12 12 class SetPwdCheckCodeState extends ForgetPwdHomeState {}
  13 +///发送验证码
  14 +class SendSmsCodeState extends ForgetPwdHomeState {}
... ...
lib/pages/login/forgetpwd/forget_password_home_page.dart
... ... @@ -40,127 +40,129 @@ class _ForgetPasswordHomePageView extends StatelessWidget {
40 40 body: Container(
41 41 color: Colors.white,
42 42 child: SafeArea(
43   - child: ListView(
44   - children: [
45   - Padding(
46   - padding: EdgeInsets.only(left: 49.w,right: 10.w),
47   - child: Column(
48   - children: [
49   - 34.verticalSpace,
50   - Row(
51   - children: [
52   - Image.asset(
53   - 'wow_logo'.assetPng,
54   - height: 49.w,
55   - width: 83.5.h,
56   - ),
57   - 12.5.horizontalSpace,
58   - Text(
59   - '修改密码\n请输入您的手机号和验证码吧',
60   - style: TextStyle(
61   - fontSize: 16.sp,
62   - color: const Color(0xFF666666)
63   - ),
64   - )
65   - ],
66   - ),
67   - Row(
68   - crossAxisAlignment: CrossAxisAlignment.start,
69   - children: [
70   - Expanded(
71   - child: Column(
72   - children: [
73   - 44.5.verticalSpace,
74   - Row(
75   - children: [
76   - Image.asset(
77   - 'phone'.assetPng,
78   - height: 45.h,
79   - width: 35.w,
80   - ),
81   - 15.horizontalSpace,
82   - Expanded(
83   - child: TextFieldCustomerWidget(
84   - height: 50.h,
85   - hitText: '请输入当前手机号',
86   - textInputType: TextInputType.phone,
87   - bgImageName: 'Input_layer_up',
88   - onChangeValue: (String value) {
89   - bloc.add(PhoneNumChangeEvent());
90   - },
91   - controller: bloc.phoneNumController,
92   - )
93   - )
94   - ],
95   - ),
96   - 11.5.verticalSpace,
97   - Row(
98   - mainAxisAlignment: MainAxisAlignment.spaceBetween,
99   - children: [
100   - Image.asset(
101   - 'lock'.assetPng,
102   - height: 34.h,
103   - width: 31.w,
104   - ),
105   - 18.5.horizontalSpace,
106   - Expanded(
107   - child: TextFieldCustomerWidget(
108   - hitText: '请输入验证码',
109   - bgImageName: 'Input_layer_down',
110   - onChangeValue: (String value) {
111   - bloc.add(CheckCodeChangeEvent());
112   - },
113   - textInputType: TextInputType.emailAddress,
114   - controller: bloc.checkNumController,
115   - )
116   - ),
117   - 16.5.horizontalSpace,
118   - TimerWidget(canSendSms: bloc.canSendSms)
119   - ],
120   - )
121   - ],
122   - )
  43 + child: SingleChildScrollView(
  44 + child: Padding(
  45 + padding: EdgeInsets.only(left: 49.w,right: 10.w),
  46 + child: Column(
  47 + children: [
  48 + 34.verticalSpace,
  49 + Row(
  50 + children: [
  51 + Image.asset(
  52 + 'wow_logo'.assetPng,
  53 + height: 49.w,
  54 + width: 83.5.h,
  55 + ),
  56 + 12.5.horizontalSpace,
  57 + Text(
  58 + '修改密码\n请输入您的手机号和验证码吧',
  59 + style: TextStyle(
  60 + fontSize: 16.sp,
  61 + color: const Color(0xFF666666)
123 62 ),
124   - 2.verticalSpace,
125   - Image.asset(
126   - 'steven_bride'.assetPng,
127   - height: 173.h,
128   - width: 157.w,
129   - )
130   - ],
131   - ),
132   - GestureDetector(
133   - onTap: () {
134   - if (bloc.canSetPwd) {
135   - bloc.add(SetPassWordEvent());
136   - }
137   - },
138   - child: Container(
139   - decoration: BoxDecoration(
140   - image: DecorationImage(
141   - image: AssetImage(
142   - bloc.canSetPwd?'login_enter'.assetPng:'login_enter_dis'.assetPng
  63 + )
  64 + ],
  65 + ),
  66 + Row(
  67 + crossAxisAlignment: CrossAxisAlignment.start,
  68 + children: [
  69 + Expanded(
  70 + child: Column(
  71 + children: [
  72 + 44.5.verticalSpace,
  73 + Row(
  74 + children: [
  75 + Image.asset(
  76 + 'phone'.assetPng,
  77 + height: 45.h,
  78 + width: 35.w,
  79 + ),
  80 + 15.horizontalSpace,
  81 + Expanded(
  82 + child: TextFieldCustomerWidget(
  83 + height: 50.h,
  84 + hitText: '请输入当前手机号',
  85 + textInputType: TextInputType.phone,
  86 + bgImageName: 'Input_layer_up',
  87 + onChangeValue: (String value) {
  88 + bloc.add(PhoneNumChangeEvent());
  89 + },
  90 + controller: bloc.phoneNumController,
  91 + )
  92 + )
  93 + ],
143 94 ),
144   - fit: BoxFit.fill
145   - ),
146   - ),
147   - padding: EdgeInsets.symmetric(
148   - horizontal: 28.w,
149   - vertical: 14.h
  95 + 11.5.verticalSpace,
  96 + Row(
  97 + mainAxisAlignment: MainAxisAlignment.spaceBetween,
  98 + children: [
  99 + Image.asset(
  100 + 'lock'.assetPng,
  101 + height: 34.h,
  102 + width: 31.w,
  103 + ),
  104 + 18.5.horizontalSpace,
  105 + Expanded(
  106 + child: TextFieldCustomerWidget(
  107 + hitText: '请输入验证码',
  108 + bgImageName: 'Input_layer_down',
  109 + onChangeValue: (String value) {
  110 + bloc.add(CheckCodeChangeEvent());
  111 + },
  112 + textInputType: TextInputType.emailAddress,
  113 + controller: bloc.checkNumController,
  114 + )
  115 + ),
  116 + 16.5.horizontalSpace,
  117 + TimerWidget(
  118 + pageType: 1,
  119 + canSendSms: bloc.canSendSms,
  120 + sendSmsEvent: () => bloc.add(SendSmsCodeEvent()),
  121 + )
  122 + ],
  123 + )
  124 + ],
  125 + )
  126 + ),
  127 + 2.verticalSpace,
  128 + Image.asset(
  129 + 'steven_bride'.assetPng,
  130 + height: 173.h,
  131 + width: 157.w,
  132 + )
  133 + ],
  134 + ),
  135 + GestureDetector(
  136 + onTap: () {
  137 + if (bloc.canSetPwd) {
  138 + bloc.add(SetPassWordEvent());
  139 + }
  140 + },
  141 + child: Container(
  142 + decoration: BoxDecoration(
  143 + image: DecorationImage(
  144 + image: AssetImage(
  145 + bloc.canSetPwd?'login_enter'.assetPng:'login_enter_dis'.assetPng
  146 + ),
  147 + fit: BoxFit.fill
150 148 ),
151   - child: Text(
152   - '确定',
153   - style: TextStyle(
154   - fontSize: 16.sp,
155   - color: Colors.white
156   - ),
  149 + ),
  150 + padding: EdgeInsets.symmetric(
  151 + horizontal: 28.w,
  152 + vertical: 14.h
  153 + ),
  154 + child: Text(
  155 + '确定',
  156 + style: TextStyle(
  157 + fontSize: 16.sp,
  158 + color: Colors.white
157 159 ),
158 160 ),
159   - )
160   - ],
161   - ),
162   - )
163   - ],
  161 + ),
  162 + )
  163 + ],
  164 + ),
  165 + ),
164 166 ),
165 167 ),
166 168 ),
... ...
lib/pages/login/loginpage/login_page.dart
... ... @@ -126,6 +126,7 @@ class _LoginPageView extends StatelessWidget {
126 126 GestureDetector(
127 127 onTap: () {
128 128 if (bloc.canLogin) {
  129 + // Navigator.of(context).pushNamed(AppRouteName.home);
129 130 bloc.add(RequestLoginEvent());
130 131 }
131 132 },
... ...
lib/pages/login/loginpage/time_widget.dart
... ... @@ -5,11 +5,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
5 5 import 'package:wow_english/common/blocs/timerbloc/timer_bloc.dart';
6 6 import 'package:wow_english/common/extension/string_extension.dart';
7 7 import 'package:wow_english/common/widgets/timer_ticker.dart';
  8 +import 'package:wow_english/pages/login/forgetpwd/bloc/forget_pwd_home_bloc.dart';
8 9 import 'package:wow_english/pages/login/loginpage/bloc/login_bloc.dart';
9 10  
10 11 class TimerWidget extends StatelessWidget {
11   - const TimerWidget({super.key, required this.canSendSms,this.sendSmsEvent});
  12 + const TimerWidget({super.key, required this.canSendSms,this.sendSmsEvent,this.pageType = 0});
12 13  
  14 + final int pageType;
13 15 final bool canSendSms;
14 16 final Function()? sendSmsEvent;
15 17  
... ... @@ -18,6 +20,7 @@ class TimerWidget extends StatelessWidget {
18 20 return BlocProvider(
19 21 create: (_) => TimerBloc(ticker: const TimerTicker()),
20 22 child: TimerWidgetView(
  23 + pageType: pageType,
21 24 canSendSms: canSendSms,
22 25 sendSmsEvent: sendSmsEvent,
23 26 ),
... ... @@ -27,28 +30,47 @@ class TimerWidget extends StatelessWidget {
27 30  
28 31 class TimerWidgetView extends StatelessWidget {
29 32 final bool canSendSms;
  33 + final int pageType;
30 34 final Function()? sendSmsEvent;
31   - const TimerWidgetView({super.key, required this.canSendSms,this.sendSmsEvent});
  35 + const TimerWidgetView({super.key, required this.canSendSms,this.sendSmsEvent,this.pageType = 0});
32 36  
33 37 @override
34 38 Widget build(BuildContext context) {
35 39 return MultiBlocListener(
36 40 listeners: [
37   - BlocListener<TimerBloc,TimerState>(
38   - listener: (context, s) {
39   - if (s is FinishedState) {
40   - ///重置计时器
41   - context.read<TimerBloc>().add(ResetEvent());
42   - }
43   - }),
44   - BlocListener<LoginBloc,LoginState>(
45   - listener: (context, s) {
46   - if (s is SmsCodeRequestState) {
47   - final bloc = BlocProvider.of<TimerBloc>(context);
48   - ///开始倒计时
49   - bloc.add(StartEvent(duration: bloc.state.duration));
50   - }
51   - }),
  41 + if(pageType == 0) ...[//登陆
  42 + BlocListener<TimerBloc,TimerState>(
  43 + listener: (context, s) {
  44 + if (s is FinishedState) {
  45 + ///重置计时器
  46 + context.read<TimerBloc>().add(ResetEvent());
  47 + }
  48 + }),
  49 + BlocListener<LoginBloc,LoginState>(
  50 + listener: (context, s) {
  51 + if (s is SmsCodeRequestState) {
  52 + final bloc = BlocProvider.of<TimerBloc>(context);
  53 + ///开始倒计时
  54 + bloc.add(StartEvent(duration: bloc.state.duration));
  55 + }
  56 + }),
  57 + ] else if (pageType == 1) ...[//忘记密码
  58 + BlocListener<TimerBloc,TimerState>(
  59 + listener: (context, s) {
  60 + if (s is FinishedState) {
  61 + ///重置计时器
  62 + context.read<TimerBloc>().add(ResetEvent());
  63 + }
  64 + }),
  65 + BlocListener<ForgetPwdHomeBloc,ForgetPwdHomeState>(
  66 + listener: (context, s) {
  67 + if (s is SendSmsCodeState) {
  68 + final bloc = BlocProvider.of<TimerBloc>(context);
  69 + ///开始倒计时
  70 + bloc.add(StartEvent(duration: bloc.state.duration));
  71 + }
  72 + }),
  73 + ]
52 74 ],
53 75 child: _buildCountdownWidget(),
54 76 );
... ...
lib/pages/login/setpwd/bloc/set_pwd_bloc.dart
... ... @@ -7,6 +7,8 @@ part &#39;set_pwd_state.dart&#39;;
7 7 class SetPwdBloc extends Bloc<SetPwdEvent, SetPwdState> {
8 8  
9 9 final String? phoneNumber;
  10 + final String? code;
  11 + final int? type;
10 12  
11 13 final TextEditingController passWordFirstController = TextEditingController();
12 14 final TextEditingController passWordSecondController = TextEditingController();
... ... @@ -33,7 +35,7 @@ class SetPwdBloc extends Bloc&lt;SetPwdEvent, SetPwdState&gt; {
33 35  
34 36 bool get ensure => _passwordCheck && _passwordEnsure;
35 37  
36   - SetPwdBloc(this.phoneNumber) : super(SetPwdInitial()) {
  38 + SetPwdBloc(this.phoneNumber, this.code, this.type) : super(SetPwdInitial()) {
37 39 on<PwdEnsureEvent>(_pwdEnsureTextChange);
38 40 on<PwdCheckEvent>(_pwdCheckTextChange);
39 41 on<SetPasswordEvent>(_setPassword);
... ...
lib/pages/login/setpwd/set_pwd_page.dart
... ... @@ -9,13 +9,15 @@ import &#39;bloc/set_pwd_bloc.dart&#39;;
9 9  
10 10  
11 11 class SetPassWordPage extends StatelessWidget {
12   - const SetPassWordPage({super.key, this.phoneNum});
  12 + const SetPassWordPage({super.key,this.phoneNum,this.code,this.type});
13 13 final String? phoneNum;
  14 + final String? code;
  15 + final int? type;
14 16  
15 17 @override
16 18 Widget build(BuildContext context) {
17 19 return BlocProvider(
18   - create: (context) => SetPwdBloc(phoneNum),
  20 + create: (context) => SetPwdBloc(phoneNum,code,type),
19 21 child: _SetPassWordPageView(),
20 22 );
21 23 }
... ...