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
ae02e980
Commit
ae02e980
authored
Aug 07, 2019
by
jinzhu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'jz/message' into dev
parents
6ad51be4
3366e6e4
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
342 additions
and
9 deletions
+342
-9
list_item.dart
lib/base/list_item.dart
+5
-0
main.dart
lib/main.dart
+1
-1
message.dart
lib/model/message/message.dart
+3
-2
notification_model.dart
lib/model/notification_model.dart
+34
-0
DioUtil.dart
lib/netWork/DioUtil.dart
+2
-2
attention_list.dart
lib/pages/message/attention/attention_list.dart
+112
-0
attention_list_item.dart
lib/pages/message/attention/attention_list_item.dart
+15
-0
message_home.dart
lib/pages/message/home/message_home.dart
+9
-4
like_list.dart
lib/pages/message/like/like_list.dart
+16
-0
like_list_item.dart
lib/pages/message/like/like_list_item.dart
+16
-0
notification_list.dart
lib/pages/message/notification/notification_list.dart
+113
-0
notification_list_item.dart
lib/pages/message/notification/notification_list_item.dart
+16
-0
No files found.
lib/base/list_item.dart
0 → 100644
View file @
ae02e980
import
'package:flutter/material.dart'
;
// The base class for the different types of items the list can contain.
abstract
class
ListItem
{}
\ No newline at end of file
lib/main.dart
View file @
ae02e980
...
...
@@ -32,7 +32,7 @@ class _MyAppState extends State<MyApp> {
void
_init
()
{
BaseOptions
options
=
DioUtil
.
getDefOptions
();
Map
<
String
,
dynamic
>
cookie
=
{
'cookie'
:
'_gm_token=
4cabd51562739648; _gtid=fac513b6a2bf11e9acfd525400e5c7a38141; sessionid=7j7s902fmro0pvybwrp374khvva6l3xf
;'
};
Map
<
String
,
dynamic
>
cookie
=
{
'cookie'
:
'_gm_token=
1987651565078867; _gtid=7b19ca1cb4d511e9bf97525400e82fab4241; sessionid=d45sucgkl5frearp8qoezpjio65z8svh
;'
};
HttpConfig
config
=
new
HttpConfig
(
options:
options
,
nativeCookie:
cookie
);
DioUtil
().
setConfig
(
config
);
}
...
...
lib/model/message/message.dart
View file @
ae02e980
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/base/list_item.dart'
;
import
'package:gmalpha_flutter/model/message/replied_content.dart'
;
// The base class for the different types of items the list can contain.
abstract
class
ListItem
{}
//
abstract class ListItem {}
// https://javiercbk.github.io/json_to_dart/ json 在线转dart
class
Message
implements
ListItem
{
final
int
userId
;
final
String
name
;
...
...
lib/model/notification_model.dart
0 → 100644
View file @
ae02e980
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/base/list_item.dart'
;
class
NotificationModel
extends
ListItem
{
int
id
;
String
title
;
String
content
;
String
icon
;
int
pushTime
;
String
url
;
NotificationModel
({
this
.
id
,
this
.
title
,
this
.
content
,
this
.
icon
,
this
.
pushTime
,
this
.
url
});
NotificationModel
.
fromJson
(
Map
<
String
,
dynamic
>
json
)
{
id
=
json
[
'id'
];
title
=
json
[
'title'
];
content
=
json
[
'content'
];
icon
=
json
[
'icon'
];
pushTime
=
json
[
'push_time'
];
url
=
json
[
'url'
];
}
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
[
'icon'
]
=
this
.
icon
;
data
[
'push_time'
]
=
this
.
pushTime
;
data
[
'url'
]
=
this
.
url
;
return
data
;
}
}
\ No newline at end of file
lib/netWork/DioUtil.dart
View file @
ae02e980
...
...
@@ -447,8 +447,8 @@ class DioUtil {
options
.
connectTimeout
=
10
*
1000
;
options
.
receiveTimeout
=
20
*
1000
;
options
.
contentType
=
ContentType
.
parse
(
'application/x-www-form-urlencoded'
);
options
.
baseUrl
=
'https://earth.iyanzhi.com/'
;
//
options.baseUrl = 'http://earth.gmapp.env/';
//
options.baseUrl = 'https://earth.iyanzhi.com/';
options
.
baseUrl
=
'http://earth.gmapp.env/'
;
Map
<
String
,
dynamic
>
headers
=
Map
<
String
,
dynamic
>();
headers
[
'Accept'
]
=
'application/json'
;
return
options
;
...
...
lib/pages/message/attention/attention_list.dart
0 → 100644
View file @
ae02e980
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/base/list_item.dart'
;
import
'package:gmalpha_flutter/netWork/DioUtil.dart'
;
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
class
AttentionList
extends
StatefulWidget
{
@override
_AttentionListState
createState
()
=>
_AttentionListState
();
}
class
_AttentionListState
extends
State
<
AttentionList
>
{
@override
// List<ListItem> messageList = List<ListItem>();
// List<ListItem> dataArr = List<ListItem>();
// int pageIndex = 1;
// List<String> data1 = [];
// RefreshController _refreshController =
// RefreshController(initialRefresh: true);
// void _onRefresh() async{
// pageIndex = 1;
// List<ListItem> newdataArr = List<ListItem>();
// newdataArr = await _fetchListData();
// if (mounted) setState(() {
// dataArr = newdataArr;
// });
// _refreshController.refreshCompleted();
// }
// void _onLoading() async{
// pageIndex ++;
// List<ListItem> newData = List<ListItem>();
// newData = await _fetchMesssageList();
// if (mounted) setState(() {
// this.dataArr.addAll(newData);
// });
// _refreshController.loadComplete();
// }
// Future<List<ListItem>> _fetchMesssageList() async {
// List<Message> messageList = List<Message>();
// BaseResp<List> baseresp = await DioUtil().request<List>(Method.get, "api/v1/reply/my", queryParameters: {'page': pageIndex, 'count': 10});
// if (baseresp.code != 0) {
// return new Future.error(baseresp.msg);
// }
// if (baseresp.data != null) {
// messageList = baseresp.data.map((value) {
// return Message.fromJson(value);
// }).toList();
// }
// _refreshController.refreshCompleted();
// return messageList;
// }
// Future<List<ListItem>> _fetchListData() async {
// List<ListItem> dataArr = List<ListItem>();
// List<ListItem> messageData = await _fetchMesssageList();
// messageData.forEach((item) {
// dataArr.add(item);
// });
// return dataArr;
// }
// @override
// Widget build(BuildContext context) {
// return Scaffold(
// appBar: new AppBar(
// title: new Text('消息'),
// ),
// body: new Container(
// child: SmartRefresher(
// child: _createListView(),
// controller: _refreshController,
// enablePullDown: true,
// enablePullUp: true,
// header: WaterDropHeader(),
// onRefresh: (){
// _onRefresh();
// },
// onLoading: () {
// _onLoading();
// }
// ),
// )
// );
// }
// Widget _createListView() {
// List<ListItem> dataArr = this.dataArr;
// return ListView.builder(
// shrinkWrap: true,
// key: new PageStorageKey('message-list'),
// itemCount: dataArr.length,
// itemBuilder: (context,index) {
// ListItem item = dataArr[index];
// if (item is Message) {
// return new MessageItem(onPressed: (){}, message:item);
// } else if (item is NotificationItem){
// return new MessageNotificationItem(onPressed: (){}, notification: item);
// } else {
// return Text('类型错误');
// }
// },
// );
// }
}
\ No newline at end of file
lib/pages/message/attention/attention_list_item.dart
0 → 100644
View file @
ae02e980
import
'package:flutter/material.dart'
;
class
AttentionListItem
extends
StatefulWidget
{
@override
_AttentionListItemState
createState
()
=>
_AttentionListItemState
();
}
class
_AttentionListItemState
extends
State
<
AttentionListItem
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
);
}
}
lib/pages/message/home/message_home.dart
View file @
ae02e980
...
...
@@ -6,6 +6,7 @@ import 'message_item.dart';
import
'package:gmalpha_flutter/model/message/message.dart'
;
import
'package:gmalpha_flutter/netWork/DioUtil.dart'
;
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
import
'package:gmalpha_flutter/base/list_item.dart'
;
class
MessageHomePage
extends
StatefulWidget
{
...
...
@@ -90,19 +91,23 @@ class _MessageHomePageState extends State<MessageHomePage> {
BaseRespR
likeResp
=
await
DioUtil
().
requestR
(
Method
.
get
,
'api/v1/message/unread'
,
queryParameters:
{
'type'
:
0
});
print
(
likeResp
);
Map
likeData
=
likeResp
.
data
;
String
likeContent
=
'
还没有人给你Like哦~
'
;
String
likeContent
=
''
;
NotificationItem
likeItem
=
NotificationItem
(
'images/message_like.png'
,
likeContent
,
likeData
[
'count'
],
'Like'
);
if
(
likeItem
.
count
>
0
)
{
likeItem
.
content
=
'有
${likeItem.content}
个人Like了你'
;
likeItem
.
content
=
'有
${likeItem.count}
个人Like了你'
;
}
else
{
likeItem
.
content
=
'还没有人给你Like哦~'
;
}
notiData
.
add
(
likeItem
);
BaseRespR
attentionResp
=
await
DioUtil
().
requestR
(
Method
.
get
,
'api/v1/message/unread'
,
queryParameters:
{
'type'
:
1
});
Map
attData
=
attentionResp
.
data
;
String
attContent
=
'
还没有人给你关注哦~
'
;
String
attContent
=
''
;
NotificationItem
attItem
=
NotificationItem
(
'images/message_att.png'
,
attContent
,
attData
[
'count'
],
'关注'
);
if
(
attItem
.
count
>
0
)
{
attItem
.
content
=
'有
${attItem.content}
个人关注了你'
;
attItem
.
content
=
'有
${attItem.count}
个人关注了你'
;
}
else
{
attContent
=
'还没有人给你关注哦~'
;
}
notiData
.
add
(
attItem
);
// this.dataArr = dataArr;
...
...
lib/pages/message/like/like_list.dart
0 → 100644
View file @
ae02e980
import
'package:flutter/material.dart'
;
class
LikeList
extends
StatefulWidget
{
@override
_LikeListState
createState
()
=>
_LikeListState
();
}
class
_LikeListState
extends
State
<
LikeList
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
);
}
}
\ No newline at end of file
lib/pages/message/like/like_list_item.dart
0 → 100644
View file @
ae02e980
import
'package:flutter/material.dart'
;
class
LkeListItem
extends
StatefulWidget
{
@override
_LkeListItemState
createState
()
=>
_LkeListItemState
();
}
class
_LkeListItemState
extends
State
<
LkeListItem
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
);
}
}
\ No newline at end of file
lib/pages/message/notification/notification_list.dart
0 → 100644
View file @
ae02e980
import
'package:flutter/material.dart'
;
import
'package:gmalpha_flutter/netWork/DioUtil.dart'
;
import
'package:pull_to_refresh/pull_to_refresh.dart'
;
import
'package:gmalpha_flutter/base/list_item.dart'
;
import
'package:gmalpha_flutter/model/notification_model.dart'
;
class
NotificationList
extends
StatefulWidget
{
@override
_NotificationListState
createState
()
=>
_NotificationListState
();
}
class
_NotificationListState
extends
State
<
NotificationList
>
{
@override
List
<
ListItem
>
dataArr
=
List
<
ListItem
>();
int
pageIndex
=
1
;
List
<
String
>
data1
=
[];
RefreshController
_refreshController
=
RefreshController
(
initialRefresh:
true
);
void
_onRefresh
()
async
{
pageIndex
=
1
;
List
<
ListItem
>
newdataArr
=
List
<
ListItem
>();
newdataArr
=
await
_fetchListData
();
if
(
mounted
)
setState
(()
{
dataArr
=
newdataArr
;
});
_refreshController
.
refreshCompleted
();
}
void
_onLoading
()
async
{
pageIndex
++;
List
<
ListItem
>
newData
=
List
<
ListItem
>();
newData
=
await
_fetchMesssageList
();
if
(
mounted
)
setState
(()
{
this
.
dataArr
.
addAll
(
newData
);
});
_refreshController
.
loadComplete
();
}
Future
<
List
<
ListItem
>>
_fetchMesssageList
()
async
{
List
<
NotificationModel
>
messageList
=
List
<
NotificationModel
>();
BaseResp
<
List
>
baseresp
=
await
DioUtil
().
request
<
List
>(
Method
.
get
,
"api/v1/message/notice"
,
queryParameters:
{
'page'
:
pageIndex
,
'count'
:
10
});
if
(
baseresp
.
code
!=
0
)
{
return
new
Future
.
error
(
baseresp
.
msg
);
}
if
(
baseresp
.
data
!=
null
)
{
messageList
=
baseresp
.
data
.
map
((
value
)
{
return
NotificationModel
.
fromJson
(
value
);
}).
toList
();
}
_refreshController
.
refreshCompleted
();
return
messageList
;
}
Future
<
List
<
ListItem
>>
_fetchListData
()
async
{
List
<
ListItem
>
dataArr
=
List
<
ListItem
>();
List
<
ListItem
>
messageData
=
await
_fetchMesssageList
();
messageData
.
forEach
((
item
)
{
dataArr
.
add
(
item
);
});
return
dataArr
;
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
new
AppBar
(
title:
new
Text
(
'消息'
),
),
body:
new
Container
(
child:
SmartRefresher
(
child:
_createListView
(),
controller:
_refreshController
,
enablePullDown:
true
,
enablePullUp:
true
,
header:
WaterDropHeader
(),
onRefresh:
(){
_onRefresh
();
},
onLoading:
()
{
_onLoading
();
}
),
)
);
}
Widget
_createListView
()
{
List
<
ListItem
>
dataArr
=
this
.
dataArr
;
return
ListView
.
builder
(
shrinkWrap:
true
,
key:
new
PageStorageKey
(
'message-list'
),
itemCount:
dataArr
.
length
,
itemBuilder:
(
context
,
index
)
{
ListItem
item
=
dataArr
[
index
];
if
(
item
is
Message
)
{
return
new
MessageItem
(
onPressed:
(){},
message:
item
);
}
else
if
(
item
is
NotificationItem
){
return
new
MessageNotificationItem
(
onPressed:
(){},
notification:
item
);
}
else
{
return
Text
(
'类型错误'
);
}
},
);
}
}
\ No newline at end of file
lib/pages/message/notification/notification_list_item.dart
0 → 100644
View file @
ae02e980
import
'package:flutter/material.dart'
;
class
NotificationListItem
extends
StatefulWidget
{
@override
_NotificationListItemState
createState
()
=>
_NotificationListItemState
();
}
class
_NotificationListItemState
extends
State
<
NotificationListItem
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
);
}
}
\ 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