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
f00a7253
Commit
f00a7253
authored
Oct 14, 2019
by
郑智刚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
消息模块通知页面
parent
de780466
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
358 additions
and
5 deletions
+358
-5
NewMessageRouter.dart
lib/NewMessageModel/NewMessageRouter.dart
+3
-0
NewMessageRouterImpl.dart
lib/NewMessageModel/NewMessageRouterImpl.dart
+7
-0
AttentionListItem.dart
lib/NewMessageModel/page/AttentionListItem.dart
+85
-0
AttentionModel.dart
lib/NewMessageModel/page/AttentionModel.dart
+41
-0
AttentionPage.dart
lib/NewMessageModel/page/AttentionPage.dart
+123
-0
MessageRepository.dart
lib/NewMessageModel/service/MessageRepository.dart
+10
-0
MessageRemote.dart
lib/NewMessageModel/service/remote/MessageRemote.dart
+5
-0
MessageApi.dart
lib/NewMessageModel/service/remote/api/MessageApi.dart
+9
-3
MessageApi.serv.dart
lib/NewMessageModel/service/remote/api/MessageApi.serv.dart
+15
-2
AttentionEntity.dart
...ewMessageModel/service/remote/entity/AttentionEntity.dart
+60
-0
No files found.
lib/NewMessageModel/NewMessageRouter.dart
View file @
f00a7253
...
...
@@ -6,4 +6,6 @@ import 'package:gmalpha_flutter/NewMessageModel/NewMessageRouterImpl.dart';
@Router
(
"NewMessageModel"
,
NewMessageRouterImpl
)
abstract
class
NewMessageRouter
implements
RouterBaser
{
Widget
getMessagePage
();
Widget
getAttentionPage
();
}
\ No newline at end of file
lib/NewMessageModel/NewMessageRouterImpl.dart
View file @
f00a7253
import
'package:flutter/widgets.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/NewMessageRouter.dart'
;
import
'package:gmalpha_flutter/newMessageModel/page/MessagePage.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/page/AttentionPage.dart'
;
class
NewMessageRouterImpl
implements
NewMessageRouter
{
...
...
@@ -8,4 +9,9 @@ class NewMessageRouterImpl implements NewMessageRouter {
Widget
getMessagePage
()
{
return
MessagePage
();
}
@override
Widget
getAttentionPage
()
{
return
AttentionPage
();
}
}
\ No newline at end of file
lib/NewMessageModel/page/AttentionListItem.dart
0 → 100644
View file @
f00a7253
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart'
;
import
'package:gmalpha_flutter/commonModel/ui/ALColors.dart'
;
class
AttentionListItem
extends
StatelessWidget
{
var
item
;
AttentionListItem
(
this
.
item
);
@override
Widget
build
(
BuildContext
context
)
{
return
SizedBox
(
child:
Card
(
elevation:
0.0
,
child:
Row
(
children:
<
Widget
>[
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
16.0
,
right:
10.0
),
child:
CircleAvatar
(
radius:
21.0
,
backgroundImage:
NetworkImage
(
item
.
icon
),
),
),
Expanded
(
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Container
(
child:
Text
(
'
${item.title}
'
,
style:
TextStyle
(
color:
ALColors
.
Color323232
,
fontSize:
13.0
),
),
),
Container
(
child:
Text
(
'
${item.content}
'
,
style:
TextStyle
(
color:
ALColors
.
Color323232
,
fontSize:
13.0
),
),
),
Container
(
child:
Text
(
'
${item.pushTime}
'
,
style:
TextStyle
(
color:
ALColors
.
Color8E8E8E
,
fontSize:
10.0
),
),
)
],
),
),
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
12.0
,
right:
16.0
),
child:
Container
(
width:
54.0
,
height:
29.0
,
child:
OutlineButton
(
padding:
const
EdgeInsets
.
only
(
left:
0.0
,
right:
0.0
,),
borderSide:
BorderSide
(
color:
ALColors
.
Color323232
),
shape:
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
zero
),
onPressed:
()
{
// TODO 跳转到详情页面
},
child:
Text
(
'详情'
,
style:
TextStyle
(
color:
ALColors
.
Color323232
,
fontSize:
13.0
),
),
),
)
)
],
),
),
);
}
}
lib/NewMessageModel/page/AttentionModel.dart
0 → 100644
View file @
f00a7253
/*
* @author zzg
* @date 2019-09-16
**/
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/MessageRepository.dart'
;
import
'package:gmalpha_flutter/commonModel/live/BaseModel.dart'
;
import
'package:gmalpha_flutter/commonModel/live/LiveData.dart'
;
import
'package:gmalpha_flutter/commonModel/toast/toast.dart'
;
class
AttentionModel
extends
BaseModel
{
LiveData
<
AttentionEntity
>
zzgLive
=
new
LiveData
();
int
page
;
int
count
;
AttentionModel
(
this
.
page
,
this
.
count
);
init
(
BuildContext
context
)
{
page
=
1
;
MessageRepository
.
getInstance
().
getAttentionList
(
page
,
count
).
listen
((
value
)
{
if
(
value
!=
null
)
{
zzgLive
.
notifyView
(
value
);
}
}).
onError
((
error
)
{
Toast
.
show
(
context
,
"
${error.toString()}
"
);
print
(
error
);
});
}
more
(
BuildContext
context
)
{
page
++;
init
(
context
);
}
@override
void
dispose
()
{
zzgLive
.
dispost
();
}
}
lib/NewMessageModel/page/AttentionPage.dart
0 → 100644
View file @
f00a7253
import
'package:flutter/material.dart'
;
import
'package:flutter_boost/flutter_boost.dart'
;
// import 'package:flutter_svg/flutter_svg.dart';
import
'package:gmalpha_flutter/NewMessageModel/page/AttentionModel.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/page/AttentionListItem.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart'
;
class
AttentionPage
extends
StatefulWidget
{
AttentionModel
_model
;
AttentionPage
()
{
_model
=
AttentionModel
(
1
,
10
);
}
@override
_AttentionPageState
createState
()
=>
_AttentionPageState
(
_model
);
}
class
_AttentionPageState
extends
State
<
AttentionPage
>
{
List
_noticeLists
=
[];
List
_newList
=
[];
AttentionModel
_model
;
_AttentionPageState
(
this
.
_model
);
ScrollController
_scrollController
=
ScrollController
();
bool
isPerformingRequest
=
false
;
@override
void
reassemble
()
{
super
.
reassemble
();
_model
.
init
(
context
);
setState
(()
{
_noticeLists
=
[];
});
}
@override
void
initState
()
{
super
.
initState
();
_model
.
init
(
context
);
_scrollController
.
addListener
(()
{
if
(
_scrollController
.
position
.
pixels
==
_scrollController
.
position
.
maxScrollExtent
)
{
_model
.
more
(
context
);
}
});
}
Widget
buildNoticeitem
(
BuildContext
context
,
int
index
)
{
if
(
index
==
_noticeLists
.
length
&&
_newList
.
length
==
0
)
{
return
Padding
(
padding:
const
EdgeInsets
.
all
(
10.0
),
child:
Center
(
child:
Text
(
'暂时无更多数据'
),
),
);
}
if
(
index
==
_noticeLists
.
length
)
{
return
_buildProgressIndicator
();
}
return
Padding
(
padding:
const
EdgeInsets
.
only
(
bottom:
21.0
),
child:
AttentionListItem
(
_noticeLists
[
index
]),
);
}
Widget
_buildProgressIndicator
()
{
return
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
<
Widget
>[
Container
(
width:
15.0
,
height:
15.0
,
child:
CircularProgressIndicator
(
strokeWidth:
2.0
),
),
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
5.0
),
child:
Text
(
'加载中...'
),
)
],
)
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
backgroundColor:
Colors
.
white
,
appBar:
AppBar
(
centerTitle:
true
,
leading:
GestureDetector
(
onTap:
()
{
FlutterBoost
.
singleton
.
closePageForContext
(
context
);
},
child:
Center
(
// child: SvgPicture.asset("images/left_arrow.svg", color: Color(0xff323232)),
),
),
),
body:
StreamBuilder
<
AttentionEntity
>(
stream:
_model
.
zzgLive
.
stream
,
initialData:
_model
.
zzgLive
.
data
,
builder:
(
context
,
data
)
{
_newList
=
data
.
data
.
data
;
for
(
var
item
in
data
.
data
.
data
)
{
_noticeLists
.
add
(
item
);
}
isPerformingRequest
=
false
;
return
ListView
.
builder
(
controller:
_scrollController
,
itemCount:
_noticeLists
.
length
+
1
,
itemBuilder:
buildNoticeitem
);
},
)
);
}
@override
void
dispose
()
{
super
.
dispose
();
}
}
\ No newline at end of file
lib/NewMessageModel/service/MessageRepository.dart
View file @
f00a7253
...
...
@@ -3,6 +3,7 @@ import 'package:gmalpha_flutter/NewMessageModel/service/remote/MessageRemote.dar
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/LatestMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/MyMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/UnreadMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart'
;
import
'package:rxdart/rxdart.dart'
;
class
MessageRepository
{
...
...
@@ -46,4 +47,12 @@ class MessageRepository {
return
value
;
});
}
Observable
<
AttentionEntity
>
getAttentionList
(
int
page
,
int
count
)
{
return
_remote
.
getAttentionList
(
page
,
count
).
map
((
value
)
{
if
(
value
!=
null
)
{
}
return
value
;
});
}
}
\ No newline at end of file
lib/NewMessageModel/service/remote/MessageRemote.dart
View file @
f00a7253
...
...
@@ -2,6 +2,7 @@ import 'package:gmalpha_flutter/NewMessageModel/service/remote/api/MessageApi.se
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/LatestMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/MyMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/UnreadMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart'
;
import
'package:rxdart/rxdart.dart'
;
class
MessageRemote
{
...
...
@@ -27,4 +28,8 @@ class MessageRemote {
Observable
<
LatestMessageEntity
>
getLatestMessage
()
{
return
MessageApiImpl
().
getLatestMessage
();
}
Observable
<
AttentionEntity
>
getAttentionList
(
int
page
,
int
count
)
{
return
MessageApiImpl
().
getAttentionList
(
page
,
count
);
}
}
lib/NewMessageModel/service/remote/api/MessageApi.dart
View file @
f00a7253
...
...
@@ -2,9 +2,11 @@
import
'package:gmalpha_flutter/Annotations/anno/Get.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/Query.dart'
;
import
'package:gmalpha_flutter/Annotations/anno/ServiceCenter.dart'
;
import
'package:gmalpha_flutter/newMessageModel/service/remote/entity/LatestMessageEntity.dart'
;
import
'package:gmalpha_flutter/newMessageModel/service/remote/entity/MyMessageEntity.dart'
;
import
'package:gmalpha_flutter/newMessageModel/service/remote/entity/UnreadMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/LatestMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/MyMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/UnreadMessageEntity.dart'
;
@ServiceCenter
()
abstract
class
MessageApi
{
...
...
@@ -17,4 +19,7 @@ abstract class MessageApi{
@Get
(
'api/v1/push/newest/info'
)
LatestMessageEntity
getLatestMessage
();
@Get
(
'api/v1/message/notice'
)
AttentionEntity
getAttentionList
(
@Query
(
'page'
)
int
page
,
@Query
(
'count'
)
int
count
);
}
\ No newline at end of file
lib/NewMessageModel/service/remote/api/MessageApi.serv.dart
View file @
f00a7253
...
...
@@ -8,10 +8,13 @@ import 'dart:convert';
import
'dart:io'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/LatestMessageEntity.dart'
;
import
'package:rxdart/rxdart.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/MyMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/UnreadMessageEntity.dart'
;
import
'package:rxdart/rxdart.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/LatestMessageEntity.dart'
;
import
'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart'
;
import
'package:gmalpha_flutter/commonModel/net/DioUtil.dart'
;
class
MessageApiImpl
{
...
...
@@ -58,4 +61,14 @@ class MessageApiImpl {
}
});
}
Observable
<
AttentionEntity
>
getAttentionList
(
int
page
,
int
count
)
{
return
Observable
.
fromFuture
(
DioUtil
().
get
(
'api/v1/message/notice'
,
data:
{
'page'
:
page
,
'count'
:
count
})).
map
((
value
)
{
if
(
value
!=
null
&&
value
.
statusCode
==
200
)
{
Map
map
=
json
.
decode
(
value
.
toString
());
return
AttentionEntity
.
fromJson
(
map
);
}
});
}
}
lib/NewMessageModel/service/remote/entity/AttentionEntity.dart
0 → 100644
View file @
f00a7253
class
AttentionEntity
{
String
message
;
int
error
;
List
<
Data
>
data
;
AttentionEntity
({
this
.
message
,
this
.
error
,
this
.
data
});
AttentionEntity
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
message
=
json
[
'message'
];
error
=
json
[
'error'
];
if
(
json
[
'data'
]
!=
null
)
{
data
=
new
List
<
Data
>();
json
[
'data'
].
forEach
((
v
)
{
data
.
add
(
new
Data
.
fromJson
(
v
));
});
}
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'message'
]
=
this
.
message
;
data
[
'error'
]
=
this
.
error
;
if
(
this
.
data
!=
null
)
{
data
[
'data'
]
=
this
.
data
.
map
((
v
)
=>
v
.
toJson
()).
toList
();
}
return
data
;
}
}
class
Data
{
int
id
;
String
title
;
String
content
;
String
url
;
String
icon
;
double
pushTime
;
Data
({
this
.
id
,
this
.
title
,
this
.
content
,
this
.
url
,
this
.
icon
,
this
.
pushTime
});
Data
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
title
=
json
[
'title'
];
content
=
json
[
'content'
];
url
=
json
[
'url'
];
icon
=
json
[
'icon'
];
pushTime
=
json
[
'push_time'
];
}
Map
<
String
,
dynamic
>
toJson
()
{
final
Map
<
String
,
dynamic
>
data
=
new
Map
<
String
,
dynamic
>();
data
[
'id'
]
=
this
.
id
;
data
[
'title'
]
=
this
.
title
;
data
[
'content'
]
=
this
.
content
;
data
[
'url'
]
=
this
.
url
;
data
[
'icon'
]
=
this
.
icon
;
data
[
'push_time'
]
=
this
.
pushTime
;
return
data
;
}
}
\ No newline at end of file
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