更新社区点赞显示问题

hmxc
小赖 4 years ago
parent 6baeb68cbf
commit d6a4d5acf6

@ -1,17 +1,18 @@
class ImgModel {
String url;
String size;
int longs;
int paragraph;
double longs;
double paragraph;
int sort;
double get aspect => paragraph / longs;
ImgModel({this.url, this.size, this.longs, this.paragraph, this.sort});
ImgModel.fromJson(Map<String, dynamic> json) {
url = json['url'];
size = json['size'];
longs = json['longs'];
paragraph = json['paragraph'];
longs = json['longs'] + .0;
paragraph = json['paragraph'] + .0;
sort = json['sort'];
}
@ -21,6 +22,12 @@ class ImgModel {
return models.first.url ?? '';
}
static ImgModel firstModel(List<ImgModel> models) {
if (models == null) return null;
if (models.isEmpty) return null;
return models.first;
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;

@ -36,6 +36,7 @@ class MyCommunityViewState extends State<MyCommunityView>
},
builder: (items) {
return ListView.separated(
padding: EdgeInsets.symmetric(vertical: 10.w),
itemBuilder: (context, index) {
final MyEventItemModel model = items[index];
MyEventItemModel preModel;

@ -62,6 +62,7 @@ class _ChatCardState extends State<ChatCard> {
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
padding: EdgeInsets.zero,
clipBehavior: Clip.antiAlias,
minWidth: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8.w),
),
@ -92,6 +93,7 @@ class _ChatCardState extends State<ChatCard> {
_buildMoreButton() {
return Builder(builder: (context) {
final userProvider = Provider.of<UserProvider>(context);
return MaterialButton(
elevation: 0,
shape: RoundedRectangleBorder(
@ -131,6 +133,18 @@ class _ChatCardState extends State<ChatCard> {
showMessage: true,
);
setState(() {
if (widget.model.isLike == 0) {
widget.model.likeNames.add(
LikeNames(
id: Random().nextInt(1000),
name: userProvider.userInfoModel.nickName,
),
);
} else {
widget.model.likeNames.removeWhere((element) =>
element.name ==
userProvider.userInfoModel.nickName);
}
widget.model.isLike =
(widget.model.isLike == 1) ? 0 : 1;
});

Loading…
Cancel
Save