Commit 1ca8ceec authored by 郑智刚's avatar 郑智刚

消息模块 通知裂变滚动

parent 53e588eb
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gmalpha_flutter/NewMessageModel/service/remote/entity/AttentionEntity.dart';
import 'package:gmalpha_flutter/NewMessageModel/util/message_date.dart';
import 'package:gmalpha_flutter/res/value/ALColors.dart';
......@@ -19,7 +20,7 @@ class AttentionListItem extends StatelessWidget {
maxLines: maxLines,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: size,
fontSize: ScreenUtil().setSp(size),
color: color,
height: 1.38,
fontWeight: weight ? FontWeight.bold : FontWeight.normal
......@@ -29,7 +30,7 @@ class AttentionListItem extends StatelessWidget {
Widget listItemHead() {
return Container(
margin: const EdgeInsets.only(right: 10.0),
margin: EdgeInsets.only(right: ScreenUtil().setWidth(10)),
child: CircleAvatar(
radius: 21.0,
backgroundImage: NetworkImage(item.icon),
......@@ -46,11 +47,11 @@ class AttentionListItem extends StatelessWidget {
child: myText('${item.title}', ALColors.Color464646, 13.0, weight: true),
),
Padding(
padding: const EdgeInsets.only(top: 4.0),
padding: EdgeInsets.only(top: ScreenUtil().setHeight(4)),
child: myText('${item.content}', ALColors.Color666666, 13.0, maxLines: 2),
),
Padding(
padding: const EdgeInsets.only(top: 3.0),
padding: EdgeInsets.only(top: ScreenUtil().setHeight(3)),
child: myText(MessageDate(item.pushTime).diffTime(), ALColors.Color999999, 10.0)
)
],
......@@ -60,9 +61,9 @@ class AttentionListItem extends StatelessWidget {
Widget listItemButton() {
return Container(
padding: const EdgeInsets.only(top: 5.0, left: 12.0),
width: 66.0,
height: 34.0,
padding: EdgeInsets.only(top: ScreenUtil().setHeight(5), left: ScreenUtil().setWidth(12)),
width: ScreenUtil().setWidth(66),
height: ScreenUtil().setHeight(34),
child: OutlineButton(
padding: const EdgeInsets.only(left: 0.0, right: 0.0,),
borderSide: BorderSide(
......
......@@ -5,8 +5,13 @@ import 'package:gmalpha_flutter/commonModel/live/BaseModel.dart';
import 'package:gmalpha_flutter/commonModel/live/LiveData.dart';
import 'package:gmalpha_flutter/commonModel/toast/toast.dart';
enum DataStatus {
DATA,
NODATA
}
class AttentionModel extends BaseModel {
LiveData<AttentionEntity> zzgLive = new LiveData();
LiveData<AttentionEntity> attentiveLive = new LiveData();
List<Data> _newList = [];
int page;
......@@ -16,24 +21,18 @@ class AttentionModel extends BaseModel {
AttentionModel(this.page, this.fromPage);
init(BuildContext context, {Function callback}) {
// 初始化或者刷新的时候增加一项无用项,用来渲染列表title
if (page == 1) {
Data firstData = Data();
_newList.add(firstData);
}
DataStatus loadStatus = DataStatus.DATA;
MessageRepository.getInstance().getAttentionList(page, count).listen((value) {
if (value != null) {
// 增加一个字段,用来判断是否还有数据
if (value.data.length == 0) {
value.noData = true;
} else {
value.noData = false;
loadStatus = DataStatus.NODATA;
}
_newList.addAll(value.data);
value.data = _newList;
zzgLive.notifyView(value);
attentiveLive.notifyView(value);
if (callback is Function) {
callback();
callback(loadStatus);
}
}
}).onError((error) {
......@@ -55,6 +54,6 @@ class AttentionModel extends BaseModel {
@override
void dispose() {
zzgLive.dispost();
attentiveLive.dispost();
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment