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

消息模块 通知裂变滚动

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