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 | static const String icNext = '${_assetImagePrefix}ic_next.png'; |
6 | 6 | static const String bgUserInformationText = '${_assetImagePrefix}bg_user_information_text.png'; |
7 | 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 | 10 | //static String get icVip2 =>'ic_vip.png'.assetImg; |
9 | 11 | } | ... | ... |
lib/common/request/apis.dart
lib/common/widgets/textfield_customer_widget.dart
1 | 1 | import 'package:flutter/material.dart'; |
2 | +import 'package:flutter/services.dart'; | |
2 | 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
3 | 4 | import 'package:wow_english/common/extension/string_extension.dart'; |
4 | 5 | |
5 | 6 | class TextFieldCustomerWidget extends StatefulWidget { |
6 | - const TextFieldCustomerWidget({super.key, | |
7 | + const TextFieldCustomerWidget({ | |
8 | + super.key, | |
7 | 9 | this.controller, |
8 | 10 | this.hitStyle, |
9 | 11 | this.textStyle, |
... | ... | @@ -14,7 +16,8 @@ class TextFieldCustomerWidget extends StatefulWidget { |
14 | 16 | this.textAlign, |
15 | 17 | this.textInputType, |
16 | 18 | this.obscureText, |
17 | - this.onChangeValue | |
19 | + this.onChangeValue, | |
20 | + this.inputFormatters, | |
18 | 21 | }); |
19 | 22 | |
20 | 23 | final TextEditingController? controller; |
... | ... | @@ -28,6 +31,7 @@ class TextFieldCustomerWidget extends StatefulWidget { |
28 | 31 | final TextInputType? textInputType; |
29 | 32 | final bool? obscureText; |
30 | 33 | final Function(String value)? onChangeValue; |
34 | + final List<TextInputFormatter>? inputFormatters; | |
31 | 35 | |
32 | 36 | @override |
33 | 37 | State<StatefulWidget> createState() { |
... | ... | @@ -39,38 +43,32 @@ class _TextFieldCustomerWidgetState extends State<TextFieldCustomerWidget> { |
39 | 43 | @override |
40 | 44 | Widget build(BuildContext context) { |
41 | 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 | 48 | alignment: Alignment.center, |
45 | 49 | decoration: BoxDecoration( |
46 | 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 | 54 | child: TextField( |
55 | + inputFormatters: widget.inputFormatters, | |
54 | 56 | controller: widget.controller, |
55 | - textAlign: widget.textAlign??TextAlign.center, | |
57 | + textAlign: widget.textAlign ?? TextAlign.center, | |
56 | 58 | textInputAction: TextInputAction.done, |
57 | 59 | keyboardType: widget.textInputType, |
58 | - obscureText: widget.obscureText?? false, | |
60 | + obscureText: widget.obscureText ?? false, | |
59 | 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 | 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 | 12 | part 'login_state.dart'; |
13 | 13 | |
14 | 14 | enum LoginType { |
15 | - ///密码登陆 | |
15 | + ///密码登录 | |
16 | 16 | pwd, |
17 | 17 | |
18 | - ///验证码登陆 | |
18 | + ///验证码登录 | |
19 | 19 | sms, |
20 | 20 | } |
21 | 21 | |
... | ... | @@ -28,7 +28,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { |
28 | 28 | ///是否阅读协议 |
29 | 29 | bool _agreement = false; |
30 | 30 | |
31 | - ///登陆方式 | |
31 | + ///登录方式 | |
32 | 32 | //LoginType _loginType = LoginType.sms; |
33 | 33 | bool _isSmsLoginType = true; |
34 | 34 | |
... | ... | @@ -54,7 +54,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { |
54 | 54 | on<RequestSmsCodeEvent>(_requestSmsCodeApi); |
55 | 55 | } |
56 | 56 | |
57 | - ///请求登陆 | |
57 | + ///请求登录 | |
58 | 58 | void _requestLoginApi(RequestLoginEvent event, Emitter<LoginState> emitter) async { |
59 | 59 | var phoneNumber = phoneNumController.text; |
60 | 60 | if (phoneNumber.isEmpty) { |
... | ... | @@ -75,7 +75,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { |
75 | 75 | await loading(() async { |
76 | 76 | var user = await UserDao.login(phoneNumber, type, checkKey, checkNumber); |
77 | 77 | if (kDebugMode) { |
78 | - print('登陆 UserEntity=$user'); | |
78 | + print('登录 UserEntity=$user'); | |
79 | 79 | } |
80 | 80 | emitter.call(LoginResultChangeState()); |
81 | 81 | }); |
... | ... | @@ -83,7 +83,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { |
83 | 83 | if (kDebugMode) { |
84 | 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 | 107 | } |
108 | 108 | } |
109 | 109 | |
110 | - ///切换登陆方式 | |
110 | + ///切换登录方式 | |
111 | 111 | void _changeLoginType(ChangeLoginTypeEvent event, Emitter<LoginState> emitter) async { |
112 | 112 | if (_isSmsLoginType) { |
113 | 113 | _isSmsLoginType = false; |
... | ... | @@ -158,7 +158,7 @@ class LoginBloc extends Bloc<LoginEvent, LoginState> { |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | - ///登陆状态判断 | |
161 | + ///登录状态判断 | |
162 | 162 | bool _loginStateChange() { |
163 | 163 | if (_agreement) { |
164 | 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 | 2 | |
3 | 3 | @immutable |
4 | 4 | abstract class LoginEvent {} |
5 | -///切换登陆方式 | |
5 | +///切换登录方式 | |
6 | 6 | class ChangeLoginTypeEvent extends LoginEvent {} |
7 | 7 | ///输入手机号 |
8 | 8 | class PhoneNumChangeEvent extends LoginEvent {} |
... | ... | @@ -12,5 +12,5 @@ class CheckFieldChangeEvent extends LoginEvent {} |
12 | 12 | class AgreementChangeEvent extends LoginEvent {} |
13 | 13 | ///发送验证码 |
14 | 14 | class RequestSmsCodeEvent extends LoginEvent {} |
15 | -///请求登陆 | |
15 | +///请求登录 | |
16 | 16 | class RequestLoginEvent extends LoginEvent {} | ... | ... |
lib/pages/login/loginpage/bloc/login_state.dart
... | ... | @@ -5,10 +5,10 @@ abstract class LoginState {} |
5 | 5 | |
6 | 6 | class LoginInitial extends LoginState {} |
7 | 7 | |
8 | -///登陆按钮状态 | |
8 | +///登录按钮状态 | |
9 | 9 | class LoginEventChangeState extends LoginState {} |
10 | 10 | |
11 | -///切换登陆方式 | |
11 | +///切换登录方式 | |
12 | 12 | class LoginTypeChangeState extends LoginState {} |
13 | 13 | |
14 | 14 | ///发送验证码按钮状态 |
... | ... | @@ -20,5 +20,5 @@ class AgreementTypeChangeState extends LoginState {} |
20 | 20 | ///获取验证码 |
21 | 21 | class SmsCodeRequestState extends LoginState {} |
22 | 22 | |
23 | -///登陆请求结果 | |
23 | +///登录请求结果 | |
24 | 24 | class LoginResultChangeState extends LoginState {} | ... | ... |
lib/pages/login/loginpage/login_page.dart
... | ... | @@ -57,7 +57,7 @@ class _LoginPageView extends StatelessWidget { |
57 | 57 | ), |
58 | 58 | padding: EdgeInsets.symmetric(horizontal: 18.w, vertical: 5.h), |
59 | 59 | child: Text( |
60 | - bloc.isSmsLoginType ? '密码登陆' : '验证码密码', | |
60 | + bloc.isSmsLoginType ? '密码登录' : '验证码登录', | |
61 | 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 | 38 | Widget build(BuildContext context) { |
39 | 39 | return MultiBlocListener( |
40 | 40 | listeners: [ |
41 | - if(pageType == 0) ...[//登陆 | |
41 | + if(pageType == 0) ...[//登录 | |
42 | 42 | BlocListener<TimerBloc,TimerState>( |
43 | 43 | listener: (context, s) { |
44 | 44 | if (s is FinishedState) { | ... | ... |
lib/pages/login/setpwd/set_pwd_page.dart
1 | +import 'package:flutter/cupertino.dart'; | |
1 | 2 | import 'package:flutter/material.dart'; |
2 | 3 | import 'package:flutter_bloc/flutter_bloc.dart'; |
3 | 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; |
... | ... | @@ -34,12 +35,15 @@ class SetPassWordPage extends StatelessWidget { |
34 | 35 | ); |
35 | 36 | } |
36 | 37 | |
38 | + /// [pageType]= [resetPwd] or [changePwd] 时,必传手机号和验证码 | |
37 | 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 | 2 | import 'package:flutter_bloc/flutter_bloc.dart'; |
3 | +import 'package:wow_english/common/core/user_util.dart'; | |
2 | 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 | 9 | part 'user_event.dart'; |
5 | 10 | part 'user_state.dart'; |
6 | 11 | |
7 | 12 | class UserBloc extends Bloc<UserEvent, UserState> { |
13 | + final TextEditingController modifyTextController = TextEditingController(); | |
14 | + | |
8 | 15 | UserBloc() : super(UserInitial()) { |
9 | 16 | on<UserLogout>(_logout); |
17 | + on<UserUpdate>(_updateUser); | |
10 | 18 | } |
11 | 19 | |
12 | 20 | void _logout(UserLogout event, Emitter<UserState> emitter) async { |
13 | - print('UserBloc._test, event: $event, emitter: $emitter'); | |
14 | 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
lib/pages/user/information/user_information_page.dart
... | ... | @@ -7,6 +7,7 @@ import 'package:wow_english/common/widgets/we_app_bar.dart'; |
7 | 7 | import 'package:wow_english/models/user_entity.dart'; |
8 | 8 | import 'package:wow_english/pages/user/bloc/user_bloc.dart'; |
9 | 9 | import 'package:wow_english/utils/image_util.dart'; |
10 | +import 'package:wow_english/utils/log_util.dart'; | |
10 | 11 | |
11 | 12 | import '../modify/modify_user_information_page.dart'; |
12 | 13 | |
... | ... | @@ -28,9 +29,11 @@ class _UserInformationView extends StatelessWidget { |
28 | 29 | @override |
29 | 30 | Widget build(BuildContext context) { |
30 | 31 | return BlocListener<UserBloc, UserState>( |
31 | - listener: (context, state) {}, | |
32 | + listener: (context, state) { | |
33 | + Log.d('UserInformationPage: $state'); | |
34 | + }, | |
32 | 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 | 42 | class _UserInformationContentView extends StatelessWidget { |
40 | 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 | 50 | @override |
... | ... | @@ -76,7 +80,7 @@ class _UserInformationContentView extends StatelessWidget { |
76 | 80 | fontSize: 21.sp, |
77 | 81 | ), |
78 | 82 | ), |
79 | - onTap: () => _openModifyPage(ModifyUserInformationType.name)), | |
83 | + onTap: () => _openModifyPage(context, ModifyUserInformationType.name)), | |
80 | 84 | 11.verticalSpace, |
81 | 85 | _buildContentRow( |
82 | 86 | '年龄', | ... | ... |
lib/pages/user/modify/modify_user_information_page.dart
1 | +import 'package:flutter/cupertino.dart'; | |
1 | 2 | import 'package:flutter/material.dart'; |
3 | +import 'package:flutter/services.dart'; | |
2 | 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 | 8 | import 'package:wow_english/common/widgets/we_app_bar.dart'; |
4 | 9 | import 'package:wow_english/pages/user/bloc/user_bloc.dart'; |
5 | 10 | |
6 | 11 | enum ModifyUserInformationType { |
7 | - avatar('修改头像'), name('修改名字'), age('修改年龄'), gender('修改性别'); | |
12 | + avatar('头像'), | |
13 | + name('名字'), | |
14 | + age('年龄'), | |
15 | + gender('性别'); | |
8 | 16 | |
9 | 17 | const ModifyUserInformationType(this.title); |
10 | 18 | |
... | ... | @@ -16,6 +24,12 @@ class ModifyUserInformationPage extends StatelessWidget { |
16 | 24 | |
17 | 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 | 33 | @override |
20 | 34 | Widget build(BuildContext context) { |
21 | 35 | return BlocProvider( |
... | ... | @@ -23,7 +37,72 @@ class ModifyUserInformationPage extends StatelessWidget { |
23 | 37 | child: Scaffold( |
24 | 38 | backgroundColor: Colors.white, |
25 | 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 | 63 | child: Column( |
64 | 64 | mainAxisAlignment: MainAxisAlignment.center, |
65 | 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 | 75 | Row( |
73 | 76 | mainAxisAlignment: MainAxisAlignment.spaceBetween, |
74 | 77 | children: [ |
... | ... | @@ -170,7 +173,7 @@ class _UserView extends StatelessWidget { |
170 | 173 | )), |
171 | 174 | 30.verticalSpace, |
172 | 175 | OutlinedButton( |
173 | - onPressed: () => {userBloc.add(UserLogout())}, | |
176 | + onPressed: () => userBloc.add(UserLogout()), | |
174 | 177 | style: ButtonStyle( |
175 | 178 | side: MaterialStateProperty.all(BorderSide(color: const Color(0xFF140C10), width: 1.5)), |
176 | 179 | shape: MaterialStateProperty.all( |
... | ... | @@ -179,7 +182,7 @@ class _UserView extends StatelessWidget { |
179 | 182 | backgroundColor: MaterialStateProperty.all(Color(0xFFFBB621)), |
180 | 183 | ), |
181 | 184 | child: Text( |
182 | - "退出登陆", | |
185 | + "退出登录", | |
183 | 186 | style: TextStyle( |
184 | 187 | //fontWeight: FontWeight.w600, |
185 | 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 | 16 | import 'package:wow_english/pages/shop/home/shop_home_page.dart'; |
17 | 17 | import 'package:wow_english/pages/tab/tab_page.dart'; |
18 | 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 | 20 | import 'package:wow_english/pages/user/user_page.dart'; |
20 | 21 | import 'package:wow_english/pages/video/lookvideo/look_video_page.dart'; |
21 | 22 | |
... | ... | @@ -27,8 +28,8 @@ class AppRouteName { |
27 | 28 | static const String home = 'home'; |
28 | 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 | 33 | static const String webView = 'webView'; |
33 | 34 | static const String lesson = 'lesson'; |
34 | 35 | static const String listen = 'listen'; |
... | ... | @@ -41,6 +42,9 @@ class AppRouteName { |
41 | 42 | |
42 | 43 | /// 用户详细信息页 |
43 | 44 | static const String userInformation = 'userInformation'; |
45 | + | |
46 | + /// 用户修改信息页,不要自己调用,使用[ModifyUserInformationPage.push]方法,隐藏这种实现 | |
47 | + //static const String userModifyInformation = 'userModifyInformation'; | |
44 | 48 | ///看视频 |
45 | 49 | static const String lookVideo = 'lookVideo'; |
46 | 50 | ///绘本 |
... | ... | @@ -95,6 +99,14 @@ class AppRouter { |
95 | 99 | return CupertinoPageRoute(builder: (_) => const UserPage()); |
96 | 100 | case AppRouteName.userInformation: |
97 | 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 | 110 | case AppRouteName.topicPic: |
99 | 111 | var courseLessonId = ''; |
100 | 112 | if (settings.arguments != null) { |
... | ... | @@ -109,7 +121,7 @@ class AppRouter { |
109 | 121 | videoUrl: videoUrl, |
110 | 122 | typeTitle: title, |
111 | 123 | )); |
112 | - case AppRouteName.setPwd: | |
124 | + /*case AppRouteName.setPwd: | |
113 | 125 | var map = settings.arguments as Map; |
114 | 126 | final phoneNum = map['phoneNumber'] as String?; |
115 | 127 | final smsCode = map['smsCode'] as String?; |
... | ... | @@ -119,7 +131,7 @@ class AppRouter { |
119 | 131 | phoneNum: phoneNum, |
120 | 132 | smsCode: smsCode, |
121 | 133 | pageType: pageType, |
122 | - )); | |
134 | + ));*/ | |
123 | 135 | case AppRouteName.webView: |
124 | 136 | final urlStr = (settings.arguments as Map)['urlStr'] as String; |
125 | 137 | final webViewTitle = (settings.arguments as Map)['webViewTitle'] as String; |
... | ... | @@ -162,4 +174,3 @@ void pushNamedAndRemoveUntil(String routeName,RoutePredicate predicate, {Object? |
162 | 174 | void popPage() { |
163 | 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 | +} | ... | ... |