fix vote image

hmxc
小赖 4 years ago
parent e3dd5ed9e3
commit 18017af532

@ -15,6 +15,12 @@ class ImgModel {
sort = json['sort']; sort = json['sort'];
} }
static String first(List<ImgModel> models) {
if (models == null) return '';
if (models.isEmpty) return '';
return models.first.url ?? '';
}
Map<String, dynamic> toJson() { Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url; data['url'] = this.url;

@ -9,6 +9,12 @@ class VotingDetailModel {
List<ImgModel> imgUrls; List<ImgModel> imgUrls;
List<AppVoteCandidateVos> appVoteCandidateVos; List<AppVoteCandidateVos> appVoteCandidateVos;
String get firstImage {
if (imgUrls == null) return '';
if (imgUrls.isEmpty) return '';
return imgUrls.first.url ?? '';
}
VotingDetailModel( VotingDetailModel(
{this.id, {this.id,
this.title, this.title,

@ -59,9 +59,11 @@ class _EventVotingPageState extends State<EventVotingPage> {
width: double.infinity, width: double.infinity,
child: ClipRect( child: ClipRect(
child: FadeInImage.assetNetwork( child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG, placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image( image: API.image(
model.imgUrls.isNotEmpty ? model.imgUrls.first.url : '')), model.imgUrls.isNotEmpty ? model.imgUrls.first.url : ''),
fit: BoxFit.cover,
),
), ),
), ),
Padding( Padding(

@ -1,3 +1,4 @@
import 'package:akuCommunity/model/common/img_model.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -122,8 +123,12 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.circular(4.w), borderRadius: BorderRadius.circular(4.w),
child: FadeInImage.assetNetwork( child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG, placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
image: API.image(model.imgUrls.first.url)), image: API.image(
ImgModel.first(model.imgUrls),
),
fit: BoxFit.cover,
),
), ),
), ),
30.w.widthBox, 30.w.widthBox,
@ -213,15 +218,11 @@ class _VotingDetailPageState extends State<VotingDetailPage> {
children: [ children: [
_model.title.text.black.size(32.sp).bold.maxLines(2).make(), _model.title.text.black.size(32.sp).bold.maxLines(2).make(),
44.w.heightBox, 44.w.heightBox,
SizedBox( ClipRRect(
width: double.infinity, borderRadius: BorderRadius.circular(8.w),
height: 228.w, child: FadeInImage.assetNetwork(
child: ClipRRect( placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
borderRadius: BorderRadius.circular(8.w), image: API.image(_model.firstImage),
child: FadeInImage.assetNetwork(
placeholder: R.ASSETS_IMAGES_LOGO_PNG,
image: API.image(_model.imgUrls.first.url),
),
), ),
), ),
44.w.heightBox, 44.w.heightBox,

@ -169,11 +169,11 @@ class ManagerFunc {
} }
static Future<VotingDetailModel> voteDetail(int id) async { static Future<VotingDetailModel> voteDetail(int id) async {
BaseModel baseModel = await NetUtil().get(API.manager.voteDetail, BaseModel baseModel = await NetUtil().get(
params: { API.manager.voteDetail,
'voteId': 1, params: {'voteId': id},
}, showMessage: false,
showMessage: false); );
return VotingDetailModel.fromJson(baseModel.data); return VotingDetailModel.fromJson(baseModel.data);
} }

Loading…
Cancel
Save