完成我的动态页面

hmxc
小赖 4 years ago
parent afd63d796a
commit 863c870334

@ -178,6 +178,9 @@ class _Community {
///4
String get hotTopic => '/user/gambit/findActivityGambit';
///
String get myEvent => '/user/gambit/myTidings';
}
class _Upload {

@ -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;
}
}

@ -60,6 +60,7 @@ class _PropertyIndexState extends State<PropertyIndex>
controller: _refreshController,
firstRefresh: true,
header: MaterialHeader(),
footer: MaterialFooter(),
onRefresh: () async {
_page = 1;
_models = await _getItems();

@ -1,4 +1,10 @@
import 'package:akuCommunity/ui/community/community_views/widgets/my_event_card.dart';
import 'package:akuCommunity/utils/headers.dart';
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/community/my_event_item_model.dart';
import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
class MyCommunityView extends StatefulWidget {
MyCommunityView({Key key}) : super(key: key);
@ -9,10 +15,31 @@ class MyCommunityView extends StatefulWidget {
class _MyCommunityViewState extends State<MyCommunityView>
with AutomaticKeepAliveClientMixin {
EasyRefreshController _refreshController = EasyRefreshController();
@override
Widget build(BuildContext context) {
super.build(context);
return Container();
return BeeListView(
path: API.community.myEvent,
controller: _refreshController,
convert: (model) {
return model.tableList
.map((e) => MyEventItemModel.fromJson(e))
.toList();
},
builder: (items) {
return ListView.separated(
itemBuilder: (context, index) {
final MyEventItemModel model = items[index];
MyEventItemModel preModel;
if (index >= 1) preModel = items[index - 1];
return MyEventCard(model: model, preModel: preModel);
},
separatorBuilder: (_, __) => 8.hb,
itemCount: items.length,
);
},
);
}
@override

@ -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…
Cancel
Save