parent
afd63d796a
commit
863c870334
@ -0,0 +1,43 @@
|
||||
import 'package:akuCommunity/model/common/img_model.dart';
|
||||
import 'package:flustars/flustars.dart';
|
||||
|
||||
class MyEventItemModel {
|
||||
int id;
|
||||
String content;
|
||||
List<ImgModel> imgUrl;
|
||||
String createDate;
|
||||
|
||||
String get firstImg {
|
||||
String img = '';
|
||||
if (imgUrl.isNotEmpty) img = imgUrl.first.url;
|
||||
return img;
|
||||
}
|
||||
|
||||
DateTime get date => DateUtil.getDateTime(createDate);
|
||||
|
||||
MyEventItemModel({this.id, this.content, this.imgUrl, this.createDate});
|
||||
|
||||
MyEventItemModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
content = json['content'];
|
||||
if (json['imgUrl'] != null) {
|
||||
imgUrl = new List<ImgModel>();
|
||||
json['imgUrl'].forEach((v) {
|
||||
imgUrl.add(new ImgModel.fromJson(v));
|
||||
});
|
||||
} else
|
||||
imgUrl = [];
|
||||
createDate = json['createDate'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['content'] = this.content;
|
||||
if (this.imgUrl != null) {
|
||||
data['imgUrl'] = this.imgUrl.map((v) => v.toJson()).toList();
|
||||
}
|
||||
data['createDate'] = this.createDate;
|
||||
return data;
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
import 'package:akuCommunity/const/resource.dart';
|
||||
import 'package:akuCommunity/constants/api.dart';
|
||||
import 'package:akuCommunity/model/community/my_event_item_model.dart';
|
||||
import 'package:akuCommunity/ui/community/notice/notice_detail_page.dart';
|
||||
import 'package:akuCommunity/utils/bee_date_util.dart';
|
||||
import 'package:akuCommunity/utils/headers.dart';
|
||||
import 'package:akuCommunity/model/community/board_model.dart';
|
||||
import 'package:akuCommunity/widget/picker/bee_image_preview.dart';
|
||||
import 'package:flustars/flustars.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:velocity_x/velocity_x.dart';
|
||||
|
||||
class MyEventCard extends StatelessWidget {
|
||||
final MyEventItemModel model;
|
||||
final MyEventItemModel preModel;
|
||||
const MyEventCard({
|
||||
Key key,
|
||||
@required this.model,
|
||||
@required this.preModel,
|
||||
}) : super(key: key);
|
||||
|
||||
bool get isFirst => preModel == null;
|
||||
|
||||
bool get notSameYear => model.date.year != (preModel?.date?.year ?? 0);
|
||||
|
||||
BeeDateUtil get beeDate => BeeDateUtil(model.date);
|
||||
|
||||
Widget title() {
|
||||
if (beeDate.sameDay) return '今天'.text.size(52.sp).bold.make();
|
||||
if (beeDate.isYesterday)
|
||||
return '昨天'.text.size(52.sp).bold.make();
|
||||
else
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
model.date.day.toString().text.size(52.sp).bold.make(),
|
||||
'${model.date.month}月'.text.size(36.sp).make(),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
(notSameYear && model.date.year != DateTime.now().year)
|
||||
? '${model.date.year}年'
|
||||
.text
|
||||
.bold
|
||||
.size(52.sp)
|
||||
.make()
|
||||
.paddingOnly(left: 32.w, top: isFirst ? 0 : 64.w, bottom: 32.w)
|
||||
: SizedBox(),
|
||||
MaterialButton(
|
||||
onPressed: () {},
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Container(
|
||||
width: 200.w,
|
||||
padding: EdgeInsets.only(left: 32.w),
|
||||
alignment: Alignment.topLeft,
|
||||
child: beeDate.sameDay ? SizedBox() : title(),
|
||||
),
|
||||
model.imgUrl.length == 0
|
||||
? SizedBox(height: 152.w)
|
||||
: GestureDetector(
|
||||
onTap: () {
|
||||
Get.to(
|
||||
BeeImagePreview.path(path: model.imgUrl.first.url),
|
||||
opaque: false,
|
||||
);
|
||||
},
|
||||
child: Hero(
|
||||
tag: model.imgUrl.first.url,
|
||||
child: Container(
|
||||
clipBehavior: Clip.antiAlias,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black12,
|
||||
borderRadius: BorderRadius.circular(8.w),
|
||||
),
|
||||
child: FadeInImage.assetNetwork(
|
||||
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
image: API.image(model.imgUrl.first.url),
|
||||
width: 152.w,
|
||||
height: 152.w,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
10.wb,
|
||||
model.content.text.make().expand(),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue