|
|
@ -1,8 +1,12 @@
|
|
|
|
import 'package:akuCommunity/constants/api.dart';
|
|
|
|
import 'package:akuCommunity/constants/api.dart';
|
|
|
|
import 'package:akuCommunity/model/common/img_model.dart';
|
|
|
|
import 'package:akuCommunity/model/common/img_model.dart';
|
|
|
|
|
|
|
|
import 'package:akuCommunity/provider/user_provider.dart';
|
|
|
|
import 'package:akuCommunity/utils/bee_date_util.dart';
|
|
|
|
import 'package:akuCommunity/utils/bee_date_util.dart';
|
|
|
|
import 'package:akuCommunity/utils/headers.dart';
|
|
|
|
import 'package:akuCommunity/utils/headers.dart';
|
|
|
|
|
|
|
|
import 'package:bot_toast/bot_toast.dart';
|
|
|
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'package:velocity_x/velocity_x.dart';
|
|
|
|
import 'package:velocity_x/velocity_x.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class ChatCard extends StatefulWidget {
|
|
|
|
class ChatCard extends StatefulWidget {
|
|
|
@ -11,7 +15,10 @@ class ChatCard extends StatefulWidget {
|
|
|
|
final List<ImgModel> headImg;
|
|
|
|
final List<ImgModel> headImg;
|
|
|
|
final List<ImgModel> contentImg;
|
|
|
|
final List<ImgModel> contentImg;
|
|
|
|
final DateTime date;
|
|
|
|
final DateTime date;
|
|
|
|
final bool canDelete;
|
|
|
|
final bool initLike;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
///userID
|
|
|
|
|
|
|
|
final int id;
|
|
|
|
ChatCard({
|
|
|
|
ChatCard({
|
|
|
|
Key key,
|
|
|
|
Key key,
|
|
|
|
this.name,
|
|
|
|
this.name,
|
|
|
@ -19,7 +26,8 @@ class ChatCard extends StatefulWidget {
|
|
|
|
this.headImg,
|
|
|
|
this.headImg,
|
|
|
|
this.contentImg,
|
|
|
|
this.contentImg,
|
|
|
|
@required this.date,
|
|
|
|
@required this.date,
|
|
|
|
this.canDelete,
|
|
|
|
this.initLike = false,
|
|
|
|
|
|
|
|
@required this.id,
|
|
|
|
}) : super(key: key);
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -27,6 +35,13 @@ class ChatCard extends StatefulWidget {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _ChatCardState extends State<ChatCard> {
|
|
|
|
class _ChatCardState extends State<ChatCard> {
|
|
|
|
|
|
|
|
bool _like = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool get _isMyself {
|
|
|
|
|
|
|
|
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
|
|
|
|
|
|
|
return (userProvider?.userInfoModel?.id ?? -1) == widget.id;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String get firstHead {
|
|
|
|
String get firstHead {
|
|
|
|
if (widget.headImg == null || widget.headImg.isEmpty)
|
|
|
|
if (widget.headImg == null || widget.headImg.isEmpty)
|
|
|
|
return '';
|
|
|
|
return '';
|
|
|
@ -49,8 +64,110 @@ class _ChatCardState extends State<ChatCard> {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_buildMoreButton() {
|
|
|
|
|
|
|
|
return Builder(builder: (context) {
|
|
|
|
|
|
|
|
return MaterialButton(
|
|
|
|
|
|
|
|
elevation: 0,
|
|
|
|
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(6.w),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
|
|
|
|
height: 40.w,
|
|
|
|
|
|
|
|
minWidth: 0,
|
|
|
|
|
|
|
|
color: Color(0xFFD8D8D8),
|
|
|
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
BotToast.showAttachedWidget(
|
|
|
|
|
|
|
|
targetContext: context,
|
|
|
|
|
|
|
|
preferDirection: PreferDirection.leftCenter,
|
|
|
|
|
|
|
|
attachedBuilder: (cancel) {
|
|
|
|
|
|
|
|
return Padding(
|
|
|
|
|
|
|
|
padding: EdgeInsets.only(right: 10.w),
|
|
|
|
|
|
|
|
child: Material(
|
|
|
|
|
|
|
|
color: Color(0xFFD8D8D8),
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(8.w),
|
|
|
|
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
|
|
|
|
child: SizedBox(
|
|
|
|
|
|
|
|
height: 78.w,
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
MaterialButton(
|
|
|
|
|
|
|
|
height: 78.w,
|
|
|
|
|
|
|
|
materialTapTargetSize:
|
|
|
|
|
|
|
|
MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
|
|
onPressed: () {
|
|
|
|
|
|
|
|
cancel();
|
|
|
|
|
|
|
|
//TODO 点赞
|
|
|
|
|
|
|
|
setState(() {
|
|
|
|
|
|
|
|
_like = !_like;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: [
|
|
|
|
|
|
|
|
_like
|
|
|
|
|
|
|
|
? Icon(Icons.favorite,
|
|
|
|
|
|
|
|
size: 30.w, color: Colors.red)
|
|
|
|
|
|
|
|
: Icon(Icons.favorite_border, size: 30.w),
|
|
|
|
|
|
|
|
10.wb,
|
|
|
|
|
|
|
|
'赞'.text.make(),
|
|
|
|
|
|
|
|
].row(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
VerticalDivider(width: 1.w, thickness: 1.w),
|
|
|
|
|
|
|
|
MaterialButton(
|
|
|
|
|
|
|
|
height: 78.w,
|
|
|
|
|
|
|
|
materialTapTargetSize:
|
|
|
|
|
|
|
|
MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
|
|
|
child: [
|
|
|
|
|
|
|
|
Icon(CupertinoIcons.bubble_right, size: 30.w),
|
|
|
|
|
|
|
|
10.wb,
|
|
|
|
|
|
|
|
'评论'.text.make(),
|
|
|
|
|
|
|
|
].row(),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
20.wb,
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
height: 8.w,
|
|
|
|
|
|
|
|
width: 8.w,
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(4.w),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
8.wb,
|
|
|
|
|
|
|
|
Container(
|
|
|
|
|
|
|
|
height: 8.w,
|
|
|
|
|
|
|
|
width: 8.w,
|
|
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
|
|
color: Colors.white,
|
|
|
|
|
|
|
|
borderRadius: BorderRadius.circular(4.w),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
20.wb,
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
|
|
|
void initState() {
|
|
|
|
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
_like = widget.initLike ?? false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@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,
|
|
|
@ -60,38 +177,55 @@ class _ChatCardState extends State<ChatCard> {
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
child: Row(
|
|
|
|
child: MaterialButton(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
children: [
|
|
|
|
onPressed: () {
|
|
|
|
Material(
|
|
|
|
//TODO go to chat detail page.
|
|
|
|
color: Color(0xFFF5F5F5),
|
|
|
|
},
|
|
|
|
borderRadius: BorderRadius.circular(6.w),
|
|
|
|
child: Row(
|
|
|
|
child: FadeInImage.assetNetwork(
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
|
|
|
children: [
|
|
|
|
image: API.image(firstHead),
|
|
|
|
Material(
|
|
|
|
height: 86.w,
|
|
|
|
color: Color(0xFFF5F5F5),
|
|
|
|
width: 86.w,
|
|
|
|
borderRadius: BorderRadius.circular(6.w),
|
|
|
|
),
|
|
|
|
clipBehavior: Clip.antiAlias,
|
|
|
|
),
|
|
|
|
child: FadeInImage.assetNetwork(
|
|
|
|
24.wb,
|
|
|
|
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
|
|
|
Column(
|
|
|
|
image: API.image(firstHead),
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
height: 86.w,
|
|
|
|
children: [
|
|
|
|
width: 86.w,
|
|
|
|
widget.name.text.size(36.sp).make(),
|
|
|
|
|
|
|
|
6.hb,
|
|
|
|
|
|
|
|
widget.title.text.make(),
|
|
|
|
|
|
|
|
20.hb,
|
|
|
|
|
|
|
|
_renderImage(),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
BeeDateUtil(widget.date).timeAgo.text.make(),
|
|
|
|
|
|
|
|
Spacer(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
).expand(),
|
|
|
|
24.wb,
|
|
|
|
],
|
|
|
|
Column(
|
|
|
|
).p(20.w),
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
widget.name.text.size(36.sp).make(),
|
|
|
|
|
|
|
|
6.hb,
|
|
|
|
|
|
|
|
widget.title.text.make(),
|
|
|
|
|
|
|
|
20.hb,
|
|
|
|
|
|
|
|
_renderImage(),
|
|
|
|
|
|
|
|
Row(
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
BeeDateUtil(widget.date).timeAgo.text.make(),
|
|
|
|
|
|
|
|
_isMyself
|
|
|
|
|
|
|
|
? FlatButton(
|
|
|
|
|
|
|
|
materialTapTargetSize:
|
|
|
|
|
|
|
|
MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
|
|
height: 48.w,
|
|
|
|
|
|
|
|
onPressed: () {},
|
|
|
|
|
|
|
|
child: '删除'.text.black.size(28.sp).make(),
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
: SizedBox(),
|
|
|
|
|
|
|
|
Spacer(),
|
|
|
|
|
|
|
|
_buildMoreButton(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
).expand(),
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
).p(20.w),
|
|
|
|
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|