Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
gmalpha_flutter
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile
gmalpha_flutter
Commits
acb5d115
Commit
acb5d115
authored
Oct 16, 2019
by
郑智刚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加loading状态
parent
85ae7098
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
9 deletions
+32
-9
AttentionModel.dart
lib/NewMessageModel/page/AttentionModel.dart
+6
-3
AttentionPage.dart
lib/NewMessageModel/page/AttentionPage.dart
+26
-6
No files found.
lib/NewMessageModel/page/AttentionModel.dart
View file @
acb5d115
...
@@ -15,7 +15,7 @@ class AttentionModel extends BaseModel {
...
@@ -15,7 +15,7 @@ class AttentionModel extends BaseModel {
AttentionModel
(
this
.
page
,
this
.
fromPage
);
AttentionModel
(
this
.
page
,
this
.
fromPage
);
init
(
BuildContext
context
)
{
init
(
BuildContext
context
,
{
Function
callback
}
)
{
// 初始化或者刷新的时候增加一项无用项,用来渲染列表title
// 初始化或者刷新的时候增加一项无用项,用来渲染列表title
if
(
page
==
1
)
{
if
(
page
==
1
)
{
Data
firstData
=
Data
();
Data
firstData
=
Data
();
...
@@ -32,6 +32,9 @@ class AttentionModel extends BaseModel {
...
@@ -32,6 +32,9 @@ class AttentionModel extends BaseModel {
_newList
.
addAll
(
value
.
data
);
_newList
.
addAll
(
value
.
data
);
value
.
data
=
_newList
;
value
.
data
=
_newList
;
zzgLive
.
notifyView
(
value
);
zzgLive
.
notifyView
(
value
);
if
(
callback
is
Function
)
{
callback
();
}
}
}
}).
onError
((
error
)
{
}).
onError
((
error
)
{
Toast
.
show
(
context
,
"
${error.toString()}
"
);
Toast
.
show
(
context
,
"
${error.toString()}
"
);
...
@@ -45,9 +48,9 @@ class AttentionModel extends BaseModel {
...
@@ -45,9 +48,9 @@ class AttentionModel extends BaseModel {
init
(
context
);
init
(
context
);
}
}
more
(
BuildContext
context
)
{
more
(
BuildContext
context
,
Function
fun
)
{
page
++;
page
++;
init
(
context
);
init
(
context
,
callback:
fun
);
}
}
@override
@override
...
...
lib/NewMessageModel/page/AttentionPage.dart
View file @
acb5d115
...
@@ -6,6 +6,15 @@ import 'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionE
...
@@ -6,6 +6,15 @@ import 'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionE
import
'package:gmalpha_flutter/commonModel/base/BasePage.dart'
;
import
'package:gmalpha_flutter/commonModel/base/BasePage.dart'
;
import
'package:gmalpha_flutter/commonModel/ui/ALColors.dart'
;
import
'package:gmalpha_flutter/commonModel/ui/ALColors.dart'
;
enum
LoadStatus
{
// 正在加载
LOADING
,
// 加载完成
COMPLETE
,
// 初始状态
INITIAL
}
class
AttentionPage
extends
StatefulWidget
{
class
AttentionPage
extends
StatefulWidget
{
final
AttentionModel
_model
;
final
AttentionModel
_model
;
AttentionPage
(
String
fromPage
)
:
_model
=
AttentionModel
(
1
,
fromPage
);
AttentionPage
(
String
fromPage
)
:
_model
=
AttentionModel
(
1
,
fromPage
);
...
@@ -14,6 +23,7 @@ class AttentionPage extends StatefulWidget {
...
@@ -14,6 +23,7 @@ class AttentionPage extends StatefulWidget {
}
}
class
_AttentionPageState
extends
BasePage
<
AttentionPage
>
{
class
_AttentionPageState
extends
BasePage
<
AttentionPage
>
{
LoadStatus
loadStatus
=
LoadStatus
.
INITIAL
;
List
<
Data
>
_noticeLists
=
[];
List
<
Data
>
_noticeLists
=
[];
bool
noData
=
false
;
bool
noData
=
false
;
AttentionModel
_model
;
AttentionModel
_model
;
...
@@ -29,6 +39,7 @@ class _AttentionPageState extends BasePage<AttentionPage> {
...
@@ -29,6 +39,7 @@ class _AttentionPageState extends BasePage<AttentionPage> {
_noticeLists
=
[];
_noticeLists
=
[];
_scrollController
.
jumpTo
(
0
);
_scrollController
.
jumpTo
(
0
);
_model
.
refresh
(
context
);
_model
.
refresh
(
context
);
loadStatus
=
LoadStatus
.
INITIAL
;
}
}
@override
@override
...
@@ -40,11 +51,20 @@ class _AttentionPageState extends BasePage<AttentionPage> {
...
@@ -40,11 +51,20 @@ class _AttentionPageState extends BasePage<AttentionPage> {
if
(
noData
==
false
if
(
noData
==
false
&&
_scrollController
.
position
.
pixels
&&
_scrollController
.
position
.
pixels
==
_scrollController
.
position
.
maxScrollExtent
)
{
==
_scrollController
.
position
.
maxScrollExtent
)
{
_model
.
more
(
context
);
setState
(()
{
loadStatus
=
LoadStatus
.
LOADING
;
});
_model
.
more
(
context
,
loadComplete
);
}
}
});
});
}
}
void
loadComplete
()
{
setState
(()
{
loadStatus
=
LoadStatus
.
COMPLETE
;
});
}
@override
@override
String
pageName
()
{
String
pageName
()
{
return
'notice_list'
;
return
'notice_list'
;
...
@@ -93,10 +113,10 @@ class _AttentionPageState extends BasePage<AttentionPage> {
...
@@ -93,10 +113,10 @@ class _AttentionPageState extends BasePage<AttentionPage> {
}
}
Widget
_buildProgressIndicator
()
{
Widget
_buildProgressIndicator
()
{
return
Container
(
return
Opacity
(
color:
Color
(
0xFFF4F3F8
)
,
opacity:
loadStatus
==
LoadStatus
.
LOADING
?
1.0
:
0.0
,
child:
Padding
(
child:
Container
(
padding:
const
EdgeInsets
.
all
(
20.0
),
color:
Color
(
0xFFF4F3F8
),
child:
Row
(
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
...
@@ -107,7 +127,7 @@ class _AttentionPageState extends BasePage<AttentionPage> {
...
@@ -107,7 +127,7 @@ class _AttentionPageState extends BasePage<AttentionPage> {
child:
CircularProgressIndicator
(
strokeWidth:
2.0
),
child:
CircularProgressIndicator
(
strokeWidth:
2.0
),
),
),
Padding
(
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
6.0
),
padding:
const
EdgeInsets
.
only
(
left:
6.0
,
top:
20.0
,
bottom:
20.0
),
child:
Text
(
child:
Text
(
'加载中...'
,
'加载中...'
,
style:
TextStyle
(
style:
TextStyle
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment