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

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

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

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

@ -1,21 +1,67 @@
// Flutter imports: // 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'; import 'package:flutter/material.dart';
// Project imports: // Project imports:
import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
class EventDetailPage extends StatefulWidget { class EventDetailPage extends StatefulWidget {
EventDetailPage({Key key}) : super(key: key); final int themeId;
EventDetailPage({
Key key,
@required this.themeId,
}) : super(key: key);
@override @override
_EventDetailPageState createState() => _EventDetailPageState(); _EventDetailPageState createState() => _EventDetailPageState();
} }
class _EventDetailPageState extends State<EventDetailPage> { class _EventDetailPageState extends State<EventDetailPage> {
EasyRefreshController _refreshController = EasyRefreshController();
EventItemModel _model;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return BeeScaffold( return BeeScaffold(
title: '详情', 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, headImg: item.headSculptureImgUrl,
themeId: item.id, themeId: item.id,
initLike: item.isLike == 1, initLike: item.isLike == 1,
comments: item.gambitThemeCommentVoList,
likeNames: item.likeNames,
onDelete: () { onDelete: () {
_refreshController.callRefresh(); _refreshController.callRefresh();
}, },

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

@ -1,4 +1,5 @@
// Flutter imports: // Flutter imports:
import 'package:akuCommunity/model/community/event_item_model.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -35,6 +36,12 @@ class ChatCard extends StatefulWidget {
final VoidCallback onDelete; final VoidCallback onDelete;
final List<GambitThemeCommentVoList> comments;
final List<LikeNames> likeNames;
final bool hideLine;
final bool canTap;
ChatCard({ ChatCard({
Key key, Key key,
@required this.name, @required this.name,
@ -42,11 +49,15 @@ class ChatCard extends StatefulWidget {
@required this.headImg, @required this.headImg,
@required this.contentImg, @required this.contentImg,
@required this.date, @required this.date,
this.initLike = false, @required this.initLike,
@required this.id, @required this.id,
@required this.content, @required this.content,
@required this.themeId, @required this.themeId,
this.onDelete, this.onDelete,
@required this.comments,
this.hideLine = false,
@required this.likeNames,
this.canTap = true,
}) : super(key: key); }) : super(key: key);
@override @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 @override
void initState() { void initState() {
super.initState(); super.initState();
@ -210,21 +272,22 @@ class _ChatCardState extends State<ChatCard> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context);
return DecoratedBox( return DecoratedBox(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
border: Border( border: Border(
bottom: BorderSide( bottom: BorderSide(
color: Color(0xFFE5E5E5), color: widget.hideLine ? Colors.transparent : Color(0xFFE5E5E5),
), ),
), ),
), ),
child: MaterialButton( child: MaterialButton(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
onPressed: () { onPressed: widget.canTap
Get.to(EventDetailPage()); ? () {
}, Get.to(EventDetailPage(themeId: widget.themeId));
}
: null,
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
@ -243,12 +306,12 @@ class _ChatCardState extends State<ChatCard> {
Column( Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
widget.name.text.size(36.sp).make(), widget.name.text.black.size(36.sp).make(),
6.hb, 6.hb,
widget.content.text.make(), widget.content.text.black.make(),
20.hb, 20.hb,
_renderImage(), _renderImage(),
widget.topic.isEmpty widget.topic?.isEmpty ?? true
? SizedBox() ? SizedBox()
: Chip( : Chip(
label: '#${widget.topic}'.text.size(22.sp).make(), label: '#${widget.topic}'.text.size(22.sp).make(),
@ -262,6 +325,7 @@ class _ChatCardState extends State<ChatCard> {
), ),
Row( Row(
children: [ children: [
64.hb,
BeeDateUtil(widget.date) BeeDateUtil(widget.date)
.timeAgo .timeAgo
.text .text
@ -309,6 +373,7 @@ class _ChatCardState extends State<ChatCard> {
_buildMoreButton(), _buildMoreButton(),
], ],
), ),
_renderLikeAndComment(),
], ],
).expand(), ).expand(),
], ],

Loading…
Cancel
Save