diff --git a/lib/model/community/activity_people_model.dart b/lib/model/community/activity_people_model.dart index fab70a62..5c00fcd4 100644 --- a/lib/model/community/activity_people_model.dart +++ b/lib/model/community/activity_people_model.dart @@ -1,8 +1,10 @@ +import 'package:akuCommunity/model/common/img_model.dart'; + class ActivityPeopleModel { int id; String name; String tel; - List imgUrl; + List imgUrl; ActivityPeopleModel({this.id, this.name, this.tel, this.imgUrl}); @@ -13,7 +15,7 @@ class ActivityPeopleModel { if (json['imgUrl'] != null) { imgUrl = []; json['imgUrl'].forEach((v) { - imgUrl.add(new ImgUrl.fromJson(v)); + imgUrl.add(new ImgModel.fromJson(v)); }); } } @@ -29,31 +31,3 @@ class ActivityPeopleModel { return data; } } - -class ImgUrl { - String url; - String size; - int longs; - int paragraph; - int sort; - - ImgUrl({this.url, this.size, this.longs, this.paragraph, this.sort}); - - ImgUrl.fromJson(Map json) { - url = json['url']; - size = json['size']; - longs = json['longs']; - paragraph = json['paragraph']; - sort = json['sort']; - } - - Map toJson() { - final Map data = new Map(); - data['url'] = this.url; - data['size'] = this.size; - data['longs'] = this.longs; - data['paragraph'] = this.paragraph; - data['sort'] = this.sort; - return data; - } -} diff --git a/lib/model/community/community_topic_model.dart b/lib/model/community/community_topic_model.dart index 20bb9d49..63e4a80b 100644 --- a/lib/model/community/community_topic_model.dart +++ b/lib/model/community/community_topic_model.dart @@ -8,13 +8,6 @@ class CommunityTopicModel { List imgUrl; int activityNum; - String get firstImg { - if (imgUrl.isEmpty) - return ''; - else - return imgUrl.first.url; - } - CommunityTopicModel( {this.id, this.title, diff --git a/lib/model/community/my_event_item_model.dart b/lib/model/community/my_event_item_model.dart index 4bd44231..b123cebf 100644 --- a/lib/model/community/my_event_item_model.dart +++ b/lib/model/community/my_event_item_model.dart @@ -8,12 +8,6 @@ class MyEventItemModel { List imgUrl; String createDate; - String get firstImg { - String img = ''; - if (imgUrl.isNotEmpty) img = imgUrl.first.url; - return img; - } - DateTime get date => DateUtil.getDateTime(createDate); MyEventItemModel({this.id, this.content, this.imgUrl, this.createDate}); diff --git a/lib/model/manager/questionnaire_detail_model.dart b/lib/model/manager/questionnaire_detail_model.dart index 49ca5f7c..e2f0114b 100644 --- a/lib/model/manager/questionnaire_detail_model.dart +++ b/lib/model/manager/questionnaire_detail_model.dart @@ -1,3 +1,5 @@ +import 'package:akuCommunity/model/common/img_model.dart'; + class QuestionnaireDetialModel { int id; String title; @@ -5,7 +7,7 @@ class QuestionnaireDetialModel { String beginDate; String endDate; List questionnaireTopicVoList; - List voResourcesImgList; + List voResourcesImgList; QuestionnaireDetialModel( {this.id, @@ -31,7 +33,7 @@ class QuestionnaireDetialModel { if (json['voResourcesImgList'] != null) { voResourcesImgList = []; json['voResourcesImgList'].forEach((v) { - voResourcesImgList.add(new VoResourcesImgList.fromJson(v)); + voResourcesImgList.add(new ImgModel.fromJson(v)); }); } else voResourcesImgList = []; @@ -115,31 +117,3 @@ class QuestionnaireChoiceVoList { } } -class VoResourcesImgList { - String url; - String size; - int longs; - int paragraph; - int sort; - - VoResourcesImgList( - {this.url, this.size, this.longs, this.paragraph, this.sort}); - - VoResourcesImgList.fromJson(Map json) { - url = json['url']; - size = json['size']; - longs = json['longs']; - paragraph = json['paragraph']; - sort = json['sort']; - } - - Map toJson() { - final Map data = new Map(); - data['url'] = this.url; - data['size'] = this.size; - data['longs'] = this.longs; - data['paragraph'] = this.paragraph; - data['sort'] = this.sort; - return data; - } -} diff --git a/lib/model/manager/voting_detail_model.dart b/lib/model/manager/voting_detail_model.dart index 3e335877..c7000599 100644 --- a/lib/model/manager/voting_detail_model.dart +++ b/lib/model/manager/voting_detail_model.dart @@ -9,12 +9,6 @@ class VotingDetailModel { List imgUrls; List appVoteCandidateVos; - String get firstImage { - if (imgUrls == null) return ''; - if (imgUrls.isEmpty) return ''; - return imgUrls.first.url ?? ''; - } - VotingDetailModel( {this.id, this.title, diff --git a/lib/model/user/committee_item_model.dart b/lib/model/user/committee_item_model.dart index 08e7f6e1..3790682b 100644 --- a/lib/model/user/committee_item_model.dart +++ b/lib/model/user/committee_item_model.dart @@ -14,10 +14,6 @@ class CommitteeItemModel { int estateNo; List imgUrls; - String get firstImg { - if (imgUrls.isEmpty) return ''; - return imgUrls.first.url; - } String get sexValue { if (sexId == 0 || sexId == null) return '未设置'; diff --git a/lib/pages/event_activity/event_voting_page.dart b/lib/pages/event_activity/event_voting_page.dart index df156223..9d420274 100644 --- a/lib/pages/event_activity/event_voting_page.dart +++ b/lib/pages/event_activity/event_voting_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -60,8 +61,7 @@ class _EventVotingPageState extends State { child: ClipRect( child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image( - model.imgUrls.isNotEmpty ? model.imgUrls.first.url : ''), + image: API.image(ImgModel.first(model.imgUrls)), fit: BoxFit.cover, ), ), diff --git a/lib/pages/event_activity/voting_detail_page.dart b/lib/pages/event_activity/voting_detail_page.dart index 6fe8a720..0c28e7f1 100644 --- a/lib/pages/event_activity/voting_detail_page.dart +++ b/lib/pages/event_activity/voting_detail_page.dart @@ -233,7 +233,7 @@ class _VotingDetailPageState extends State { borderRadius: BorderRadius.circular(8.w), child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(_model.firstImage), + image: API.image(ImgModel.first(_model.imgUrls)), ), ), 44.w.heightBox, diff --git a/lib/pages/goods_manage_page/goods_manage_page.dart b/lib/pages/goods_manage_page/goods_manage_page.dart index c9c6c997..393d6a8b 100644 --- a/lib/pages/goods_manage_page/goods_manage_page.dart +++ b/lib/pages/goods_manage_page/goods_manage_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -22,7 +23,7 @@ class GoodsManagePage extends StatefulWidget { } class _GoodsManagePageState extends State { - EasyRefreshController _easyRefreshController; + EasyRefreshController _easyRefreshController = EasyRefreshController(); Container _goodsCard(ArticleBorrowModel model) { return Container( @@ -50,10 +51,11 @@ class _GoodsManagePageState extends State { width: 160.w, margin: EdgeInsets.only(right: 20.w), child: ClipRRect( - child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image( - model.imgUrls.isEmpty ? '' : model.imgUrls.first.url))), + child: FadeInImage.assetNetwork( + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(ImgModel.first(model.imgUrls)), + ), + ), ), Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/pages/industry_committee/industry_committee_page.dart b/lib/pages/industry_committee/industry_committee_page.dart index a99ff700..055e7c6a 100644 --- a/lib/pages/industry_committee/industry_committee_page.dart +++ b/lib/pages/industry_committee/industry_committee_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -80,7 +81,7 @@ class _IndustryCommitteePageState extends State { borderRadius: BorderRadius.circular(4.w), child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(model.firstImg), + image: API.image(ImgModel.first(model.imgUrls)), height: 150.w, width: 150.w, fit: BoxFit.cover, diff --git a/lib/pages/things_page/widget/fixed_detail_page.dart b/lib/pages/things_page/widget/fixed_detail_page.dart index 1cd2b95f..263d729c 100644 --- a/lib/pages/things_page/widget/fixed_detail_page.dart +++ b/lib/pages/things_page/widget/fixed_detail_page.dart @@ -38,7 +38,7 @@ class CancelModel { class _FixedDetailPageState extends State { bool _onLoading = true; - EasyRefreshController _easyRefreshController; + EasyRefreshController _easyRefreshController = EasyRefreshController(); FixedDetailModel _model = FixedDetailModel(); bool get showRepairCard => _model?.appDispatchListVo != null; bool get showProcessCard => _model.appProcessRecordVo.isNotEmpty; diff --git a/lib/ui/community/activity/activity_card.dart b/lib/ui/community/activity/activity_card.dart index c9cd443d..31cf2b01 100644 --- a/lib/ui/community/activity/activity_card.dart +++ b/lib/ui/community/activity/activity_card.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/material.dart'; import 'package:flustars/flustars.dart'; @@ -18,8 +19,6 @@ class ActivityCard extends StatelessWidget { @required this.model, }) : super(key: key); - String get firstPath => - (model.imgUrls?.isEmpty ?? true) ? null : model.imgUrls.first.url; bool get outdate => model.end.compareTo(DateTime.now()) == -1; Widget build(BuildContext context) { return MaterialButton( @@ -38,15 +37,15 @@ class ActivityCard extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - firstPath == null + ImgModel.first(model.imgUrls) == null ? SizedBox() : Hero( - tag: firstPath, + tag: ImgModel.first(model.imgUrls), child: Material( color: Colors.grey, child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(firstPath), + image: API.image(ImgModel.first(model.imgUrls)), height: 210.w, width: double.infinity, fit: BoxFit.cover, diff --git a/lib/ui/community/activity/activity_people_list_page.dart b/lib/ui/community/activity/activity_people_list_page.dart index 2e19e7d2..b59ee58a 100644 --- a/lib/ui/community/activity/activity_people_list_page.dart +++ b/lib/ui/community/activity/activity_people_list_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -47,7 +48,7 @@ class _ActivityPeopleListPageState extends State { 20.wb, FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(model.imgUrl.first.url), + image: API.image(ImgModel.first(model.imgUrl)), height: 60.w, width: 60.w, ), diff --git a/lib/ui/community/community_views/topic/topic_community_view.dart b/lib/ui/community/community_views/topic/topic_community_view.dart index bd3fbb8e..8049c61c 100644 --- a/lib/ui/community/community_views/topic/topic_community_view.dart +++ b/lib/ui/community/community_views/topic/topic_community_view.dart @@ -1,5 +1,6 @@ import 'dart:ui'; +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -47,7 +48,7 @@ class TopicCommunityViewState extends State children: [ FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(model.firstImg), + image: API.image(ImgModel.first(model.imgUrl)), height: 160.w, width: 250.w, fit: BoxFit.cover, diff --git a/lib/ui/community/community_views/topic/topic_detail_page.dart b/lib/ui/community/community_views/topic/topic_detail_page.dart index 0e55e1d4..df5f02ef 100644 --- a/lib/ui/community/community_views/topic/topic_detail_page.dart +++ b/lib/ui/community/community_views/topic/topic_detail_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -63,7 +64,7 @@ class _TopicDetailPageState extends State { delegate: TopicSliverHeader( id: widget.model.id, title: widget.model.summary, - imgPath: widget.model.firstImg, + imgPath: ImgModel.first(widget.model.imgUrl), subTitle: widget.model.content, ), pinned: true, diff --git a/lib/ui/community/community_views/widgets/chat_card.dart b/lib/ui/community/community_views/widgets/chat_card.dart index be0c833a..f63616f5 100644 --- a/lib/ui/community/community_views/widgets/chat_card.dart +++ b/lib/ui/community/community_views/widgets/chat_card.dart @@ -47,14 +47,6 @@ class _ChatCardState extends State { return (userProvider?.userInfoModel?.id ?? -1) == widget.model.createId; } - String get firstHead { - if (widget.model.headSculptureImgUrl == null || - widget.model.headSculptureImgUrl.isEmpty) - return ''; - else - return widget.model.headSculptureImgUrl.first.url; - } - _renderImage() { if (widget.model.imgUrls.isEmpty) return SizedBox(); if (widget.model.imgUrls.length == 1) @@ -78,10 +70,10 @@ class _ChatCardState extends State { maxWidth: 300.w, ), child: Hero( - tag: widget.model.imgUrls.first.url, + tag: ImgModel.first(widget.model.imgUrls), child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(widget.model.imgUrls.first.url), + image: API.image(ImgModel.first(widget.model.imgUrls)), ), ), ), @@ -306,7 +298,8 @@ class _ChatCardState extends State { clipBehavior: Clip.antiAlias, child: FadeInImage.assetNetwork( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, - image: API.image(firstHead), + image: + API.image(ImgModel.first(widget.model.headSculptureImgUrl)), height: 86.w, width: 86.w, fit: BoxFit.cover, diff --git a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart index 56a22c4e..d146545e 100644 --- a/lib/ui/manager/questionnaire/questionnaire_detail_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_detail_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -219,11 +220,13 @@ class _QuestionnaireDetailPageState extends State { borderRadius: BorderRadius.circular(4.w), ), width: double.infinity, - height: 228.w, clipBehavior: Clip.antiAlias, child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image(_model.voResourcesImgList.first.url)), + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image( + ImgModel.first(_model.voResourcesImgList), + ), + ), ), 40.w.heightBox, Container( diff --git a/lib/ui/manager/questionnaire/questionnaire_page.dart b/lib/ui/manager/questionnaire/questionnaire_page.dart index b34bc702..db5ebd90 100644 --- a/lib/ui/manager/questionnaire/questionnaire_page.dart +++ b/lib/ui/manager/questionnaire/questionnaire_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/model/common/img_model.dart'; import 'package:flutter/material.dart'; import 'package:flustars/flustars.dart'; @@ -21,7 +22,7 @@ class QuestionnairePage extends StatefulWidget { } class _QuestionnairePageState extends State { - EasyRefreshController _easyRefreshController; + EasyRefreshController _easyRefreshController = EasyRefreshController(); @override void initState() { super.initState(); @@ -68,8 +69,9 @@ class _QuestionnairePageState extends State { height: 120.w, child: ClipRRect( child: FadeInImage.assetNetwork( - placeholder: R.ASSETS_IMAGES_LOGO_PNG, - image: API.image(model.imgUrls.first.url)), + placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP, + image: API.image(ImgModel.first(model.imgUrls)), + ), ), ), 20.w.widthBox, @@ -146,6 +148,12 @@ class _QuestionnairePageState extends State { ); } + @override + void dispose() { + _easyRefreshController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return BeeScaffold(