Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OnePoem
/
OnePoem-App
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
reason
2022-03-30 18:23:38 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ed418d10ac955d14f77a8f5b89c9a9d222d25da2
ed418d10
1 parent
16c4288b
增加了邮箱地址验证逻辑
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
53 additions
and
21 deletions
lib/generated/intl/messages_en.dart
lib/generated/intl/messages_zh.dart
lib/login/page/register_page.dart
lib/login/widgets/my_text_field.dart
lib/net/http_api.dart
pubspec.lock
pubspec.yaml
lib/generated/intl/messages_en.dart
View file @
ed418d1
...
...
@@ -21,7 +21,6 @@ class MessageLookup extends MessageLookupByLibrary {
String
get
localeName
=>
'en'
;
final
messages
=
_notInlinedMessages
(
_notInlinedMessages
);
static
Map
<
String
,
Function
>
_notInlinedMessages
(
_
)
=>
<
String
,
Function
>{
"accountEditPageUserBirthday"
:
MessageLookupByLibrary
.
simpleMessage
(
"Birthday"
),
...
...
lib/generated/intl/messages_zh.dart
View file @
ed418d1
...
...
@@ -21,7 +21,6 @@ class MessageLookup extends MessageLookupByLibrary {
String
get
localeName
=>
'zh'
;
final
messages
=
_notInlinedMessages
(
_notInlinedMessages
);
static
Map
<
String
,
Function
>
_notInlinedMessages
(
_
)
=>
<
String
,
Function
>{
"accountEditPageUserBirthday"
:
MessageLookupByLibrary
.
simpleMessage
(
"出生日期"
),
...
...
lib/login/page/register_page.dart
View file @
ed418d1
import
'package:flutter/foundation.dart'
;
import
'package:Parlando/net/dio_utils.dart'
;
import
'package:Parlando/net/http_api.dart'
;
import
'package:email_validator/email_validator.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/services.dart'
;
import
'package:Parlando/home/webview_page.dart'
;
import
'package:Parlando/login/widgets/my_text_field.dart'
;
import
'package:Parlando/res/resources.dart'
;
import
'package:Parlando/res/styles.dart'
;
import
'package:Parlando/util/change_notifier_manage.dart'
;
import
'package:Parlando/util/other_utils.dart'
;
import
'package:Parlando/util/toast_utils.dart'
;
...
...
@@ -34,7 +34,6 @@ class _RegisterPageState extends State<RegisterPage>
final
FocusNode
_nodeText2
=
FocusNode
();
final
FocusNode
_nodeText3
=
FocusNode
();
bool
_clickable
=
false
;
bool
_switchSelected
=
true
;
@override
Map
<
ChangeNotifier
,
List
<
VoidCallback
>?>?
changeNotifier
()
{
...
...
@@ -71,7 +70,18 @@ class _RegisterPageState extends State<RegisterPage>
}
void
_register
()
{
Toast
.
show
(
'点击注册'
);
Map
<
String
,
String
>
params
=
<
String
,
String
>{
"email"
:
_nameController
.
text
,
"password"
:
_passwordController
.
text
,
"verify_code"
:
_vCodeController
.
text
,
};
DioUtils
.
instance
.
asyncRequestNetwork
(
Method
.
post
,
HttpApi
.
register
,
params:
params
,
onSuccess:
(
data
)
{},
onError:
(
code
,
msg
)
{},
);
}
@override
...
...
@@ -99,8 +109,8 @@ class _RegisterPageState extends State<RegisterPage>
key:
const
Key
(
'phone'
),
focusNode:
_nodeText1
,
controller:
_nameController
,
maxLength:
1
1
,
keyboardType:
TextInputType
.
phone
,
maxLength:
1
00
,
keyboardType:
TextInputType
.
emailAddress
,
hintText:
ParlandoLocalizations
.
of
(
context
).
inputPhoneHint
,
),
Gaps
.
vGap8
,
...
...
@@ -110,15 +120,28 @@ class _RegisterPageState extends State<RegisterPage>
controller:
_vCodeController
,
keyboardType:
TextInputType
.
number
,
getVCode:
()
async
{
if
(
_nameController
.
text
.
length
==
11
)
{
bool
valid
=
EmailValidator
.
validate
(
_nameController
.
text
);
if
(
valid
)
{
Toast
.
show
(
ParlandoLocalizations
.
of
(
context
).
verificationButton
);
/// 一般可以在这里发送真正的请求,请求成功返回true
return
true
;
Map
<
String
,
String
>
params
=
<
String
,
String
>{
"email"
:
_nameController
.
text
,
};
DioUtils
.
instance
.
asyncRequestNetwork
(
Method
.
get
,
HttpApi
.
verify
,
params:
[],
queryParameters:
params
,
onSuccess:
(
data
)
{
print
(
data
);
},
onError:
(
code
,
msg
)
{},
);
}
else
{
Toast
.
show
(
ParlandoLocalizations
.
of
(
context
).
inputPhoneInvalid
);
return
false
;
}
return
true
;
},
maxLength:
6
,
hintText:
ParlandoLocalizations
.
of
(
context
).
inputVerificationCodeHint
,
...
...
@@ -137,7 +160,7 @@ class _RegisterPageState extends State<RegisterPage>
Text
.
rich
(
TextSpan
(
text:
'登录即代表同意并阅读'
,
style:
TextStyle
(
fontSize:
14
,
color:
const
Color
(
0xFF999999
)),
style:
const
TextStyle
(
fontSize:
14
,
color:
Color
(
0xFF999999
)),
children:
[
TextSpan
(
text:
'《用户协议》'
,
...
...
@@ -146,12 +169,12 @@ class _RegisterPageState extends State<RegisterPage>
..
onTap
=
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
{
return
WebViewPage
(
return
const
WebViewPage
(
title:
'《用户协议》'
,
url:
'https://flutter.dev'
);
}));
},
),
TextSpan
(
text:
'和'
),
const
TextSpan
(
text:
'和'
),
TextSpan
(
text:
'《隐私政策》'
,
style:
TextStyle
(
color:
Theme
.
of
(
context
).
primaryColor
),
...
...
@@ -159,7 +182,7 @@ class _RegisterPageState extends State<RegisterPage>
..
onTap
=
()
{
Navigator
.
of
(
context
)
.
push
(
MaterialPageRoute
(
builder:
(
context
)
{
return
WebViewPage
(
return
const
WebViewPage
(
title:
'《隐私政策》'
,
url:
'https://flutter.dev'
);
}));
},
...
...
lib/login/widgets/my_text_field.dart
View file @
ed418d1
...
...
@@ -113,10 +113,11 @@ class _MyTextFieldState extends State<MyTextField> {
textInputAction:
TextInputAction
.
done
,
keyboardType:
widget
.
keyboardType
,
// 数字、手机号限制格式为0到9, 密码限制不包含汉字
inputFormatters:
(
widget
.
keyboardType
==
TextInputType
.
number
||
widget
.
keyboardType
==
TextInputType
.
phone
)
?
[
FilteringTextInputFormatter
.
allow
(
RegExp
(
'[0-9]'
))]
:
[
FilteringTextInputFormatter
.
deny
(
RegExp
(
'[
\
u4e00-
\
u9fa5]'
))],
inputFormatters:
[
FilteringTextInputFormatter
.
deny
(
RegExp
(
'[
\
u4e00-
\
u9fa5]'
),
),
],
decoration:
InputDecoration
(
contentPadding:
EdgeInsets
.
symmetric
(
vertical:
16
.
px
),
hintText:
widget
.
hintText
,
...
...
lib/net/http_api.dart
View file @
ed418d1
class
HttpApi
{
static
const
String
setting
=
'setting'
;
static
const
String
register
=
'register'
;
static
const
String
verify
=
'verify'
;
static
const
String
search
=
'search/repositories'
;
static
const
String
subscriptions
=
'users/simplezhli/subscriptions'
;
static
const
String
upload
=
'uuc/upload-inco'
;
...
...
pubspec.lock
View file @
ed418d1
...
...
@@ -302,6 +302,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.5"
email_validator:
dependency: "direct main"
description:
name: email_validator
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.1"
fake_async:
dependency: transitive
description:
...
...
pubspec.yaml
View file @
ed418d1
...
...
@@ -106,6 +106,7 @@ dependencies:
# A Dart timer that can be paused, resumed and reset.
pausable_timer
:
^1.0.0+3
email_validator
:
^2.0.1
dependency_overrides
:
decimal
:
1.5.0
...
...
Please
register
or
login
to post a comment