Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ethan
/
appframe
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 5dadc46a
authored
2025-11-24 18:37:23 +0800
by
tanghuan
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
微信登录时,增加loading
1 parent
c500d097
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
31 deletions
lib/bloc/login_main_cubit.dart
lib/ui/pages/login_main_page.dart
lib/bloc/login_main_cubit.dart
View file @
5dadc46
...
...
@@ -8,23 +8,33 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import
'package:fluwx/fluwx.dart'
;
import
'package:shared_preferences/shared_preferences.dart'
;
class
LoginMainState
extends
Equatable
{
final
bool
agreed
;
final
bool
showAgreed
;
final
bool
loading
;
const
LoginMainState
({
this
.
agreed
=
false
,
this
.
showAgreed
=
false
});
const
LoginMainState
({
this
.
agreed
=
false
,
this
.
showAgreed
=
false
,
this
.
loading
=
false
,
});
@override
List
<
Object
?>
get
props
=>
[
agreed
,
showAgreed
];
List
<
Object
?>
get
props
=>
[
agreed
,
showAgreed
,
loading
,
];
LoginMainState
copyWith
({
bool
?
agreed
,
bool
?
showAgreed
,
bool
?
loading
,
})
{
return
LoginMainState
(
agreed:
agreed
??
this
.
agreed
,
showAgreed:
showAgreed
??
this
.
showAgreed
,
loading:
loading
??
this
.
loading
,
);
}
}
...
...
@@ -67,6 +77,9 @@ class LoginMainCubit extends Cubit<LoginMainState> {
if
(!
result
)
{
throw
Exception
(
'微信授权处理失败'
);
}
// 控制显示加载框
emit
(
state
.
copyWith
(
loading:
true
));
}
void
goLoginPhone
()
{
...
...
@@ -98,7 +111,7 @@ class LoginMainCubit extends Cubit<LoginMainState> {
sharedPreferences
.
setString
(
'auth_stuId'
,
stuId
??
''
);
sharedPreferences
.
setString
(
'auth_ip'
,
Constant
.
h5Server
);
if
(
Constant
.
needIM
)
{
if
(
Constant
.
needIM
)
{
// IM登录, 正式使用时,需要从服务端获取用户签名
var
loginResult
=
await
_imService
.
login
(
userCode
);
if
(
loginResult
)
{
...
...
lib/ui/pages/login_main_page.dart
View file @
5dadc46
...
...
@@ -14,7 +14,9 @@ class LoginMainPage extends StatelessWidget {
create:
(
context
)
=>
LoginMainCubit
(
LoginMainState
()),
child:
BlocConsumer
<
LoginMainCubit
,
LoginMainState
>(
builder:
(
context
,
state
)
{
var
loginMainCubit
=
context
.
read
<
LoginMainCubit
>();
return
Scaffold
(
return
Stack
(
children:
[
Scaffold
(
resizeToAvoidBottomInset:
true
,
backgroundColor:
Colors
.
white
,
body:
SafeArea
(
...
...
@@ -36,7 +38,6 @@ class LoginMainPage extends StatelessWidget {
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
SizedBox
(
height:
30
),
// _buildHeader(),
LoginPageHeaderWidget
(),
SizedBox
(
height:
25
),
_buildLoginButtons
(
context
,
loginMainCubit
,
state
.
agreed
),
...
...
@@ -49,6 +50,25 @@ class LoginMainPage extends StatelessWidget {
],
)),
),
),
state
.
loading
?
Container
(
color:
Colors
.
black54
,
width:
MediaQuery
.
of
(
context
).
size
.
width
,
child:
Center
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
CircularProgressIndicator
(
color:
Color
(
0xFF7691FA
),
),
],
),
),
)
:
SizedBox
(),
],
);
},
listener:
(
context
,
state
)
{
if
(
state
.
showAgreed
)
{
...
...
@@ -58,31 +78,6 @@ class LoginMainPage extends StatelessWidget {
);
}
Widget
_buildHeader
()
{
return
Column
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'欢迎登录'
,
style:
TextStyle
(
fontSize:
25
,
fontWeight:
FontWeight
.
bold
,
color:
Colors
.
black87
,
),
),
SizedBox
(
height:
6
),
Text
(
'班小二,班级群必备效率工具'
,
style:
TextStyle
(
fontSize:
14
,
color:
Colors
.
black87
,
),
),
],
);
}
Widget
_buildLoginButtons
(
BuildContext
context
,
LoginMainCubit
loginMainCubit
,
bool
agreed
)
{
return
Column
(
children:
[
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment