reason

增加了邮箱地址验证逻辑

...@@ -21,7 +21,6 @@ class MessageLookup extends MessageLookupByLibrary { ...@@ -21,7 +21,6 @@ class MessageLookup extends MessageLookupByLibrary {
21 String get localeName => 'en'; 21 String get localeName => 'en';
22 22
23 final messages = _notInlinedMessages(_notInlinedMessages); 23 final messages = _notInlinedMessages(_notInlinedMessages);
24 -
25 static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ 24 static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
26 "accountEditPageUserBirthday": 25 "accountEditPageUserBirthday":
27 MessageLookupByLibrary.simpleMessage("Birthday"), 26 MessageLookupByLibrary.simpleMessage("Birthday"),
......
...@@ -21,7 +21,6 @@ class MessageLookup extends MessageLookupByLibrary { ...@@ -21,7 +21,6 @@ class MessageLookup extends MessageLookupByLibrary {
21 String get localeName => 'zh'; 21 String get localeName => 'zh';
22 22
23 final messages = _notInlinedMessages(_notInlinedMessages); 23 final messages = _notInlinedMessages(_notInlinedMessages);
24 -
25 static Map<String, Function> _notInlinedMessages(_) => <String, Function>{ 24 static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
26 "accountEditPageUserBirthday": 25 "accountEditPageUserBirthday":
27 MessageLookupByLibrary.simpleMessage("出生日期"), 26 MessageLookupByLibrary.simpleMessage("出生日期"),
......
1 -import 'package:flutter/foundation.dart'; 1 +import 'package:Parlando/net/dio_utils.dart';
2 +import 'package:Parlando/net/http_api.dart';
3 +import 'package:email_validator/email_validator.dart';
2 import 'package:flutter/gestures.dart'; 4 import 'package:flutter/gestures.dart';
3 import 'package:flutter/material.dart'; 5 import 'package:flutter/material.dart';
4 -import 'package:flutter/services.dart';
5 import 'package:Parlando/home/webview_page.dart'; 6 import 'package:Parlando/home/webview_page.dart';
6 import 'package:Parlando/login/widgets/my_text_field.dart'; 7 import 'package:Parlando/login/widgets/my_text_field.dart';
7 import 'package:Parlando/res/resources.dart'; 8 import 'package:Parlando/res/resources.dart';
8 -import 'package:Parlando/res/styles.dart';
9 import 'package:Parlando/util/change_notifier_manage.dart'; 9 import 'package:Parlando/util/change_notifier_manage.dart';
10 import 'package:Parlando/util/other_utils.dart'; 10 import 'package:Parlando/util/other_utils.dart';
11 import 'package:Parlando/util/toast_utils.dart'; 11 import 'package:Parlando/util/toast_utils.dart';
...@@ -34,7 +34,6 @@ class _RegisterPageState extends State<RegisterPage> ...@@ -34,7 +34,6 @@ class _RegisterPageState extends State<RegisterPage>
34 final FocusNode _nodeText2 = FocusNode(); 34 final FocusNode _nodeText2 = FocusNode();
35 final FocusNode _nodeText3 = FocusNode(); 35 final FocusNode _nodeText3 = FocusNode();
36 bool _clickable = false; 36 bool _clickable = false;
37 - bool _switchSelected=true;
38 37
39 @override 38 @override
40 Map<ChangeNotifier, List<VoidCallback>?>? changeNotifier() { 39 Map<ChangeNotifier, List<VoidCallback>?>? changeNotifier() {
...@@ -71,7 +70,18 @@ class _RegisterPageState extends State<RegisterPage> ...@@ -71,7 +70,18 @@ class _RegisterPageState extends State<RegisterPage>
71 } 70 }
72 71
73 void _register() { 72 void _register() {
74 - Toast.show('点击注册'); 73 + Map<String, String> params = <String, String>{
74 + "email": _nameController.text,
75 + "password": _passwordController.text,
76 + "verify_code": _vCodeController.text,
77 + };
78 + DioUtils.instance.asyncRequestNetwork(
79 + Method.post,
80 + HttpApi.register,
81 + params: params,
82 + onSuccess: (data) {},
83 + onError: (code, msg) {},
84 + );
75 } 85 }
76 86
77 @override 87 @override
...@@ -99,8 +109,8 @@ class _RegisterPageState extends State<RegisterPage> ...@@ -99,8 +109,8 @@ class _RegisterPageState extends State<RegisterPage>
99 key: const Key('phone'), 109 key: const Key('phone'),
100 focusNode: _nodeText1, 110 focusNode: _nodeText1,
101 controller: _nameController, 111 controller: _nameController,
102 - maxLength: 11, 112 + maxLength: 100,
103 - keyboardType: TextInputType.phone, 113 + keyboardType: TextInputType.emailAddress,
104 hintText: ParlandoLocalizations.of(context).inputPhoneHint, 114 hintText: ParlandoLocalizations.of(context).inputPhoneHint,
105 ), 115 ),
106 Gaps.vGap8, 116 Gaps.vGap8,
...@@ -110,15 +120,28 @@ class _RegisterPageState extends State<RegisterPage> ...@@ -110,15 +120,28 @@ class _RegisterPageState extends State<RegisterPage>
110 controller: _vCodeController, 120 controller: _vCodeController,
111 keyboardType: TextInputType.number, 121 keyboardType: TextInputType.number,
112 getVCode: () async { 122 getVCode: () async {
113 - if (_nameController.text.length == 11) { 123 + bool valid = EmailValidator.validate(_nameController.text);
124 + if (valid) {
114 Toast.show(ParlandoLocalizations.of(context).verificationButton); 125 Toast.show(ParlandoLocalizations.of(context).verificationButton);
115 - 126 + Map<String, String> params = <String, String>{
116 - /// 一般可以在这里发送真正的请求,请求成功返回true 127 + "email": _nameController.text,
117 - return true; 128 + };
129 + DioUtils.instance.asyncRequestNetwork(
130 + Method.get,
131 + HttpApi.verify,
132 + params: [],
133 + queryParameters: params,
134 + onSuccess: (data) {
135 + print(data);
136 + },
137 + onError: (code, msg) {},
138 + );
118 } else { 139 } else {
119 Toast.show(ParlandoLocalizations.of(context).inputPhoneInvalid); 140 Toast.show(ParlandoLocalizations.of(context).inputPhoneInvalid);
120 return false; 141 return false;
121 } 142 }
143 +
144 + return true;
122 }, 145 },
123 maxLength: 6, 146 maxLength: 6,
124 hintText: ParlandoLocalizations.of(context).inputVerificationCodeHint, 147 hintText: ParlandoLocalizations.of(context).inputVerificationCodeHint,
...@@ -137,7 +160,7 @@ class _RegisterPageState extends State<RegisterPage> ...@@ -137,7 +160,7 @@ class _RegisterPageState extends State<RegisterPage>
137 Text.rich( 160 Text.rich(
138 TextSpan( 161 TextSpan(
139 text: '登录即代表同意并阅读', 162 text: '登录即代表同意并阅读',
140 - style: TextStyle(fontSize: 14, color: const Color(0xFF999999)), 163 + style: const TextStyle(fontSize: 14, color: Color(0xFF999999)),
141 children: [ 164 children: [
142 TextSpan( 165 TextSpan(
143 text: '《用户协议》', 166 text: '《用户协议》',
...@@ -146,12 +169,12 @@ class _RegisterPageState extends State<RegisterPage> ...@@ -146,12 +169,12 @@ class _RegisterPageState extends State<RegisterPage>
146 ..onTap = () { 169 ..onTap = () {
147 Navigator.of(context) 170 Navigator.of(context)
148 .push(MaterialPageRoute(builder: (context) { 171 .push(MaterialPageRoute(builder: (context) {
149 - return WebViewPage( 172 + return const WebViewPage(
150 title: '《用户协议》', url: 'https://flutter.dev'); 173 title: '《用户协议》', url: 'https://flutter.dev');
151 })); 174 }));
152 }, 175 },
153 ), 176 ),
154 - TextSpan(text: '和'), 177 + const TextSpan(text: '和'),
155 TextSpan( 178 TextSpan(
156 text: '《隐私政策》', 179 text: '《隐私政策》',
157 style: TextStyle(color: Theme.of(context).primaryColor), 180 style: TextStyle(color: Theme.of(context).primaryColor),
...@@ -159,7 +182,7 @@ class _RegisterPageState extends State<RegisterPage> ...@@ -159,7 +182,7 @@ class _RegisterPageState extends State<RegisterPage>
159 ..onTap = () { 182 ..onTap = () {
160 Navigator.of(context) 183 Navigator.of(context)
161 .push(MaterialPageRoute(builder: (context) { 184 .push(MaterialPageRoute(builder: (context) {
162 - return WebViewPage( 185 + return const WebViewPage(
163 title: '《隐私政策》', url: 'https://flutter.dev'); 186 title: '《隐私政策》', url: 'https://flutter.dev');
164 })); 187 }));
165 }, 188 },
......
...@@ -113,10 +113,11 @@ class _MyTextFieldState extends State<MyTextField> { ...@@ -113,10 +113,11 @@ class _MyTextFieldState extends State<MyTextField> {
113 textInputAction: TextInputAction.done, 113 textInputAction: TextInputAction.done,
114 keyboardType: widget.keyboardType, 114 keyboardType: widget.keyboardType,
115 // 数字、手机号限制格式为0到9, 密码限制不包含汉字 115 // 数字、手机号限制格式为0到9, 密码限制不包含汉字
116 - inputFormatters: (widget.keyboardType == TextInputType.number || 116 + inputFormatters: [
117 - widget.keyboardType == TextInputType.phone) 117 + FilteringTextInputFormatter.deny(
118 - ? [FilteringTextInputFormatter.allow(RegExp('[0-9]'))] 118 + RegExp('[\u4e00-\u9fa5]'),
119 - : [FilteringTextInputFormatter.deny(RegExp('[\u4e00-\u9fa5]'))], 119 + ),
120 + ],
120 decoration: InputDecoration( 121 decoration: InputDecoration(
121 contentPadding: EdgeInsets.symmetric(vertical: 16.px), 122 contentPadding: EdgeInsets.symmetric(vertical: 16.px),
122 hintText: widget.hintText, 123 hintText: widget.hintText,
......
1 class HttpApi { 1 class HttpApi {
2 static const String setting = 'setting'; 2 static const String setting = 'setting';
3 + static const String register = 'register';
4 + static const String verify = 'verify';
3 static const String search = 'search/repositories'; 5 static const String search = 'search/repositories';
4 static const String subscriptions = 'users/simplezhli/subscriptions'; 6 static const String subscriptions = 'users/simplezhli/subscriptions';
5 static const String upload = 'uuc/upload-inco'; 7 static const String upload = 'uuc/upload-inco';
......
...@@ -302,6 +302,13 @@ packages: ...@@ -302,6 +302,13 @@ packages:
302 url: "https://pub.flutter-io.cn" 302 url: "https://pub.flutter-io.cn"
303 source: hosted 303 source: hosted
304 version: "4.0.5" 304 version: "4.0.5"
305 + email_validator:
306 + dependency: "direct main"
307 + description:
308 + name: email_validator
309 + url: "https://pub.flutter-io.cn"
310 + source: hosted
311 + version: "2.0.1"
305 fake_async: 312 fake_async:
306 dependency: transitive 313 dependency: transitive
307 description: 314 description:
......
...@@ -106,6 +106,7 @@ dependencies: ...@@ -106,6 +106,7 @@ dependencies:
106 106
107 # A Dart timer that can be paused, resumed and reset. 107 # A Dart timer that can be paused, resumed and reset.
108 pausable_timer: ^1.0.0+3 108 pausable_timer: ^1.0.0+3
109 + email_validator: ^2.0.1
109 110
110 dependency_overrides: 111 dependency_overrides:
111 decimal: 1.5.0 112 decimal: 1.5.0
......