Commit c9df43c8fb1b436b67d8b568537673eb20ba5e81
1 parent
53e9e6db
feat: 修改个人信息、接口
Showing
19 changed files
with
227 additions
and
66 deletions
assets/images/bg_button_blue.png
0 → 100644
14.8 KB
assets/images/bg_button_blue_accent.png
0 → 100644
14.9 KB
assets/images/bg_steve_write.png
0 → 100644
174 KB
lib/common/core/assets_const.dart
| @@ -5,5 +5,7 @@ class AssetsConst { | @@ -5,5 +5,7 @@ class AssetsConst { | ||
| 5 | static const String icNext = '${_assetImagePrefix}ic_next.png'; | 5 | static const String icNext = '${_assetImagePrefix}ic_next.png'; |
| 6 | static const String bgUserInformationText = '${_assetImagePrefix}bg_user_information_text.png'; | 6 | static const String bgUserInformationText = '${_assetImagePrefix}bg_user_information_text.png'; |
| 7 | static const String bgEditUserInformation = '${_assetImagePrefix}bg_edit_information.png'; | 7 | static const String bgEditUserInformation = '${_assetImagePrefix}bg_edit_information.png'; |
| 8 | + static const String bgButtonBlue = '${_assetImagePrefix}bg_button_blue.png'; | ||
| 9 | + static const String bgButtonBlueAccent = '${_assetImagePrefix}bg_button_blue_accent.png'; | ||
| 8 | //static String get icVip2 =>'ic_vip.png'.assetImg; | 10 | //static String get icVip2 =>'ic_vip.png'.assetImg; |
| 9 | } | 11 | } |
lib/common/request/apis.dart
| @@ -6,7 +6,7 @@ class Apis { | @@ -6,7 +6,7 @@ class Apis { | ||
| 6 | // 接口地址:https://app.apifox.com/link/project/2684751/apis/api-89897678 | 6 | // 接口地址:https://app.apifox.com/link/project/2684751/apis/api-89897678 |
| 7 | static const String appConfig = 'system/app/config'; | 7 | static const String appConfig = 'system/app/config'; |
| 8 | 8 | ||
| 9 | - /// 登陆 | 9 | + /// 登录 |
| 10 | static const String login = 'login'; | 10 | static const String login = 'login'; |
| 11 | 11 | ||
| 12 | /// 登出 | 12 | /// 登出 |
lib/common/widgets/textfield_customer_widget.dart
| 1 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 2 | +import 'package:flutter/services.dart'; | ||
| 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| 3 | import 'package:wow_english/common/extension/string_extension.dart'; | 4 | import 'package:wow_english/common/extension/string_extension.dart'; |
| 4 | 5 | ||
| 5 | class TextFieldCustomerWidget extends StatefulWidget { | 6 | class TextFieldCustomerWidget extends StatefulWidget { |
| 6 | - const TextFieldCustomerWidget({super.key, | 7 | + const TextFieldCustomerWidget({ |
| 8 | + super.key, | ||
| 7 | this.controller, | 9 | this.controller, |
| 8 | this.hitStyle, | 10 | this.hitStyle, |
| 9 | this.textStyle, | 11 | this.textStyle, |
| @@ -14,7 +16,8 @@ class TextFieldCustomerWidget extends StatefulWidget { | @@ -14,7 +16,8 @@ class TextFieldCustomerWidget extends StatefulWidget { | ||
| 14 | this.textAlign, | 16 | this.textAlign, |
| 15 | this.textInputType, | 17 | this.textInputType, |
| 16 | this.obscureText, | 18 | this.obscureText, |
| 17 | - this.onChangeValue | 19 | + this.onChangeValue, |
| 20 | + this.inputFormatters, | ||
| 18 | }); | 21 | }); |
| 19 | 22 | ||
| 20 | final TextEditingController? controller; | 23 | final TextEditingController? controller; |
| @@ -28,6 +31,7 @@ class TextFieldCustomerWidget extends StatefulWidget { | @@ -28,6 +31,7 @@ class TextFieldCustomerWidget extends StatefulWidget { | ||
| 28 | final TextInputType? textInputType; | 31 | final TextInputType? textInputType; |
| 29 | final bool? obscureText; | 32 | final bool? obscureText; |
| 30 | final Function(String value)? onChangeValue; | 33 | final Function(String value)? onChangeValue; |
| 34 | + final List<TextInputFormatter>? inputFormatters; | ||
| 31 | 35 | ||
| 32 | @override | 36 | @override |
| 33 | State<StatefulWidget> createState() { | 37 | State<StatefulWidget> createState() { |
| @@ -39,38 +43,32 @@ class _TextFieldCustomerWidgetState extends State<TextFieldCustomerWidget> { | @@ -39,38 +43,32 @@ class _TextFieldCustomerWidgetState extends State<TextFieldCustomerWidget> { | ||
| 39 | @override | 43 | @override |
| 40 | Widget build(BuildContext context) { | 44 | Widget build(BuildContext context) { |
| 41 | return Container( | 45 | return Container( |
| 42 | - height: widget.height??45.h, | ||
| 43 | - width: widget.width??double.infinity, | 46 | + height: widget.height ?? 45.h, |
| 47 | + width: widget.width ?? double.infinity, | ||
| 44 | alignment: Alignment.center, | 48 | alignment: Alignment.center, |
| 45 | decoration: BoxDecoration( | 49 | decoration: BoxDecoration( |
| 46 | image: DecorationImage( | 50 | image: DecorationImage( |
| 47 | - image: AssetImage( | ||
| 48 | - '${widget.bgImageName}'.assetPng | ||
| 49 | - ), | ||
| 50 | - fit: BoxFit.fill, | ||
| 51 | - ) | ||
| 52 | - ), | 51 | + image: AssetImage('${widget.bgImageName}'.assetPng), |
| 52 | + fit: BoxFit.fill, | ||
| 53 | + )), | ||
| 53 | child: TextField( | 54 | child: TextField( |
| 55 | + inputFormatters: widget.inputFormatters, | ||
| 54 | controller: widget.controller, | 56 | controller: widget.controller, |
| 55 | - textAlign: widget.textAlign??TextAlign.center, | 57 | + textAlign: widget.textAlign ?? TextAlign.center, |
| 56 | textInputAction: TextInputAction.done, | 58 | textInputAction: TextInputAction.done, |
| 57 | keyboardType: widget.textInputType, | 59 | keyboardType: widget.textInputType, |
| 58 | - obscureText: widget.obscureText?? false, | 60 | + obscureText: widget.obscureText ?? false, |
| 59 | decoration: InputDecoration( | 61 | decoration: InputDecoration( |
| 60 | - hintText: widget.hitText??'', | ||
| 61 | - border: InputBorder.none, | ||
| 62 | - hintStyle: widget.hitStyle?? TextStyle( | ||
| 63 | - fontSize: 16.sp, | ||
| 64 | - color:const Color(0xFF999999) | ||
| 65 | - ) | ||
| 66 | - ), | ||
| 67 | - style: widget.textStyle?? TextStyle( | ||
| 68 | - color: const Color(0xFF333333), | ||
| 69 | - fontSize: 16.sp, | ||
| 70 | - ), | 62 | + hintText: widget.hitText ?? '', |
| 63 | + border: InputBorder.none, | ||
| 64 | + hintStyle: widget.hitStyle ?? TextStyle(fontSize: 16.sp, color: const Color(0xFF999999))), | ||
| 65 | + style: widget.textStyle ?? | ||
| 66 | + TextStyle( | ||
| 67 | + color: const Color(0xFF333333), | ||
| 68 | + fontSize: 16.sp, | ||
| 69 | + ), | ||
| 71 | onChanged: widget.onChangeValue, | 70 | onChanged: widget.onChangeValue, |
| 72 | ), | 71 | ), |
| 73 | ); | 72 | ); |
| 74 | } | 73 | } |
| 75 | } | 74 | } |
| 76 | - |
lib/pages/login/loginpage/bloc/login_bloc.dart
| @@ -12,10 +12,10 @@ part 'login_event.dart'; | @@ -12,10 +12,10 @@ part 'login_event.dart'; | ||
| 12 | part 'login_state.dart'; | 12 | part 'login_state.dart'; |
| 13 | 13 | ||
| 14 | enum LoginType { | 14 | enum LoginType { |
| 15 | - ///密码登陆 | 15 | + ///密码登录 |
| 16 | pwd, | 16 | pwd, |
| 17 | 17 | ||
| 18 | - ///验证码登陆 | 18 | + ///验证码登录 |
| 19 | sms, | 19 | sms, |
| 20 | } | 20 | } |
| 21 | 21 | ||
| @@ -28,7 +28,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | @@ -28,7 +28,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | ||
| 28 | ///是否阅读协议 | 28 | ///是否阅读协议 |
| 29 | bool _agreement = false; | 29 | bool _agreement = false; |
| 30 | 30 | ||
| 31 | - ///登陆方式 | 31 | + ///登录方式 |
| 32 | //LoginType _loginType = LoginType.sms; | 32 | //LoginType _loginType = LoginType.sms; |
| 33 | bool _isSmsLoginType = true; | 33 | bool _isSmsLoginType = true; |
| 34 | 34 | ||
| @@ -54,7 +54,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | @@ -54,7 +54,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | ||
| 54 | on<RequestSmsCodeEvent>(_requestSmsCodeApi); | 54 | on<RequestSmsCodeEvent>(_requestSmsCodeApi); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | - ///请求登陆 | 57 | + ///请求登录 |
| 58 | void _requestLoginApi(RequestLoginEvent event, Emitter<LoginState> emitter) async { | 58 | void _requestLoginApi(RequestLoginEvent event, Emitter<LoginState> emitter) async { |
| 59 | var phoneNumber = phoneNumController.text; | 59 | var phoneNumber = phoneNumController.text; |
| 60 | if (phoneNumber.isEmpty) { | 60 | if (phoneNumber.isEmpty) { |
| @@ -75,7 +75,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | @@ -75,7 +75,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | ||
| 75 | await loading(() async { | 75 | await loading(() async { |
| 76 | var user = await UserDao.login(phoneNumber, type, checkKey, checkNumber); | 76 | var user = await UserDao.login(phoneNumber, type, checkKey, checkNumber); |
| 77 | if (kDebugMode) { | 77 | if (kDebugMode) { |
| 78 | - print('登陆 UserEntity=$user'); | 78 | + print('登录 UserEntity=$user'); |
| 79 | } | 79 | } |
| 80 | emitter.call(LoginResultChangeState()); | 80 | emitter.call(LoginResultChangeState()); |
| 81 | }); | 81 | }); |
| @@ -83,7 +83,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | @@ -83,7 +83,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | ||
| 83 | if (kDebugMode) { | 83 | if (kDebugMode) { |
| 84 | print(e); | 84 | print(e); |
| 85 | } | 85 | } |
| 86 | - showToast('登陆失败${(e as ApiException?)?.message?.prefixColon}'); | 86 | + showToast('登录失败${(e as ApiException?)?.message?.prefixColon}'); |
| 87 | } | 87 | } |
| 88 | } | 88 | } |
| 89 | 89 | ||
| @@ -107,7 +107,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | @@ -107,7 +107,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | ||
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | - ///切换登陆方式 | 110 | + ///切换登录方式 |
| 111 | void _changeLoginType(ChangeLoginTypeEvent event, Emitter<LoginState> emitter) async { | 111 | void _changeLoginType(ChangeLoginTypeEvent event, Emitter<LoginState> emitter) async { |
| 112 | if (_isSmsLoginType) { | 112 | if (_isSmsLoginType) { |
| 113 | _isSmsLoginType = false; | 113 | _isSmsLoginType = false; |
| @@ -158,7 +158,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | @@ -158,7 +158,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { | ||
| 158 | } | 158 | } |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | - ///登陆状态判断 | 161 | + ///登录状态判断 |
| 162 | bool _loginStateChange() { | 162 | bool _loginStateChange() { |
| 163 | if (_agreement) { | 163 | if (_agreement) { |
| 164 | if (phoneNumController.text.isNotEmpty && checkNumController.text.isNotEmpty) { | 164 | if (phoneNumController.text.isNotEmpty && checkNumController.text.isNotEmpty) { |
lib/pages/login/loginpage/bloc/login_event.dart
| @@ -2,7 +2,7 @@ part of 'login_bloc.dart'; | @@ -2,7 +2,7 @@ part of 'login_bloc.dart'; | ||
| 2 | 2 | ||
| 3 | @immutable | 3 | @immutable |
| 4 | abstract class LoginEvent {} | 4 | abstract class LoginEvent {} |
| 5 | -///切换登陆方式 | 5 | +///切换登录方式 |
| 6 | class ChangeLoginTypeEvent extends LoginEvent {} | 6 | class ChangeLoginTypeEvent extends LoginEvent {} |
| 7 | ///输入手机号 | 7 | ///输入手机号 |
| 8 | class PhoneNumChangeEvent extends LoginEvent {} | 8 | class PhoneNumChangeEvent extends LoginEvent {} |
| @@ -12,5 +12,5 @@ class CheckFieldChangeEvent extends LoginEvent {} | @@ -12,5 +12,5 @@ class CheckFieldChangeEvent extends LoginEvent {} | ||
| 12 | class AgreementChangeEvent extends LoginEvent {} | 12 | class AgreementChangeEvent extends LoginEvent {} |
| 13 | ///发送验证码 | 13 | ///发送验证码 |
| 14 | class RequestSmsCodeEvent extends LoginEvent {} | 14 | class RequestSmsCodeEvent extends LoginEvent {} |
| 15 | -///请求登陆 | 15 | +///请求登录 |
| 16 | class RequestLoginEvent extends LoginEvent {} | 16 | class RequestLoginEvent extends LoginEvent {} |
lib/pages/login/loginpage/bloc/login_state.dart
| @@ -5,10 +5,10 @@ abstract class LoginState {} | @@ -5,10 +5,10 @@ abstract class LoginState {} | ||
| 5 | 5 | ||
| 6 | class LoginInitial extends LoginState {} | 6 | class LoginInitial extends LoginState {} |
| 7 | 7 | ||
| 8 | -///登陆按钮状态 | 8 | +///登录按钮状态 |
| 9 | class LoginEventChangeState extends LoginState {} | 9 | class LoginEventChangeState extends LoginState {} |
| 10 | 10 | ||
| 11 | -///切换登陆方式 | 11 | +///切换登录方式 |
| 12 | class LoginTypeChangeState extends LoginState {} | 12 | class LoginTypeChangeState extends LoginState {} |
| 13 | 13 | ||
| 14 | ///发送验证码按钮状态 | 14 | ///发送验证码按钮状态 |
| @@ -20,5 +20,5 @@ class AgreementTypeChangeState extends LoginState {} | @@ -20,5 +20,5 @@ class AgreementTypeChangeState extends LoginState {} | ||
| 20 | ///获取验证码 | 20 | ///获取验证码 |
| 21 | class SmsCodeRequestState extends LoginState {} | 21 | class SmsCodeRequestState extends LoginState {} |
| 22 | 22 | ||
| 23 | -///登陆请求结果 | 23 | +///登录请求结果 |
| 24 | class LoginResultChangeState extends LoginState {} | 24 | class LoginResultChangeState extends LoginState {} |
lib/pages/login/loginpage/login_page.dart
| @@ -57,7 +57,7 @@ class _LoginPageView extends StatelessWidget { | @@ -57,7 +57,7 @@ class _LoginPageView extends StatelessWidget { | ||
| 57 | ), | 57 | ), |
| 58 | padding: EdgeInsets.symmetric(horizontal: 18.w, vertical: 5.h), | 58 | padding: EdgeInsets.symmetric(horizontal: 18.w, vertical: 5.h), |
| 59 | child: Text( | 59 | child: Text( |
| 60 | - bloc.isSmsLoginType ? '密码登陆' : '验证码密码', | 60 | + bloc.isSmsLoginType ? '密码登录' : '验证码登录', |
| 61 | style: TextStyle(fontSize: 16.sp), | 61 | style: TextStyle(fontSize: 16.sp), |
| 62 | ), | 62 | ), |
| 63 | ), | 63 | ), |
lib/pages/login/loginpage/time_widget.dart
| @@ -38,7 +38,7 @@ class TimerWidgetView extends StatelessWidget { | @@ -38,7 +38,7 @@ class TimerWidgetView extends StatelessWidget { | ||
| 38 | Widget build(BuildContext context) { | 38 | Widget build(BuildContext context) { |
| 39 | return MultiBlocListener( | 39 | return MultiBlocListener( |
| 40 | listeners: [ | 40 | listeners: [ |
| 41 | - if(pageType == 0) ...[//登陆 | 41 | + if(pageType == 0) ...[//登录 |
| 42 | BlocListener<TimerBloc,TimerState>( | 42 | BlocListener<TimerBloc,TimerState>( |
| 43 | listener: (context, s) { | 43 | listener: (context, s) { |
| 44 | if (s is FinishedState) { | 44 | if (s is FinishedState) { |
lib/pages/login/setpwd/set_pwd_page.dart
| 1 | +import 'package:flutter/cupertino.dart'; | ||
| 1 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 2 | import 'package:flutter_bloc/flutter_bloc.dart'; | 3 | import 'package:flutter_bloc/flutter_bloc.dart'; |
| 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; | 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
| @@ -34,12 +35,15 @@ class SetPassWordPage extends StatelessWidget { | @@ -34,12 +35,15 @@ class SetPassWordPage extends StatelessWidget { | ||
| 34 | ); | 35 | ); |
| 35 | } | 36 | } |
| 36 | 37 | ||
| 38 | + /// [pageType]= [resetPwd] or [changePwd] 时,必传手机号和验证码 | ||
| 37 | static push(BuildContext context, SetPwdPageType pageType, {String? phoneNum, String? smsCode}) { | 39 | static push(BuildContext context, SetPwdPageType pageType, {String? phoneNum, String? smsCode}) { |
| 38 | - Navigator.of(context).pushNamed(AppRouteName.setPwd, arguments: { | ||
| 39 | - 'pageType': pageType, | ||
| 40 | - 'phoneNum': phoneNum, | ||
| 41 | - 'smsCode': smsCode, | ||
| 42 | - }); | 40 | + Navigator.of(context).push(CupertinoPageRoute(builder: (context) { |
| 41 | + return SetPassWordPage( | ||
| 42 | + phoneNum: phoneNum, | ||
| 43 | + smsCode: smsCode, | ||
| 44 | + pageType: pageType, | ||
| 45 | + ); | ||
| 46 | + })); | ||
| 43 | } | 47 | } |
| 44 | } | 48 | } |
| 45 | 49 |
lib/pages/user/bloc/user_bloc.dart
| 1 | +import 'package:flutter/widgets.dart'; | ||
| 1 | import 'package:flutter_bloc/flutter_bloc.dart'; | 2 | import 'package:flutter_bloc/flutter_bloc.dart'; |
| 3 | +import 'package:wow_english/common/core/user_util.dart'; | ||
| 2 | import 'package:wow_english/common/request/dao/user_dao.dart'; | 4 | import 'package:wow_english/common/request/dao/user_dao.dart'; |
| 5 | +import 'package:wow_english/models/user_entity.dart'; | ||
| 6 | +import 'package:wow_english/pages/user/modify/modify_user_information_page.dart'; | ||
| 7 | +import 'package:wow_english/utils/log_util.dart'; | ||
| 3 | 8 | ||
| 4 | part 'user_event.dart'; | 9 | part 'user_event.dart'; |
| 5 | part 'user_state.dart'; | 10 | part 'user_state.dart'; |
| 6 | 11 | ||
| 7 | class UserBloc extends Bloc<UserEvent, UserState> { | 12 | class UserBloc extends Bloc<UserEvent, UserState> { |
| 13 | + final TextEditingController modifyTextController = TextEditingController(); | ||
| 14 | + | ||
| 8 | UserBloc() : super(UserInitial()) { | 15 | UserBloc() : super(UserInitial()) { |
| 9 | on<UserLogout>(_logout); | 16 | on<UserLogout>(_logout); |
| 17 | + on<UserUpdate>(_updateUser); | ||
| 10 | } | 18 | } |
| 11 | 19 | ||
| 12 | void _logout(UserLogout event, Emitter<UserState> emitter) async { | 20 | void _logout(UserLogout event, Emitter<UserState> emitter) async { |
| 13 | - print('UserBloc._test, event: $event, emitter: $emitter'); | ||
| 14 | await UserDao.logout(); | 21 | await UserDao.logout(); |
| 15 | } | 22 | } |
| 23 | + | ||
| 24 | + void _updateUser(UserUpdate event, Emitter<UserState> emitter) async { | ||
| 25 | + Log.d('_updateUser, event: ${event.type}, emitter.isDone: ${emitter.isDone}, text=${modifyTextController.text}'); | ||
| 26 | + UserEntity user = UserUtil.getUser()!; | ||
| 27 | + switch (event.type) { | ||
| 28 | + case ModifyUserInformationType.avatar: | ||
| 29 | + break; | ||
| 30 | + case ModifyUserInformationType.name: | ||
| 31 | + String name = modifyTextController.text; | ||
| 32 | + user.name = name; | ||
| 33 | + try { | ||
| 34 | + await UserDao.updateUserInfo(user); | ||
| 35 | + emitter(UserInfoUpdated()); | ||
| 36 | + } catch (e) { | ||
| 37 | + print(e); | ||
| 38 | + } | ||
| 39 | + break; | ||
| 40 | + case ModifyUserInformationType.age: | ||
| 41 | + String age = modifyTextController.text; | ||
| 42 | + break; | ||
| 43 | + case ModifyUserInformationType.gender: | ||
| 44 | + break; | ||
| 45 | + } | ||
| 46 | + } | ||
| 16 | } | 47 | } |
lib/pages/user/bloc/user_event.dart
| @@ -5,3 +5,9 @@ sealed class UserEvent {} | @@ -5,3 +5,9 @@ sealed class UserEvent {} | ||
| 5 | class UserStarted extends UserEvent {} | 5 | class UserStarted extends UserEvent {} |
| 6 | 6 | ||
| 7 | class UserLogout extends UserEvent {} | 7 | class UserLogout extends UserEvent {} |
| 8 | + | ||
| 9 | +class UserUpdate extends UserEvent { | ||
| 10 | + final ModifyUserInformationType type; | ||
| 11 | + | ||
| 12 | + UserUpdate(this.type); | ||
| 13 | +} |
lib/pages/user/information/user_information_page.dart
| @@ -7,6 +7,7 @@ import 'package:wow_english/common/widgets/we_app_bar.dart'; | @@ -7,6 +7,7 @@ import 'package:wow_english/common/widgets/we_app_bar.dart'; | ||
| 7 | import 'package:wow_english/models/user_entity.dart'; | 7 | import 'package:wow_english/models/user_entity.dart'; |
| 8 | import 'package:wow_english/pages/user/bloc/user_bloc.dart'; | 8 | import 'package:wow_english/pages/user/bloc/user_bloc.dart'; |
| 9 | import 'package:wow_english/utils/image_util.dart'; | 9 | import 'package:wow_english/utils/image_util.dart'; |
| 10 | +import 'package:wow_english/utils/log_util.dart'; | ||
| 10 | 11 | ||
| 11 | import '../modify/modify_user_information_page.dart'; | 12 | import '../modify/modify_user_information_page.dart'; |
| 12 | 13 | ||
| @@ -28,9 +29,11 @@ class _UserInformationView extends StatelessWidget { | @@ -28,9 +29,11 @@ class _UserInformationView extends StatelessWidget { | ||
| 28 | @override | 29 | @override |
| 29 | Widget build(BuildContext context) { | 30 | Widget build(BuildContext context) { |
| 30 | return BlocListener<UserBloc, UserState>( | 31 | return BlocListener<UserBloc, UserState>( |
| 31 | - listener: (context, state) {}, | 32 | + listener: (context, state) { |
| 33 | + Log.d('UserInformationPage: $state'); | ||
| 34 | + }, | ||
| 32 | child: BlocBuilder<UserBloc, UserState>(builder: (context, state) { | 35 | child: BlocBuilder<UserBloc, UserState>(builder: (context, state) { |
| 33 | - return const _UserInformationContentView(); | 36 | + return _UserInformationContentView(); |
| 34 | }), | 37 | }), |
| 35 | ); | 38 | ); |
| 36 | } | 39 | } |
| @@ -39,8 +42,9 @@ class _UserInformationView extends StatelessWidget { | @@ -39,8 +42,9 @@ class _UserInformationView extends StatelessWidget { | ||
| 39 | class _UserInformationContentView extends StatelessWidget { | 42 | class _UserInformationContentView extends StatelessWidget { |
| 40 | const _UserInformationContentView({super.key}); | 43 | const _UserInformationContentView({super.key}); |
| 41 | 44 | ||
| 42 | - void _openModifyPage(ModifyUserInformationType type) { | ||
| 43 | - print('_openModifyPage($type)'); | 45 | + void _openModifyPage(BuildContext context, ModifyUserInformationType type) { |
| 46 | + Log.d('_openModifyPage($type)'); | ||
| 47 | + ModifyUserInformationPage.push(context, type); | ||
| 44 | } | 48 | } |
| 45 | 49 | ||
| 46 | @override | 50 | @override |
| @@ -76,7 +80,7 @@ class _UserInformationContentView extends StatelessWidget { | @@ -76,7 +80,7 @@ class _UserInformationContentView extends StatelessWidget { | ||
| 76 | fontSize: 21.sp, | 80 | fontSize: 21.sp, |
| 77 | ), | 81 | ), |
| 78 | ), | 82 | ), |
| 79 | - onTap: () => _openModifyPage(ModifyUserInformationType.name)), | 83 | + onTap: () => _openModifyPage(context, ModifyUserInformationType.name)), |
| 80 | 11.verticalSpace, | 84 | 11.verticalSpace, |
| 81 | _buildContentRow( | 85 | _buildContentRow( |
| 82 | '年龄', | 86 | '年龄', |
lib/pages/user/modify/modify_user_information_page.dart
| 1 | +import 'package:flutter/cupertino.dart'; | ||
| 1 | import 'package:flutter/material.dart'; | 2 | import 'package:flutter/material.dart'; |
| 3 | +import 'package:flutter/services.dart'; | ||
| 2 | import 'package:flutter_bloc/flutter_bloc.dart'; | 4 | import 'package:flutter_bloc/flutter_bloc.dart'; |
| 5 | +import 'package:flutter_screenutil/flutter_screenutil.dart'; | ||
| 6 | +import 'package:wow_english/common/core/assets_const.dart'; | ||
| 7 | +import 'package:wow_english/common/widgets/textfield_customer_widget.dart'; | ||
| 3 | import 'package:wow_english/common/widgets/we_app_bar.dart'; | 8 | import 'package:wow_english/common/widgets/we_app_bar.dart'; |
| 4 | import 'package:wow_english/pages/user/bloc/user_bloc.dart'; | 9 | import 'package:wow_english/pages/user/bloc/user_bloc.dart'; |
| 5 | 10 | ||
| 6 | enum ModifyUserInformationType { | 11 | enum ModifyUserInformationType { |
| 7 | - avatar('修改头像'), name('修改名字'), age('修改年龄'), gender('修改性别'); | 12 | + avatar('头像'), |
| 13 | + name('名字'), | ||
| 14 | + age('年龄'), | ||
| 15 | + gender('性别'); | ||
| 8 | 16 | ||
| 9 | const ModifyUserInformationType(this.title); | 17 | const ModifyUserInformationType(this.title); |
| 10 | 18 | ||
| @@ -16,6 +24,12 @@ class ModifyUserInformationPage extends StatelessWidget { | @@ -16,6 +24,12 @@ class ModifyUserInformationPage extends StatelessWidget { | ||
| 16 | 24 | ||
| 17 | const ModifyUserInformationPage({super.key, required this.type}); | 25 | const ModifyUserInformationPage({super.key, required this.type}); |
| 18 | 26 | ||
| 27 | + static push(BuildContext context, ModifyUserInformationType type) { | ||
| 28 | + Navigator.of(context).push(CupertinoPageRoute(builder: (context) { | ||
| 29 | + return ModifyUserInformationPage(type: type); | ||
| 30 | + })); | ||
| 31 | + } | ||
| 32 | + | ||
| 19 | @override | 33 | @override |
| 20 | Widget build(BuildContext context) { | 34 | Widget build(BuildContext context) { |
| 21 | return BlocProvider( | 35 | return BlocProvider( |
| @@ -23,7 +37,72 @@ class ModifyUserInformationPage extends StatelessWidget { | @@ -23,7 +37,72 @@ class ModifyUserInformationPage extends StatelessWidget { | ||
| 23 | child: Scaffold( | 37 | child: Scaffold( |
| 24 | backgroundColor: Colors.white, | 38 | backgroundColor: Colors.white, |
| 25 | appBar: WEAppBar( | 39 | appBar: WEAppBar( |
| 26 | - titleText: type.title, | 40 | + titleText: '修改${type.title}', |
| 41 | + ), | ||
| 42 | + body: BlocListener<UserBloc, UserState>( | ||
| 43 | + listener: (context, state) { | ||
| 44 | + }, | ||
| 45 | + child: BlocBuilder<UserBloc, UserState>(builder: (context, state) { | ||
| 46 | + //final bloc = context.read<UserBloc>(); | ||
| 47 | + // 区别是什么? | ||
| 48 | + //BlocProvider.of<UserBloc>(context); | ||
| 49 | + return SingleChildScrollView( | ||
| 50 | + child: Column( | ||
| 51 | + children: [ | ||
| 52 | + Padding( | ||
| 53 | + padding: EdgeInsets.only(left: 65.w, right: 55.w, top: 38.h), | ||
| 54 | + child: Row( | ||
| 55 | + children: [ | ||
| 56 | + Text( | ||
| 57 | + type.title, | ||
| 58 | + style: TextStyle( | ||
| 59 | + fontWeight: FontWeight.w700, | ||
| 60 | + color: const Color(0xFF333333), | ||
| 61 | + fontSize: 21.sp, | ||
| 62 | + ), | ||
| 63 | + ), | ||
| 64 | + 20.horizontalSpace, | ||
| 65 | + TextFieldCustomerWidget( | ||
| 66 | + height: 65.h, | ||
| 67 | + width: 222.w, | ||
| 68 | + bgImageName: 'Input_layer_up', | ||
| 69 | + textInputType: TextInputType.name, | ||
| 70 | + inputFormatters: [ | ||
| 71 | + LengthLimitingTextInputFormatter(12), | ||
| 72 | + FilteringTextInputFormatter.deny(RegExp('[ ]')), | ||
| 73 | + ], | ||
| 74 | + //controller: bloc.modifyTextController, | ||
| 75 | + /*onChangeValue: (String value) { | ||
| 76 | + bloc.add(CodeNumberChangeEvent()); | ||
| 77 | + },*/ | ||
| 78 | + ), | ||
| 79 | + Expanded( | ||
| 80 | + child: Container(), | ||
| 81 | + ), | ||
| 82 | + // 按钮 | ||
| 83 | + GestureDetector( | ||
| 84 | + onTap: () { | ||
| 85 | + // 更新type类型的字段 | ||
| 86 | + //bloc.add(UserUpdate(type)); | ||
| 87 | + }, | ||
| 88 | + child: Container( | ||
| 89 | + alignment: Alignment.center, | ||
| 90 | + width: 90.w, | ||
| 91 | + height: 44.h, | ||
| 92 | + decoration: BoxDecoration( | ||
| 93 | + image: DecorationImage(image: AssetImage(AssetsConst.bgButtonBlue), fit: BoxFit.fill), | ||
| 94 | + ), | ||
| 95 | + child: Text( | ||
| 96 | + '确定', | ||
| 97 | + style: TextStyle(fontSize: 17.sp, color: Colors.white), | ||
| 98 | + ), | ||
| 99 | + ), | ||
| 100 | + ) | ||
| 101 | + ], | ||
| 102 | + )), | ||
| 103 | + ], | ||
| 104 | + )); | ||
| 105 | + }), | ||
| 27 | ), | 106 | ), |
| 28 | ), | 107 | ), |
| 29 | ); | 108 | ); |
lib/pages/user/user_page.dart
| @@ -63,12 +63,15 @@ class _UserView extends StatelessWidget { | @@ -63,12 +63,15 @@ class _UserView extends StatelessWidget { | ||
| 63 | child: Column( | 63 | child: Column( |
| 64 | mainAxisAlignment: MainAxisAlignment.center, | 64 | mainAxisAlignment: MainAxisAlignment.center, |
| 65 | children: <Widget>[ | 65 | children: <Widget>[ |
| 66 | - // banner | ||
| 67 | - Offstage( | ||
| 68 | - child: Container( | ||
| 69 | - child: Image.asset(bannerUrl), constraints: BoxConstraints(maxHeight: 196.h)), | ||
| 70 | - ), | ||
| 71 | - 30.verticalSpace, | 66 | + // todo banner,暂时没有接口获取banner URL |
| 67 | + /*Offstage( | ||
| 68 | + child: Column( | ||
| 69 | + children: [ | ||
| 70 | + Container(child: Image.asset(bannerUrl), constraints: BoxConstraints(maxHeight: 196.h)), | ||
| 71 | + 30.verticalSpace, | ||
| 72 | + ], | ||
| 73 | + ), | ||
| 74 | + ),*/ | ||
| 72 | Row( | 75 | Row( |
| 73 | mainAxisAlignment: MainAxisAlignment.spaceBetween, | 76 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 74 | children: [ | 77 | children: [ |
| @@ -170,7 +173,7 @@ class _UserView extends StatelessWidget { | @@ -170,7 +173,7 @@ class _UserView extends StatelessWidget { | ||
| 170 | )), | 173 | )), |
| 171 | 30.verticalSpace, | 174 | 30.verticalSpace, |
| 172 | OutlinedButton( | 175 | OutlinedButton( |
| 173 | - onPressed: () => {userBloc.add(UserLogout())}, | 176 | + onPressed: () => userBloc.add(UserLogout()), |
| 174 | style: ButtonStyle( | 177 | style: ButtonStyle( |
| 175 | side: MaterialStateProperty.all(BorderSide(color: const Color(0xFF140C10), width: 1.5)), | 178 | side: MaterialStateProperty.all(BorderSide(color: const Color(0xFF140C10), width: 1.5)), |
| 176 | shape: MaterialStateProperty.all( | 179 | shape: MaterialStateProperty.all( |
| @@ -179,7 +182,7 @@ class _UserView extends StatelessWidget { | @@ -179,7 +182,7 @@ class _UserView extends StatelessWidget { | ||
| 179 | backgroundColor: MaterialStateProperty.all(Color(0xFFFBB621)), | 182 | backgroundColor: MaterialStateProperty.all(Color(0xFFFBB621)), |
| 180 | ), | 183 | ), |
| 181 | child: Text( | 184 | child: Text( |
| 182 | - "退出登陆", | 185 | + "退出登录", |
| 183 | style: TextStyle( | 186 | style: TextStyle( |
| 184 | //fontWeight: FontWeight.w600, | 187 | //fontWeight: FontWeight.w600, |
| 185 | color: Colors.white, | 188 | color: Colors.white, |
lib/route/route.dart
| @@ -16,6 +16,7 @@ import 'package:wow_english/pages/shop/exchangelist/exchange_lesson_list_page.da | @@ -16,6 +16,7 @@ import 'package:wow_english/pages/shop/exchangelist/exchange_lesson_list_page.da | ||
| 16 | import 'package:wow_english/pages/shop/home/shop_home_page.dart'; | 16 | import 'package:wow_english/pages/shop/home/shop_home_page.dart'; |
| 17 | import 'package:wow_english/pages/tab/tab_page.dart'; | 17 | import 'package:wow_english/pages/tab/tab_page.dart'; |
| 18 | import 'package:wow_english/pages/user/information/user_information_page.dart'; | 18 | import 'package:wow_english/pages/user/information/user_information_page.dart'; |
| 19 | +import 'package:wow_english/pages/user/modify/modify_user_information_page.dart'; | ||
| 19 | import 'package:wow_english/pages/user/user_page.dart'; | 20 | import 'package:wow_english/pages/user/user_page.dart'; |
| 20 | import 'package:wow_english/pages/video/lookvideo/look_video_page.dart'; | 21 | import 'package:wow_english/pages/video/lookvideo/look_video_page.dart'; |
| 21 | 22 | ||
| @@ -27,8 +28,8 @@ class AppRouteName { | @@ -27,8 +28,8 @@ class AppRouteName { | ||
| 27 | static const String home = 'home'; | 28 | static const String home = 'home'; |
| 28 | static const String fogPwd = 'fogPwd'; | 29 | static const String fogPwd = 'fogPwd'; |
| 29 | 30 | ||
| 30 | - /// 设置密码,修改密码;不要自己调用,使用[SetPassWordPage.push]方法 | ||
| 31 | - static const String setPwd = 'setPwd'; | 31 | + /// 设置密码,修改密码;不要自己调用,使用[SetPassWordPage.push]方法,隐藏这种实现 |
| 32 | + //static const String setPwd = 'setPwd'; | ||
| 32 | static const String webView = 'webView'; | 33 | static const String webView = 'webView'; |
| 33 | static const String lesson = 'lesson'; | 34 | static const String lesson = 'lesson'; |
| 34 | static const String listen = 'listen'; | 35 | static const String listen = 'listen'; |
| @@ -41,6 +42,9 @@ class AppRouteName { | @@ -41,6 +42,9 @@ class AppRouteName { | ||
| 41 | 42 | ||
| 42 | /// 用户详细信息页 | 43 | /// 用户详细信息页 |
| 43 | static const String userInformation = 'userInformation'; | 44 | static const String userInformation = 'userInformation'; |
| 45 | + | ||
| 46 | + /// 用户修改信息页,不要自己调用,使用[ModifyUserInformationPage.push]方法,隐藏这种实现 | ||
| 47 | + //static const String userModifyInformation = 'userModifyInformation'; | ||
| 44 | ///看视频 | 48 | ///看视频 |
| 45 | static const String lookVideo = 'lookVideo'; | 49 | static const String lookVideo = 'lookVideo'; |
| 46 | ///绘本 | 50 | ///绘本 |
| @@ -95,6 +99,14 @@ class AppRouter { | @@ -95,6 +99,14 @@ class AppRouter { | ||
| 95 | return CupertinoPageRoute(builder: (_) => const UserPage()); | 99 | return CupertinoPageRoute(builder: (_) => const UserPage()); |
| 96 | case AppRouteName.userInformation: | 100 | case AppRouteName.userInformation: |
| 97 | return CupertinoPageRoute(builder: (_) => const UserInformationPage()); | 101 | return CupertinoPageRoute(builder: (_) => const UserInformationPage()); |
| 102 | + /*case AppRouteName.userModifyInformation: | ||
| 103 | + return CupertinoPageRoute(builder: (_) { | ||
| 104 | + ModifyUserInformationType argument = ModifyUserInformationType.name; | ||
| 105 | + if (settings.arguments != null) { | ||
| 106 | + argument = settings.arguments as ModifyUserInformationType; | ||
| 107 | + } | ||
| 108 | + return ModifyUserInformationPage(type: argument); | ||
| 109 | + });*/ | ||
| 98 | case AppRouteName.topicPic: | 110 | case AppRouteName.topicPic: |
| 99 | var courseLessonId = ''; | 111 | var courseLessonId = ''; |
| 100 | if (settings.arguments != null) { | 112 | if (settings.arguments != null) { |
| @@ -109,7 +121,7 @@ class AppRouter { | @@ -109,7 +121,7 @@ class AppRouter { | ||
| 109 | videoUrl: videoUrl, | 121 | videoUrl: videoUrl, |
| 110 | typeTitle: title, | 122 | typeTitle: title, |
| 111 | )); | 123 | )); |
| 112 | - case AppRouteName.setPwd: | 124 | + /*case AppRouteName.setPwd: |
| 113 | var map = settings.arguments as Map; | 125 | var map = settings.arguments as Map; |
| 114 | final phoneNum = map['phoneNumber'] as String?; | 126 | final phoneNum = map['phoneNumber'] as String?; |
| 115 | final smsCode = map['smsCode'] as String?; | 127 | final smsCode = map['smsCode'] as String?; |
| @@ -119,7 +131,7 @@ class AppRouter { | @@ -119,7 +131,7 @@ class AppRouter { | ||
| 119 | phoneNum: phoneNum, | 131 | phoneNum: phoneNum, |
| 120 | smsCode: smsCode, | 132 | smsCode: smsCode, |
| 121 | pageType: pageType, | 133 | pageType: pageType, |
| 122 | - )); | 134 | + ));*/ |
| 123 | case AppRouteName.webView: | 135 | case AppRouteName.webView: |
| 124 | final urlStr = (settings.arguments as Map)['urlStr'] as String; | 136 | final urlStr = (settings.arguments as Map)['urlStr'] as String; |
| 125 | final webViewTitle = (settings.arguments as Map)['webViewTitle'] as String; | 137 | final webViewTitle = (settings.arguments as Map)['webViewTitle'] as String; |
| @@ -162,4 +174,3 @@ void pushNamedAndRemoveUntil(String routeName,RoutePredicate predicate, {Object? | @@ -162,4 +174,3 @@ void pushNamedAndRemoveUntil(String routeName,RoutePredicate predicate, {Object? | ||
| 162 | void popPage() { | 174 | void popPage() { |
| 163 | Navigator.pop(AppRouter.context); | 175 | Navigator.pop(AppRouter.context); |
| 164 | } | 176 | } |
| 165 | - |
lib/utils/text_input_formatter.dart
0 → 100644
| 1 | +import 'package:flutter/services.dart'; | ||
| 2 | + | ||
| 3 | +class RegexFormatter extends TextInputFormatter { | ||
| 4 | + RegexFormatter({required this.regex}); | ||
| 5 | + | ||
| 6 | + /// 需要匹配的正则表达 | ||
| 7 | + final String regex; | ||
| 8 | + | ||
| 9 | + @override | ||
| 10 | + TextEditingValue formatEditUpdate( | ||
| 11 | + TextEditingValue oldValue, | ||
| 12 | + TextEditingValue newValue, | ||
| 13 | + ) { | ||
| 14 | + if (newValue.text.isEmpty) { | ||
| 15 | + return TextEditingValue.empty; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + if (!RegExp(regex).hasMatch(newValue.text)) { | ||
| 19 | + return oldValue; | ||
| 20 | + } | ||
| 21 | + return newValue; | ||
| 22 | + } | ||
| 23 | +} |