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 Pun
2022-01-25 21:31:27 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a0d883f93264d5a09e129e625fdba136a6da38d6
a0d883f9
1 parent
884b2639
增加了登录状态判断
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
11 deletions
lib/home/splash_page.dart
lib/login/page/login_page.dart
lib/res/constant.dart
lib/setting/page/setting_page.dart
lib/setting/widgets/exit_dialog.dart
lib/home/splash_page.dart
View file @
a0d883f
...
...
@@ -6,6 +6,7 @@ import 'package:one_poem/extension/shared/size_fit.dart';
import
'package:one_poem/login/login_router.dart'
;
import
'package:one_poem/res/constant.dart'
;
import
'package:one_poem/routers/fluro_navigator.dart'
;
import
'package:one_poem/routers/routers.dart'
;
import
'package:one_poem/util/device_utils.dart'
;
import
'package:one_poem/util/image_utils.dart'
;
import
'package:one_poem/util/theme_utils.dart'
;
...
...
@@ -83,7 +84,11 @@ class _SplashPageState extends State<SplashPage> {
}
void
_goLogin
()
{
NavigatorUtils
.
push
(
context
,
LoginRouter
.
loginPage
,
replace:
true
);
if
(
SpUtil
.
containsKey
(
Constant
.
userToken
)!)
{
NavigatorUtils
.
push
(
context
,
Routes
.
home
,
clearStack:
true
);
}
else
{
NavigatorUtils
.
push
(
context
,
LoginRouter
.
loginPage
,
replace:
true
);
}
}
@override
...
...
lib/login/page/login_page.dart
View file @
a0d883f
import
'package:flustars/flustars.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -40,6 +41,7 @@ class _LoginPageState extends State<LoginPage>
final
FocusNode
_nodeText1
=
FocusNode
();
final
FocusNode
_nodeText2
=
FocusNode
();
bool
_clickable
=
false
;
bool
isLogin
=
false
;
@override
Map
<
ChangeNotifier
,
List
<
VoidCallback
>?>?
changeNotifier
()
{
...
...
@@ -117,8 +119,13 @@ class _LoginPageState extends State<LoginPage>
}
void
_login
()
{
SpUtil
.
putString
(
Constant
.
phone
,
_nameController
.
text
);
NavigatorUtils
.
push
(
context
,
Routes
.
home
,
clearStack:
true
);
isLogin
=
true
;
setState
(()
{});
Future
.
delayed
(
const
Duration
(
seconds:
2
),
()
{
//TODO 接入接口后获得user token则表明登录成功
SpUtil
.
putString
(
Constant
.
userToken
,
"this is user token!"
);
NavigatorUtils
.
push
(
context
,
Routes
.
home
,
clearStack:
true
);
});
}
@override
...
...
@@ -131,11 +138,28 @@ class _LoginPageState extends State<LoginPage>
NavigatorUtils
.
push
(
context
,
LoginRouter
.
smsLoginPage
);
},
),
body:
MyScrollView
(
keyboardConfig:
Utils
.
getKeyboardActionsConfig
(
context
,
<
FocusNode
>[
_nodeText1
,
_nodeText2
]),
padding:
EdgeInsets
.
only
(
left:
16
.
px
,
right:
16
.
px
,
top:
20
.
px
),
children:
_buildBody
,
body:
Stack
(
children:
[
MyScrollView
(
keyboardConfig:
Utils
.
getKeyboardActionsConfig
(
context
,
<
FocusNode
>[
_nodeText1
,
_nodeText2
,
]),
padding:
EdgeInsets
.
only
(
left:
16
.
px
,
right:
16
.
px
,
top:
20
.
px
,
),
children:
_buildBody
,
),
isLogin
?
const
Center
(
child:
CupertinoActivityIndicator
(
radius:
16.0
,
),
)
:
Container
(),
],
),
);
}
...
...
@@ -184,7 +208,7 @@ class _LoginPageState extends State<LoginPage>
}));
},
),
const
TextSpan
(
text:
'
和
'
),
const
TextSpan
(
text:
'
&
'
),
TextSpan
(
text:
'《隐私政策》'
,
style:
TextStyle
(
color:
Theme
.
of
(
context
).
primaryColor
),
...
...
lib/res/constant.dart
View file @
a0d883f
...
...
@@ -23,4 +23,5 @@ class Constant {
static
const
String
theme
=
'AppTheme'
;
static
const
String
locale
=
'locale'
;
static
const
String
userToken
=
'userToken'
;
}
...
...
lib/setting/page/setting_page.dart
View file @
a0d883f
...
...
@@ -11,8 +11,6 @@ import 'package:one_poem/widgets/my_app_bar.dart';
import
'../setting_router.dart'
;
import
'package:one_poem/extension/int_extension.dart'
;
class
SettingPage
extends
StatefulWidget
{
const
SettingPage
({
Key
?
key
})
:
super
(
key:
key
);
...
...
lib/setting/widgets/exit_dialog.dart
View file @
a0d883f
import
'package:flustars/flustars.dart'
;
import
'package:flutter/material.dart'
;
import
'package:one_poem/login/login_router.dart'
;
import
'package:one_poem/res/constant.dart'
;
import
'package:one_poem/res/styles.dart'
;
import
'package:one_poem/routers/fluro_navigator.dart'
;
import
'package:one_poem/widgets/base_dialog.dart'
;
...
...
@@ -25,6 +27,7 @@ class _ExitDialog extends State<ExitDialog> {
child:
const
Text
(
'您确定要退出登录吗?'
,
style:
TextStyles
.
textSize16
),
),
onPressed:
()
{
SpUtil
.
remove
(
Constant
.
userToken
);
NavigatorUtils
.
push
(
context
,
LoginRouter
.
loginPage
,
clearStack:
true
);
},
);
...
...
Please
register
or
login
to post a comment