You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

84 lines
2.7 KiB

4 years ago
// Flutter imports:
import 'package:aku_community_manager/ui/home/messages/system_message_green_card.dart';
import 'package:aku_community_manager/ui/home/messages/system_message_hygience_card.dart';
import 'package:common_utils/common_utils.dart';
4 years ago
import 'package:flutter/material.dart';
4 years ago
// Package imports:
import 'package:flutter_easyrefresh/easy_refresh.dart';
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.dart';
4 years ago
// Project imports:
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/message/system_message_item_model.dart';
4 years ago
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/ui/home/messages/system_message_card.dart';
4 years ago
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart';
4 years ago
class SystemMessage extends StatefulWidget {
SystemMessage({Key? key}) : super(key: key);
4 years ago
@override
_SystemMessageState createState() => _SystemMessageState();
}
class _SystemMessageState extends State<SystemMessage> {
EasyRefreshController _refreshController = EasyRefreshController();
String? _sendDate;
4 years ago
@override
Widget build(BuildContext context) {
return AkuScaffold(
title: '系统消息',
body: BeeListView(
controller: _refreshController,
builder: (items) {
return ListView.separated(
padding: EdgeInsets.symmetric(horizontal: 32.w),
itemBuilder: (context, index) {
return _buildCard(items[index], index);
},
separatorBuilder: (context, index) {
return 10.w.heightBox;
},
itemCount: items.length);
},
path: API.message.systemList,
convert: (model) => model.tableList!
.map((e) => SystemMessageItemModel.fromJson(e))
.toList(),
4 years ago
),
);
}
Widget _buildCard(SystemMessageItemModel model, int index) {
String? _date =
DateUtil.formatDateStr(model.sendDate!, format: 'yyyy-MM-dd');
if (_sendDate != null && _sendDate == _date && index != 0) {
_date = null;
} else {
_sendDate = _date;
}
switch (model.type) {
case 1:
return SystemMessageCard(
relationId: model.relationId!,
date: _date,
type: 1,
);
case 2:
return Container();
case 3:
return SystemMessageGreenCard(
relationId: model.relationId!, date: _date, type: 3);
case 4:
return SystemMessageHygienceCard(
relationId: model.relationId!, date: _date, type: 4);
default:
return Container();
}
}
4 years ago
}