添加动态详情页面,卡片添加点赞和评论

hmxc
小赖 4 years ago
parent 56bd1ea481
commit 11f9ce371a

@ -190,6 +190,9 @@ class _Community {
///
String get deleteMyEvent => '/user/gambit/falseDelete';
///
String get getEventDetail => '/user/gambit/GambitThemeDetail';
}
class _Upload {

@ -46,7 +46,8 @@ class EventItemModel {
json['likeNames'].forEach((v) {
likeNames.add(new LikeNames.fromJson(v));
});
}
} else
likeNames = [];
if (json['imgUrls'] != null) {
imgUrls = new List<ImgModel>();
json['imgUrls'].forEach((v) {
@ -66,7 +67,8 @@ class EventItemModel {
json['gambitThemeCommentVoList'].forEach((v) {
gambitThemeCommentVoList.add(new GambitThemeCommentVoList.fromJson(v));
});
}
} else
gambitThemeCommentVoList = [];
}
Map<String, dynamic> toJson() {

@ -1,21 +1,67 @@
// Flutter imports:
import 'package:akuCommunity/constants/api.dart';
import 'package:akuCommunity/model/community/event_item_model.dart';
import 'package:akuCommunity/ui/community/community_views/widgets/chat_card.dart';
import 'package:akuCommunity/utils/network/base_model.dart';
import 'package:akuCommunity/utils/network/net_util.dart';
import 'package:flutter/material.dart';
// Project imports:
import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
class EventDetailPage extends StatefulWidget {
EventDetailPage({Key key}) : super(key: key);
final int themeId;
EventDetailPage({
Key key,
@required this.themeId,
}) : super(key: key);
@override
_EventDetailPageState createState() => _EventDetailPageState();
}
class _EventDetailPageState extends State<EventDetailPage> {
EasyRefreshController _refreshController = EasyRefreshController();
EventItemModel _model;
@override
Widget build(BuildContext context) {
return BeeScaffold(
title: '详情',
body: EasyRefresh(
controller: _refreshController,
header: MaterialHeader(),
firstRefresh: true,
onRefresh: () async {
BaseModel model = await NetUtil().get(
API.community.getEventDetail,
params: {'themeId': widget.themeId},
);
_model = EventItemModel.fromJson(model.data);
setState(() {});
},
child: _model == null
? SizedBox()
: ListView(
children: [
ChatCard(
initLike: _model.isLike == 1,
name: _model.createName,
topic: _model.gambitTitle,
headImg: _model.headSculptureImgUrl,
contentImg: _model.imgUrls,
date: _model.date,
id: _model.id,
content: _model.content,
themeId: _model.id,
comments: _model.gambitThemeCommentVoList,
likeNames: _model.likeNames,
hideLine: true,
canTap: false,
),
],
),
),
);
}
}

@ -54,6 +54,8 @@ class NewCommunityViewState extends State<NewCommunityView>
headImg: item.headSculptureImgUrl,
themeId: item.id,
initLike: item.isLike == 1,
comments: item.gambitThemeCommentVoList,
likeNames: item.likeNames,
onDelete: () {
_refreshController.callRefresh();
},

@ -76,6 +76,8 @@ class _TopicDetailPageState extends State<TopicDetailPage> {
onDelete: () {
_refreshController.callRefresh();
},
comments: item.gambitThemeCommentVoList,
likeNames: item.likeNames,
);
},
childCount: items.length,

@ -1,4 +1,5 @@
// Flutter imports:
import 'package:akuCommunity/model/community/event_item_model.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -35,6 +36,12 @@ class ChatCard extends StatefulWidget {
final VoidCallback onDelete;
final List<GambitThemeCommentVoList> comments;
final List<LikeNames> likeNames;
final bool hideLine;
final bool canTap;
ChatCard({
Key key,
@required this.name,
@ -42,11 +49,15 @@ class ChatCard extends StatefulWidget {
@required this.headImg,
@required this.contentImg,
@required this.date,
this.initLike = false,
@required this.initLike,
@required this.id,
@required this.content,
@required this.themeId,
this.onDelete,
@required this.comments,
this.hideLine = false,
@required this.likeNames,
this.canTap = true,
}) : super(key: key);
@override
@ -202,6 +213,57 @@ class _ChatCardState extends State<ChatCard> {
});
}
_renderLike() {
return Padding(
padding: EdgeInsets.symmetric(horizontal: 16.w),
child: Flex(
direction: Axis.horizontal,
children: [
Icon(Icons.favorite_border_rounded, size: 24.w),
14.wb,
...widget.likeNames
.map((e) => e.name.text.make())
.toList()
.sepWidget(separate: ','.text.make()),
],
),
);
}
_renderComment() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: widget.comments.map((e) {
StringBuffer buffer = StringBuffer();
buffer.write(e.createName);
if (e.parentName != null) buffer.write('回复${e.parentName}');
buffer.write(':${e.content}');
return buffer.toString().text.make();
}).toList(),
);
}
_renderLikeAndComment() {
return Material(
borderRadius: BorderRadius.circular(8.w),
color: Color(0xFFF7F7F7),
child: Padding(
padding: EdgeInsets.all(8.w),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.likeNames.isEmpty ? SizedBox() : _renderLike(),
(widget.likeNames.isNotEmpty && widget.comments.isNotEmpty)
? Divider(height: 1.w, thickness: 1.w)
: SizedBox(),
widget.comments.isEmpty ? SizedBox() : _renderComment(),
],
),
),
);
}
@override
void initState() {
super.initState();
@ -210,21 +272,22 @@ class _ChatCardState extends State<ChatCard> {
@override
Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
return DecoratedBox(
decoration: BoxDecoration(
color: Colors.white,
border: Border(
bottom: BorderSide(
color: Color(0xFFE5E5E5),
color: widget.hideLine ? Colors.transparent : Color(0xFFE5E5E5),
),
),
),
child: MaterialButton(
padding: EdgeInsets.zero,
onPressed: () {
Get.to(EventDetailPage());
},
onPressed: widget.canTap
? () {
Get.to(EventDetailPage(themeId: widget.themeId));
}
: null,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -243,12 +306,12 @@ class _ChatCardState extends State<ChatCard> {
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
widget.name.text.size(36.sp).make(),
widget.name.text.black.size(36.sp).make(),
6.hb,
widget.content.text.make(),
widget.content.text.black.make(),
20.hb,
_renderImage(),
widget.topic.isEmpty
widget.topic?.isEmpty ?? true
? SizedBox()
: Chip(
label: '#${widget.topic}'.text.size(22.sp).make(),
@ -262,6 +325,7 @@ class _ChatCardState extends State<ChatCard> {
),
Row(
children: [
64.hb,
BeeDateUtil(widget.date)
.timeAgo
.text
@ -309,6 +373,7 @@ class _ChatCardState extends State<ChatCard> {
_buildMoreButton(),
],
),
_renderLikeAndComment(),
],
).expand(),
],

Loading…
Cancel
Save