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; });