From d6a4d5acf6f9c5a305d6238582c74db1cb427cf3 Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 2 Apr 2021 13:40:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=A4=BE=E5=8C=BA=E7=82=B9?= =?UTF-8?q?=E8=B5=9E=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/model/common/img_model.dart | 15 +++++++++++---- .../community_views/my_community_view.dart | 1 + .../community_views/widgets/chat_card.dart | 14 ++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/lib/model/common/img_model.dart b/lib/model/common/img_model.dart index 7614a251..fe1e9a54 100644 --- a/lib/model/common/img_model.dart +++ b/lib/model/common/img_model.dart @@ -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 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 models) { + if (models == null) return null; + if (models.isEmpty) return null; + return models.first; + } + Map toJson() { final Map data = new Map(); data['url'] = this.url; diff --git a/lib/ui/community/community_views/my_community_view.dart b/lib/ui/community/community_views/my_community_view.dart index 01fd2b49..f25dd296 100644 --- a/lib/ui/community/community_views/my_community_view.dart +++ b/lib/ui/community/community_views/my_community_view.dart @@ -36,6 +36,7 @@ class MyCommunityViewState extends State }, builder: (items) { return ListView.separated( + padding: EdgeInsets.symmetric(vertical: 10.w), itemBuilder: (context, index) { final MyEventItemModel model = items[index]; MyEventItemModel preModel; diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index 1ed60867..0124b50f 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -62,6 +62,7 @@ class _ChatCardState extends State { 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 { _buildMoreButton() { return Builder(builder: (context) { + final userProvider = Provider.of(context); return MaterialButton( elevation: 0, shape: RoundedRectangleBorder( @@ -131,6 +133,18 @@ class _ChatCardState extends State { 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; });